Skip to content

Commit

Permalink
feat(clerk-js): Share breadcrumb title in all Verified domain flows (#…
Browse files Browse the repository at this point in the history
…1633)

* feat(clerk-js): Share breadcrumb title in all Verified domain flows

* chore(clerk-js): Add changeset

* chore(clerk-js): OrganizationProfile bundle up to 10KB
  • Loading branch information
panteliselef authored Aug 25, 2023
1 parent 0a5f632 commit 5a723c8
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .changeset/cool-bikes-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 1 addition & 1 deletion packages/clerk-js/bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{ "path": "./dist/vendors*.js", "maxSize": "70KB" },
{ "path": "./dist/createorganization*.js", "maxSize": "5KB" },
{ "path": "./dist/impersonationfab*.js", "maxSize": "5KB" },
{ "path": "./dist/organizationprofile*.js", "maxSize": "8.7KB" },
{ "path": "./dist/organizationprofile*.js", "maxSize": "10KB" },
{ "path": "./dist/organizationswitcher*.js", "maxSize": "5KB" },
{ "path": "./dist/signin*.js", "maxSize": "10KB" },
{ "path": "./dist/signup*.js", "maxSize": "10KB" },
Expand Down
4 changes: 3 additions & 1 deletion packages/clerk-js/src/ui/common/RemoveResourcePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useWizard, Wizard } from './Wizard';

