Skip to content

Commit

Permalink
fix(clerk-js): Add descriptor for formatted dates in tables (#3465)
Browse files Browse the repository at this point in the history
  • Loading branch information
panteliselef authored May 30, 2024
1 parent 73e5d61 commit b8e4632
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/warm-candles-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@clerk/clerk-js': minor
'@clerk/types': minor
---

Add descriptor for formatted dates in tables. Those elements can be identified by the `cl-formattedDate__tableCell` css class.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useOrganization, useUser } from '@clerk/shared/react';
import type { OrganizationMembershipResource } from '@clerk/types';

import { Protect } from '../../common/Gate';
import { Badge, localizationKeys, Td, Text } from '../../customizables';
import { Badge, Box, descriptors, localizationKeys, Td, Text } from '../../customizables';
import { ThreeDotsMenu, useCardState, UserPreview } from '../../elements';
import { useFetchRoles, useLocalizeCustomRoles } from '../../hooks/useFetchRoles';
import { handleError } from '../../utils';
Expand Down Expand Up @@ -91,7 +91,15 @@ const MemberRow = (props: {
badge={isCurrentUser && <Badge localizationKey={localizationKeys('badge__you')} />}
/>
</Td>
<Td>{membership.createdAt.toLocaleDateString()}</Td>
<Td>
<Box
as='span'
elementDescriptor={descriptors.formattedDate}
elementId={descriptors.formattedDate.setId('tableCell')}
>
{membership.createdAt.toLocaleDateString()}
</Box>
</Td>
<Td>
<Protect
permission={'org:sys_memberships:manage'}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useOrganization } from '@clerk/shared/react';
import type { OrganizationInvitationResource } from '@clerk/types';

import { localizationKeys, Td, Text } from '../../customizables';
import { Box, descriptors, localizationKeys, Td, Text } from '../../customizables';
import { ThreeDotsMenu, useCardState, UserPreview } from '../../elements';
import { useFetchRoles, useLocalizeCustomRoles } from '../../hooks/useFetchRoles';
import { handleError } from '../../utils';
Expand Down Expand Up @@ -79,7 +79,15 @@ const InvitationRow = (props: {
user={{ primaryEmailAddress: { emailAddress: invitation.emailAddress } } as any}
/>
</Td>
<Td>{invitation.createdAt.toLocaleDateString()}</Td>
<Td>
<Box
as='span'
elementDescriptor={descriptors.formattedDate}
elementId={descriptors.formattedDate.setId('tableCell')}
>
{invitation.createdAt.toLocaleDateString()}
</Box>
</Td>
<Td>
<Text
colorScheme='secondary'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useOrganization } from '@clerk/shared/react';
import type { OrganizationMembershipRequestResource } from '@clerk/types';

import { Button, Flex, localizationKeys, Td } from '../../customizables';
import { Box, Button, descriptors, Flex, localizationKeys, Td } from '../../customizables';
import { useCardState, UserPreview, withCardStateProvider } from '../../elements';
import { handleError } from '../../utils';
import { DataTable, RowContainer } from './MemberListTable';
Expand Down Expand Up @@ -84,7 +84,15 @@ const RequestRow = withCardStateProvider(
user={{ primaryEmailAddress: { emailAddress: request.publicUserData.identifier } } as any}
/>
</Td>
<Td>{request.createdAt.toLocaleDateString()}</Td>
<Td>
<Box
as='span'
elementDescriptor={descriptors.formattedDate}
elementId={descriptors.formattedDate.setId('tableCell')}
>
{request.createdAt.toLocaleDateString()}
</Box>
</Td>

<Td>
<AcceptRejectRequestButtons {...{ onAccept, onReject }} />
Expand Down
2 changes: 2 additions & 0 deletions packages/clerk-js/src/ui/customizables/elementDescriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ export const APPEARANCE_KEYS = containsAllElementsConfigKeys([
'formattedPhoneNumberFlag',
'formattedPhoneNumberText',

'formattedDate',

'scrollBox',

'navbar',
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/appearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ export type ElementsConfig = {
formattedPhoneNumberFlag: WithOptions;
formattedPhoneNumberText: WithOptions;

formattedDate: WithOptions<'tableCell'>;

scrollBox: WithOptions;

navbar: WithOptions;
Expand Down

0 comments on commit b8e4632

Please sign in to comment.