Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/clerk-js/sandbox/scenarios/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { UserButtonSignedIn } from './user-button-signed-in';
export { CheckoutAccountCredit } from './checkout-account-credit';
export { OrgProfileSeatLimit } from './org-profile-seat-limit';
74 changes: 74 additions & 0 deletions packages/clerk-js/sandbox/scenarios/org-profile-seat-limit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import {
BillingService,
clerkHandlers,
EnvironmentService,
SessionService,
setClerkState,
type MockScenario,
UserService,
OrganizationService,
} from '@clerk/msw';

export function OrgProfileSeatLimit(): MockScenario {
const organization = OrganizationService.create({ maxAllowedMemberships: 10 });
const user = UserService.create();
user.organizationMemberships = [
{
object: 'organization_membership',
id: 'orgmem_3004mVaZrB4yD63C9KuwTMWNKbj',
public_metadata: {},
role: 'org:owner',
role_name: 'Owner',
permissions: [
'org:applications:create',
'org:applications:manage',
'org:applications:delete',
'org:billing:read',
'org:billing:manage',
'org:config:read',
'org:config:manage',
'org:global:read',
'org:global:manage',
'org:instances:create',
'org:instances:manage',
'org:instances:delete',
'org:restrictions:read',
'org:restrictions:manage',
'org:secrets:manage',
'org:users:imp',
'org:sys_profile:manage',
'org:sys_profile:delete',
'org:sys_billing:read',
'org:sys_billing:manage',
'org:sys_domains:read',
'org:sys_domains:manage',
'org:sys_memberships:read',
'org:sys_memberships:manage',
],
created_at: 1752751315275,
updated_at: 1752751315275,
organization,
},
];
const session = SessionService.create(user);
const plans = BillingService.createDefaultPlans();
const subscription = BillingService.createSubscription(plans[1]);

setClerkState({
environment: EnvironmentService.MULTI_SESSION,
session,
user,
organization,
billing: {
plans,
subscription,
},
});

return {
description: 'OrganizationProfile with a seat limit',
handlers: clerkHandlers,
initialState: { session, user, organization },
name: 'org-profile-seat-limit',
};
}
1 change: 1 addition & 0 deletions packages/localizations/src/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ export const enUS: LocalizationResource = {
start: {
headerTitle__general: 'General',
headerTitle__members: 'Members',
membershipSeatUsageLabel: '{{count}} of {{limit}} seats used',
profileSection: {
primaryButton: 'Update profile',
title: 'Organization Profile',
Expand Down
6 changes: 4 additions & 2 deletions packages/msw/request-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1114,8 +1114,10 @@ export const clerkHandlers = [
const membership = (currentUser as any).organizationMemberships.find((m: any) => m.organization?.id === orgId);
if (membership) {
return createNoStoreResponse({
data: [SessionService.serialize(membership)],
total_count: 1,
response: {
data: [SessionService.serialize(membership)],
total_count: 1,
},
});
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/types/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,7 @@ export type __internal_LocalizationResource = {
badge__manualInvitation: LocalizationValue;
start: {
headerTitle__members: LocalizationValue;
membershipSeatUsageLabel: LocalizationValue<'count' | 'limit'>;
headerTitle__general: LocalizationValue;
profileSection: {
title: LocalizationValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import { Tab, TabPanel, TabPanels, Tabs, TabsList } from '@/ui/elements/Tabs';

import { NotificationCountBadge, useProtect } from '../../common';
import { useEnvironment } from '../../contexts';
import { Col, descriptors, Flex, localizationKeys } from '../../customizables';
import { Box, Col, descriptors, Flex, Icon, localizationKeys, Text } from '../../customizables';
import { Action } from '../../elements/Action';
import { mqu } from '../../styledSystem';
import { ActiveMembersList } from './ActiveMembersList';
import { MembersActionsRow } from './MembersActions';
import { MembersSearch } from './MembersSearch';
import { OrganizationMembersTabInvitations } from './OrganizationMembersTabInvitations';
import { OrganizationMembersTabRequests } from './OrganizationMembersTabRequests';
import { Users } from '@/icons';

export const ACTIVE_MEMBERS_PAGE_SIZE = 10;

Expand All @@ -33,7 +34,7 @@ export const OrganizationMembers = withCardStateProvider(() => {
const [query, setQuery] = useState('');
const [search, setSearch] = useState('');

const { membershipRequests, memberships, invitations } = useOrganization({
const { membershipRequests, memberships, invitations, organization } = useOrganization({
membershipRequests: isDomainsEnabled || undefined,
invitations: canManageMemberships || undefined,
memberships: canReadMemberships
Expand All @@ -43,6 +44,7 @@ export const OrganizationMembers = withCardStateProvider(() => {
}
: undefined,
});
organization?.maxAllowedMemberships;

if (canManageMemberships === null) {
return null;
Expand All @@ -57,6 +59,7 @@ export const OrganizationMembers = withCardStateProvider(() => {
elementDescriptor={descriptors.profilePage}
elementId={descriptors.profilePage.setId('organizationMembers')}
gap={4}
sx={theme => ({ paddingBottom: theme.space.$13 })}
>
<Action.Root animate={false}>
<Animated asChild>
Expand Down Expand Up @@ -173,6 +176,46 @@ export const OrganizationMembers = withCardStateProvider(() => {
</Tabs>
</Action.Root>
</Col>

{canReadMemberships && !!memberships?.count && organization?.maxAllowedMemberships && (
<Box
sx={theme => ({
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
backgroundColor: theme.colors.$colorBackground,
borderTop: `1px solid ${theme.colors.$borderAlpha100}`,
paddingInline: theme.space.$4,
height: theme.space.$13,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
})}
>
<Text
sx={t => ({
display: 'inline-flex',
alignItems: 'center',
gap: t.space.$2,
})}
>
<Icon
icon={Users}
size='md'
colorScheme='neutral'
/>
<Text
as='span'
colorScheme='inherit'
localizationKey={localizationKeys('organizationProfile.start.membershipSeatUsageLabel', {
count: memberships.count + (invitations?.count ?? 0),
limit: organization.maxAllowedMemberships,
})}
/>
</Text>
</Box>
)}
</Col>
);
});