@arbidocs/blocks 0.5.130 → 0.5.132
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DocumentReviewCard-M53XFLI2.cjs → DocumentReviewCard-2VI5OOLE.cjs} +3 -3
- package/dist/{DocumentReviewCard-M53XFLI2.cjs.map → DocumentReviewCard-2VI5OOLE.cjs.map} +1 -1
- package/dist/{FilesViewerDialog-EFRMXIM5.cjs → FilesViewerDialog-77YTFIX3.cjs} +4 -4
- package/dist/{FilesViewerDialog-EFRMXIM5.cjs.map → FilesViewerDialog-77YTFIX3.cjs.map} +1 -1
- package/dist/{WorkspaceTableView-QPROJRCF.cjs → WorkspaceTableView-7BMZ2O3Y.cjs} +6 -6
- package/dist/{WorkspaceTableView-QPROJRCF.cjs.map → WorkspaceTableView-7BMZ2O3Y.cjs.map} +1 -1
- package/dist/{chunk-KWHGYHRC.cjs → chunk-KSDTK66A.cjs} +2 -2
- package/dist/{chunk-KWHGYHRC.cjs.map → chunk-KSDTK66A.cjs.map} +1 -1
- package/dist/{chunk-MI3N3ZOT.cjs → chunk-PDDYAY4Z.cjs} +20 -20
- package/dist/{chunk-MI3N3ZOT.cjs.map → chunk-PDDYAY4Z.cjs.map} +1 -1
- package/dist/{chunk-T73BHNQX.cjs → chunk-TBPCG2PV.cjs} +240 -89
- package/dist/chunk-TBPCG2PV.cjs.map +1 -0
- package/dist/{chunk-GOQV6NOK.cjs → chunk-U7KB42OQ.cjs} +4 -4
- package/dist/{chunk-GOQV6NOK.cjs.map → chunk-U7KB42OQ.cjs.map} +1 -1
- package/dist/{chunk-GEZB3OEC.cjs → chunk-XJE7W42L.cjs} +18 -17
- package/dist/chunk-XJE7W42L.cjs.map +1 -0
- package/dist/connect/index.cjs +1413 -653
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/viewer.cjs +1 -1
- package/dist/connection/billing/ChangePlanDialog.d.ts +2 -1
- package/dist/connection/billing/ChangePlanDialog.js +8 -3
- package/dist/connection/billing/ChangePlanDialog.js.map +2 -2
- package/dist/connection/billing/ChangeProPlan.js +4 -4
- package/dist/connection/billing/ChangeProPlan.js.map +2 -2
- package/dist/connection/billing/CollaboratorPlan.js +5 -3
- package/dist/connection/billing/CollaboratorPlan.js.map +2 -2
- package/dist/connection/billing/ConnectedWelcomeDialog.d.ts +5 -13
- package/dist/connection/billing/ConnectedWelcomeDialog.js +38 -19
- package/dist/connection/billing/ConnectedWelcomeDialog.js.map +2 -2
- package/dist/connection/billing/MonthlySpendCap.d.ts +10 -3
- package/dist/connection/billing/MonthlySpendCap.js +103 -11
- package/dist/connection/billing/MonthlySpendCap.js.map +2 -2
- package/dist/connection/billing/NewProjectFlow.js +20 -7
- package/dist/connection/billing/NewProjectFlow.js.map +2 -2
- package/dist/connection/billing/ProjectDetail.js +1 -1
- package/dist/connection/billing/ProjectDetail.js.map +2 -2
- package/dist/connection/billing/ProjectPurchaseOptions.d.ts +14 -3
- package/dist/connection/billing/ProjectPurchaseOptions.js +472 -139
- package/dist/connection/billing/ProjectPurchaseOptions.js.map +2 -2
- package/dist/connection/billing/ProjectUsageCard.js +4 -4
- package/dist/connection/billing/ProjectUsageCard.js.map +2 -2
- package/dist/connection/billing/ReduceAddonDialog.js +2 -2
- package/dist/connection/billing/ReduceAddonDialog.js.map +2 -2
- package/dist/connection/billing/StripeCheckoutModal.js +3 -2
- package/dist/connection/billing/StripeCheckoutModal.js.map +2 -2
- package/dist/connection/billing/SubscriptionPlans.d.ts +5 -1
- package/dist/connection/billing/SubscriptionPlans.js +89 -6
- package/dist/connection/billing/SubscriptionPlans.js.map +2 -2
- package/dist/connection/billing/index.d.ts +1 -1
- package/dist/connection/billing/index.js +2 -2
- package/dist/connection/billing/index.js.map +2 -2
- package/dist/connection/billing/referral-reward.d.ts +2 -3
- package/dist/connection/billing/referral-reward.js +8 -3
- package/dist/connection/billing/referral-reward.js.map +2 -2
- package/dist/connection/billing/tax-quote.d.ts +2 -2
- package/dist/connection/billing/tax-quote.js +1 -0
- package/dist/connection/billing/tax-quote.js.map +2 -2
- package/dist/connection/command/ConnectedCommandPalette.js +2 -0
- package/dist/connection/command/ConnectedCommandPalette.js.map +2 -2
- package/dist/connection/command/actions.js +1 -1
- package/dist/connection/command/actions.js.map +2 -2
- package/dist/connection/contacts/ConnectedAddContacts.d.ts +7 -1
- package/dist/connection/contacts/ConnectedAddContacts.js +33 -17
- package/dist/connection/contacts/ConnectedAddContacts.js.map +2 -2
- package/dist/connection/contacts/ConnectedInviteContactsDialog.js +3 -2
- package/dist/connection/contacts/ConnectedInviteContactsDialog.js.map +2 -2
- package/dist/connection/contacts/ConnectedWelcomeInvitations.d.ts +6 -0
- package/dist/connection/contacts/ConnectedWelcomeInvitations.js +198 -0
- package/dist/connection/contacts/ConnectedWelcomeInvitations.js.map +7 -0
- package/dist/connection/projects/ConnectedProjectsPanel.js +17 -5
- package/dist/connection/projects/ConnectedProjectsPanel.js.map +2 -2
- package/dist/connection/shell/ConnectedWorkspaceSwitcher.js +3 -3
- package/dist/connection/shell/ConnectedWorkspaceSwitcher.js.map +2 -2
- package/dist/connection/workspace-form/ConnectedWorkspaceFormModal.js +2 -2
- package/dist/connection/workspace-form/ConnectedWorkspaceFormModal.js.map +2 -2
- package/dist/connection/workspace-list/ConnectedWorkspaceList.js +1 -1
- package/dist/connection/workspace-list/ConnectedWorkspaceList.js.map +2 -2
- package/dist/connection/workspace-list/useConnectedWorkspaceList.d.ts +1 -1
- package/dist/connection/workspace-list/useConnectedWorkspaceList.js +4 -4
- package/dist/connection/workspace-list/useConnectedWorkspaceList.js.map +2 -2
- package/dist/embed/index.cjs +8 -8
- package/dist/index.cjs +48 -48
- package/dist/index.cjs.map +1 -1
- package/dist/nav/actions.d.ts +2 -0
- package/dist/nav/actions.js.map +2 -2
- package/dist/settings/Billing.d.ts +2 -2
- package/dist/settings/Billing.js +4 -3
- package/dist/settings/Billing.js.map +2 -2
- package/dist/settings/PanelFrame.d.ts +3 -1
- package/dist/settings/PanelFrame.js +3 -2
- package/dist/settings/PanelFrame.js.map +2 -2
- package/dist/settings/SubscriptionParts.d.ts +4 -2
- package/dist/settings/SubscriptionParts.js +22 -3
- package/dist/settings/SubscriptionParts.js.map +2 -2
- package/dist/settings/WelcomeDialog.d.ts +31 -4
- package/dist/settings/WelcomeDialog.js +221 -82
- package/dist/settings/WelcomeDialog.js.map +2 -2
- package/dist/settings/index.cjs +144 -144
- package/dist/styles.css +1 -1
- package/dist/workflow-canvas/index.cjs +7 -7
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/src/connection/billing/project-purchase.css +518 -39
- package/dist/chunk-GEZB3OEC.cjs.map +0 -1
- package/dist/chunk-T73BHNQX.cjs.map +0 -1
|
@@ -5,7 +5,7 @@ import { Dialog, DialogContent } from "@arbidocs/react/ui";
|
|
|
5
5
|
import { useEffect, useState } from "react";
|
|
6
6
|
import { AtSign, ArrowLeft } from "lucide-react";
|
|
7
7
|
import { ModalBreadcrumbHeader } from "../../settings/ModalBreadcrumbHeader.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useReferralOffer } from "../billing/referral-reward.js";
|
|
9
9
|
import { formatMoney } from "../billing/reward-balance.js";
|
|
10
10
|
import { ConnectedAuthorizeAgent as AuthorizeAgent } from "../config/ConnectedAuthorizeAgent.js";
|
|
11
11
|
import { ConnectedAddContacts } from "./ConnectedAddContacts.js";
|
|
@@ -15,6 +15,7 @@ function ConnectedInviteContactsDialog({
|
|
|
15
15
|
onOpenChange
|
|
16
16
|
}) {
|
|
17
17
|
const { data: userSettings } = useUserSettings();
|
|
18
|
+
const offer = useReferralOffer(open);
|
|
18
19
|
const isDeveloper = userSettings?.developer === true;
|
|
19
20
|
const [pendingAction, setPendingAction] = useTransientView(
|
|
20
21
|
PENDING_ACTION_VIEW,
|
|
@@ -59,7 +60,7 @@ function ConnectedInviteContactsDialog({
|
|
|
59
60
|
ConnectedAddContacts,
|
|
60
61
|
{
|
|
61
62
|
onClose: handleClose,
|
|
62
|
-
rewardAmount: formatMoney(
|
|
63
|
+
rewardAmount: offer ? formatMoney(offer.amount, offer.currency) : void 0
|
|
63
64
|
}
|
|
64
65
|
),
|
|
65
66
|
isDeveloper && /* @__PURE__ */ jsxs(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/contacts/ConnectedInviteContactsDialog.tsx"],
|
|
4
|
-
"sourcesContent": ["import { ArbiBotHeadIcon as ArbiBotIcon, useTransientView, useUserSettings } from '@arbidocs/react'\nimport { Dialog, DialogContent } from '@arbidocs/react/ui'\nimport { useEffect, useState } from 'react'\nimport { AtSign, ArrowLeft } from 'lucide-react'\nimport { ModalBreadcrumbHeader } from '../../settings/ModalBreadcrumbHeader'\nimport {
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["import { ArbiBotHeadIcon as ArbiBotIcon, useTransientView, useUserSettings } from '@arbidocs/react'\nimport { Dialog, DialogContent } from '@arbidocs/react/ui'\nimport { useEffect, useState } from 'react'\nimport { AtSign, ArrowLeft } from 'lucide-react'\nimport { ModalBreadcrumbHeader } from '../../settings/ModalBreadcrumbHeader'\nimport { useReferralOffer } from '../billing/referral-reward'\nimport { formatMoney } from '../billing/reward-balance'\nimport { ConnectedAuthorizeAgent as AuthorizeAgent } from '../config/ConnectedAuthorizeAgent'\nimport { ConnectedAddContacts } from './ConnectedAddContacts'\n\n/** A one-shot action from a link (`/action/authorize-agent`), taken by the surface it names. */\nexport const PENDING_ACTION_VIEW = 'page.pendingAction'\n\nexport interface ConnectedInviteContactsDialogProps {\n open: boolean\n onOpenChange: (open: boolean) => void\n}\n\ntype Mode = 'email' | 'assistant'\n\n/**\n * The `inviteContacts` global dialog: add people to your directory by e-mail (with the referral\n * offer). For developers it also hosts the beta \"Connect an agent\" flow, reached through a small\n * link rather than a tab; an `/action/authorize-agent` link (`PENDING_ACTION_VIEW`) opens straight\n * on it.\n */\nexport function ConnectedInviteContactsDialog({\n open,\n onOpenChange,\n}: ConnectedInviteContactsDialogProps) {\n const { data: userSettings } = useUserSettings()\n const offer = useReferralOffer(open)\n // Authorizing assistants is a developer-only beta capability.\n const isDeveloper = userSettings?.developer === true\n\n // The authorize-agent deeplink sets this; consume it to open straight into\n // assistant mode.\n const [pendingAction, setPendingAction] = useTransientView<string | null>(\n PENDING_ACTION_VIEW,\n null\n )\n\n const [mode, setMode] = useState<Mode>('email')\n\n // Each opening starts on email\u2026\n useEffect(() => {\n if (open) setMode('email')\n }, [open])\n // \u2026or on the assistant when a developer followed the deeplink; the one-shot action is then\n // cleared. (Not in one effect: clearing the action re-ran it and put the mode back to email.)\n useEffect(() => {\n if (!open || !isDeveloper || pendingAction !== 'authorize-agent') return\n setMode('assistant')\n setPendingAction(undefined)\n }, [open, isDeveloper, pendingAction, setPendingAction])\n\n const handleClose = () => onOpenChange(false)\n\n const isAssistant = isDeveloper && mode === 'assistant'\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent presentation=\"sheet\" className=\"max-w-md max-h-panel overflow-y-auto\">\n <ModalBreadcrumbHeader\n icon={isAssistant ? <ArbiBotIcon className=\"w-4 h-4\" /> : <AtSign className=\"w-4 h-4\" />}\n title={isAssistant ? 'Connect an Agent' : 'Add Contact by Email'}\n />\n\n {isAssistant ? (\n <>\n <button\n type=\"button\"\n onClick={() => setMode('email')}\n className=\"mb-3 inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground\"\n data-testid=\"back-to-email\"\n >\n <ArrowLeft className=\"h-3.5 w-3.5\" />\n Back to email invite\n </button>\n <AuthorizeAgent onClose={handleClose} />\n </>\n ) : (\n <>\n <ConnectedAddContacts\n onClose={handleClose}\n rewardAmount={offer ? formatMoney(offer.amount, offer.currency) : undefined}\n />\n {isDeveloper && (\n <button\n type=\"button\"\n onClick={() => setMode('assistant')}\n className=\"mt-3 inline-flex w-full items-center justify-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground\"\n data-testid=\"connect-agent-link\"\n >\n <ArbiBotIcon className=\"h-3.5 w-3.5\" />\n Connect an agent\n <span className=\"opacity-70\">(beta)</span>\n </button>\n )}\n </>\n )}\n </DialogContent>\n </Dialog>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAgE8B,SAKpB,UALoB,KAMlB,YANkB;AAhE9B,SAAS,mBAAmB,aAAa,kBAAkB,uBAAuB;AAClF,SAAS,QAAQ,qBAAqB;AACtC,SAAS,WAAW,gBAAgB;AACpC,SAAS,QAAQ,iBAAiB;AAClC,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B,sBAAsB;AAC1D,SAAS,4BAA4B;AAG9B,MAAM,sBAAsB;AAe5B,SAAS,8BAA8B;AAAA,EAC5C;AAAA,EACA;AACF,GAAuC;AACrC,QAAM,EAAE,MAAM,aAAa,IAAI,gBAAgB;AAC/C,QAAM,QAAQ,iBAAiB,IAAI;AAEnC,QAAM,cAAc,cAAc,cAAc;AAIhD,QAAM,CAAC,eAAe,gBAAgB,IAAI;AAAA,IACxC;AAAA,IACA;AAAA,EACF;AAEA,QAAM,CAAC,MAAM,OAAO,IAAI,SAAe,OAAO;AAG9C,YAAU,MAAM;AACd,QAAI,KAAM,SAAQ,OAAO;AAAA,EAC3B,GAAG,CAAC,IAAI,CAAC;AAGT,YAAU,MAAM;AACd,QAAI,CAAC,QAAQ,CAAC,eAAe,kBAAkB,kBAAmB;AAClE,YAAQ,WAAW;AACnB,qBAAiB,MAAS;AAAA,EAC5B,GAAG,CAAC,MAAM,aAAa,eAAe,gBAAgB,CAAC;AAEvD,QAAM,cAAc,MAAM,aAAa,KAAK;AAE5C,QAAM,cAAc,eAAe,SAAS;AAE5C,SACE,oBAAC,UAAO,MAAY,cAClB,+BAAC,iBAAc,cAAa,SAAQ,WAAU,wCAC5C;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM,cAAc,oBAAC,eAAY,WAAU,WAAU,IAAK,oBAAC,UAAO,WAAU,WAAU;AAAA,QACtF,OAAO,cAAc,qBAAqB;AAAA;AAAA,IAC5C;AAAA,IAEC,cACC,iCACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAS,MAAM,QAAQ,OAAO;AAAA,UAC9B,WAAU;AAAA,UACV,eAAY;AAAA,UAEZ;AAAA,gCAAC,aAAU,WAAU,eAAc;AAAA,YAAE;AAAA;AAAA;AAAA,MAEvC;AAAA,MACA,oBAAC,kBAAe,SAAS,aAAa;AAAA,OACxC,IAEA,iCACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,SAAS;AAAA,UACT,cAAc,QAAQ,YAAY,MAAM,QAAQ,MAAM,QAAQ,IAAI;AAAA;AAAA,MACpE;AAAA,MACC,eACC;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAS,MAAM,QAAQ,WAAW;AAAA,UAClC,WAAU;AAAA,UACV,eAAY;AAAA,UAEZ;AAAA,gCAAC,eAAY,WAAU,eAAc;AAAA,YAAE;AAAA,YAEvC,oBAAC,UAAK,WAAU,cAAa,oBAAM;AAAA;AAAA;AAAA,MACrC;AAAA,OAEJ;AAAA,KAEJ,GACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Contact progress with referral status and bonuses from the owner-scoped API. */
|
|
2
|
+
export declare function ConnectedWelcomeInvitations({ currentUserExtId, onBack, onNavigate, }: {
|
|
3
|
+
currentUserExtId: string;
|
|
4
|
+
onBack: () => void;
|
|
5
|
+
onNavigate?: () => void;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import {
|
|
5
|
+
useReferralSummary,
|
|
6
|
+
useArbiSessionStore,
|
|
7
|
+
useDeleteContact,
|
|
8
|
+
useContacts,
|
|
9
|
+
useInviteContacts
|
|
10
|
+
} from "@arbidocs/react";
|
|
11
|
+
import { CheckCircle2, Clock, MessageSquare, RotateCcw, Trash2 } from "lucide-react";
|
|
12
|
+
import { Button } from "@arbidocs/react/ui";
|
|
13
|
+
import { useBlocksEnvironment } from "../../provider/environment.js";
|
|
14
|
+
import { summarizeContactInvites } from "../../collaboration/contacts/invite-plan.js";
|
|
15
|
+
import { ConnectedAddContacts } from "./ConnectedAddContacts.js";
|
|
16
|
+
import { formatMoney } from "../billing/reward-balance.js";
|
|
17
|
+
const titles = {
|
|
18
|
+
pending: "Invited",
|
|
19
|
+
joined: "Joined",
|
|
20
|
+
accepted: "Accepted",
|
|
21
|
+
subscribed: "Subscribed"
|
|
22
|
+
};
|
|
23
|
+
function ConnectedWelcomeInvitations({
|
|
24
|
+
currentUserExtId,
|
|
25
|
+
onBack,
|
|
26
|
+
onNavigate
|
|
27
|
+
}) {
|
|
28
|
+
const session = useArbiSessionStore();
|
|
29
|
+
const { confirm, notify, openDirectChat } = useBlocksEnvironment();
|
|
30
|
+
const remove = useDeleteContact();
|
|
31
|
+
const resend = useInviteContacts();
|
|
32
|
+
const listRef = useRef(null);
|
|
33
|
+
const history = useReferralSummary(currentUserExtId);
|
|
34
|
+
const { data: contacts = [] } = useContacts();
|
|
35
|
+
const invitations = [...history.data?.invitations ?? []];
|
|
36
|
+
if (history.data) {
|
|
37
|
+
for (const contact of contacts) {
|
|
38
|
+
if (contact.status !== "registered" || !contact.external_id || !contact.email || !contact.user?.external_id?.startsWith("usr-") || invitations.some(
|
|
39
|
+
(row) => row.contact_id === contact.external_id || row.email.toLowerCase() === contact.email.toLowerCase()
|
|
40
|
+
))
|
|
41
|
+
continue;
|
|
42
|
+
invitations.push({
|
|
43
|
+
contact_id: contact.external_id,
|
|
44
|
+
user_id: contact.user.external_id,
|
|
45
|
+
email: contact.email,
|
|
46
|
+
name: [contact.user.given_name, contact.user.family_name].filter(Boolean).join(" ") || contact.email,
|
|
47
|
+
status: "joined",
|
|
48
|
+
expired: false,
|
|
49
|
+
has_shared_workspace: false,
|
|
50
|
+
potential_bonus: 0,
|
|
51
|
+
earned_bonus: 0,
|
|
52
|
+
created_at: contact.created_at
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
invitations.sort(
|
|
57
|
+
(a, b) => Number(b.status === "pending") - Number(a.status === "pending") || Date.parse(b.created_at) - Date.parse(a.created_at)
|
|
58
|
+
);
|
|
59
|
+
const pending = invitations.filter((row) => row.status === "pending").length;
|
|
60
|
+
const unavailable = !history.data;
|
|
61
|
+
const currency = history.data?.currency;
|
|
62
|
+
const money = (amount) => amount != null && currency ? formatMoney(amount, currency) : "\u2014";
|
|
63
|
+
const potential = invitations.reduce((sum, row) => sum + row.potential_bonus, 0);
|
|
64
|
+
const earned = invitations.reduce((sum, row) => sum + row.earned_bonus, 0);
|
|
65
|
+
const deleteInvitation = async (row) => {
|
|
66
|
+
const yes = await confirm({
|
|
67
|
+
title: "Delete invitation",
|
|
68
|
+
message: `Delete the invitation to ${row.email}?${row.has_shared_workspace ? "\n\nThis also cancels its pending workspace access." : ""}`
|
|
69
|
+
});
|
|
70
|
+
if (!yes) return;
|
|
71
|
+
try {
|
|
72
|
+
await remove.mutateAsync(row.contact_id);
|
|
73
|
+
await history.refetch();
|
|
74
|
+
} catch {
|
|
75
|
+
notify("The invitation could not be deleted. Try again.", "error");
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const resendInvitation = async (row) => {
|
|
79
|
+
try {
|
|
80
|
+
const response = await resend.mutateAsync([row.email]);
|
|
81
|
+
const result = summarizeContactInvites(response);
|
|
82
|
+
notify(result.message, result.failed ? "error" : "success");
|
|
83
|
+
await history.refetch();
|
|
84
|
+
} catch {
|
|
85
|
+
notify("The invitation could not be sent. Try again.", "error");
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const message = (row) => {
|
|
89
|
+
if (!row.user_id) return;
|
|
90
|
+
if (openDirectChat) openDirectChat(row.user_id);
|
|
91
|
+
else session.openDmTab(row.user_id);
|
|
92
|
+
onNavigate?.();
|
|
93
|
+
};
|
|
94
|
+
return /* @__PURE__ */ jsxs("div", { className: "welcome-invitations", children: [
|
|
95
|
+
/* @__PURE__ */ jsxs("p", { className: "text-sm text-muted-foreground", children: [
|
|
96
|
+
"They get ",
|
|
97
|
+
/* @__PURE__ */ jsx("strong", { children: money(history.data?.invitee_reward_amount) }),
|
|
98
|
+
" when they accept and join. You earn ",
|
|
99
|
+
/* @__PURE__ */ jsx("strong", { children: money(history.data?.reward_amount) }),
|
|
100
|
+
" when they subscribe to Pro."
|
|
101
|
+
] }),
|
|
102
|
+
/* @__PURE__ */ jsx(
|
|
103
|
+
ConnectedAddContacts,
|
|
104
|
+
{
|
|
105
|
+
keepFormOpen: true,
|
|
106
|
+
labels: { cancel: "Close" },
|
|
107
|
+
onClose: onBack,
|
|
108
|
+
onSuccess: () => {
|
|
109
|
+
void history.refetch().then(() => {
|
|
110
|
+
if (listRef.current) listRef.current.scrollTop = 0;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
/* @__PURE__ */ jsxs("section", { className: "welcome-invitation-history", "aria-label": "Your invitations", children: [
|
|
116
|
+
/* @__PURE__ */ jsxs("div", { className: "welcome-invitation-heading", children: [
|
|
117
|
+
/* @__PURE__ */ jsx("h3", { children: "Your invitations" }),
|
|
118
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
119
|
+
"Pending ",
|
|
120
|
+
/* @__PURE__ */ jsx("strong", { children: unavailable ? "\u2014" : pending })
|
|
121
|
+
] })
|
|
122
|
+
] }),
|
|
123
|
+
history.isLoading ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Loading invitations\u2026" }) : history.isError ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Invitation history couldn\u2019t load. Try again." }) : invitations.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "No invitations yet." }) : /* @__PURE__ */ jsx("ul", { ref: listRef, className: "welcome-invitation-list", children: invitations.map((row) => /* @__PURE__ */ jsxs("li", { children: [
|
|
124
|
+
row.status === "pending" ? /* @__PURE__ */ jsx(Clock, { className: "h-4 w-4 shrink-0 text-amber-600" }) : /* @__PURE__ */ jsx(CheckCircle2, { className: "h-4 w-4 shrink-0 text-green-600" }),
|
|
125
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", title: row.email, children: row.name || row.email }),
|
|
126
|
+
/* @__PURE__ */ jsxs(
|
|
127
|
+
"span",
|
|
128
|
+
{
|
|
129
|
+
className: "welcome-invitation-status",
|
|
130
|
+
"data-status": row.expired ? "expired" : row.status,
|
|
131
|
+
title: row.status === "joined" ? "On ARBI without accepting your invitation; no referral bonus attributed." : void 0,
|
|
132
|
+
children: [
|
|
133
|
+
row.expired ? "Expired" : titles[row.status],
|
|
134
|
+
row.status === "subscribed" && row.earned_bonus > 0 && /* @__PURE__ */ jsxs("strong", { className: "welcome-invitation-credited", children: [
|
|
135
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
136
|
+
money(row.earned_bonus),
|
|
137
|
+
" credited"
|
|
138
|
+
] })
|
|
139
|
+
]
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
row.status === "pending" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
143
|
+
row.expired && /* @__PURE__ */ jsx(
|
|
144
|
+
Button,
|
|
145
|
+
{
|
|
146
|
+
type: "button",
|
|
147
|
+
size: "icon",
|
|
148
|
+
variant: "ghost",
|
|
149
|
+
title: "Resend invitation",
|
|
150
|
+
"aria-label": `Resend invitation to ${row.email}`,
|
|
151
|
+
disabled: resend.isPending,
|
|
152
|
+
onClick: () => void resendInvitation(row),
|
|
153
|
+
children: /* @__PURE__ */ jsx(RotateCcw, { className: "h-4 w-4" })
|
|
154
|
+
}
|
|
155
|
+
),
|
|
156
|
+
/* @__PURE__ */ jsx(
|
|
157
|
+
Button,
|
|
158
|
+
{
|
|
159
|
+
type: "button",
|
|
160
|
+
size: "icon",
|
|
161
|
+
variant: "ghost",
|
|
162
|
+
title: "Delete invitation",
|
|
163
|
+
"aria-label": `Delete invitation to ${row.email}`,
|
|
164
|
+
disabled: remove.isPending,
|
|
165
|
+
onClick: () => void deleteInvitation(row),
|
|
166
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" })
|
|
167
|
+
}
|
|
168
|
+
)
|
|
169
|
+
] }) : /* @__PURE__ */ jsx(
|
|
170
|
+
Button,
|
|
171
|
+
{
|
|
172
|
+
type: "button",
|
|
173
|
+
size: "icon",
|
|
174
|
+
variant: "ghost",
|
|
175
|
+
title: "Message",
|
|
176
|
+
"aria-label": `Message ${row.name || row.email}`,
|
|
177
|
+
onClick: () => message(row),
|
|
178
|
+
children: /* @__PURE__ */ jsx(MessageSquare, { className: "h-4 w-4" })
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
] }, row.contact_id)) }),
|
|
182
|
+
/* @__PURE__ */ jsxs("div", { className: "welcome-invitation-totals", children: [
|
|
183
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
184
|
+
"Potential bonus ",
|
|
185
|
+
/* @__PURE__ */ jsx("strong", { children: unavailable ? "\u2014" : money(potential) })
|
|
186
|
+
] }),
|
|
187
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
188
|
+
"Earned bonus ",
|
|
189
|
+
/* @__PURE__ */ jsx("strong", { children: unavailable ? "\u2014" : money(earned) })
|
|
190
|
+
] })
|
|
191
|
+
] })
|
|
192
|
+
] })
|
|
193
|
+
] });
|
|
194
|
+
}
|
|
195
|
+
export {
|
|
196
|
+
ConnectedWelcomeInvitations
|
|
197
|
+
};
|
|
198
|
+
//# sourceMappingURL=ConnectedWelcomeInvitations.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/connection/contacts/ConnectedWelcomeInvitations.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useRef } from 'react'\nimport {\n useReferralSummary,\n useArbiSessionStore,\n useDeleteContact,\n useContacts,\n useInviteContacts,\n} from '@arbidocs/react'\nimport type { ReferralInvitation } from '@arbidocs/client'\nimport { CheckCircle2, Clock, MessageSquare, RotateCcw, Trash2 } from 'lucide-react'\nimport { Button } from '@arbidocs/react/ui'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { summarizeContactInvites } from '../../collaboration/contacts/invite-plan'\nimport { ConnectedAddContacts } from './ConnectedAddContacts'\nimport { formatMoney } from '../billing/reward-balance'\n\ntype InvitationRow = Omit<ReferralInvitation, 'status'> & {\n status: ReferralInvitation['status'] | 'joined'\n}\ntype Stage = InvitationRow['status']\nconst titles: Record<Stage, string> = {\n pending: 'Invited',\n joined: 'Joined',\n accepted: 'Accepted',\n subscribed: 'Subscribed',\n}\n\n/** Contact progress with referral status and bonuses from the owner-scoped API. */\nexport function ConnectedWelcomeInvitations({\n currentUserExtId,\n onBack,\n onNavigate,\n}: {\n currentUserExtId: string\n onBack: () => void\n onNavigate?: () => void\n}) {\n const session = useArbiSessionStore()\n const { confirm, notify, openDirectChat } = useBlocksEnvironment()\n const remove = useDeleteContact()\n const resend = useInviteContacts()\n const listRef = useRef<HTMLUListElement>(null)\n const history = useReferralSummary(currentUserExtId)\n const { data: contacts = [] } = useContacts()\n const invitations: InvitationRow[] = [...(history.data?.invitations ?? [])]\n // A registered contact outside the accepted-referral history carries no bonus attribution.\n if (history.data) {\n for (const contact of contacts) {\n if (\n contact.status !== 'registered' ||\n !contact.external_id ||\n !contact.email ||\n !contact.user?.external_id?.startsWith('usr-') ||\n invitations.some(\n (row) =>\n row.contact_id === contact.external_id ||\n row.email.toLowerCase() === contact.email!.toLowerCase()\n )\n )\n continue\n invitations.push({\n contact_id: contact.external_id,\n user_id: contact.user.external_id,\n email: contact.email,\n name:\n [contact.user.given_name, contact.user.family_name].filter(Boolean).join(' ') ||\n contact.email,\n status: 'joined',\n expired: false,\n has_shared_workspace: false,\n potential_bonus: 0,\n earned_bonus: 0,\n created_at: contact.created_at,\n })\n }\n }\n invitations.sort(\n (a, b) =>\n Number(b.status === 'pending') - Number(a.status === 'pending') ||\n Date.parse(b.created_at) - Date.parse(a.created_at)\n )\n const pending = invitations.filter((row) => row.status === 'pending').length\n const unavailable = !history.data\n const currency = history.data?.currency\n const money = (amount: number | undefined) =>\n amount != null && currency ? formatMoney(amount, currency) : '\u2014'\n const potential = invitations.reduce((sum, row) => sum + row.potential_bonus, 0)\n const earned = invitations.reduce((sum, row) => sum + row.earned_bonus, 0)\n const deleteInvitation = async (row: InvitationRow) => {\n const yes = await confirm({\n title: 'Delete invitation',\n message: `Delete the invitation to ${row.email}?${row.has_shared_workspace ? '\\n\\nThis also cancels its pending workspace access.' : ''}`,\n })\n if (!yes) return\n try {\n await remove.mutateAsync(row.contact_id)\n await history.refetch()\n } catch {\n notify('The invitation could not be deleted. Try again.', 'error')\n }\n }\n const resendInvitation = async (row: InvitationRow) => {\n try {\n const response = await resend.mutateAsync([row.email])\n const result = summarizeContactInvites(response)\n notify(result.message, result.failed ? 'error' : 'success')\n await history.refetch()\n } catch {\n notify('The invitation could not be sent. Try again.', 'error')\n }\n }\n const message = (row: InvitationRow) => {\n if (!row.user_id) return\n if (openDirectChat) openDirectChat(row.user_id)\n else session.openDmTab(row.user_id)\n onNavigate?.()\n }\n return (\n <div className=\"welcome-invitations\">\n <p className=\"text-sm text-muted-foreground\">\n They get <strong>{money(history.data?.invitee_reward_amount)}</strong> when they accept and\n join. You earn <strong>{money(history.data?.reward_amount)}</strong> when they subscribe to\n Pro.\n </p>\n <ConnectedAddContacts\n keepFormOpen\n labels={{ cancel: 'Close' }}\n onClose={onBack}\n onSuccess={() => {\n void history.refetch().then(() => {\n if (listRef.current) listRef.current.scrollTop = 0\n })\n }}\n />\n <section className=\"welcome-invitation-history\" aria-label=\"Your invitations\">\n <div className=\"welcome-invitation-heading\">\n <h3>Your invitations</h3>\n <span>\n Pending <strong>{unavailable ? '\u2014' : pending}</strong>\n </span>\n </div>\n {history.isLoading ? (\n <p className=\"text-sm text-muted-foreground\">Loading invitations\u2026</p>\n ) : history.isError ? (\n <p className=\"text-sm text-muted-foreground\">\n Invitation history couldn\u2019t load. Try again.\n </p>\n ) : invitations.length === 0 ? (\n <p className=\"text-sm text-muted-foreground\">No invitations yet.</p>\n ) : (\n <ul ref={listRef} className=\"welcome-invitation-list\">\n {invitations.map((row) => (\n <li key={row.contact_id}>\n {row.status === 'pending' ? (\n <Clock className=\"h-4 w-4 shrink-0 text-amber-600\" />\n ) : (\n <CheckCircle2 className=\"h-4 w-4 shrink-0 text-green-600\" />\n )}\n <span className=\"min-w-0 flex-1 truncate\" title={row.email}>\n {row.name || row.email}\n </span>\n <span\n className=\"welcome-invitation-status\"\n data-status={row.expired ? 'expired' : row.status}\n title={\n row.status === 'joined'\n ? 'On ARBI without accepting your invitation; no referral bonus attributed.'\n : undefined\n }\n >\n {row.expired ? 'Expired' : titles[row.status]}\n {row.status === 'subscribed' && row.earned_bonus > 0 && (\n <strong className=\"welcome-invitation-credited\">\n <span aria-hidden=\"true\"> \u00B7 </span>\n {money(row.earned_bonus)} credited\n </strong>\n )}\n </span>\n {row.status === 'pending' ? (\n <>\n {row.expired && (\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"ghost\"\n title=\"Resend invitation\"\n aria-label={`Resend invitation to ${row.email}`}\n disabled={resend.isPending}\n onClick={() => void resendInvitation(row)}\n >\n <RotateCcw className=\"h-4 w-4\" />\n </Button>\n )}\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"ghost\"\n title=\"Delete invitation\"\n aria-label={`Delete invitation to ${row.email}`}\n disabled={remove.isPending}\n onClick={() => void deleteInvitation(row)}\n >\n <Trash2 className=\"h-4 w-4\" />\n </Button>\n </>\n ) : (\n <Button\n type=\"button\"\n size=\"icon\"\n variant=\"ghost\"\n title=\"Message\"\n aria-label={`Message ${row.name || row.email}`}\n onClick={() => message(row)}\n >\n <MessageSquare className=\"h-4 w-4\" />\n </Button>\n )}\n </li>\n ))}\n </ul>\n )}\n <div className=\"welcome-invitation-totals\">\n <span>\n Potential bonus <strong>{unavailable ? '\u2014' : money(potential)}</strong>\n </span>\n <span>\n Earned bonus <strong>{unavailable ? '\u2014' : money(earned)}</strong>\n </span>\n </div>\n </section>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAuHM,SA4DY,UA3DD,KADX;AAvHN,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,cAAc,OAAO,eAAe,WAAW,cAAc;AACtE,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC,SAAS,+BAA+B;AACxC,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAM5B,MAAM,SAAgC;AAAA,EACpC,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,YAAY;AACd;AAGO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,UAAU,oBAAoB;AACpC,QAAM,EAAE,SAAS,QAAQ,eAAe,IAAI,qBAAqB;AACjE,QAAM,SAAS,iBAAiB;AAChC,QAAM,SAAS,kBAAkB;AACjC,QAAM,UAAU,OAAyB,IAAI;AAC7C,QAAM,UAAU,mBAAmB,gBAAgB;AACnD,QAAM,EAAE,MAAM,WAAW,CAAC,EAAE,IAAI,YAAY;AAC5C,QAAM,cAA+B,CAAC,GAAI,QAAQ,MAAM,eAAe,CAAC,CAAE;AAE1E,MAAI,QAAQ,MAAM;AAChB,eAAW,WAAW,UAAU;AAC9B,UACE,QAAQ,WAAW,gBACnB,CAAC,QAAQ,eACT,CAAC,Q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cACC,MAAK;AAAA,cACL,MAAK;AAAA,cACL,SAAQ;AAAA,cACR,OAAM;AAAA,cACN,cAAY,wBAAwB,IAAI,KAAK;AAAA,cAC7C,UAAU,OAAO;AAAA,cACjB,SAAS,MAAM,KAAK,iBAAiB,GAAG;AAAA,cAExC,8BAAC,UAAO,WAAU,WAAU;AAAA;AAAA,UAC9B;AAAA,WACF,IAEA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,MAAK;AAAA,YACL,SAAQ;AAAA,YACR,OAAM;AAAA,YACN,cAAY,WAAW,IAAI,QAAQ,IAAI,KAAK;AAAA,YAC5C,SAAS,MAAM,QAAQ,GAAG;AAAA,YAE1B,8BAAC,iBAAc,WAAU,WAAU;AAAA;AAAA,QACrC;AAAA,WA/DK,IAAI,UAiEb,CACD,GACH;AAAA,MAEF,qBAAC,SAAI,WAAU,6BACb;AAAA,6BAAC,UAAK;AAAA;AAAA,UACY,oBAAC,YAAQ,wBAAc,WAAM,MAAM,SAAS,GAAE;AAAA,WAChE;AAAA,QACA,qBAAC,UAAK;AAAA;AAAA,UACS,oBAAC,YAAQ,wBAAc,WAAM,MAAM,MAAM,GAAE;AAAA,WAC1D;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -3,10 +3,9 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useMemo, useState } from "react";
|
|
4
4
|
import { ExternalLink, Plus } from "lucide-react";
|
|
5
5
|
import {
|
|
6
|
-
PROJECT_CREATION_DENIED_REASON,
|
|
7
6
|
useArbiSessionState,
|
|
8
7
|
useArbiSessionStore,
|
|
9
|
-
|
|
8
|
+
useProjectCreationDenial,
|
|
10
9
|
useProjects
|
|
11
10
|
} from "@arbidocs/react";
|
|
12
11
|
import { Button, EntityIcon, entityNoun, getEntityLabel } from "@arbidocs/react/ui";
|
|
@@ -21,6 +20,7 @@ import {
|
|
|
21
20
|
} from "../../settings/index.js";
|
|
22
21
|
import { ArbiHost } from "../../provider/host.js";
|
|
23
22
|
import { useConnectedWorkspace } from "../ConnectionProvider.js";
|
|
23
|
+
import { ChangePlanDialog } from "../billing/ChangePlanDialog.js";
|
|
24
24
|
import { NewProjectFlow } from "../billing/NewProjectFlow.js";
|
|
25
25
|
import { ProjectDetail } from "../billing/ProjectDetail.js";
|
|
26
26
|
import { ProjectsTable } from "../billing/ProjectsTable.js";
|
|
@@ -59,11 +59,12 @@ function ConnectedProjectsPanel({
|
|
|
59
59
|
[openLocally]
|
|
60
60
|
);
|
|
61
61
|
const { data: projects } = useProjects();
|
|
62
|
-
const
|
|
62
|
+
const denial = useProjectCreationDenial();
|
|
63
63
|
const { userId } = useConnectedWorkspace();
|
|
64
64
|
const { stripeEnabled } = useBillingSupport();
|
|
65
65
|
const billingPortal = useOpenBillingPortal();
|
|
66
66
|
const [newProjectOpen, setNewProjectOpen] = useState(false);
|
|
67
|
+
const [upgradeOpen, setUpgradeOpen] = useState(false);
|
|
67
68
|
useAutoRefreshPendingProjects();
|
|
68
69
|
const ownedCount = (projects ?? []).filter((p) => p.created_by === userId).length;
|
|
69
70
|
const activeProjectId = tabs.activeProjectId && tabs.openProjectIds.includes(tabs.activeProjectId) ? tabs.activeProjectId : null;
|
|
@@ -88,6 +89,8 @@ function ConnectedProjectsPanel({
|
|
|
88
89
|
[ownedCount, tabs, projects]
|
|
89
90
|
);
|
|
90
91
|
const paidProject = projects?.find(isPaid);
|
|
92
|
+
const personalProject = projects?.find((p) => p.is_personal && p.created_by === userId);
|
|
93
|
+
const upgradeFirst = denial?.refusal === "pro_required" && !!personalProject;
|
|
91
94
|
const panel = /* @__PURE__ */ jsxs(PanelFrame, { className, testId: "projects-panel", children: [
|
|
92
95
|
/* @__PURE__ */ jsx(DraggableHeader, { children: /* @__PURE__ */ jsx(
|
|
93
96
|
TabHeader,
|
|
@@ -99,11 +102,12 @@ function ConnectedProjectsPanel({
|
|
|
99
102
|
PanelAddButton,
|
|
100
103
|
{
|
|
101
104
|
label: `New ${entityNoun("PROJECT")}`,
|
|
102
|
-
onClick: () => setNewProjectOpen(true),
|
|
105
|
+
onClick: () => upgradeFirst ? setUpgradeOpen(true) : setNewProjectOpen(true),
|
|
103
106
|
icon: /* @__PURE__ */ jsx(Plus, { className: "size-4" }),
|
|
104
107
|
isCompact,
|
|
105
108
|
testId: "new-project-button",
|
|
106
|
-
|
|
109
|
+
tooltip: upgradeFirst ? denial?.reason : void 0,
|
|
110
|
+
disabledReason: upgradeFirst ? void 0 : denial?.reason
|
|
107
111
|
}
|
|
108
112
|
),
|
|
109
113
|
rightContent: headerRight,
|
|
@@ -136,6 +140,14 @@ function ConnectedProjectsPanel({
|
|
|
136
140
|
/* @__PURE__ */ jsx(SharedProjects, {}),
|
|
137
141
|
/* @__PURE__ */ jsx(ConnectedDeploymentStorage, {})
|
|
138
142
|
] }) }),
|
|
143
|
+
/* @__PURE__ */ jsx(
|
|
144
|
+
ChangePlanDialog,
|
|
145
|
+
{
|
|
146
|
+
project: upgradeFirst ? personalProject ?? null : null,
|
|
147
|
+
open: upgradeOpen && upgradeFirst,
|
|
148
|
+
onOpenChange: setUpgradeOpen
|
|
149
|
+
}
|
|
150
|
+
),
|
|
139
151
|
/* @__PURE__ */ jsx(
|
|
140
152
|
NewProjectFlow,
|
|
141
153
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/projects/ConnectedProjectsPanel.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * The Projects panel (\"Plan & Usage\"): the base tab lists the user's projects (plan, usage,\n * collaborators), the billing portal, the projects shared with them and the deployment's storage\n * (`ConnectedDeploymentStorage`, for its admins); each project the user opens gets a closeable tab\n * with its detail and its storage (`ConnectedProjectStorage`). \"New project\" sits after the tabs.\n * The projects list as a page of its own is `ConnectedProjectsListPage`.\n *\n * Opening a project anywhere goes through `BlocksEnvironment.openProject`. A host that opens\n * project tabs elsewhere opens them in the session (`openProjectTab`, the panel's tabs by default);\n * a host may keep them itself (`tabs`).\n */\nimport { useMemo, useState, type ReactNode } from 'react'\nimport { ExternalLink, Plus } from 'lucide-react'\nimport {\n
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * The Projects panel (\"Plan & Usage\"): the base tab lists the user's projects (plan, usage,\n * collaborators), the billing portal, the projects shared with them and the deployment's storage\n * (`ConnectedDeploymentStorage`, for its admins); each project the user opens gets a closeable tab\n * with its detail and its storage (`ConnectedProjectStorage`). \"New project\" sits after the tabs.\n * The projects list as a page of its own is `ConnectedProjectsListPage`.\n *\n * Opening a project anywhere goes through `BlocksEnvironment.openProject`. A host that opens\n * project tabs elsewhere opens them in the session (`openProjectTab`, the panel's tabs by default);\n * a host may keep them itself (`tabs`).\n */\nimport { useMemo, useState, type ReactNode } from 'react'\nimport { ExternalLink, Plus } from 'lucide-react'\nimport {\n useArbiSessionState,\n useArbiSessionStore,\n useProjectCreationDenial,\n useProjects,\n} from '@arbidocs/react'\nimport { Button, EntityIcon, entityNoun, getEntityLabel } from '@arbidocs/react/ui'\nimport { TabHeader, type Tab } from '../../shell/TabHeader'\nimport {\n DraggableHeader,\n PanelActionsRow,\n PanelAddButton,\n PanelFrame,\n PanelFrameBody,\n PanelScroll,\n} from '../../settings'\nimport { ArbiHost } from '../../provider/host'\nimport { useConnectedWorkspace } from '../ConnectionProvider'\nimport { ChangePlanDialog } from '../billing/ChangePlanDialog'\nimport { NewProjectFlow } from '../billing/NewProjectFlow'\nimport { ProjectDetail } from '../billing/ProjectDetail'\nimport { ProjectsTable } from '../billing/ProjectsTable'\nimport { SharedProjects } from '../billing/SharedProjects'\nimport { useBillingSupport } from '../billing/support'\nimport { useAutoRefreshPendingProjects } from '../billing/useAutoRefreshPendingProjects'\nimport { useOpenBillingPortal } from '../billing/useOpenBillingPortal'\nimport { ConnectedDeploymentStorage } from '../storage/ConnectedDeploymentStorage'\nimport { ConnectedProjectStorage } from '../storage/ConnectedProjectStorage'\n\n/** The base tab's id. */\nexport const PROJECTS_BASE_TAB_ID = 'projects'\n\n/** The panel's project tabs, kept by a host. */\nexport interface ProjectPanelTabs {\n /** The open project tabs, in order. */\n openProjectIds: readonly string[]\n /** The project shown, or `null` for the base list. */\n activeProjectId: string | null\n /** Show a project's tab (`null`: the base list). */\n onSelect: (projectId: string | null) => void\n onClose: (projectId: string) => void\n}\n\nexport interface ConnectedProjectsPanelProps {\n /** Host-kept tabs; without, the session's (`tabs.projects`, which `openProjectTab` opens). */\n tabs?: ProjectPanelTabs\n /** At the right of the tab header (e.g. the panel's mode switcher). */\n headerRight?: ReactNode\n className?: string\n}\n\nconst isPaid = (p: { subscription: string }) =>\n p.subscription === 'active' || p.subscription === 'past_due'\n\n/** The session's project tabs. */\nfunction useSessionProjectTabs(): ProjectPanelTabs {\n const session = useArbiSessionStore()\n const openProjectIds = useArbiSessionState((state) => state.tabs.projects)\n const activeProjectId = useArbiSessionState((state) => state.tabs.activeProject)\n return useMemo(\n () => ({\n openProjectIds,\n activeProjectId,\n onSelect: (id) => (id ? session.openProjectTab(id) : session.selectProjectTab(null)),\n onClose: (id) => session.closeProjectTab(id),\n }),\n [session, openProjectIds, activeProjectId]\n )\n}\n\nexport function ConnectedProjectsPanel({\n tabs: hostTabs,\n headerRight,\n className,\n}: ConnectedProjectsPanelProps) {\n const sessionTabs = useSessionProjectTabs()\n const tabs = hostTabs ?? sessionTabs\n const openLocally = sessionTabs.onSelect\n // No id: the list.\n const localHost = useMemo(\n () => ({ environment: { openProject: (id?: string) => openLocally(id ?? null) } }),\n [openLocally]\n )\n const { data: projects } = useProjects()\n const denial = useProjectCreationDenial()\n const { userId } = useConnectedWorkspace()\n const { stripeEnabled } = useBillingSupport()\n const billingPortal = useOpenBillingPortal()\n const [newProjectOpen, setNewProjectOpen] = useState(false)\n const [upgradeOpen, setUpgradeOpen] = useState(false)\n // A project paid for at checkout shows as pending until Stripe confirms it.\n useAutoRefreshPendingProjects()\n\n const ownedCount = (projects ?? []).filter((p) => p.created_by === userId).length\n const activeProjectId =\n tabs.activeProjectId && tabs.openProjectIds.includes(tabs.activeProjectId)\n ? tabs.activeProjectId\n : null\n\n const headerTabs = useMemo<Tab[]>(\n () => [\n {\n id: PROJECTS_BASE_TAB_ID,\n // Named by its job; \"project\" is for the per-project tabs, where owning several matters.\n label: 'Plan & Usage',\n icon: <EntityIcon entityType=\"PROJECT\" />,\n // Most users own one project: a count only once there are several.\n count: ownedCount > 1 ? ownedCount : undefined,\n },\n ...tabs.openProjectIds.map((id) => ({\n id,\n label: projects?.find((p) => p.external_id === id)?.name ?? getEntityLabel('PROJECT'),\n icon: <EntityIcon entityType=\"PROJECT\" />,\n onClose: () => tabs.onClose(id),\n closeTooltip: `Close ${entityNoun('PROJECT')}`,\n })),\n ],\n [ownedCount, tabs, projects]\n )\n\n const paidProject = projects?.find(isPaid)\n // Without Pro (hosted service), \"New\" upgrades the personal project: then projects can be created.\n const personalProject = projects?.find((p) => p.is_personal && p.created_by === userId)\n const upgradeFirst = denial?.refusal === 'pro_required' && !!personalProject\n const panel = (\n <PanelFrame className={className} testId=\"projects-panel\">\n <DraggableHeader>\n <TabHeader\n tabs={headerTabs}\n activeTabId={activeProjectId ?? PROJECTS_BASE_TAB_ID}\n onTabChange={(id) => tabs.onSelect(id === PROJECTS_BASE_TAB_ID ? null : id)}\n // \"+ New\" right after the tabs; just its icon in a narrow header.\n afterTabs={(isCompact) => (\n <PanelAddButton\n label={`New ${entityNoun('PROJECT')}`}\n onClick={() => (upgradeFirst ? setUpgradeOpen(true) : setNewProjectOpen(true))}\n icon={<Plus className=\"size-4\" />}\n isCompact={isCompact}\n testId=\"new-project-button\"\n tooltip={upgradeFirst ? denial?.reason : undefined}\n disabledReason={upgradeFirst ? undefined : denial?.reason}\n />\n )}\n rightContent={headerRight}\n variant=\"underline\"\n // The panel is ~544px, \"compact\" at the default 640: that would hide the count and the\n // open project's name. \"+ New\" still collapses on a really narrow panel.\n compactBreakpoint={360}\n />\n </DraggableHeader>\n\n <PanelFrameBody>\n {activeProjectId ? (\n <PanelScroll>\n <ProjectDetail\n projectExtId={activeProjectId}\n storage={<ConnectedProjectStorage projectExtId={activeProjectId} />}\n />\n </PanelScroll>\n ) : (\n <PanelScroll variant=\"padded\">\n <ProjectsTable />\n {/* A list-level action, not a project tab's. */}\n {stripeEnabled && paidProject && (\n <PanelActionsRow>\n <Button\n onClick={() => billingPortal.open(paidProject.external_id)}\n size=\"sm\"\n variant=\"outline\"\n disabled={billingPortal.isPending}\n className=\"flex items-center gap-1\"\n >\n {billingPortal.isPending ? 'Opening\u2026' : 'Billing portal'}\n {!billingPortal.isPending && <ExternalLink className=\"h-3.5 w-3.5\" />}\n </Button>\n </PanelActionsRow>\n )}\n <SharedProjects />\n {/* Box admins and billing managers only (renders nothing for anyone else). */}\n <ConnectedDeploymentStorage />\n </PanelScroll>\n )}\n </PanelFrameBody>\n\n <ChangePlanDialog\n project={upgradeFirst ? (personalProject ?? null) : null}\n open={upgradeOpen && upgradeFirst}\n onOpenChange={setUpgradeOpen}\n />\n\n <NewProjectFlow\n open={newProjectOpen}\n onOpenChange={setNewProjectOpen}\n defaultName={`${getEntityLabel('PROJECT')} ${(projects?.length ?? 0) + 1}`}\n />\n </PanelFrame>\n )\n\n // Without host tabs, a project opened inside the panel opens here.\n return hostTabs ? panel : <ArbiHost config={localHost}>{panel}</ArbiHost>\n}\n"],
|
|
5
|
+
"mappings": ";AAsHc,cA4DE,YA5DF;AA3Gd,SAAS,SAAS,gBAAgC;AAClD,SAAS,cAAc,YAAY;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,QAAQ,YAAY,YAAY,sBAAsB;AAC/D,SAAS,iBAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB;AACzB,SAAS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AS,QAAQ,WAAY,iBAAM;AAChE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
PROJECT_CREATION_DENIED_REASON,
|
|
5
5
|
readWorkspaceLastOpened,
|
|
6
6
|
toShellWorkspace,
|
|
7
|
-
|
|
7
|
+
useCanCreateWorkspaces,
|
|
8
8
|
useCurrentWorkspace,
|
|
9
9
|
useShellWorkspaces,
|
|
10
10
|
useSwitchWorkspace,
|
|
@@ -24,7 +24,7 @@ function ConnectedWorkspaceSwitcher({
|
|
|
24
24
|
const { workspace } = useCurrentWorkspace();
|
|
25
25
|
const { data: workspaces = [] } = useWorkspaces();
|
|
26
26
|
const { switchWorkspace } = useSwitchWorkspace();
|
|
27
|
-
const
|
|
27
|
+
const canCreateWorkspaces = useCanCreateWorkspaces();
|
|
28
28
|
const { active, recent, open } = useShellWorkspaces({
|
|
29
29
|
workspaces,
|
|
30
30
|
selectedId: workspace?.external_id ?? null,
|
|
@@ -45,7 +45,7 @@ function ConnectedWorkspaceSwitcher({
|
|
|
45
45
|
...props,
|
|
46
46
|
workspace: current,
|
|
47
47
|
recent,
|
|
48
|
-
newWorkspaceDisabledReason:
|
|
48
|
+
newWorkspaceDisabledReason: canCreateWorkspaces === false ? PROJECT_CREATION_DENIED_REASON : void 0,
|
|
49
49
|
onSwitch: (w) => void open(w),
|
|
50
50
|
labels: {
|
|
51
51
|
plural: getEntityLabel("WORKSPACE", "PLURAL"),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/shell/ConnectedWorkspaceSwitcher.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * The workspace switcher, connected: the open workspace (with its project pill), the other\n * workspaces most recently opened first, switching through the shared session, and the create\n * permission. The host says where \"all workspaces\" and \"new\" go and where a switch lands.\n */\n\nimport type { WorkspaceResponse } from '@arbidocs/sdk/browser'\nimport {\n PROJECT_CREATION_DENIED_REASON,\n readWorkspaceLastOpened,\n toShellWorkspace,\n
|
|
5
|
-
"mappings": ";AAqEI;AA9DJ;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,uBAAuB,sBAAsB;AACtD,SAAS,yBAAsD;AAC/D,SAAS,4BAA4B;AAGrC,MAAM,aAAa;AAGnB,SAAS,kBAAkB,OAA2B,WAA8B;AAClF,SAAO,EAAE,aAAa,qBAAqB,SAAS,EAAE;AACxD;AAWO,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA,GAAG;AACL,GAAoC;AAClC,QAAM,EAAE,UAAU,IAAI,oBAAoB;AAC1C,QAAM,EAAE,MAAM,aAAa,CAAC,EAAE,IAAI,cAAc;AAChD,QAAM,EAAE,gBAAgB,IAAI,mBAAmB;AAC/C,QAAM,
|
|
4
|
+
"sourcesContent": ["/**\n * The workspace switcher, connected: the open workspace (with its project pill), the other\n * workspaces most recently opened first, switching through the shared session, and the create\n * permission. The host says where \"all workspaces\" and \"new\" go and where a switch lands.\n */\n\nimport type { WorkspaceResponse } from '@arbidocs/sdk/browser'\nimport {\n PROJECT_CREATION_DENIED_REASON,\n readWorkspaceLastOpened,\n toShellWorkspace,\n useCanCreateWorkspaces,\n useCurrentWorkspace,\n useShellWorkspaces,\n useSwitchWorkspace,\n useWorkspaces,\n type ShellWorkspaceItem,\n} from '@arbidocs/react'\nimport { formatCompactLastSeen, getEntityLabel } from '@arbidocs/react/ui'\nimport { WorkspaceSwitcher, type WorkspaceSwitcherProps } from '../../shell/Workspace'\nimport { workspaceProjectLine } from './workspace-project-line'\n\n/** How many recent workspaces to offer for quick-switch. */\nconst MAX_RECENT = 4\n\n/** `decorate` for `useShellWorkspaces`; module-level so its identity is stable. */\nfunction decorateWorkspace(_item: ShellWorkspaceItem, workspace: WorkspaceResponse) {\n return { projectLine: workspaceProjectLine(workspace) }\n}\n\nexport interface ConnectedWorkspaceSwitcherProps extends Pick<\n WorkspaceSwitcherProps,\n 'compact' | 'variant' | 'onGoToList' | 'onNewWorkspace'\n> {\n /** After a switch succeeded: where the person lands. */\n onSwitched?: () => void\n}\n\n/** Renders nothing while no workspace is open. */\nexport function ConnectedWorkspaceSwitcher({\n onSwitched,\n ...props\n}: ConnectedWorkspaceSwitcherProps) {\n const { workspace } = useCurrentWorkspace()\n const { data: workspaces = [] } = useWorkspaces()\n const { switchWorkspace } = useSwitchWorkspace()\n const canCreateWorkspaces = useCanCreateWorkspaces()\n\n const { active, recent, open } = useShellWorkspaces({\n workspaces,\n selectedId: workspace?.external_id ?? null,\n decorate: decorateWorkspace,\n recentLimit: MAX_RECENT,\n lastOpened: readWorkspaceLastOpened(),\n formatLastSeen: formatCompactLastSeen,\n // switchWorkspace reports its own failures.\n select: async (w) => {\n if (await switchWorkspace({ id: w.id, name: w.name })) onSwitched?.()\n },\n })\n if (!workspace) return null\n\n // The list may not hold the workspace yet (loading): the session's is the truth for this one.\n const current: ShellWorkspaceItem =\n active?.id === workspace.external_id\n ? active\n : { ...toShellWorkspace(workspace), projectLine: workspaceProjectLine(workspace) }\n\n return (\n <WorkspaceSwitcher\n {...props}\n workspace={current}\n recent={recent}\n newWorkspaceDisabledReason={\n canCreateWorkspaces === false ? PROJECT_CREATION_DENIED_REASON : undefined\n }\n onSwitch={(w) => void open(w)}\n labels={{\n plural: getEntityLabel('WORKSPACE', 'PLURAL'),\n singular: getEntityLabel('WORKSPACE', 'SINGULAR'),\n }}\n />\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAqEI;AA9DJ;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,uBAAuB,sBAAsB;AACtD,SAAS,yBAAsD;AAC/D,SAAS,4BAA4B;AAGrC,MAAM,aAAa;AAGnB,SAAS,kBAAkB,OAA2B,WAA8B;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
+
import { PROJECT_CREATION_DENIED_REASON, useCanCreateWorkspaces } from "@arbidocs/react";
|
|
5
5
|
import { Button, EntityIcon, getEntityLabel } from "@arbidocs/react/ui";
|
|
6
6
|
import {
|
|
7
7
|
WorkspaceFormModal
|
|
@@ -19,7 +19,7 @@ function ConnectedWorkspaceFormModal({
|
|
|
19
19
|
...frame
|
|
20
20
|
}) {
|
|
21
21
|
const [submitting, setSubmitting] = useState(false);
|
|
22
|
-
const allowed =
|
|
22
|
+
const allowed = useCanCreateWorkspaces();
|
|
23
23
|
const { openWorkspace, live } = useConnectedWorkspace();
|
|
24
24
|
const demoSeed = !live ? seed : void 0;
|
|
25
25
|
const canCreate = demoSeed ? true : allowed;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/workspace-form/ConnectedWorkspaceFormModal.tsx"],
|
|
4
|
-
"sourcesContent": ["/** Workspace creation bound to the existing form modal and project picker. */\nimport { useState } from 'react'\nimport { PROJECT_CREATION_DENIED_REASON,
|
|
5
|
-
"mappings": ";AAgCS,cA2BC,YA3BD;AA/BT,SAAS,gBAAgB;AACzB,SAAS,gCAAgC,
|
|
4
|
+
"sourcesContent": ["/** Workspace creation bound to the existing form modal and project picker. */\nimport { useState } from 'react'\nimport { PROJECT_CREATION_DENIED_REASON, useCanCreateWorkspaces } from '@arbidocs/react'\nimport { Button, EntityIcon, getEntityLabel } from '@arbidocs/react/ui'\nimport {\n WorkspaceFormModal,\n type WorkspaceFormModalProps,\n} from '../../workspaces/WorkspaceFormParts'\nimport { useConnectedWorkspace } from '../ConnectionProvider'\nimport { WorkspaceCreateForm } from './WorkspaceCreateForm'\n\nimport type { WorkspaceCreated, WorkspaceFormSeed } from './types'\n\nexport interface ConnectedWorkspaceFormModalProps extends Omit<\n WorkspaceFormModalProps,\n 'children'\n> {\n /** Demo fixture data and local creation; ignored while signed in to a live session. */\n seed?: WorkspaceFormSeed\n /** Preselect the owning project (the forProject variant). */\n projectId?: string | null\n /** Complete the host's creation flow. By default the new workspace is opened. */\n onCreated?: (workspace: WorkspaceCreated) => Promise<void> | void\n}\n\nexport function ConnectedWorkspaceFormModal({\n open,\n onOpenChange,\n projectId,\n onCreated,\n seed,\n testId = 'create-workspace-modal',\n icon = <EntityIcon entityType=\"WORKSPACE\" className=\"size-5\" />,\n ...frame\n}: ConnectedWorkspaceFormModalProps) {\n const [submitting, setSubmitting] = useState(false)\n const allowed = useCanCreateWorkspaces()\n const { openWorkspace, live } = useConnectedWorkspace()\n const demoSeed = !live ? seed : undefined\n const canCreate = demoSeed ? true : allowed\n const workspaceLabel = getEntityLabel('WORKSPACE')\n\n return (\n <WorkspaceFormModal\n {...frame}\n {...(canCreate === false\n ? {\n variant: 'create' as const,\n title: `Create New ${workspaceLabel}`,\n intro: undefined,\n }\n : {})}\n open={open}\n onOpenChange={(next) => !submitting && onOpenChange(next)}\n icon={icon}\n testId={testId}\n >\n {canCreate === false ? (\n <div className=\"flex flex-col gap-5\" data-testid=\"create-workspace-not-allowed\">\n <p className=\"text-sm text-muted-foreground\">\n {PROJECT_CREATION_DENIED_REASON} When a colleague adds you to a{' '}\n {workspaceLabel.toLowerCase()}, it appears in your list.\n </p>\n <Button className=\"self-end\" onClick={() => onOpenChange(false)}>\n OK\n </Button>\n </div>\n ) : open ? (\n <WorkspaceCreateForm\n key={projectId ?? 'default'}\n defaultProjectId={projectId}\n seed={demoSeed}\n onPendingChange={setSubmitting}\n onCreated={\n onCreated ??\n ((workspace) => openWorkspace(workspace.external_id, { name: workspace.name }))\n }\n onCancel={() => onOpenChange(false)}\n />\n ) : null}\n </WorkspaceFormModal>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAgCS,cA2BC,YA3BD;AA/BT,SAAS,gBAAgB;AACzB,SAAS,gCAAgC,8BAA8B;AACvE,SAAS,QAAQ,YAAY,sBAAsB;AACnD;AAAA,EACE;AAAA,OAEK;AACP,SAAS,6BAA6B;AACtC,SA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
@@ -82,7 +82,7 @@ function ConnectedWorkspaceList({
|
|
|
82
82
|
if (select) select();
|
|
83
83
|
else void openWorkspace(workspace.external_id, { name: workspace.name });
|
|
84
84
|
};
|
|
85
|
-
const createDisabledReason = list.
|
|
85
|
+
const createDisabledReason = list.canCreateWorkspaces === false ? PROJECT_CREATION_DENIED_REASON : void 0;
|
|
86
86
|
if (temporaryOnly && workspacesQuery.isSuccess && workspacesQuery.data?.length === 0) {
|
|
87
87
|
return /* @__PURE__ */ jsx(
|
|
88
88
|
NoWorkspaceAccess,
|