mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-10 01:16:39 +02:00
fix: project archive card (#8024)
Fix archived project card after new projects list refactor. Archive card was not showing button actions in footer.
This commit is contained in:
parent
712d1c6fa4
commit
eb55067983
@ -1,10 +1,8 @@
|
|||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import {
|
import {
|
||||||
StyledProjectCard,
|
StyledProjectCard,
|
||||||
StyledDivHeader,
|
|
||||||
StyledBox,
|
StyledBox,
|
||||||
StyledCardTitle,
|
StyledCardTitle,
|
||||||
StyledDivInfo,
|
|
||||||
StyledProjectCardBody,
|
StyledProjectCardBody,
|
||||||
StyledIconBox,
|
StyledIconBox,
|
||||||
StyledActions,
|
StyledActions,
|
||||||
@ -16,8 +14,7 @@ import { ProjectIcon } from 'component/common/ProjectIcon/ProjectIcon';
|
|||||||
import { formatDateYMDHM } from 'utils/formatDate';
|
import { formatDateYMDHM } from 'utils/formatDate';
|
||||||
import { useLocationSettings } from 'hooks/useLocationSettings';
|
import { useLocationSettings } from 'hooks/useLocationSettings';
|
||||||
import { parseISO } from 'date-fns';
|
import { parseISO } from 'date-fns';
|
||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
import { Box, Link, styled, Tooltip } from '@mui/material';
|
||||||
import { Box, Link, Tooltip } from '@mui/material';
|
|
||||||
import { Link as RouterLink } from 'react-router-dom';
|
import { Link as RouterLink } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
DELETE_PROJECT,
|
DELETE_PROJECT,
|
||||||
@ -29,6 +26,7 @@ import Delete from '@mui/icons-material/Delete';
|
|||||||
import { Highlighter } from 'component/common/Highlighter/Highlighter';
|
import { Highlighter } from 'component/common/Highlighter/Highlighter';
|
||||||
import { useSearchHighlightContext } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext';
|
import { useSearchHighlightContext } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext';
|
||||||
import { TimeAgo } from 'component/common/TimeAgo/TimeAgo';
|
import { TimeAgo } from 'component/common/TimeAgo/TimeAgo';
|
||||||
|
import { flexRow } from 'themes/themeStyles';
|
||||||
|
|
||||||
export type ProjectArchiveCardProps = {
|
export type ProjectArchiveCardProps = {
|
||||||
id: string;
|
id: string;
|
||||||
@ -40,6 +38,24 @@ export type ProjectArchiveCardProps = {
|
|||||||
owners?: ProjectSchemaOwners;
|
owners?: ProjectSchemaOwners;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const StyledDivHeader = styled('div')(({ theme }) => ({
|
||||||
|
...flexRow,
|
||||||
|
width: '100%',
|
||||||
|
gap: theme.spacing(1),
|
||||||
|
minHeight: theme.spacing(6),
|
||||||
|
marginBottom: theme.spacing(1),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const StyledTitle = styled(StyledCardTitle)(({ theme }) => ({
|
||||||
|
margin: 0,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const StyledContent = styled('div')(({ theme }) => ({
|
||||||
|
...flexRow,
|
||||||
|
fontSize: theme.fontSizes.smallerBody,
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
}));
|
||||||
|
|
||||||
export const ProjectArchiveCard: FC<ProjectArchiveCardProps> = ({
|
export const ProjectArchiveCard: FC<ProjectArchiveCardProps> = ({
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
@ -61,49 +77,46 @@ export const ProjectArchiveCard: FC<ProjectArchiveCardProps> = ({
|
|||||||
</StyledIconBox>
|
</StyledIconBox>
|
||||||
<StyledBox data-loading>
|
<StyledBox data-loading>
|
||||||
<Tooltip title={`id: ${id}`} arrow>
|
<Tooltip title={`id: ${id}`} arrow>
|
||||||
<StyledCardTitle>
|
<StyledTitle>
|
||||||
<Highlighter search={searchQuery}>
|
<Highlighter search={searchQuery}>
|
||||||
{name}
|
{name}
|
||||||
</Highlighter>
|
</Highlighter>
|
||||||
</StyledCardTitle>
|
</StyledTitle>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</StyledBox>
|
</StyledBox>
|
||||||
<ProjectModeBadge mode={mode} />
|
<ProjectModeBadge mode={mode} />
|
||||||
</StyledDivHeader>
|
</StyledDivHeader>
|
||||||
<StyledDivInfo>
|
<StyledContent>
|
||||||
<ConditionallyRender
|
<Tooltip
|
||||||
condition={Boolean(archivedAt)}
|
title={
|
||||||
show={
|
archivedAt
|
||||||
<Tooltip
|
? formatDateYMDHM(
|
||||||
title={formatDateYMDHM(
|
parseISO(archivedAt as string),
|
||||||
parseISO(archivedAt as string),
|
locationSettings.locale,
|
||||||
locationSettings.locale,
|
)
|
||||||
)}
|
: undefined
|
||||||
arrow
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={(theme) => ({
|
|
||||||
color: theme.palette.text.secondary,
|
|
||||||
})}
|
|
||||||
>
|
|
||||||
<p data-loading>
|
|
||||||
Archived:{' '}
|
|
||||||
<TimeAgo
|
|
||||||
date={archivedAt}
|
|
||||||
refresh={false}
|
|
||||||
/>
|
|
||||||
</p>
|
|
||||||
</Box>
|
|
||||||
</Tooltip>
|
|
||||||
}
|
}
|
||||||
/>
|
arrow
|
||||||
|
placement='top'
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
sx={(theme) => ({
|
||||||
|
color: theme.palette.text.secondary,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<p data-loading>
|
||||||
|
Archived:{' '}
|
||||||
|
<TimeAgo date={archivedAt} refresh={false} />
|
||||||
|
</p>
|
||||||
|
</Box>
|
||||||
|
</Tooltip>
|
||||||
<Link
|
<Link
|
||||||
component={RouterLink}
|
component={RouterLink}
|
||||||
to={`/archive?search=project%3A${encodeURI(id)}`}
|
to={`/archive?search=project%3A${encodeURI(id)}`}
|
||||||
>
|
>
|
||||||
<p>View archived flags</p>
|
<p>View archived flags</p>
|
||||||
</Link>
|
</Link>
|
||||||
</StyledDivInfo>
|
</StyledContent>
|
||||||
</StyledProjectCardBody>
|
</StyledProjectCardBody>
|
||||||
<ProjectCardFooter id={id} disabled owners={owners}>
|
<ProjectCardFooter id={id} disabled owners={owners}>
|
||||||
<StyledActions>
|
<StyledActions>
|
||||||
|
@ -100,5 +100,5 @@ export const StyledIconBox = styled(Box)(({ theme }) => ({
|
|||||||
|
|
||||||
export const StyledActions = styled(Box)(({ theme }) => ({
|
export const StyledActions = styled(Box)(({ theme }) => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
marginRight: theme.spacing(2),
|
margin: theme.spacing(0.5),
|
||||||
}));
|
}));
|
||||||
|
@ -15,6 +15,9 @@ import { ProjectLastSeen } from './ProjectLastSeen/ProjectLastSeen';
|
|||||||
import type { IProjectCard } from 'interfaces/project';
|
import type { IProjectCard } from 'interfaces/project';
|
||||||
import { Highlighter } from 'component/common/Highlighter/Highlighter';
|
import { Highlighter } from 'component/common/Highlighter/Highlighter';
|
||||||
import { useSearchHighlightContext } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext';
|
import { useSearchHighlightContext } from 'component/common/Table/SearchHighlightContext/SearchHighlightContext';
|
||||||
|
import { ProjectMembers } from './ProjectCardFooter/ProjectMembers/ProjectMembers';
|
||||||
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
|
import { DEFAULT_PROJECT_ID } from 'hooks/api/getters/useDefaultProject/useDefaultProjectId';
|
||||||
|
|
||||||
const StyledUpdated = styled('span')(({ theme }) => ({
|
const StyledUpdated = styled('span')(({ theme }) => ({
|
||||||
color: theme.palette.text.secondary,
|
color: theme.palette.text.secondary,
|
||||||
@ -99,11 +102,12 @@ export const ProjectCard = ({
|
|||||||
</div>
|
</div>
|
||||||
</StyledInfo>
|
</StyledInfo>
|
||||||
</StyledProjectCardBody>
|
</StyledProjectCardBody>
|
||||||
<ProjectCardFooter
|
<ProjectCardFooter id={id} owners={owners}>
|
||||||
id={id}
|
<ConditionallyRender
|
||||||
owners={owners}
|
condition={id !== DEFAULT_PROJECT_ID}
|
||||||
memberCount={memberCount}
|
show={<ProjectMembers count={memberCount} members={[]} />}
|
||||||
/>
|
/>
|
||||||
|
</ProjectCardFooter>
|
||||||
</StyledProjectCard>
|
</StyledProjectCard>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -8,8 +8,6 @@ import {
|
|||||||
import { ProjectOwners } from './ProjectOwners/ProjectOwners';
|
import { ProjectOwners } from './ProjectOwners/ProjectOwners';
|
||||||
import { useUiFlag } from 'hooks/useUiFlag';
|
import { useUiFlag } from 'hooks/useUiFlag';
|
||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
import { ProjectMembers } from './ProjectMembers/ProjectMembers';
|
|
||||||
import { DEFAULT_PROJECT_ID } from 'hooks/api/getters/useDefaultProject/useDefaultProjectId';
|
|
||||||
|
|
||||||
interface IProjectCardFooterProps {
|
interface IProjectCardFooterProps {
|
||||||
id?: string;
|
id?: string;
|
||||||
@ -17,7 +15,6 @@ interface IProjectCardFooterProps {
|
|||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
owners: IProjectOwnersProps['owners'];
|
owners: IProjectOwnersProps['owners'];
|
||||||
memberCount?: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const StyledFooter = styled(Box)<{ disabled: boolean }>(
|
const StyledFooter = styled(Box)<{ disabled: boolean }>(
|
||||||
@ -38,7 +35,6 @@ export const ProjectCardFooter: FC<IProjectCardFooterProps> = ({
|
|||||||
children,
|
children,
|
||||||
owners,
|
owners,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
memberCount,
|
|
||||||
}) => {
|
}) => {
|
||||||
const projectListImprovementsEnabled = useUiFlag('projectListImprovements');
|
const projectListImprovementsEnabled = useUiFlag('projectListImprovements');
|
||||||
|
|
||||||
@ -49,14 +45,7 @@ export const ProjectCardFooter: FC<IProjectCardFooterProps> = ({
|
|||||||
show={<ProjectOwners owners={owners} />}
|
show={<ProjectOwners owners={owners} />}
|
||||||
elseShow={<LegacyProjectOwners owners={owners} />}
|
elseShow={<LegacyProjectOwners owners={owners} />}
|
||||||
/>
|
/>
|
||||||
<ConditionallyRender
|
{children}
|
||||||
condition={
|
|
||||||
Boolean(projectListImprovementsEnabled) &&
|
|
||||||
id !== DEFAULT_PROJECT_ID
|
|
||||||
}
|
|
||||||
show={<ProjectMembers count={memberCount} members={[]} />}
|
|
||||||
elseShow={children}
|
|
||||||
/>
|
|
||||||
</StyledFooter>
|
</StyledFooter>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user