Skip to content

Commit

Permalink
[Gitar] Updating TSX files
Browse files Browse the repository at this point in the history
  • Loading branch information
Gitar committed Sep 23, 2024
1 parent 992eb2e commit 04c25c1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import type React from 'react';
import type { FC } from 'react';
import { Box, styled } from '@mui/material';
import {
type IProjectOwnersProps,
ProjectOwners as LegacyProjectOwners,
} from '../LegacyProjectOwners/LegacyProjectOwners';
import { type IProjectOwnersProps } from '../LegacyProjectOwners/LegacyProjectOwners';
import { ProjectOwners } from './ProjectOwners/ProjectOwners';
import { useUiFlag } from 'hooks/useUiFlag';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';

interface IProjectCardFooterProps {
id?: string;
Expand All @@ -31,20 +26,13 @@ const StyledFooter = styled(Box)<{ disabled: boolean }>(
);

export const ProjectCardFooter: FC<IProjectCardFooterProps> = ({
id,
children,
owners,
disabled = false,
}) => {
const projectListImprovementsEnabled = useUiFlag('projectListImprovements');

return (
<StyledFooter disabled={disabled}>
<ConditionallyRender
condition={Boolean(projectListImprovementsEnabled)}
show={<ProjectOwners owners={owners} />}
elseShow={<LegacyProjectOwners owners={owners} />}
/>
<ProjectOwners owners={owners} />
{children}
</StyledFooter>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import type { FC } from 'react';
import LockIcon from '@mui/icons-material/Lock';
import ProtectedProjectIcon from '@mui/icons-material/LockOutlined';
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
import PrivateProjectIcon from '@mui/icons-material/VisibilityOffOutlined';
import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip';
import { Badge } from 'component/common/Badge/Badge';
import { useUiFlag } from 'hooks/useUiFlag';
import { styled } from '@mui/material';

interface IProjectModeBadgeProps {
Expand All @@ -19,50 +15,28 @@ const StyledIcon = styled('div')(({ theme }) => ({
}));

export const ProjectModeBadge: FC<IProjectModeBadgeProps> = ({ mode }) => {
const projectListImprovementsEnabled = useUiFlag('projectListImprovements');

if (mode === 'private') {
if (projectListImprovementsEnabled) {
return (
<HtmlTooltip
title="This project's collaboration mode is set to private. The project and associated feature flags can only be seen by members of the project."
arrow
>
<StyledIcon>
<PrivateProjectIcon fontSize='inherit' />
</StyledIcon>
</HtmlTooltip>
);
}
return (
<HtmlTooltip
title="This project's collaboration mode is set to private. The project and associated feature flags can only be seen by members of the project."
arrow
>
<Badge color='warning' icon={<VisibilityOffIcon />} />
<StyledIcon>
<PrivateProjectIcon fontSize='inherit' />
</StyledIcon>
</HtmlTooltip>
);
}

if (mode === 'protected') {
if (projectListImprovementsEnabled) {
return (
<HtmlTooltip
title="This project's collaboration mode is set to protected. Only admins and project members can submit change requests."
arrow
>
<StyledIcon>
<ProtectedProjectIcon fontSize='inherit' />
</StyledIcon>
</HtmlTooltip>
);
}
return (
<HtmlTooltip
title="This project's collaboration mode is set to protected. Only admins and project members can submit change requests."
arrow
>
<Badge color='warning' icon={<LockIcon />} />
<StyledIcon>
<ProtectedProjectIcon fontSize='inherit' />
</StyledIcon>
</HtmlTooltip>
);
}
Expand Down
12 changes: 2 additions & 10 deletions frontend/src/component/project/ProjectList/ProjectGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import type { ComponentType, ReactNode } from 'react';
import { Link } from 'react-router-dom';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import { ProjectCard as LegacyProjectCard } from '../ProjectCard/LegacyProjectCard';
import { ProjectCard as NewProjectCard } from '../ProjectCard/ProjectCard';
import type { ProjectSchema } from 'openapi';
import loadingData from './loadingData';
import { TablePlaceholder } from 'component/common/Table';
import { styled, Typography } from '@mui/material';
import { useUiFlag } from 'hooks/useUiFlag';
import { useSearchHighlightContext } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext';
import { flexColumn } from 'themes/themeStyles';

Expand Down Expand Up @@ -72,10 +70,7 @@ export const ProjectGroup = ({
ProjectCardComponent,
link = true,
}: ProjectGroupProps) => {
const projectListImprovementsEnabled = useUiFlag('projectListImprovements');
const ProjectCard =
ProjectCardComponent ??
(projectListImprovementsEnabled ? NewProjectCard : LegacyProjectCard);
const ProjectCard = ProjectCardComponent ?? NewProjectCard;
const { searchQuery } = useSearchHighlightContext();

return (
Expand All @@ -91,10 +86,7 @@ export const ProjectGroup = ({
}
/>
<ConditionallyRender
condition={
Boolean(sectionSubtitle) &&
projectListImprovementsEnabled
}
condition={Boolean(sectionSubtitle)}
show={
<Typography variant='body2' color='text.secondary'>
{sectionSubtitle}
Expand Down
9 changes: 1 addition & 8 deletions frontend/src/component/project/ProjectList/ProjectList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { useUiFlag } from 'hooks/useUiFlag';
import { ProjectsListSort } from './ProjectsListSort/ProjectsListSort';
import { useProjectsListState } from './hooks/useProjectsListState';
import { SearchHighlightProvider } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext';
import { ProjectList as LegacyProjectList } from './LegacyProjectList';
import { ProjectCreationButton } from './ProjectCreationButton/ProjectCreationButton';
import { useGroupedProjects } from './hooks/useGroupedProjects';
import { useProjectsSearchAndSort } from './hooks/useProjectsSearchAndSort';
Expand Down Expand Up @@ -146,11 +145,5 @@ const NewProjectList = () => {
};

export const ProjectList: FC = () => {
const projectListImprovementsEnabled = useUiFlag('projectListImprovements');

if (projectListImprovementsEnabled) {
return <NewProjectList />;
}

return <LegacyProjectList />;
return <NewProjectList />;
};

0 comments on commit 04c25c1

Please sign in to comment.