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

🔥(frontend) remove temporarily team feature #331

Merged
merged 1 commit into from
Aug 8, 2024
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
1 change: 1 addition & 0 deletions src/frontend/apps/desk/.env.development
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
NEXT_PUBLIC_API_ORIGIN=http://localhost:8071
NEXT_PUBLIC_FEATURE_TEAM=true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Est-ce qu'on peut déclarer de manière explicite le feature flag aussi pour tous les autres environnements (preprod, prod) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ici c'est juste les var environnements propres à Next.js; il n'y a pas de notion de preprod, staging etc.. Pour la preprod et la prod c'est dans les helm charts qu'il faudrait les indiquer, mais ce n'est pas nécessaire de les mettre pour que ca fonctionne correctement.
Quoi qu'il en soit c'est temporaire, j'espère que team va rapidement etre release, et qu'on enleve ce flag.

1 change: 1 addition & 0 deletions src/frontend/apps/desk/.env.test
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
NEXT_PUBLIC_API_ORIGIN=http://test.jest
NEXT_PUBLIC_FEATURE_TEAM=true
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 @@ -11,7 +11,7 @@ export function MainLayout({ children }: PropsWithChildren) {
<Box $height="100vh">
<Header />
<Box $css="flex: 1;" $direction="row">
<Menu />
{process.env.NEXT_PUBLIC_FEATURE_TEAM === 'true' && <Menu />}
<Box
as="main"
$height={`calc(100vh - ${HEADER_HEIGHT})`}
Expand Down
47 changes: 47 additions & 0 deletions src/frontend/apps/desk/src/core/__tests__/MainLayout.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';

import { AppWrapper } from '@/tests/utils';

import { MainLayout } from '../MainLayout';

jest.mock('next/navigation', () => ({
...jest.requireActual('next/navigation'),
usePathname: () => '/',
}));

describe('MainLayout', () => {
it('checks menu rendering', () => {
render(<MainLayout />, { wrapper: AppWrapper });

expect(
screen.getByRole('button', {
name: /Teams button/i,
}),
).toBeInTheDocument();

expect(
screen.getByRole('button', {
name: /Mail Domains button/i,
}),
).toBeInTheDocument();
});

it('checks menu rendering without team feature', () => {
process.env.NEXT_PUBLIC_FEATURE_TEAM = 'false';

render(<MainLayout />, { wrapper: AppWrapper });

expect(
screen.queryByRole('button', {
name: /Teams button/i,
}),
).not.toBeInTheDocument();

expect(
screen.queryByRole('button', {
name: /Mail Domains button/i,
}),
).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export const Panel = () => {
$minWidth: '0',
};

const styleNoTeam = process.env.NEXT_PUBLIC_FEATURE_TEAM !== 'true' && {
$display: 'none',
tabIndex: -1,
};

const transition = 'all 0.5s ease-in-out';

return (
Expand Down Expand Up @@ -52,6 +57,7 @@ export const Panel = () => {
transition: ${transition};
`}
onClick={() => setIsOpen(!isOpen)}
{...styleNoTeam}
>
<IconOpenClose width={24} height={24} aria-hidden="true" />
</BoxButton>
Expand Down
20 changes: 5 additions & 15 deletions src/frontend/apps/desk/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import type { ReactElement } from 'react';
import MailDomains from './mail-domains';
import Teams from './teams';

import { TeamLayout } from '@/features/teams/team-management';
import { NextPageWithLayout } from '@/types/next';

import Teams from './teams/';

const Page: NextPageWithLayout = () => {
return <Teams />;
};

Page.getLayout = function getLayout(page: ReactElement) {
return <TeamLayout>{page}</TeamLayout>;
};

export default Page;
export default process.env.NEXT_PUBLIC_FEATURE_TEAM === 'true'
? Teams
: MailDomains;
Loading