Skip to content

Commit

Permalink
Create feature flag and use hook to display account tab conditionally (
Browse files Browse the repository at this point in the history
…#2843)

create feature flag and use hook to display account tab conditionally
  • Loading branch information
bosiraphael authored Dec 5, 2023
1 parent 72d696a commit 2dcce31
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
27 changes: 16 additions & 11 deletions front/src/modules/settings/components/SettingsNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import NavItem from '@/ui/navigation/navigation-drawer/components/NavItem';
import NavTitle from '@/ui/navigation/navigation-drawer/components/NavTitle';
import SubMenuNavbar from '@/ui/navigation/navigation-drawer/components/SubMenuNavbar';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';

export const SettingsNavbar = () => {
const navigate = useNavigate();
Expand All @@ -27,6 +28,12 @@ export const SettingsNavbar = () => {
navigate(AppPath.SignIn);
}, [signOut, navigate]);

const isMessagingEnabled = useIsFeatureEnabled('IS_MESSAGING_ENABLED');
const isMessagingActive = !!useMatch({
path: useResolvedPath('/settings/accounts').pathname,
end: true,
});

return (
<SubMenuNavbar backButtonTitle="Settings" displayVersion={true}>
<NavTitle label="User" />
Expand All @@ -52,17 +59,15 @@ export const SettingsNavbar = () => {
})
}
/>
<NavItem
label="Accounts"
to="/settings/accounts"
Icon={IconAt}
active={
!!useMatch({
path: useResolvedPath('/settings/accounts').pathname,
end: true,
})
}
/>

{isMessagingEnabled && (
<NavItem
label="Accounts"
to="/settings/accounts"
Icon={IconAt}
active={isMessagingActive}
/>
)}

<NavTitle label="Workspace" />
<NavItem
Expand Down
7 changes: 5 additions & 2 deletions server/src/database/typeorm-seeds/core/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { DataSource } from 'typeorm';

const tableName = 'featureFlag';

// import { SeedWorkspaceId } from 'src/database/typeorm-seeds/core/workspaces';

export const seedFeatureFlags = async (
workspaceDataSource: DataSource,
schemaName: string,
Expand All @@ -20,6 +18,11 @@ export const seedFeatureFlags = async (
workspaceId: workspaceId,
value: true,
},
{
key: 'IS_MESSAGING_ENABLED',
workspaceId: workspaceId,
value: true,
},
])
.execute();
};
Expand Down

0 comments on commit 2dcce31

Please sign in to comment.