type RemovePageProps = {
title: LocalizationKey;
breadcrumbTitle?: LocalizationKey;
messageLine1: LocalizationKey;
messageLine2: LocalizationKey;
successMessage: LocalizationKey;
Expand All @@ -16,7 +17,7 @@ type RemovePageProps = {
};

export const RemoveResourcePage = withCardStateProvider((props: RemovePageProps) => {
const { title, messageLine1, messageLine2, successMessage, deleteResource } = props;
const { title, messageLine1, messageLine2, breadcrumbTitle, successMessage, deleteResource } = props;
const wizard = useWizard();
const card = useCardState();

Expand All @@ -32,6 +33,7 @@ export const RemoveResourcePage = withCardStateProvider((props: RemovePageProps)
<Wizard {...wizard.props}>
<ContentPage
headerTitle={title}
breadcrumbTitle={breadcrumbTitle}
Breadcrumbs={props.Breadcrumbs}
>
<Form.Root onSubmit={handleSubmit}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ export const AddDomainPage = withCardStateProvider(() => {
const { organizationSettings } = useEnvironment();
const title = localizationKeys('organizationProfile.createDomainPage.title');
const subtitle = localizationKeys('organizationProfile.createDomainPage.subtitle');
const breadcrumbTitle = localizationKeys('organizationProfile.profilePage.domainSection.title');
const card = useCardState();
const { organization } = useCoreOrganization();
const { navigate } = useRouter();

const nameField = useFormControl('name', '', {
type: 'text',
label: localizationKeys('formFieldLabel__organizationEmailDomain'),
placeholder: localizationKeys('formFieldInputPlaceholder__organizationEmailDomain'),
label: localizationKeys('formFieldLabel__organizationDomain'),
placeholder: localizationKeys('formFieldInputPlaceholder__organizationDomain'),
});

if (!organization || !organizationSettings) {
Expand Down Expand Up @@ -47,6 +48,7 @@ export const AddDomainPage = withCardStateProvider(() => {
<ContentPage
headerTitle={title}
headerSubtitle={subtitle}
breadcrumbTitle={breadcrumbTitle}
Breadcrumbs={OrganizationProfileBreadcrumbs}
>
<Form.Root onSubmit={onSubmit}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export const OrganizationProfileNavbar = (

const pageToRootNavbarRouteMap = {
'invite-members': organizationProfileRoutes.find(r => r.id === 'members'),
'add-domain': organizationProfileRoutes.find(r => r.id === 'settings'),
domain: organizationProfileRoutes.find(r => r.id === 'settings'),
profile: organizationProfileRoutes.find(r => r.id === 'settings'),
leave: organizationProfileRoutes.find(r => r.id === 'settings'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export const RemoveDomainPage = () => {
},
);

const { domains } = useCoreOrganization({
domains: {
infinite: true,
},
});

if (!organization || !organizationSettings) {
return null;
}
Expand Down Expand Up @@ -60,7 +66,8 @@ export const RemoveDomainPage = () => {
successMessage={localizationKeys('organizationProfile.removeDomainPage.successMessage', {
domain: ref.current?.name,
})}
deleteResource={() => Promise.resolve(domain?.delete())}
deleteResource={() => domain?.delete().then((domains as any).unstable__mutate())}
breadcrumbTitle={localizationKeys('organizationProfile.profilePage.domainSection.title')}
Breadcrumbs={OrganizationProfileBreadcrumbs}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const VerifiedDomainPage = withCardStateProvider(() => {
const { params, navigate, queryParams } = useRouter();
const mode = (queryParams.mode ?? 'edit') as 'select' | 'edit';

const breadcrumbTitle = localizationKeys('organizationProfile.profilePage.domainSection.title');
const allowsEdit = mode === 'edit';

const enrollmentMode = useFormControl('enrollmentMode', '', {
Expand Down Expand Up @@ -133,7 +134,8 @@ export const VerifiedDomainPage = withCardStateProvider(() => {
}
return (
<ContentPage
headerTitle={domain.name}
headerTitle={domain?.name}
breadcrumbTitle={breadcrumbTitle}
gap={4}
Breadcrumbs={OrganizationProfileBreadcrumbs}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useRef } from 'react';

import { useWizard, Wizard } from '../../common';
import { useCoreOrganization, useEnvironment } from '../../contexts';
Expand Down Expand Up @@ -35,6 +35,9 @@ export const VerifyDomainPage = withCardStateProvider(() => {
const subtitle = localizationKeys('organizationProfile.verifyDomainPage.subtitle', {
domainName: domain?.name ?? '',
});

const breadcrumbTitle = localizationKeys('organizationProfile.profilePage.domainSection.title');

const status = useLoadingStatus();

const codeControlState = useFormControl('code', '');
Expand All @@ -44,11 +47,20 @@ export const VerifyDomainPage = withCardStateProvider(() => {

const emailField = useFormControl('affiliationEmailAddress', '', {
type: 'text',
label: localizationKeys('formFieldLabel__organizationEmailDomainEmailAddress'),
placeholder: localizationKeys('formFieldInputPlaceholder__organizationEmailDomainEmailAddress'),
informationText: localizationKeys('formFieldLabel__organizationEmailDomainEmailAddressDescription'),
label: localizationKeys('formFieldLabel__organizationDomainEmailAddress'),
placeholder: localizationKeys('formFieldInputPlaceholder__organizationDomainEmailAddress'),
informationText: localizationKeys('formFieldLabel__organizationDomainEmailAddressDescription'),
});

const affiliationEmailAddressRef = useRef<string>();

const subtitleVerificationCodeScreen = localizationKeys(
'organizationProfile.verifyDomainPage.subtitleVerificationCodeScreen',
{
emailAddress: affiliationEmailAddressRef.current,
},
);

const resolve = async () => {
setSuccess(true);
await sleep(750);
Expand Down Expand Up @@ -96,8 +108,12 @@ export const VerifyDomainPage = withCardStateProvider(() => {

const onSubmitPrepare = (e: React.FormEvent) => {
e.preventDefault();
if (!domain) {
return;
}
affiliationEmailAddressRef.current = `${emailField.value}@${domain.name}`;
return domain
?.prepareAffiliationVerification({
.prepareAffiliationVerification({
affiliationEmailAddress: `${emailField.value}@${domain.name}`,
})
.then(wizard.nextStep)
Expand Down Expand Up @@ -129,6 +145,7 @@ export const VerifyDomainPage = withCardStateProvider(() => {
<Wizard {...wizard.props}>
<ContentPage
headerTitle={title}
breadcrumbTitle={breadcrumbTitle}
headerSubtitle={subtitle}
Breadcrumbs={OrganizationProfileBreadcrumbs}
>
Expand All @@ -147,7 +164,8 @@ export const VerifyDomainPage = withCardStateProvider(() => {

<ContentPage
headerTitle={title}
headerSubtitle={subtitle}
breadcrumbTitle={breadcrumbTitle}
headerSubtitle={subtitleVerificationCodeScreen}
Breadcrumbs={OrganizationProfileBreadcrumbs}
>
<CodeForm
Expand Down
15 changes: 9 additions & 6 deletions packages/clerk-js/src/ui/elements/ContentPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { CardAlert, Header, NavbarMenuButtonRow, useCardState } from './index';

type PageProps = PropsOfComponent<typeof Col> & {
headerTitle: LocalizationKey | string;
breadcrumbTitle?: LocalizationKey;
Breadcrumbs?: React.ComponentType<any> | null;
headerSubtitle?: LocalizationKey;
};

export const ContentPage = (props: PageProps) => {
const { headerTitle, headerSubtitle, children, Breadcrumbs, sx, ...rest } = props;
const { headerTitle, headerSubtitle, breadcrumbTitle, children, Breadcrumbs, sx, ...rest } = props;
const card = useCardState();

return (
Expand All @@ -27,7 +28,7 @@ export const ContentPage = (props: PageProps) => {
<Header.Root>
{Breadcrumbs && (
<Breadcrumbs
title={headerTitle}
title={breadcrumbTitle || headerTitle}
sx={(t: any) => ({ marginBottom: t.space.$5 })}
/>
)}
Expand All @@ -36,10 +37,12 @@ export const ContentPage = (props: PageProps) => {
localizationKey={headerTitle}
textVariant={'xxlargeMedium'}
/>
<Header.Subtitle
variant={'regularRegular'}
localizationKey={headerSubtitle}
/>
{headerSubtitle && (
<Header.Subtitle
variant={'regularRegular'}
localizationKey={headerSubtitle}
/>
)}
</Header.Root>
<Col gap={8}>{children}</Col>
</Col>
Expand Down
10 changes: 5 additions & 5 deletions packages/localizations/src/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export const enUS: LocalizationResource = {
formFieldLabel__backupCode: 'Backup code',
formFieldLabel__organizationName: 'Organization name',
formFieldLabel__organizationSlug: 'Slug URL',
formFieldLabel__organizationEmailDomain: 'Email domain',
formFieldLabel__organizationEmailDomainEmailAddress: 'Verification email address',
formFieldLabel__organizationEmailDomainEmailAddressDescription:
formFieldLabel__organizationDomain: 'Email domain',
formFieldLabel__organizationDomainEmailAddress: 'Verification email address',
formFieldLabel__organizationDomainEmailAddressDescription:
'Enter an email address under this domain to receive a code and verify this domain.',
formFieldLabel__organizationDomainDeletePending: 'Delete pending invitations and suggestions',
formFieldLabel__confirmDeletion: 'Confirmation',
Expand All @@ -57,8 +57,8 @@ export const enUS: LocalizationResource = {
formFieldInputPlaceholder__backupCode: '',
formFieldInputPlaceholder__organizationName: '',
formFieldInputPlaceholder__organizationSlug: '',
formFieldInputPlaceholder__organizationEmailDomain: '',
formFieldInputPlaceholder__organizationEmailDomainEmailAddress: '',
formFieldInputPlaceholder__organizationDomain: '',
formFieldInputPlaceholder__organizationDomainEmailAddress: '',
formFieldError__notMatchingPasswords: `Passwords don't match.`,
formFieldError__matchingPasswords: 'Passwords match.',
formFieldAction__forgotPassword: 'Forgot password?',
Expand Down
10 changes: 5 additions & 5 deletions packages/types/src/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ type _LocalizationResource = {
formFieldLabel__backupCode: LocalizationValue;
formFieldLabel__organizationName: LocalizationValue;
formFieldLabel__organizationSlug: LocalizationValue;
formFieldLabel__organizationEmailDomain: LocalizationValue;
formFieldLabel__organizationEmailDomainEmailAddress: LocalizationValue;
formFieldLabel__organizationEmailDomainEmailAddressDescription: LocalizationValue;
formFieldLabel__organizationDomain: LocalizationValue;
formFieldLabel__organizationDomainEmailAddress: LocalizationValue;
formFieldLabel__organizationDomainEmailAddressDescription: LocalizationValue;
formFieldLabel__organizationDomainDeletePending: LocalizationValue;
formFieldLabel__confirmDeletion: LocalizationValue;
formFieldLabel__role: LocalizationValue;
Expand All @@ -74,8 +74,8 @@ type _LocalizationResource = {
formFieldInputPlaceholder__backupCode: LocalizationValue;
formFieldInputPlaceholder__organizationName: LocalizationValue;
formFieldInputPlaceholder__organizationSlug: LocalizationValue;
formFieldInputPlaceholder__organizationEmailDomain: LocalizationValue;
formFieldInputPlaceholder__organizationEmailDomainEmailAddress: LocalizationValue;
formFieldInputPlaceholder__organizationDomain: LocalizationValue;
formFieldInputPlaceholder__organizationDomainEmailAddress: LocalizationValue;
formFieldError__notMatchingPasswords: LocalizationValue;
formFieldError__matchingPasswords: LocalizationValue;
formFieldAction__forgotPassword: LocalizationValue;
Expand Down

0 comments on commit 5a723c8

Please sign in to comment.