1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-10 01:16:39 +02:00
This commit is contained in:
Thomas Heartman 2025-03-21 10:19:28 +01:00 committed by GitHub
commit bf7c92ac39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 83 additions and 84 deletions

View File

@ -0,0 +1,18 @@
import { styled } from '@mui/material';
export const StrategyList = styled('ol')(({ theme }) => ({
listStyle: 'none',
padding: 0,
margin: 0,
'& > li': {
paddingBlock: theme.spacing(2.5),
position: 'relative',
},
'& > li + li': {
borderTop: `1px solid ${theme.palette.divider}`,
},
'& > li:first-of-type': {
paddingTop: theme.spacing(1),
},
}));

View File

@ -0,0 +1,15 @@
import { type Theme, styled } from '@mui/material';
export const releasePlanBackground = (theme: Theme) =>
theme.palette.background.elevation2;
export const strategyBackground = (theme: Theme) =>
theme.palette.background.elevation1;
export const StrategyListItem = styled('li')<{
'data-type'?: 'release-plan' | 'strategy';
}>(({ theme, ...props }) => ({
background:
props['data-type'] === 'release-plan'
? releasePlanBackground(theme)
: strategyBackground(theme),
}));

View File

@ -1,4 +1,5 @@
import { styled } from '@mui/material'; import { styled } from '@mui/material';
import { disabledStrategyClassName } from '../StrategyItemContainer/disabled-strategy-utils';
const Chip = styled('div')(({ theme }) => ({ const Chip = styled('div')(({ theme }) => ({
padding: theme.spacing(0.75, 1), padding: theme.spacing(0.75, 1),
@ -11,12 +12,14 @@ const Chip = styled('div')(({ theme }) => ({
borderRadius: theme.shape.borderRadiusLarge, borderRadius: theme.shape.borderRadiusLarge,
backgroundColor: theme.palette.secondary.border, backgroundColor: theme.palette.secondary.border,
left: theme.spacing(4), left: theme.spacing(4),
// if the strategy it's applying to is disabled
[`&:has(+ * .${disabledStrategyClassName}, + .${disabledStrategyClassName})`]:
{
filter: 'grayscale(1)',
},
})); }));
export const StrategySeparator = ({ className }: { className?: string }) => { export const StrategySeparator = () => {
return ( return <Chip role='separator'>OR</Chip>;
<Chip role='separator' className={className}>
OR
</Chip>
);
}; };

View File

@ -4,7 +4,7 @@ import {
useEffect, useEffect,
useState, useState,
} from 'react'; } from 'react';
import { Alert, Pagination, type Theme, styled } from '@mui/material'; import { Alert, Pagination, styled } from '@mui/material';
import useFeatureStrategyApi from 'hooks/api/actions/useFeatureStrategyApi/useFeatureStrategyApi'; import useFeatureStrategyApi from 'hooks/api/actions/useFeatureStrategyApi/useFeatureStrategyApi';
import { formatUnknownError } from 'utils/formatUnknownError'; import { formatUnknownError } from 'utils/formatUnknownError';
import useToast from 'hooks/useToast'; import useToast from 'hooks/useToast';
@ -22,7 +22,12 @@ import { useReleasePlans } from 'hooks/api/getters/useReleasePlans/useReleasePla
import { ReleasePlan } from '../../../ReleasePlan/ReleasePlan'; import { ReleasePlan } from '../../../ReleasePlan/ReleasePlan';
import { StrategySeparator } from 'component/common/StrategySeparator/StrategySeparator'; import { StrategySeparator } from 'component/common/StrategySeparator/StrategySeparator';
import { ProjectEnvironmentStrategyDraggableItem } from './StrategyDraggableItem/ProjectEnvironmentStrategyDraggableItem'; import { ProjectEnvironmentStrategyDraggableItem } from './StrategyDraggableItem/ProjectEnvironmentStrategyDraggableItem';
import { disabledStrategyClassName } from 'component/common/StrategyItemContainer/disabled-strategy-utils'; import {
StrategyListItem,
releasePlanBackground,
strategyBackground,
} from 'component/common/StrategyList/StrategyListItem';
import { StrategyList } from 'component/common/StrategyList/StrategyList';
interface IEnvironmentAccordionBodyProps { interface IEnvironmentAccordionBodyProps {
isDisabled: boolean; isDisabled: boolean;
@ -34,37 +39,6 @@ const StyledAccordionBodyInnerContainer = styled('div')(({ theme }) => ({
borderBottom: `1px solid ${theme.palette.divider}`, borderBottom: `1px solid ${theme.palette.divider}`,
})); }));
export const StyledContentList = styled('ol')(({ theme }) => ({
listStyle: 'none',
padding: 0,
margin: 0,
'& > li': {
paddingBlock: theme.spacing(2.5),
position: 'relative',
},
'& > li + li': {
borderTop: `1px solid ${theme.palette.divider}`,
},
'& > li:first-of-type': {
paddingTop: theme.spacing(1),
},
}));
const releasePlanBackground = (theme: Theme) =>
theme.palette.background.elevation2;
const strategyBackground = (theme: Theme) =>
theme.palette.background.elevation1;
export const StyledListItem = styled('li')<{
'data-type'?: 'release-plan' | 'strategy';
}>(({ theme, ...props }) => ({
background:
props['data-type'] === 'release-plan'
? releasePlanBackground(theme)
: strategyBackground(theme),
}));
const AlertContainer = styled('div')(({ theme }) => ({ const AlertContainer = styled('div')(({ theme }) => ({
padding: theme.spacing(2), padding: theme.spacing(2),
paddingBottom: theme.spacing(0), paddingBottom: theme.spacing(0),
@ -74,14 +48,6 @@ const AlertContainer = styled('div')(({ theme }) => ({
}, },
})); }));
// todo: consider exporting this into a shared thing or move it into the separator itself (either as a disabled prop or using the css here)
export const StyledStrategySeparator = styled(StrategySeparator)({
[`&:has(+ * .${disabledStrategyClassName}, + .${disabledStrategyClassName})`]:
{
filter: 'grayscale(1)',
},
});
export const EnvironmentAccordionBody = ({ export const EnvironmentAccordionBody = ({
featureEnvironment, featureEnvironment,
isDisabled, isDisabled,
@ -257,21 +223,21 @@ export const EnvironmentAccordionBody = ({
</Alert> </Alert>
</AlertContainer> </AlertContainer>
) : null} ) : null}
<StyledContentList> <StrategyList>
{releasePlans.map((plan) => ( {releasePlans.map((plan) => (
<StyledListItem data-type='release-plan' key={plan.id}> <StrategyListItem data-type='release-plan' key={plan.id}>
<ReleasePlan <ReleasePlan
plan={plan} plan={plan}
environmentIsDisabled={isDisabled} environmentIsDisabled={isDisabled}
/> />
</StyledListItem> </StrategyListItem>
))} ))}
{paginateStrategies ? ( {paginateStrategies ? (
<> <>
{page.map((strategy, index) => ( {page.map((strategy, index) => (
<StyledListItem key={strategy.id}> <StrategyListItem key={strategy.id}>
{index > 0 || releasePlans.length > 0 ? ( {index > 0 || releasePlans.length > 0 ? (
<StyledStrategySeparator /> <StrategySeparator />
) : null} ) : null}
<ProjectEnvironmentStrategyDraggableItem <ProjectEnvironmentStrategyDraggableItem
@ -280,15 +246,15 @@ export const EnvironmentAccordionBody = ({
environmentName={featureEnvironment.name} environmentName={featureEnvironment.name}
otherEnvironments={otherEnvironments} otherEnvironments={otherEnvironments}
/> />
</StyledListItem> </StrategyListItem>
))} ))}
</> </>
) : ( ) : (
<> <>
{strategies.map((strategy, index) => ( {strategies.map((strategy, index) => (
<StyledListItem key={strategy.id}> <StrategyListItem key={strategy.id}>
{index > 0 || releasePlans.length > 0 ? ( {index > 0 || releasePlans.length > 0 ? (
<StyledStrategySeparator /> <StrategySeparator />
) : null} ) : null}
<ProjectEnvironmentStrategyDraggableItem <ProjectEnvironmentStrategyDraggableItem
@ -301,11 +267,11 @@ export const EnvironmentAccordionBody = ({
onDragOver={onDragOver(strategy.id)} onDragOver={onDragOver(strategy.id)}
onDragEnd={onDragEnd} onDragEnd={onDragEnd}
/> />
</StyledListItem> </StrategyListItem>
))} ))}
</> </>
)} )}
</StyledContentList> </StrategyList>
{paginateStrategies ? ( {paginateStrategies ? (
<Pagination <Pagination
count={pages.length} count={pages.length}

View File

@ -11,12 +11,11 @@ import {
type MilestoneStatus, type MilestoneStatus,
} from './ReleasePlanMilestoneStatus'; } from './ReleasePlanMilestoneStatus';
import { useState } from 'react'; import { useState } from 'react';
import {
StyledContentList,
StyledListItem,
} from '../../FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/EnvironmentAccordionBody';
import { StrategySeparator } from 'component/common/StrategySeparator/StrategySeparator'; import { StrategySeparator } from 'component/common/StrategySeparator/StrategySeparator';
import { StrategyItem } from '../../FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyItem/StrategyItem'; import { StrategyItem } from '../../FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyItem/StrategyItem';
import { StrategyList } from 'component/common/StrategyList/StrategyList';
import { StrategyListItem } from 'component/common/StrategyList/StrategyListItem';
const StyledAccordion = styled(Accordion, { const StyledAccordion = styled(Accordion, {
shouldForwardProp: (prop) => prop !== 'status', shouldForwardProp: (prop) => prop !== 'status',
@ -117,9 +116,9 @@ export const ReleasePlanMilestone = ({
</StyledSecondaryLabel> </StyledSecondaryLabel>
</StyledAccordionSummary> </StyledAccordionSummary>
<StyledAccordionDetails> <StyledAccordionDetails>
<StyledContentList> <StrategyList>
{milestone.strategies.map((strategy, index) => ( {milestone.strategies.map((strategy, index) => (
<StyledListItem key={strategy.id}> <StrategyListItem key={strategy.id}>
{index > 0 ? <StrategySeparator /> : null} {index > 0 ? <StrategySeparator /> : null}
<StrategyItem <StrategyItem
@ -132,9 +131,9 @@ export const ReleasePlanMilestone = ({
'', '',
}} }}
/> />
</StyledListItem> </StrategyListItem>
))} ))}
</StyledContentList> </StrategyList>
</StyledAccordionDetails> </StyledAccordionDetails>
</StyledAccordion> </StyledAccordion>
); );

View File

@ -3,12 +3,11 @@ import type {
PlaygroundStrategySchema, PlaygroundStrategySchema,
PlaygroundRequestSchema, PlaygroundRequestSchema,
} from 'openapi'; } from 'openapi';
import {
StyledContentList,
StyledListItem,
StyledStrategySeparator,
} from 'component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/EnvironmentAccordionBody';
import { FeatureStrategyItem } from './StrategyItem/FeatureStrategyItem'; import { FeatureStrategyItem } from './StrategyItem/FeatureStrategyItem';
import { StrategySeparator } from 'component/common/StrategySeparator/StrategySeparator';
import { StrategyList } from 'component/common/StrategyList/StrategyList';
import { StrategyListItem } from 'component/common/StrategyList/StrategyListItem';
interface PlaygroundResultStrategyListProps { interface PlaygroundResultStrategyListProps {
strategies: PlaygroundStrategySchema[]; strategies: PlaygroundStrategySchema[];
@ -31,7 +30,7 @@ const StyledListTitleDescription = styled('p')(({ theme }) => ({
fontSize: theme.typography.body2.fontSize, fontSize: theme.typography.body2.fontSize,
})); }));
const RestyledContentList = styled(StyledContentList)(({ theme }) => ({ const StyledStrategyList = styled(StrategyList)(({ theme }) => ({
marginInline: `calc(var(--popover-inline-padding) * -1)`, marginInline: `calc(var(--popover-inline-padding) * -1)`,
borderTop: `1px solid ${theme.palette.divider}`, borderTop: `1px solid ${theme.palette.divider}`,
'> li:last-of-type': { '> li:last-of-type': {
@ -63,17 +62,17 @@ export const PlaygroundResultStrategyLists = ({
</StyledListTitleDescription> </StyledListTitleDescription>
) : null} ) : null}
</StyledHeaderGroup> </StyledHeaderGroup>
<RestyledContentList> <StyledStrategyList>
{strategies?.map((strategy, index) => ( {strategies?.map((strategy, index) => (
<StyledListItem key={strategy.id}> <StrategyListItem key={strategy.id}>
{index > 0 ? <StyledStrategySeparator /> : ''} {index > 0 ? <StrategySeparator /> : ''}
<FeatureStrategyItem <FeatureStrategyItem
strategy={strategy} strategy={strategy}
input={input} input={input}
/> />
</StyledListItem> </StrategyListItem>
))} ))}
</RestyledContentList> </StyledStrategyList>
</div> </div>
); );
}; };

View File

@ -19,15 +19,14 @@ import { ReleasePlanTemplateAddStrategyForm } from '../../MilestoneStrategy/Rele
import DragIndicator from '@mui/icons-material/DragIndicator'; import DragIndicator from '@mui/icons-material/DragIndicator';
import { type OnMoveItem, useDragItem } from 'hooks/useDragItem'; import { type OnMoveItem, useDragItem } from 'hooks/useDragItem';
import type { IExtendedMilestonePayload } from 'component/releases/hooks/useTemplateForm'; import type { IExtendedMilestonePayload } from 'component/releases/hooks/useTemplateForm';
import {
StyledContentList,
StyledListItem,
} from 'component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/EnvironmentAccordionBody';
import { StrategySeparator } from 'component/common/StrategySeparator/StrategySeparator'; import { StrategySeparator } from 'component/common/StrategySeparator/StrategySeparator';
import Edit from '@mui/icons-material/Edit'; import Edit from '@mui/icons-material/Edit';
import Delete from '@mui/icons-material/DeleteOutlined'; import Delete from '@mui/icons-material/DeleteOutlined';
import { StrategyDraggableItem } from 'component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyDraggableItem'; import { StrategyDraggableItem } from 'component/feature/FeatureView/FeatureOverview/FeatureOverviewEnvironments/FeatureOverviewEnvironment/EnvironmentAccordionBody/StrategyDraggableItem/StrategyDraggableItem';
import { ScreenReaderOnly } from 'component/common/ScreenReaderOnly/ScreenReaderOnly'; import { ScreenReaderOnly } from 'component/common/ScreenReaderOnly/ScreenReaderOnly';
import { StrategyList } from 'component/common/StrategyList/StrategyList';
import { StrategyListItem } from 'component/common/StrategyList/StrategyListItem';
const leftPadding = 3; const leftPadding = 3;
@ -469,9 +468,9 @@ export const MilestoneCard = ({
/> />
</StyledAccordionSummary> </StyledAccordionSummary>
<StyledAccordionDetails> <StyledAccordionDetails>
<StyledContentList> <StrategyList>
{milestone.strategies.map((strg, index) => ( {milestone.strategies.map((strg, index) => (
<StyledListItem key={strg.id}> <StrategyListItem key={strg.id}>
{index > 0 ? <StrategySeparator /> : null} {index > 0 ? <StrategySeparator /> : null}
<StrategyDraggableItem <StrategyDraggableItem
@ -513,9 +512,9 @@ export const MilestoneCard = ({
</> </>
} }
/> />
</StyledListItem> </StrategyListItem>
))} ))}
</StyledContentList> </StrategyList>
<StyledAccordionFooter> <StyledAccordionFooter>
<Button <Button
variant='text' variant='text'