Add feature flag for team account deletion
Updated the team account settings page to support a new feature flag for enabling team deletion. Only the primary user can delete the account if this feature is enabled. Also, corrected the required error message in feature-flags.config.ts file for more clarity.
This commit is contained in:
@@ -4,6 +4,7 @@ import { TeamAccountSettingsContainer } from '@kit/team-accounts/components';
|
|||||||
import { PageBody } from '@kit/ui/page';
|
import { PageBody } from '@kit/ui/page';
|
||||||
import { Trans } from '@kit/ui/trans';
|
import { Trans } from '@kit/ui/trans';
|
||||||
|
|
||||||
|
import featuresFlagConfig from '~/config/feature-flags.config';
|
||||||
import pathsConfig from '~/config/paths.config';
|
import pathsConfig from '~/config/paths.config';
|
||||||
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
import { createI18nServerInstance } from '~/lib/i18n/i18n.server';
|
||||||
|
|
||||||
@@ -41,6 +42,10 @@ async function TeamAccountSettingsPage(props: Props) {
|
|||||||
primaryOwnerUserId: data.primary_owner_user_id,
|
primaryOwnerUserId: data.primary_owner_user_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const features = {
|
||||||
|
enableTeamDeletion: featuresFlagConfig.enableTeamDeletion,
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TeamAccountLayoutPageHeader
|
<TeamAccountLayoutPageHeader
|
||||||
@@ -51,7 +56,11 @@ async function TeamAccountSettingsPage(props: Props) {
|
|||||||
|
|
||||||
<PageBody>
|
<PageBody>
|
||||||
<div className={'flex max-w-2xl flex-1 flex-col'}>
|
<div className={'flex max-w-2xl flex-1 flex-col'}>
|
||||||
<TeamAccountSettingsContainer account={account} paths={paths} />
|
<TeamAccountSettingsContainer
|
||||||
|
account={account}
|
||||||
|
paths={paths}
|
||||||
|
features={features}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</PageBody>
|
</PageBody>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const FeatureFlagsSchema = z.object({
|
|||||||
}),
|
}),
|
||||||
enableTeamDeletion: z.boolean({
|
enableTeamDeletion: z.boolean({
|
||||||
description: 'Enable team deletion.',
|
description: 'Enable team deletion.',
|
||||||
required_error: 'Provide the variable NEXT_PUBLIC_ENABLE_TEAM_DELETION',
|
required_error: 'Provide the variable NEXT_PUBLIC_ENABLE_TEAM_ACCOUNTS_DELETION',
|
||||||
}),
|
}),
|
||||||
enableTeamAccounts: z.boolean({
|
enableTeamAccounts: z.boolean({
|
||||||
description: 'Enable team accounts.',
|
description: 'Enable team accounts.',
|
||||||
|
|||||||
@@ -39,12 +39,17 @@ import { leaveTeamAccountAction } from '../../server/actions/leave-team-account-
|
|||||||
export function TeamAccountDangerZone({
|
export function TeamAccountDangerZone({
|
||||||
account,
|
account,
|
||||||
primaryOwnerUserId,
|
primaryOwnerUserId,
|
||||||
|
features,
|
||||||
}: React.PropsWithChildren<{
|
}: React.PropsWithChildren<{
|
||||||
account: {
|
account: {
|
||||||
name: string;
|
name: string;
|
||||||
id: string;
|
id: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
features: {
|
||||||
|
enableTeamDeletion: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
primaryOwnerUserId: string;
|
primaryOwnerUserId: string;
|
||||||
}>) {
|
}>) {
|
||||||
const { data: user } = useUser();
|
const { data: user } = useUser();
|
||||||
@@ -56,7 +61,7 @@ export function TeamAccountDangerZone({
|
|||||||
// Only the primary owner can delete the team account
|
// Only the primary owner can delete the team account
|
||||||
const userIsPrimaryOwner = user.id === primaryOwnerUserId;
|
const userIsPrimaryOwner = user.id === primaryOwnerUserId;
|
||||||
|
|
||||||
if (userIsPrimaryOwner) {
|
if (userIsPrimaryOwner && features.enableTeamDeletion) {
|
||||||
return <DeleteTeamContainer account={account} />;
|
return <DeleteTeamContainer account={account} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,10 @@ export function TeamAccountSettingsContainer(props: {
|
|||||||
paths: {
|
paths: {
|
||||||
teamAccountSettings: string;
|
teamAccountSettings: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
features: {
|
||||||
|
enableTeamDeletion: boolean;
|
||||||
|
}
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className={'flex w-full flex-col space-y-6'}>
|
<div className={'flex w-full flex-col space-y-6'}>
|
||||||
@@ -78,6 +82,7 @@ export function TeamAccountSettingsContainer(props: {
|
|||||||
<TeamAccountDangerZone
|
<TeamAccountDangerZone
|
||||||
primaryOwnerUserId={props.account.primaryOwnerUserId}
|
primaryOwnerUserId={props.account.primaryOwnerUserId}
|
||||||
account={props.account}
|
account={props.account}
|
||||||
|
features={props.features}
|
||||||
/>
|
/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
Reference in New Issue
Block a user