Skip to content

Commit

Permalink
fix(clerk-js): Add confirmation input when users try to leave an orga…
Browse files Browse the repository at this point in the history
…nization

fix(clerk-js): Add confirmation input when users try to leave an organization

fix(clerk-js): Allow admin to leave organization if there are more than one

fix(clerk-js): Add placeholders in inputs

fix(clerk-js): Add placeholders in inputs

fix(clerk-js): Revert organization admins count

fix(clerk-js): Revert organization admins count
  • Loading branch information
raptisj committed Jul 7, 2023
1 parent 972f24f commit 1a151e7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
12 changes: 12 additions & 0 deletions .changeset/few-dingos-happen.md
@@ -0,0 +1,12 @@
---
'@clerk/localizations': minor
'@clerk/clerk-js': minor
'@clerk/types': minor
---

Add a confirmation input as an additional check when doing destructive actions such as:
- delete an organization
- delete a user account
- leave an organization

Νew localization keys were introduced to support the above
Expand Up @@ -30,9 +30,14 @@ export const LeaveOrganizationPage = () => {

return (
<ActionConfirmationPage
organizationName={organization?.name}
title={localizationKeys('organizationProfile.profilePage.dangerSection.leaveOrganization.title')}
messageLine1={localizationKeys('organizationProfile.profilePage.dangerSection.leaveOrganization.messageLine1')}
messageLine2={localizationKeys('organizationProfile.profilePage.dangerSection.leaveOrganization.messageLine2')}
actionDescription={localizationKeys(
'organizationProfile.profilePage.dangerSection.leaveOrganization.actionDescription',
{ organizationName: organization?.name },
)}
submitLabel={localizationKeys('organizationProfile.profilePage.dangerSection.leaveOrganization.title')}
successMessage={localizationKeys(
'organizationProfile.profilePage.dangerSection.leaveOrganization.successMessage',
Expand Down Expand Up @@ -106,6 +111,7 @@ const ActionConfirmationPage = withCardStateProvider((props: ActionConfirmationP
type: 'text',
label: localizationKeys('formFieldLabel__confirmDeletion'),
isRequired: true,
placeholder: organizationName,
});

const canSubmit = actionDescription ? confirmationField.value === organizationName : true;
Expand All @@ -128,21 +134,14 @@ const ActionConfirmationPage = withCardStateProvider((props: ActionConfirmationP
<Text localizationKey={messageLine1} />
<Text localizationKey={messageLine2} />

{actionDescription && (
<>
<Text
localizationKey={actionDescription}
variant='regularRegular'
/>

<Form.ControlRow elementId={confirmationField.id}>
<Form.Control
{...confirmationField.props}
required
/>
</Form.ControlRow>
</>
)}
<Text localizationKey={actionDescription} />

<Form.ControlRow elementId={confirmationField.id}>
<Form.Control
{...confirmationField.props}
required
/>
</Form.ControlRow>

<FormButtonContainer>
<Form.SubmitButton
Expand Down
Expand Up @@ -29,6 +29,7 @@ export const DeletePage = withCardStateProvider(() => {
type: 'text',
label: localizationKeys('formFieldLabel__confirmDeletion'),
isRequired: true,
placeholder: 'Delete account',
});

const canSubmit = confirmationField.value === 'Delete account';
Expand Down
1 change: 1 addition & 0 deletions packages/localizations/src/en-US.ts
Expand Up @@ -548,6 +548,7 @@ export const enUS: LocalizationResource = {
'Are you sure you want to leave this organization? You will lose access to this organization and its applications.',
messageLine2: 'This action is permanent and irreversible.',
successMessage: 'You have left the organization.',
actionDescription: 'Type {{organizationName}} below to continue.',
},
deleteOrganization: {
title: 'Delete organization',
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/localization.ts
Expand Up @@ -567,6 +567,7 @@ type _LocalizationResource = {
title: LocalizationValue;
messageLine1: LocalizationValue;
messageLine2: LocalizationValue;
actionDescription: LocalizationValue;
successMessage: LocalizationValue;
};
deleteOrganization: {
Expand Down

0 comments on commit 1a151e7

Please sign in to comment.