- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 740
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes [issue/1-2666](https://linear.app/unleash/issue/1-2666/archived-projects-view)
- Loading branch information
Showing
16 changed files
with
437 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import type { ComponentProps, FC } from 'react'; | ||
import { SvgIcon } from '@mui/material'; | ||
import { ReactComponent as Svg } from 'assets/icons/projectIconSmall.svg'; | ||
|
||
export const ProjectIcon = () => ( | ||
<SvgIcon component={Svg} viewBox={'0 0 14 10'} /> | ||
); | ||
export const ProjectIcon: FC<ComponentProps<typeof SvgIcon>> = ({ | ||
...props | ||
}) => <SvgIcon component={Svg} viewBox={'0 0 14 10'} {...props} />; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
frontend/src/component/project/NewProjectCard/ProjectArchiveCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import type { FC } from 'react'; | ||
import { | ||
StyledProjectCard, | ||
StyledDivHeader, | ||
StyledBox, | ||
StyledCardTitle, | ||
StyledDivInfo, | ||
StyledParagraphInfo, | ||
StyledProjectCardBody, | ||
StyledIconBox, | ||
StyledActions, | ||
} from './NewProjectCard.styles'; | ||
import { ProjectCardFooter } from './ProjectCardFooter/ProjectCardFooter'; | ||
import { ProjectModeBadge } from './ProjectModeBadge/ProjectModeBadge'; | ||
import { ProjectOwners } from './ProjectOwners/ProjectOwners'; | ||
import type { ProjectSchemaOwners } from 'openapi'; | ||
import { ProjectIcon } from 'component/common/ProjectIcon/ProjectIcon'; | ||
import { formatDateYMDHM } from 'utils/formatDate'; | ||
import { useLocationSettings } from 'hooks/useLocationSettings'; | ||
import { parseISO } from 'date-fns'; | ||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; | ||
import TimeAgo from 'react-timeago'; | ||
import { Box, Link, Tooltip } from '@mui/material'; | ||
import { Link as RouterLink } from 'react-router-dom'; | ||
import { | ||
CREATE_PROJECT, | ||
DELETE_PROJECT, | ||
} from 'component/providers/AccessProvider/permissions'; | ||
import Undo from '@mui/icons-material/Undo'; | ||
import PermissionIconButton from 'component/common/PermissionIconButton/PermissionIconButton'; | ||
import Delete from '@mui/icons-material/Delete'; | ||
|
||
interface IProjectArchiveCardProps { | ||
id: string; | ||
name: string; | ||
createdAt?: string; | ||
archivedAt?: string; | ||
featureCount: number; | ||
onRevive: () => void; | ||
onDelete: () => void; | ||
mode: string; | ||
owners?: ProjectSchemaOwners; | ||
} | ||
|
||
export const ProjectArchiveCard: FC<IProjectArchiveCardProps> = ({ | ||
id, | ||
name, | ||
archivedAt, | ||
featureCount = 0, | ||
onRevive, | ||
onDelete, | ||
mode, | ||
owners, | ||
}) => { | ||
const { locationSettings } = useLocationSettings(); | ||
const Actions: FC<{ | ||
id: string; | ||
}> = ({ id }) => ( | ||
<StyledActions> | ||
<PermissionIconButton | ||
onClick={onRevive} | ||
projectId={id} | ||
permission={CREATE_PROJECT} | ||
tooltipProps={{ title: 'Restore project' }} | ||
data-testid={`revive-feature-flag-button`} | ||
> | ||
<Undo /> | ||
</PermissionIconButton> | ||
<PermissionIconButton | ||
permission={DELETE_PROJECT} | ||
projectId={id} | ||
tooltipProps={{ title: 'Permanently delete project' }} | ||
onClick={onDelete} | ||
> | ||
<Delete /> | ||
</PermissionIconButton> | ||
</StyledActions> | ||
); | ||
|
||
return ( | ||
<StyledProjectCard disabled> | ||
<StyledProjectCardBody> | ||
<StyledDivHeader> | ||
<StyledIconBox> | ||
<ProjectIcon color='action' /> | ||
</StyledIconBox> | ||
<StyledBox data-loading> | ||
<StyledCardTitle>{name}</StyledCardTitle> | ||
</StyledBox> | ||
<ProjectModeBadge mode={mode} /> | ||
</StyledDivHeader> | ||
<StyledDivInfo> | ||
<Link | ||
component={RouterLink} | ||
to={`/archive?search=project%3A${encodeURI(id)}`} | ||
> | ||
<StyledParagraphInfo disabled data-loading> | ||
{featureCount} | ||
</StyledParagraphInfo> | ||
<p data-loading> | ||
archived {featureCount === 1 ? 'flag' : 'flags'} | ||
</p> | ||
</Link> | ||
<ConditionallyRender | ||
condition={Boolean(archivedAt)} | ||
show={ | ||
<Tooltip | ||
title={formatDateYMDHM( | ||
parseISO(archivedAt as string), | ||
locationSettings.locale, | ||
)} | ||
arrow | ||
> | ||
<Box | ||
sx={(theme) => ({ | ||
color: theme.palette.text.secondary, | ||
})} | ||
> | ||
<StyledParagraphInfo disabled data-loading> | ||
Archived | ||
</StyledParagraphInfo> | ||
<p data-loading> | ||
<TimeAgo | ||
date={ | ||
new Date(archivedAt as string) | ||
} | ||
/> | ||
</p> | ||
</Box> | ||
</Tooltip> | ||
} | ||
/> | ||
</StyledDivInfo> | ||
</StyledProjectCardBody> | ||
<ProjectCardFooter id={id} Actions={Actions} disabled> | ||
<ProjectOwners owners={owners} /> | ||
</ProjectCardFooter> | ||
</StyledProjectCard> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.