Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create feature flag and use hook to display account tab conditionally #2843

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading