@streamoid/settings 0.4.6 → 0.6.0
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/index.d.mts +116 -35
- package/dist/index.d.ts +116 -35
- package/dist/index.js +209 -123
- package/dist/index.mjs +209 -123
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -31,7 +31,6 @@ __export(index_exports, {
|
|
|
31
31
|
InviteUpdateModal: () => InviteUpdateModal,
|
|
32
32
|
MemberListFrame: () => MemberListFrame,
|
|
33
33
|
MemberListToolbar: () => MemberListToolbar,
|
|
34
|
-
OrgMembershipTag: () => OrgMembershipTag,
|
|
35
34
|
OrganizationContent: () => OrganizationContent,
|
|
36
35
|
OrganizationInviteModal: () => OrganizationInviteModal,
|
|
37
36
|
OrganizationModal: () => OrganizationModal,
|
|
@@ -1600,7 +1599,7 @@ function ScopeHeader({
|
|
|
1600
1599
|
}) {
|
|
1601
1600
|
const displayName = name?.trim() || (kind === "workspace" ? "Workspace" : "Organization");
|
|
1602
1601
|
const ScopeIcon = kind === "workspace" ? import_icons.SiconWorkspace : import_icons.SiconGlobe;
|
|
1603
|
-
const roleLabel = role === "admin" ? "You're an admin" : role ? "You're a member" : null;
|
|
1602
|
+
const roleLabel = role === "admin" ? "You're an admin" : role === "member" ? "You're a member" : role === "guest" ? "You're a guest" : null;
|
|
1604
1603
|
const detail = [roleLabel, ...facts].filter((part) => typeof part === "string" && part.length > 0).join(" \xB7 ");
|
|
1605
1604
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1606
1605
|
"div",
|
|
@@ -2098,8 +2097,9 @@ function OrganizationAffiliationCard({
|
|
|
2098
2097
|
let cancelled = false;
|
|
2099
2098
|
organizationAdapter.list().then((orgs) => {
|
|
2100
2099
|
if (cancelled) return;
|
|
2101
|
-
|
|
2102
|
-
|
|
2100
|
+
const joinable = orgs.filter((org) => org.role !== "guest");
|
|
2101
|
+
setAvailableOrgs(joinable);
|
|
2102
|
+
setSelectedOrgId((prev) => prev || joinable[0]?._id || "");
|
|
2103
2103
|
}).catch(() => {
|
|
2104
2104
|
if (!cancelled) setAvailableOrgs([]);
|
|
2105
2105
|
});
|
|
@@ -2582,12 +2582,19 @@ function InviteUpdateModal({
|
|
|
2582
2582
|
onSave,
|
|
2583
2583
|
onRemove,
|
|
2584
2584
|
canRemove = true,
|
|
2585
|
+
showOrganizationStanding = false,
|
|
2586
|
+
organizationName,
|
|
2587
|
+
allowGuestStanding = true,
|
|
2588
|
+
initialOrganizationStanding = "guest",
|
|
2585
2589
|
onInvite
|
|
2586
2590
|
}) {
|
|
2587
2591
|
useOverlayOpen(open, onClose);
|
|
2588
2592
|
const [emailValue, setEmailValue] = (0, import_react7.useState)("");
|
|
2589
2593
|
const [hasChanges, setHasChanges] = (0, import_react7.useState)(false);
|
|
2590
2594
|
const [role, setRole] = (0, import_react7.useState)("admin");
|
|
2595
|
+
const [orgStanding, setOrgStanding] = (0, import_react7.useState)(
|
|
2596
|
+
initialOrganizationStanding
|
|
2597
|
+
);
|
|
2591
2598
|
const [canUseCredits, setCanUseCredits] = (0, import_react7.useState)(false);
|
|
2592
2599
|
const [canInviteUser, setCanInviteUser] = (0, import_react7.useState)(false);
|
|
2593
2600
|
const [artifaxOn, setArtifaxOn] = (0, import_react7.useState)(!hiddenApps.includes("artifax"));
|
|
@@ -2624,6 +2631,7 @@ function InviteUpdateModal({
|
|
|
2624
2631
|
setEmailValue("");
|
|
2625
2632
|
setHasChanges(false);
|
|
2626
2633
|
setRole("admin");
|
|
2634
|
+
setOrgStanding(initialOrganizationStanding);
|
|
2627
2635
|
setCanUseCredits(true);
|
|
2628
2636
|
setCanInviteUser(true);
|
|
2629
2637
|
setArtifaxOn(!hidden.has("artifax"));
|
|
@@ -2633,7 +2641,7 @@ function InviteUpdateModal({
|
|
|
2633
2641
|
setStoreSearch("");
|
|
2634
2642
|
setSelectedStores(/* @__PURE__ */ new Set());
|
|
2635
2643
|
}
|
|
2636
|
-
}, [open, initialPermissions, hiddenKey]);
|
|
2644
|
+
}, [open, initialPermissions, hiddenKey, initialOrganizationStanding]);
|
|
2637
2645
|
if (!open) return null;
|
|
2638
2646
|
const isInvite = mode === "invite";
|
|
2639
2647
|
const hasEmail = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(emailValue.trim());
|
|
@@ -3009,6 +3017,95 @@ function InviteUpdateModal({
|
|
|
3009
3017
|
]
|
|
3010
3018
|
}
|
|
3011
3019
|
),
|
|
3020
|
+
showOrganizationStanding && mode === "invite" && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
3021
|
+
"div",
|
|
3022
|
+
{
|
|
3023
|
+
className: "flex flex-col items-start justify-center shrink-0 w-full",
|
|
3024
|
+
style: { gap: T6.spXs },
|
|
3025
|
+
children: [
|
|
3026
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FieldLabel2, { text: "Organization access" }),
|
|
3027
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
3028
|
+
"div",
|
|
3029
|
+
{
|
|
3030
|
+
className: "shrink-0 w-full relative",
|
|
3031
|
+
style: { borderRadius: T6.rXl },
|
|
3032
|
+
children: [
|
|
3033
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3034
|
+
"div",
|
|
3035
|
+
{
|
|
3036
|
+
"aria-hidden": true,
|
|
3037
|
+
className: "absolute inset-0 pointer-events-none",
|
|
3038
|
+
style: {
|
|
3039
|
+
border: `0.5px solid ${T6.borderSubtle}`,
|
|
3040
|
+
borderRadius: T6.rXl
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
),
|
|
3044
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex flex-row items-center size-full", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3045
|
+
"div",
|
|
3046
|
+
{
|
|
3047
|
+
className: "flex items-center w-full",
|
|
3048
|
+
style: { padding: T6.spXs },
|
|
3049
|
+
children: [
|
|
3050
|
+
["colleague", "Colleague"],
|
|
3051
|
+
...allowGuestStanding ? [["guest", "Guest"]] : []
|
|
3052
|
+
].map(([value, label]) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3053
|
+
"div",
|
|
3054
|
+
{
|
|
3055
|
+
className: "flex-1 min-w-0 cursor-pointer",
|
|
3056
|
+
style: {
|
|
3057
|
+
background: orgStanding === value ? T6.neutral300 : "transparent",
|
|
3058
|
+
borderRadius: T6.rMd
|
|
3059
|
+
},
|
|
3060
|
+
onClick: () => {
|
|
3061
|
+
setOrgStanding(value);
|
|
3062
|
+
markChanged();
|
|
3063
|
+
},
|
|
3064
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "flex flex-row items-center justify-center size-full", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3065
|
+
"div",
|
|
3066
|
+
{
|
|
3067
|
+
className: "flex items-center justify-center w-full",
|
|
3068
|
+
style: { padding: T6.spMd },
|
|
3069
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3070
|
+
"span",
|
|
3071
|
+
{
|
|
3072
|
+
style: {
|
|
3073
|
+
fontFamily: T6.font,
|
|
3074
|
+
fontSize: T6.fsSm,
|
|
3075
|
+
fontWeight: orgStanding === value ? 500 : 400,
|
|
3076
|
+
lineHeight: T6.lhSm,
|
|
3077
|
+
color: orgStanding === value ? T6.inverse : T6.muted,
|
|
3078
|
+
textAlign: "center"
|
|
3079
|
+
},
|
|
3080
|
+
children: label
|
|
3081
|
+
}
|
|
3082
|
+
)
|
|
3083
|
+
}
|
|
3084
|
+
) })
|
|
3085
|
+
},
|
|
3086
|
+
value
|
|
3087
|
+
))
|
|
3088
|
+
}
|
|
3089
|
+
) })
|
|
3090
|
+
]
|
|
3091
|
+
}
|
|
3092
|
+
),
|
|
3093
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
3094
|
+
"span",
|
|
3095
|
+
{
|
|
3096
|
+
style: {
|
|
3097
|
+
fontFamily: T6.font,
|
|
3098
|
+
fontSize: T6.fsXs,
|
|
3099
|
+
fontWeight: 400,
|
|
3100
|
+
lineHeight: T6.lhXs,
|
|
3101
|
+
color: T6.tertiary
|
|
3102
|
+
},
|
|
3103
|
+
children: orgStanding === "colleague" ? `Joins ${organizationName || "the organization"} as a member \u2014 they'll also see its shared workspaces.` : `This workspace only. They see nothing else in ${organizationName || "the organization"}.`
|
|
3104
|
+
}
|
|
3105
|
+
)
|
|
3106
|
+
]
|
|
3107
|
+
}
|
|
3108
|
+
),
|
|
3012
3109
|
role !== "admin" && shownApps.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
3013
3110
|
"div",
|
|
3014
3111
|
{
|
|
@@ -3641,7 +3738,11 @@ function InviteUpdateModal({
|
|
|
3641
3738
|
catalogixStores: role === "admin" || showsApp("catalogix") ? Array.from(selectedStores) : []
|
|
3642
3739
|
};
|
|
3643
3740
|
if (isInvite && onInvite) {
|
|
3644
|
-
onInvite(
|
|
3741
|
+
onInvite(
|
|
3742
|
+
perms,
|
|
3743
|
+
emailValue.trim(),
|
|
3744
|
+
showOrganizationStanding ? orgStanding : void 0
|
|
3745
|
+
);
|
|
3645
3746
|
} else if (onSave) {
|
|
3646
3747
|
onSave(perms);
|
|
3647
3748
|
}
|
|
@@ -3815,31 +3916,6 @@ function MemberListFrame({
|
|
|
3815
3916
|
}
|
|
3816
3917
|
);
|
|
3817
3918
|
}
|
|
3818
|
-
function OrgMembershipTag({
|
|
3819
|
-
organizationName,
|
|
3820
|
-
isOrgAdmin
|
|
3821
|
-
}) {
|
|
3822
|
-
const org = organizationName?.trim() || "the organization";
|
|
3823
|
-
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3824
|
-
"span",
|
|
3825
|
-
{
|
|
3826
|
-
className: "shrink-0 whitespace-nowrap",
|
|
3827
|
-
style: {
|
|
3828
|
-
fontFamily: T7.font,
|
|
3829
|
-
fontSize: T7.fsXs,
|
|
3830
|
-
fontWeight: 500,
|
|
3831
|
-
lineHeight: T7.lhSm,
|
|
3832
|
-
padding: "1px 8px",
|
|
3833
|
-
borderRadius: "var(--radius-full)",
|
|
3834
|
-
color: isOrgAdmin ? T7.primary : T7.muted,
|
|
3835
|
-
border: `1px solid ${isOrgAdmin ? T7.primary : T7.borderSubtle}`,
|
|
3836
|
-
backgroundColor: "transparent"
|
|
3837
|
-
},
|
|
3838
|
-
title: `Admin of ${org} \u2014 keeps access to this workspace regardless of what is set here. Manage under Organization \u203A People.`,
|
|
3839
|
-
children: "Org admin"
|
|
3840
|
-
}
|
|
3841
|
-
);
|
|
3842
|
-
}
|
|
3843
3919
|
function RoleChip({
|
|
3844
3920
|
role,
|
|
3845
3921
|
label
|
|
@@ -4258,8 +4334,6 @@ function AccessIcons({ permissions }) {
|
|
|
4258
4334
|
function TeamRow({
|
|
4259
4335
|
member,
|
|
4260
4336
|
variant,
|
|
4261
|
-
orgMembership,
|
|
4262
|
-
organizationName,
|
|
4263
4337
|
onClick,
|
|
4264
4338
|
onCancelInvite,
|
|
4265
4339
|
onResendInvite
|
|
@@ -4325,22 +4399,13 @@ function TeamRow({
|
|
|
4325
4399
|
]
|
|
4326
4400
|
}
|
|
4327
4401
|
),
|
|
4328
|
-
/* @__PURE__ */ (0, import_jsx_runtime12.
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
),
|
|
4336
|
-
orgMembership && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4337
|
-
OrgMembershipTag,
|
|
4338
|
-
{
|
|
4339
|
-
organizationName,
|
|
4340
|
-
isOrgAdmin: orgMembership.isOrgAdmin
|
|
4341
|
-
}
|
|
4342
|
-
)
|
|
4343
|
-
] }),
|
|
4402
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex items-center shrink-0", style: { gap: 6 }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4403
|
+
RoleChip,
|
|
4404
|
+
{
|
|
4405
|
+
role: member.permissions.role === "admin" ? "admin" : "member",
|
|
4406
|
+
label: member.permissions.role === "admin" ? "Workspace admin" : "Member"
|
|
4407
|
+
}
|
|
4408
|
+
) }),
|
|
4344
4409
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(AccessIcons, { permissions: member.permissions }),
|
|
4345
4410
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4346
4411
|
"div",
|
|
@@ -4407,7 +4472,7 @@ function TeamsContent({
|
|
|
4407
4472
|
organizationName,
|
|
4408
4473
|
hiddenApps
|
|
4409
4474
|
} = {}) {
|
|
4410
|
-
const { auth, api,
|
|
4475
|
+
const { auth, api, workspace, organization, toast } = useSettingsAdapters();
|
|
4411
4476
|
const user = auth.user;
|
|
4412
4477
|
const [activeTab, setActiveTab] = (0, import_react8.useState)("active");
|
|
4413
4478
|
const [activeMembers, setActiveMembers] = (0, import_react8.useState)([]);
|
|
@@ -4417,9 +4482,6 @@ function TeamsContent({
|
|
|
4417
4482
|
const [highestRole, setHighestRole] = (0, import_react8.useState)("admin");
|
|
4418
4483
|
const [searchQuery, setSearchQuery] = (0, import_react8.useState)("");
|
|
4419
4484
|
const [loadingData, setLoadingData] = (0, import_react8.useState)(false);
|
|
4420
|
-
const [orgMemberRoles, setOrgMemberRoles] = (0, import_react8.useState)(
|
|
4421
|
-
() => /* @__PURE__ */ new Map()
|
|
4422
|
-
);
|
|
4423
4485
|
const [modal, setModal] = (0, import_react8.useState)({
|
|
4424
4486
|
open: false,
|
|
4425
4487
|
mode: "invite"
|
|
@@ -4498,37 +4560,6 @@ function TeamsContent({
|
|
|
4498
4560
|
}
|
|
4499
4561
|
}
|
|
4500
4562
|
];
|
|
4501
|
-
const organizationId = organization.current?.id ?? null;
|
|
4502
|
-
(0, import_react8.useEffect)(() => {
|
|
4503
|
-
if (!organizationId) {
|
|
4504
|
-
setOrgMemberRoles(/* @__PURE__ */ new Map());
|
|
4505
|
-
return;
|
|
4506
|
-
}
|
|
4507
|
-
let cancelled = false;
|
|
4508
|
-
organization.fetchMembers().then((members2) => {
|
|
4509
|
-
if (cancelled) return;
|
|
4510
|
-
const next = /* @__PURE__ */ new Map();
|
|
4511
|
-
for (const m of members2) {
|
|
4512
|
-
const email = m.user?.email?.trim().toLowerCase();
|
|
4513
|
-
if (email) next.set(email, m.role);
|
|
4514
|
-
}
|
|
4515
|
-
setOrgMemberRoles(next);
|
|
4516
|
-
}).catch(() => {
|
|
4517
|
-
if (!cancelled) setOrgMemberRoles(/* @__PURE__ */ new Map());
|
|
4518
|
-
});
|
|
4519
|
-
return () => {
|
|
4520
|
-
cancelled = true;
|
|
4521
|
-
};
|
|
4522
|
-
}, [organizationId, organization]);
|
|
4523
|
-
const orgMembershipFor = (0, import_react8.useCallback)(
|
|
4524
|
-
(email) => {
|
|
4525
|
-
const key = email?.trim().toLowerCase();
|
|
4526
|
-
if (!key || orgMemberRoles.size === 0) return void 0;
|
|
4527
|
-
const role = orgMemberRoles.get(key);
|
|
4528
|
-
return role ? { isOrgAdmin: role === "admin" } : void 0;
|
|
4529
|
-
},
|
|
4530
|
-
[orgMemberRoles]
|
|
4531
|
-
);
|
|
4532
4563
|
const fetchData = (0, import_react8.useCallback)(async () => {
|
|
4533
4564
|
setLoadingData(true);
|
|
4534
4565
|
try {
|
|
@@ -4743,7 +4774,7 @@ function TeamsContent({
|
|
|
4743
4774
|
toast.error(msg);
|
|
4744
4775
|
}
|
|
4745
4776
|
};
|
|
4746
|
-
const handleInvite = async (permissions, email) => {
|
|
4777
|
+
const handleInvite = async (permissions, email, organizationStanding) => {
|
|
4747
4778
|
if (highestRole === "member") {
|
|
4748
4779
|
toast.error("You do not have permission to invite users");
|
|
4749
4780
|
closeModal();
|
|
@@ -4757,7 +4788,12 @@ function TeamsContent({
|
|
|
4757
4788
|
inviteAccess: permissions.canInviteUser,
|
|
4758
4789
|
role: permissions.role,
|
|
4759
4790
|
serviceIds,
|
|
4760
|
-
storeIds: permissions.catalogixStores || []
|
|
4791
|
+
storeIds: permissions.catalogixStores || [],
|
|
4792
|
+
// Omitted when the control was never shown, which leaves the backend
|
|
4793
|
+
// deriving the standing from the invitee's email domain as before.
|
|
4794
|
+
...organizationStanding ? {
|
|
4795
|
+
organizationRole: organizationStanding === "colleague" ? "member" : "guest"
|
|
4796
|
+
} : {}
|
|
4761
4797
|
});
|
|
4762
4798
|
toast.success(`Invitation sent to ${email}`);
|
|
4763
4799
|
await fetchData();
|
|
@@ -4778,6 +4814,9 @@ function TeamsContent({
|
|
|
4778
4814
|
const members = activeTab === "active" ? filteredActive : filteredPending;
|
|
4779
4815
|
const workspaceCurrent = workspace.current;
|
|
4780
4816
|
const orgVisibility = workspaceCurrent?.orgVisibility ?? "private";
|
|
4817
|
+
const workspaceOrgId = workspaceCurrent?.organizationId;
|
|
4818
|
+
const orgCurrent = organization.current;
|
|
4819
|
+
const mayGrantOrgMembership = !!workspaceOrgId && orgCurrent?.id === workspaceOrgId && orgCurrent?.role !== "guest" && (orgCurrent?.role === "admin" || orgCurrent?.inviteAccess === true);
|
|
4781
4820
|
const teamInnerContent = /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
4782
4821
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4783
4822
|
ScopeHeader,
|
|
@@ -4859,8 +4898,6 @@ function TeamsContent({
|
|
|
4859
4898
|
{
|
|
4860
4899
|
member,
|
|
4861
4900
|
variant: activeTab,
|
|
4862
|
-
orgMembership: orgMembershipFor(member.userEmail),
|
|
4863
|
-
organizationName,
|
|
4864
4901
|
onClick: activeTab === "active" ? () => openUpdateModal(member) : void 0,
|
|
4865
4902
|
onCancelInvite: () => void handleCancelPendingInvite(member),
|
|
4866
4903
|
onResendInvite: () => void handleResendPendingInvite(member)
|
|
@@ -4887,6 +4924,8 @@ function TeamsContent({
|
|
|
4887
4924
|
// Must be admin or have invite permission, AND cannot remove yourself
|
|
4888
4925
|
(highestRole === "admin" || currentMemberPermissions?.canInviteUser === true) && modal.target?.userId !== user?.id
|
|
4889
4926
|
),
|
|
4927
|
+
showOrganizationStanding: mayGrantOrgMembership,
|
|
4928
|
+
organizationName: organizationName ?? orgCurrent?.name,
|
|
4890
4929
|
onInvite: handleInvite
|
|
4891
4930
|
}
|
|
4892
4931
|
)
|
|
@@ -5095,6 +5134,10 @@ function OrganizationInviteModal({
|
|
|
5095
5134
|
mode,
|
|
5096
5135
|
userEmail = "email@domain.in",
|
|
5097
5136
|
initialRole,
|
|
5137
|
+
lockRole,
|
|
5138
|
+
canClaimDomain = true,
|
|
5139
|
+
claimableDomain,
|
|
5140
|
+
lockedRoleLabel,
|
|
5098
5141
|
initialInviteAccess,
|
|
5099
5142
|
allowSubmitWithoutChanges = false,
|
|
5100
5143
|
canRemove = true,
|
|
@@ -5107,7 +5150,7 @@ function OrganizationInviteModal({
|
|
|
5107
5150
|
useOverlayOpen(open, onClose);
|
|
5108
5151
|
const [inviteMode, setInviteMode] = (0, import_react9.useState)("email");
|
|
5109
5152
|
const [emailValue, setEmailValue] = (0, import_react9.useState)("");
|
|
5110
|
-
const [domainValue, setDomainValue] = (0, import_react9.useState)("");
|
|
5153
|
+
const [domainValue, setDomainValue] = (0, import_react9.useState)(claimableDomain ?? "");
|
|
5111
5154
|
const [hasChanges, setHasChanges] = (0, import_react9.useState)(false);
|
|
5112
5155
|
const [role, setRole] = (0, import_react9.useState)("admin");
|
|
5113
5156
|
const [inviteAccess, setInviteAccess] = (0, import_react9.useState)(false);
|
|
@@ -5119,19 +5162,22 @@ function OrganizationInviteModal({
|
|
|
5119
5162
|
if (!open) {
|
|
5120
5163
|
setInviteMode("email");
|
|
5121
5164
|
setEmailValue("");
|
|
5122
|
-
setDomainValue("");
|
|
5165
|
+
setDomainValue(claimableDomain ?? "");
|
|
5123
5166
|
setHasChanges(false);
|
|
5124
5167
|
setRole("admin");
|
|
5125
5168
|
setInviteAccess(true);
|
|
5126
5169
|
}
|
|
5127
|
-
}, [open, mode, initialRole, initialInviteAccess]);
|
|
5170
|
+
}, [open, mode, initialRole, initialInviteAccess, claimableDomain]);
|
|
5128
5171
|
if (!open) return null;
|
|
5129
5172
|
const isInvite = mode === "invite";
|
|
5130
5173
|
const isEmailInvite = isInvite && inviteMode === "email";
|
|
5131
5174
|
const isDomainInvite = isInvite && inviteMode === "domain";
|
|
5132
5175
|
const hasEmail = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(emailValue.trim());
|
|
5133
5176
|
const hasDomain = /^[^\s@]+\.[^\s@]+$/.test(domainValue.trim());
|
|
5134
|
-
const isSubmitDisabled = isEmailInvite ? !hasEmail : isDomainInvite ? !hasDomain :
|
|
5177
|
+
const isSubmitDisabled = isEmailInvite ? !hasEmail : isDomainInvite ? !hasDomain : (
|
|
5178
|
+
// A locked role has nothing this modal can legitimately submit.
|
|
5179
|
+
lockRole || !(allowSubmitWithoutChanges || hasChanges)
|
|
5180
|
+
);
|
|
5135
5181
|
function markChanged() {
|
|
5136
5182
|
setHasChanges(true);
|
|
5137
5183
|
}
|
|
@@ -5206,7 +5252,7 @@ function OrganizationInviteModal({
|
|
|
5206
5252
|
className: "flex flex-col items-start w-full",
|
|
5207
5253
|
style: { padding: `${T9.sp3xl} ${T9.sp6xl}`, gap: T9.sp3xl },
|
|
5208
5254
|
children: [
|
|
5209
|
-
isInvite && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
5255
|
+
isInvite && canClaimDomain && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
5210
5256
|
"div",
|
|
5211
5257
|
{
|
|
5212
5258
|
className: "flex flex-col items-start justify-center shrink-0 w-full",
|
|
@@ -5267,9 +5313,9 @@ function OrganizationInviteModal({
|
|
|
5267
5313
|
}
|
|
5268
5314
|
),
|
|
5269
5315
|
isDomainInvite && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
5270
|
-
"
|
|
5316
|
+
"span",
|
|
5271
5317
|
{
|
|
5272
|
-
className: "flex-1 min-w-0
|
|
5318
|
+
className: "flex-1 min-w-0 truncate",
|
|
5273
5319
|
style: {
|
|
5274
5320
|
fontFamily: T9.font,
|
|
5275
5321
|
fontSize: T9.fsSm,
|
|
@@ -5277,9 +5323,7 @@ function OrganizationInviteModal({
|
|
|
5277
5323
|
lineHeight: T9.lhSm,
|
|
5278
5324
|
color: T9.primary
|
|
5279
5325
|
},
|
|
5280
|
-
|
|
5281
|
-
value: domainValue,
|
|
5282
|
-
onChange: (e) => setDomainValue(e.target.value)
|
|
5326
|
+
children: domainValue
|
|
5283
5327
|
}
|
|
5284
5328
|
),
|
|
5285
5329
|
!isInvite && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
@@ -5312,9 +5356,10 @@ function OrganizationInviteModal({
|
|
|
5312
5356
|
color: T9.muted
|
|
5313
5357
|
},
|
|
5314
5358
|
children: [
|
|
5315
|
-
"Anyone
|
|
5316
|
-
domainValue.trim()
|
|
5317
|
-
"
|
|
5359
|
+
"Anyone who signs up or logs in with an @",
|
|
5360
|
+
domainValue.trim(),
|
|
5361
|
+
" ",
|
|
5362
|
+
"address will automatically join this organization from now on."
|
|
5318
5363
|
]
|
|
5319
5364
|
}
|
|
5320
5365
|
)
|
|
@@ -5328,7 +5373,21 @@ function OrganizationInviteModal({
|
|
|
5328
5373
|
style: { gap: T9.spXs },
|
|
5329
5374
|
children: [
|
|
5330
5375
|
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(FieldLabel3, { text: isDomainInvite ? "Auto-join role" : "Role" }),
|
|
5331
|
-
/* @__PURE__ */ (0, import_jsx_runtime13.
|
|
5376
|
+
lockRole ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
5377
|
+
"span",
|
|
5378
|
+
{
|
|
5379
|
+
style: {
|
|
5380
|
+
fontFamily: T9.font,
|
|
5381
|
+
fontSize: T9.fsSm,
|
|
5382
|
+
lineHeight: T9.lhSm,
|
|
5383
|
+
color: T9.muted
|
|
5384
|
+
},
|
|
5385
|
+
children: [
|
|
5386
|
+
lockedRoleLabel || "Guest",
|
|
5387
|
+
" \u2014 invited to specific workspaces only, with no access to the rest of the organization. Remove them to end that access."
|
|
5388
|
+
]
|
|
5389
|
+
}
|
|
5390
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
5332
5391
|
SegmentedToggle,
|
|
5333
5392
|
{
|
|
5334
5393
|
options: [
|
|
@@ -5346,7 +5405,7 @@ function OrganizationInviteModal({
|
|
|
5346
5405
|
]
|
|
5347
5406
|
}
|
|
5348
5407
|
),
|
|
5349
|
-
!isDomainInvite && role === "member" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
5408
|
+
!isDomainInvite && !lockRole && role === "member" && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
5350
5409
|
"div",
|
|
5351
5410
|
{
|
|
5352
5411
|
className: "flex items-center shrink-0 w-full cursor-pointer",
|
|
@@ -5860,6 +5919,12 @@ function OrganizationModal({
|
|
|
5860
5919
|
|
|
5861
5920
|
// src/organization-content.tsx
|
|
5862
5921
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
5922
|
+
function orgRoleLabel(role) {
|
|
5923
|
+
if (role === "admin") return "Org admin";
|
|
5924
|
+
if (role === "member") return "Member";
|
|
5925
|
+
if (role === "guest") return "Guest";
|
|
5926
|
+
return role || "Member";
|
|
5927
|
+
}
|
|
5863
5928
|
var T11 = {
|
|
5864
5929
|
primary: "var(--alias-text---icons-primary)",
|
|
5865
5930
|
inverse: "var(--alias-text---icons-inverse)",
|
|
@@ -6003,7 +6068,7 @@ function MemberRow({
|
|
|
6003
6068
|
RoleChip,
|
|
6004
6069
|
{
|
|
6005
6070
|
role: member.role === "admin" ? "admin" : "member",
|
|
6006
|
-
label: member.role
|
|
6071
|
+
label: orgRoleLabel(member.role)
|
|
6007
6072
|
}
|
|
6008
6073
|
),
|
|
6009
6074
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
@@ -6111,7 +6176,7 @@ function InviteRow({
|
|
|
6111
6176
|
RoleChip,
|
|
6112
6177
|
{
|
|
6113
6178
|
role: role === "admin" ? "admin" : "member",
|
|
6114
|
-
label: role
|
|
6179
|
+
label: orgRoleLabel(role)
|
|
6115
6180
|
}
|
|
6116
6181
|
),
|
|
6117
6182
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
@@ -6258,7 +6323,8 @@ function JoinRequestRow({
|
|
|
6258
6323
|
function Section({
|
|
6259
6324
|
title,
|
|
6260
6325
|
children,
|
|
6261
|
-
empty
|
|
6326
|
+
empty,
|
|
6327
|
+
emptyText
|
|
6262
6328
|
}) {
|
|
6263
6329
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col items-start shrink-0 w-full", style: { gap: T11.spMd }, children: [
|
|
6264
6330
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
@@ -6293,7 +6359,7 @@ function Section({
|
|
|
6293
6359
|
lineHeight: T11.lhSm,
|
|
6294
6360
|
color: T11.muted
|
|
6295
6361
|
},
|
|
6296
|
-
children: "Nothing here yet"
|
|
6362
|
+
children: emptyText ?? "Nothing here yet"
|
|
6297
6363
|
}
|
|
6298
6364
|
) }) : children
|
|
6299
6365
|
}
|
|
@@ -6313,7 +6379,9 @@ function OrganizationContent({
|
|
|
6313
6379
|
const [invites, setInvites] = (0, import_react11.useState)([]);
|
|
6314
6380
|
const [workspaces, setWorkspaces] = (0, import_react11.useState)([]);
|
|
6315
6381
|
const [joinRequests, setJoinRequests] = (0, import_react11.useState)([]);
|
|
6316
|
-
const [highestRole, setHighestRole] = (0, import_react11.useState)("
|
|
6382
|
+
const [highestRole, setHighestRole] = (0, import_react11.useState)("guest");
|
|
6383
|
+
const [emailDomain, setEmailDomain] = (0, import_react11.useState)(null);
|
|
6384
|
+
const [canClaimEmailDomain, setCanClaimEmailDomain] = (0, import_react11.useState)(true);
|
|
6317
6385
|
const [searchQuery, setSearchQuery] = (0, import_react11.useState)("");
|
|
6318
6386
|
const [loadingData, setLoadingData] = (0, import_react11.useState)(false);
|
|
6319
6387
|
const [modal, setModal] = (0, import_react11.useState)({ open: false, mode: "invite" });
|
|
@@ -6328,6 +6396,12 @@ function OrganizationContent({
|
|
|
6328
6396
|
organization.getHighestRole?.().catch(() => null) ?? Promise.resolve(null)
|
|
6329
6397
|
]);
|
|
6330
6398
|
if (highestRoleRes?.role) setHighestRole(highestRoleRes.role);
|
|
6399
|
+
if (highestRoleRes?.emailDomain !== void 0) {
|
|
6400
|
+
setEmailDomain(highestRoleRes.emailDomain ?? null);
|
|
6401
|
+
}
|
|
6402
|
+
if (highestRoleRes?.canClaimEmailDomain !== void 0) {
|
|
6403
|
+
setCanClaimEmailDomain(highestRoleRes.canClaimEmailDomain);
|
|
6404
|
+
}
|
|
6331
6405
|
if (membersRes) setMembers(membersRes.filter((m) => m?.user));
|
|
6332
6406
|
if (invitesRes) setInvites(invitesRes);
|
|
6333
6407
|
if (workspacesRes) setWorkspaces(workspacesRes);
|
|
@@ -6418,7 +6492,7 @@ function OrganizationContent({
|
|
|
6418
6492
|
const openUpdateModal = (member) => setModal({ open: true, mode: "update", target: member });
|
|
6419
6493
|
const closeModal = () => setModal({ open: false, mode: "invite" });
|
|
6420
6494
|
const handleInviteEmail = async (input) => {
|
|
6421
|
-
if (highestRole
|
|
6495
|
+
if (highestRole !== "admin") {
|
|
6422
6496
|
toast.error("You do not have permission to invite members");
|
|
6423
6497
|
closeModal();
|
|
6424
6498
|
return;
|
|
@@ -6433,7 +6507,7 @@ function OrganizationContent({
|
|
|
6433
6507
|
}
|
|
6434
6508
|
};
|
|
6435
6509
|
const handleInviteDomain = async (input) => {
|
|
6436
|
-
if (highestRole
|
|
6510
|
+
if (highestRole !== "admin") {
|
|
6437
6511
|
toast.error("You do not have permission to invite members");
|
|
6438
6512
|
closeModal();
|
|
6439
6513
|
return;
|
|
@@ -6453,7 +6527,7 @@ function OrganizationContent({
|
|
|
6453
6527
|
closeModal();
|
|
6454
6528
|
return;
|
|
6455
6529
|
}
|
|
6456
|
-
if (highestRole
|
|
6530
|
+
if (highestRole !== "admin") {
|
|
6457
6531
|
toast.error("You do not have permission to manage members");
|
|
6458
6532
|
closeModal();
|
|
6459
6533
|
return;
|
|
@@ -6486,7 +6560,7 @@ function OrganizationContent({
|
|
|
6486
6560
|
closeModal();
|
|
6487
6561
|
return;
|
|
6488
6562
|
}
|
|
6489
|
-
if (highestRole
|
|
6563
|
+
if (highestRole !== "admin") {
|
|
6490
6564
|
toast.error("You do not have permission to manage members");
|
|
6491
6565
|
closeModal();
|
|
6492
6566
|
return;
|
|
@@ -6505,7 +6579,7 @@ function OrganizationContent({
|
|
|
6505
6579
|
closeModal();
|
|
6506
6580
|
};
|
|
6507
6581
|
const handleCancelInvite = async (invite) => {
|
|
6508
|
-
if (highestRole
|
|
6582
|
+
if (highestRole !== "admin") {
|
|
6509
6583
|
toast.error("You do not have permission to manage invites");
|
|
6510
6584
|
return;
|
|
6511
6585
|
}
|
|
@@ -6530,7 +6604,7 @@ function OrganizationContent({
|
|
|
6530
6604
|
};
|
|
6531
6605
|
const handleResendInvite = async (invite) => {
|
|
6532
6606
|
if (invite.kind !== "email") return;
|
|
6533
|
-
if (highestRole
|
|
6607
|
+
if (highestRole !== "admin") {
|
|
6534
6608
|
toast.error("You do not have permission to invite members");
|
|
6535
6609
|
return;
|
|
6536
6610
|
}
|
|
@@ -6746,14 +6820,22 @@ function OrganizationContent({
|
|
|
6746
6820
|
}
|
|
6747
6821
|
);
|
|
6748
6822
|
const domainsView = /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
6749
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
6750
|
-
|
|
6823
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
6824
|
+
Section,
|
|
6751
6825
|
{
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6826
|
+
title: "Auto-join by email domain",
|
|
6827
|
+
empty: domainInvites.length === 0,
|
|
6828
|
+
emptyText: canClaimEmailDomain ? void 0 : `Auto-join needs a company email domain.${emailDomain ? ` ${emailDomain} is a public email provider, so it` : " A public email provider"} can't be claimed \u2014 invite people by email instead.`,
|
|
6829
|
+
children: domainInvites.map((inv) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
6830
|
+
InviteRow,
|
|
6831
|
+
{
|
|
6832
|
+
invite: inv,
|
|
6833
|
+
onCancel: () => void handleCancelInvite(inv)
|
|
6834
|
+
},
|
|
6835
|
+
inv._id
|
|
6836
|
+
))
|
|
6837
|
+
}
|
|
6838
|
+
),
|
|
6757
6839
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
6758
6840
|
Section,
|
|
6759
6841
|
{
|
|
@@ -6783,10 +6865,14 @@ function OrganizationContent({
|
|
|
6783
6865
|
open: modal.open,
|
|
6784
6866
|
mode: modal.mode,
|
|
6785
6867
|
userEmail: modal.target?.user.email,
|
|
6786
|
-
initialRole: modal.target?.role,
|
|
6868
|
+
initialRole: modal.target?.role === "admin" || modal.target?.role === "member" ? modal.target.role : void 0,
|
|
6787
6869
|
initialInviteAccess: modal.target?.inviteAccess,
|
|
6788
6870
|
allowSubmitWithoutChanges: false,
|
|
6871
|
+
lockRole: modal.target?.role === "guest",
|
|
6872
|
+
lockedRoleLabel: orgRoleLabel(modal.target?.role),
|
|
6789
6873
|
canRemove: highestRole === "admin",
|
|
6874
|
+
canClaimDomain: canClaimEmailDomain,
|
|
6875
|
+
claimableDomain: emailDomain,
|
|
6790
6876
|
onClose: closeModal,
|
|
6791
6877
|
onInviteEmail: handleInviteEmail,
|
|
6792
6878
|
onInviteDomain: handleInviteDomain,
|
|
@@ -6856,7 +6942,7 @@ function OrganizationContent({
|
|
|
6856
6942
|
variant: "primary",
|
|
6857
6943
|
size: "md",
|
|
6858
6944
|
styleVariant: "icon-left",
|
|
6859
|
-
state: highestRole
|
|
6945
|
+
state: highestRole !== "admin" ? "disabled" : "default",
|
|
6860
6946
|
icon: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_icons7.SiconUserAdd, { className: "w-5 h-5", color: "var(--alias-text---icons-inverse)" }),
|
|
6861
6947
|
onClick: openInviteModal
|
|
6862
6948
|
}
|