mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-24 17:51:14 +02:00
chore: adapt release templates to new logic
This commit is contained in:
parent
6d6c662aef
commit
022aabd808
@ -2,7 +2,7 @@ import { useReleasePlanTemplates } from 'hooks/api/getters/useReleasePlanTemplat
|
|||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
import { ReactComponent as ReleaseTemplateIcon } from 'assets/img/releaseTemplates.svg';
|
import { ReactComponent as ReleaseTemplateIcon } from 'assets/img/releaseTemplates.svg';
|
||||||
import type { IReleasePlanTemplate } from 'interfaces/releasePlans.ts';
|
import type { IReleasePlanTemplate } from 'interfaces/releasePlans.ts';
|
||||||
import { Box, Button, styled } from '@mui/material';
|
import { Box, styled } from '@mui/material';
|
||||||
import type { StrategyFilterValue } from './FeatureStrategyMenuCards.tsx';
|
import type { StrategyFilterValue } from './FeatureStrategyMenuCards.tsx';
|
||||||
import type { Dispatch, SetStateAction } from 'react';
|
import type { Dispatch, SetStateAction } from 'react';
|
||||||
import { Link as RouterLink } from 'react-router-dom';
|
import { Link as RouterLink } from 'react-router-dom';
|
||||||
@ -74,16 +74,6 @@ const StyledNoTemplatesDescription = styled('p')(({ theme }) => ({
|
|||||||
color: theme.palette.text.secondary,
|
color: theme.palette.text.secondary,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const StyledViewMoreButton = styled(Button)(({ theme }) => ({
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
height: theme.spacing(10),
|
|
||||||
padding: theme.spacing(2),
|
|
||||||
border: `1px solid ${theme.palette.divider}`,
|
|
||||||
borderRadius: theme.spacing(1),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const StyledLink = styled(RouterLink)({
|
const StyledLink = styled(RouterLink)({
|
||||||
textDecoration: 'none',
|
textDecoration: 'none',
|
||||||
'&:hover': {
|
'&:hover': {
|
||||||
@ -113,10 +103,9 @@ export const FeatureStrategyMenuCardsReleaseTemplates = ({
|
|||||||
|
|
||||||
const isFiltered = filter === 'releaseTemplates';
|
const isFiltered = filter === 'releaseTemplates';
|
||||||
const shouldShowHeader = !isFiltered || templates.length > 0;
|
const shouldShowHeader = !isFiltered || templates.length > 0;
|
||||||
|
const releaseTemplatesDisplayLimit = isFiltered
|
||||||
const slicedTemplates = isFiltered
|
? 0
|
||||||
? templates
|
: RELEASE_TEMPLATE_DISPLAY_LIMIT;
|
||||||
: templates.slice(0, RELEASE_TEMPLATE_DISPLAY_LIMIT);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
@ -153,8 +142,12 @@ export const FeatureStrategyMenuCardsReleaseTemplates = ({
|
|||||||
</StyledNoTemplatesBody>
|
</StyledNoTemplatesBody>
|
||||||
</StyledNoTemplatesContainer>
|
</StyledNoTemplatesContainer>
|
||||||
) : (
|
) : (
|
||||||
<FeatureStrategyMenuCardsSection>
|
<FeatureStrategyMenuCardsSection
|
||||||
{slicedTemplates.map((template) => (
|
limit={releaseTemplatesDisplayLimit}
|
||||||
|
viewMore={() => setFilter('releaseTemplates')}
|
||||||
|
viewMoreLabel='View more templates'
|
||||||
|
>
|
||||||
|
{templates.map((template) => (
|
||||||
<FeatureStrategyMenuCard
|
<FeatureStrategyMenuCard
|
||||||
key={template.id}
|
key={template.id}
|
||||||
name={template.name}
|
name={template.name}
|
||||||
@ -175,16 +168,6 @@ export const FeatureStrategyMenuCardsReleaseTemplates = ({
|
|||||||
</FeatureStrategyMenuCardAction>
|
</FeatureStrategyMenuCardAction>
|
||||||
</FeatureStrategyMenuCard>
|
</FeatureStrategyMenuCard>
|
||||||
))}
|
))}
|
||||||
{slicedTemplates.length < templates.length &&
|
|
||||||
templates.length > RELEASE_TEMPLATE_DISPLAY_LIMIT && (
|
|
||||||
<StyledViewMoreButton
|
|
||||||
variant='text'
|
|
||||||
size='small'
|
|
||||||
onClick={() => setFilter('releaseTemplates')}
|
|
||||||
>
|
|
||||||
View more templates
|
|
||||||
</StyledViewMoreButton>
|
|
||||||
)}
|
|
||||||
</FeatureStrategyMenuCardsSection>
|
</FeatureStrategyMenuCardsSection>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
Loading…
Reference in New Issue
Block a user