Skip to content

Commit

Permalink
♻️(features) rename "TEAMS" flag
Browse files Browse the repository at this point in the history
To match recent changes we rename the "TEAMS" feature flag
to "TEAMS_DISPLAY".
  • Loading branch information
qbey committed Nov 15, 2024
1 parent 59f3499 commit 90a3e26
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/backend/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def get_abilities(self):
),
},
"teams": {
"can_view": teams_can_view and settings.FEATURES["TEAMS"],
"can_view": teams_can_view and settings.FEATURES["TEAMS_DISPLAY"],
"can_create": teams_can_view and settings.FEATURES["TEAMS_CREATE"],
},
"mailboxes": {
Expand Down
4 changes: 2 additions & 2 deletions src/backend/core/tests/test_api_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_api_config_anonymous():
"CONTACTS_DISPLAY": True,
"CONTACTS_CREATE": True,
"MAILBOXES_CREATE": True,
"TEAMS": True,
"TEAMS_DISPLAY": True,
"TEAMS_CREATE": True,
},
"RELEASE": "NA",
Expand All @@ -46,7 +46,7 @@ def test_api_config_authenticated():
"CONTACTS_DISPLAY": True,
"CONTACTS_CREATE": True,
"MAILBOXES_CREATE": True,
"TEAMS": True,
"TEAMS_DISPLAY": True,
"TEAMS_CREATE": True,
},
"RELEASE": "NA",
Expand Down
2 changes: 1 addition & 1 deletion src/backend/people/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ def FEATURES(self):
"CONTACTS_CREATE", # Used in the users/me/ endpoint
"CONTACTS_DISPLAY", # Used in the users/me/ endpoint
"MAILBOXES_CREATE", # Used in the users/me/ endpoint
"TEAMS",
"TEAMS_DISPLAY",
"TEAMS_CREATE", # Used in the users/me/ endpoint
}

Expand Down
12 changes: 10 additions & 2 deletions src/frontend/apps/desk/src/__tests__/pages.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ describe('Page', () => {

it('checks Page rendering with team feature', () => {
useConfigStore.setState({
config: { RELEASE: '1.0.0', FEATURES: { TEAMS: true }, LANGUAGES: [] },
config: {
RELEASE: '1.0.0',
FEATURES: { TEAMS_DISPLAY: true },
LANGUAGES: [],
},
});

render(<Page />, { wrapper: AppWrapper });
Expand All @@ -31,7 +35,11 @@ describe('Page', () => {

it('checks Page rendering without team feature', () => {
useConfigStore.setState({
config: { RELEASE: '1.0.0', FEATURES: { TEAMS: false }, LANGUAGES: [] },
config: {
RELEASE: '1.0.0',
FEATURES: { TEAMS_DISPLAY: false },
LANGUAGES: [],
},
});

render(<Page />, { wrapper: AppWrapper });
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/apps/desk/src/core/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function MainLayout({ children }: PropsWithChildren) {
<Box $height="100vh">
<Header />
<Box $css="flex: 1;" $direction="row">
{config?.FEATURES.TEAMS && <Menu />}
{config?.FEATURES.TEAMS_DISPLAY && <Menu />}
<Box
as="main"
$height={`calc(100vh - ${HEADER_HEIGHT})`}
Expand Down
18 changes: 15 additions & 3 deletions src/frontend/apps/desk/src/core/__tests__/MainLayout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ jest.mock('next/navigation', () => ({
describe('MainLayout', () => {
it('checks menu rendering with team feature', () => {
useConfigStore.setState({
config: { RELEASE: '1.0.0', FEATURES: { TEAMS: true }, LANGUAGES: [] },
config: {
RELEASE: '1.0.0',
FEATURES: { TEAMS_DISPLAY: true },
LANGUAGES: [],
},
});
useAuthStore.setState({
authenticated: true,
Expand Down Expand Up @@ -51,7 +55,11 @@ describe('MainLayout', () => {

it('checks menu rendering with no abilities', () => {
useConfigStore.setState({
config: { RELEASE: '1.0.0', FEATURES: { TEAMS: true }, LANGUAGES: [] },
config: {
RELEASE: '1.0.0',
FEATURES: { TEAMS_DISPLAY: true },
LANGUAGES: [],
},
});
useAuthStore.setState({
authenticated: true,
Expand Down Expand Up @@ -85,7 +93,11 @@ describe('MainLayout', () => {

it('checks menu rendering without team feature', () => {
useConfigStore.setState({
config: { RELEASE: '1.0.0', FEATURES: { TEAMS: false }, LANGUAGES: [] },
config: {
RELEASE: '1.0.0',
FEATURES: { TEAMS_DISPLAY: false },
LANGUAGES: [],
},
});
useAuthStore.setState({
authenticated: true,
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/apps/desk/src/core/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ export interface Config {
LANGUAGES: [string, string][];
RELEASE: string;
FEATURES: {
TEAMS: boolean;
TEAMS_DISPLAY: boolean;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const Panel = () => {
$minWidth: '0',
};

const styleNoTeam = !config?.FEATURES.TEAMS && {
const styleNoTeam = !config?.FEATURES.TEAMS_DISPLAY && {
$display: 'none',
tabIndex: -1,
};
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/apps/desk/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const Page: NextPageWithLayout = () => {
const router = useNavigate();

useEffect(() => {
router.push(config?.FEATURES.TEAMS ? '/teams/' : '/mail-domains/');
}, [config?.FEATURES.TEAMS, router]);
router.push(config?.FEATURES.TEAMS_DISPLAY ? '/teams/' : '/mail-domains/');
}, [config?.FEATURES.TEAMS_DISPLAY, router]);

return null;
};
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/apps/e2e/__tests__/app-desk/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ test.describe('Config', () => {
CONTACTS_DISPLAY: true,
MAILBOXES_CREATE: true,
TEAMS_CREATE: true,
TEAMS: true,
TEAMS_DISPLAY: true,
},
RELEASE: 'NA',
});
Expand All @@ -48,7 +48,7 @@ test.describe('Config', () => {
['en-us', 'English'],
['fr-fr', 'French'],
],
FEATURES: { TEAMS: false },
FEATURES: { TEAMS_DISPLAY: false },
},
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/helm/env.d/preprod/values.desk.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ backend:
secretKeyRef:
name: backend
key: MAIL_PROVISIONING_API_CREDENTIALS
FEATURE_TEAMS: False
FEATURE_TEAMS_DISPLAY: False
FEATURE_CONTACTS_DISPLAY: False
FEATURE_CONTACTS_CREATE: False
FEATURE_TEAMS_CREATE: False
Expand Down
2 changes: 1 addition & 1 deletion src/helm/env.d/production/values.desk.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ backend:
secretKeyRef:
name: backend
key: MAIL_PROVISIONING_API_CREDENTIALS
FEATURE_TEAMS: False
FEATURE_TEAMS_DISPLAY: False
FEATURE_CONTACTS_DISPLAY: False
FEATURE_CONTACTS_CREATE: False
FEATURE_TEAMS_CREATE: False
Expand Down

0 comments on commit 90a3e26

Please sign in to comment.