mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
feat: delete segment from CR (#4469)
This commit is contained in:
parent
84cbd669eb
commit
c1314a8ee8
@ -29,11 +29,19 @@ export const ChangeRequest: VFC<IChangeRequestProps> = ({
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{changeRequest.segments?.map(segment => (
|
{changeRequest.segments?.map(segmentChange => (
|
||||||
<SegmentChange
|
<SegmentChange
|
||||||
key={segment.payload.id}
|
key={segmentChange.payload.id}
|
||||||
segmentChange={segment}
|
segmentChange={segmentChange}
|
||||||
onNavigate={onNavigate}
|
onNavigate={onNavigate}
|
||||||
|
actions={
|
||||||
|
<ChangeActions
|
||||||
|
changeRequest={changeRequest}
|
||||||
|
feature={'Unused'}
|
||||||
|
change={segmentChange}
|
||||||
|
onRefetch={onRefetch}
|
||||||
|
/>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
@ -55,7 +63,7 @@ export const ChangeRequest: VFC<IChangeRequestProps> = ({
|
|||||||
{feature.changes.map((change, index) => (
|
{feature.changes.map((change, index) => (
|
||||||
<FeatureChange
|
<FeatureChange
|
||||||
key={index}
|
key={index}
|
||||||
discard={
|
actions={
|
||||||
<ChangeActions
|
<ChangeActions
|
||||||
changeRequest={changeRequest}
|
changeRequest={changeRequest}
|
||||||
feature={feature.name}
|
feature={feature.name}
|
||||||
@ -71,7 +79,7 @@ export const ChangeRequest: VFC<IChangeRequestProps> = ({
|
|||||||
))}
|
))}
|
||||||
{feature.defaultChange ? (
|
{feature.defaultChange ? (
|
||||||
<FeatureChange
|
<FeatureChange
|
||||||
discard={
|
actions={
|
||||||
<Typography
|
<Typography
|
||||||
variant="body2"
|
variant="body2"
|
||||||
color="text.secondary"
|
color="text.secondary"
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
import React, { FC, useState } from 'react';
|
import React, { FC, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
IFeatureChange,
|
|
||||||
IChangeRequest,
|
IChangeRequest,
|
||||||
IChangeRequestAddStrategy,
|
IChangeRequestAddStrategy,
|
||||||
IChangeRequestUpdateStrategy,
|
IChangeRequestUpdateStrategy,
|
||||||
} from '../../../changeRequest.types';
|
IChange,
|
||||||
|
} from 'component/changeRequest/changeRequest.types';
|
||||||
import { useChangeRequestApi } from 'hooks/api/actions/useChangeRequestApi/useChangeRequestApi';
|
import { useChangeRequestApi } from 'hooks/api/actions/useChangeRequestApi/useChangeRequestApi';
|
||||||
import useToast from 'hooks/useToast';
|
import useToast from 'hooks/useToast';
|
||||||
import { formatUnknownError } from 'utils/formatUnknownError';
|
import { formatUnknownError } from 'utils/formatUnknownError';
|
||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled';
|
import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled';
|
||||||
import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
|
import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
|
||||||
import { changesCount } from '../../../changesCount';
|
import { changesCount } from 'component/changeRequest/changesCount';
|
||||||
import {
|
import {
|
||||||
IconButton,
|
IconButton,
|
||||||
ListItemIcon,
|
ListItemIcon,
|
||||||
@ -26,10 +26,7 @@ import {
|
|||||||
import { Delete, Edit, MoreVert } from '@mui/icons-material';
|
import { Delete, Edit, MoreVert } from '@mui/icons-material';
|
||||||
import { EditChange } from './EditChange';
|
import { EditChange } from './EditChange';
|
||||||
|
|
||||||
const useShowActions = (
|
const useShowActions = (changeRequest: IChangeRequest, change: IChange) => {
|
||||||
changeRequest: IChangeRequest,
|
|
||||||
change: IFeatureChange
|
|
||||||
) => {
|
|
||||||
const { isChangeRequestConfigured } = useChangeRequestsEnabled(
|
const { isChangeRequestConfigured } = useChangeRequestsEnabled(
|
||||||
changeRequest.project
|
changeRequest.project
|
||||||
);
|
);
|
||||||
@ -60,7 +57,7 @@ const StyledPopover = styled(Popover)(({ theme }) => ({
|
|||||||
export const ChangeActions: FC<{
|
export const ChangeActions: FC<{
|
||||||
changeRequest: IChangeRequest;
|
changeRequest: IChangeRequest;
|
||||||
feature: string;
|
feature: string;
|
||||||
change: IFeatureChange;
|
change: IChange;
|
||||||
onRefetch?: () => void;
|
onRefetch?: () => void;
|
||||||
}> = ({ changeRequest, feature, change, onRefetch }) => {
|
}> = ({ changeRequest, feature, change, onRefetch }) => {
|
||||||
const { showDiscard, showEdit } = useShowActions(changeRequest, change);
|
const { showDiscard, showEdit } = useShowActions(changeRequest, change);
|
||||||
|
@ -40,7 +40,7 @@ interface IEnvironmentStrategyExecutionOrderProps {
|
|||||||
project: string;
|
project: string;
|
||||||
environment: string;
|
environment: string;
|
||||||
change: IChangeRequestReorderStrategy;
|
change: IChangeRequestReorderStrategy;
|
||||||
discard?: ReactNode;
|
actions?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const EnvironmentStrategyExecutionOrder = ({
|
export const EnvironmentStrategyExecutionOrder = ({
|
||||||
@ -48,7 +48,7 @@ export const EnvironmentStrategyExecutionOrder = ({
|
|||||||
environment,
|
environment,
|
||||||
change,
|
change,
|
||||||
project,
|
project,
|
||||||
discard,
|
actions,
|
||||||
}: IEnvironmentStrategyExecutionOrderProps) => {
|
}: IEnvironmentStrategyExecutionOrderProps) => {
|
||||||
const { feature: featureData } = useFeature(project, feature);
|
const { feature: featureData } = useFeature(project, feature);
|
||||||
const featureEnvironment = featureData.environments.find(
|
const featureEnvironment = featureData.environments.find(
|
||||||
@ -96,7 +96,7 @@ export const EnvironmentStrategyExecutionOrder = ({
|
|||||||
>
|
>
|
||||||
Updating strategy execution order to:
|
Updating strategy execution order to:
|
||||||
</TooltipLink>
|
</TooltipLink>
|
||||||
{discard}
|
{actions}
|
||||||
</StyledChangeHeader>
|
</StyledChangeHeader>
|
||||||
<StyledStrategyExecutionWrapper>
|
<StyledStrategyExecutionWrapper>
|
||||||
{updatedStrategies.map((strategy, index) => (
|
{updatedStrategies.map((strategy, index) => (
|
||||||
|
@ -55,12 +55,12 @@ const StyledAlert = styled(Alert)(({ theme }) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
export const FeatureChange: FC<{
|
export const FeatureChange: FC<{
|
||||||
discard: ReactNode;
|
actions: ReactNode;
|
||||||
index: number;
|
index: number;
|
||||||
changeRequest: IChangeRequest;
|
changeRequest: IChangeRequest;
|
||||||
change: IFeatureChange;
|
change: IFeatureChange;
|
||||||
feature: IChangeRequestFeature;
|
feature: IChangeRequestFeature;
|
||||||
}> = ({ index, change, feature, changeRequest, discard }) => {
|
}> = ({ index, change, feature, changeRequest, actions }) => {
|
||||||
const lastIndex = feature.defaultChange
|
const lastIndex = feature.defaultChange
|
||||||
? feature.changes.length + 1
|
? feature.changes.length + 1
|
||||||
: feature.changes.length;
|
: feature.changes.length;
|
||||||
@ -87,7 +87,7 @@ export const FeatureChange: FC<{
|
|||||||
{change.action === 'updateEnabled' && (
|
{change.action === 'updateEnabled' && (
|
||||||
<ToggleStatusChange
|
<ToggleStatusChange
|
||||||
enabled={change.payload.enabled}
|
enabled={change.payload.enabled}
|
||||||
discard={discard}
|
actions={actions}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ export const FeatureChange: FC<{
|
|||||||
change.action === 'deleteStrategy' ||
|
change.action === 'deleteStrategy' ||
|
||||||
change.action === 'updateStrategy' ? (
|
change.action === 'updateStrategy' ? (
|
||||||
<StrategyChange
|
<StrategyChange
|
||||||
discard={discard}
|
actions={actions}
|
||||||
change={change}
|
change={change}
|
||||||
featureName={feature.name}
|
featureName={feature.name}
|
||||||
environmentName={changeRequest.environment}
|
environmentName={changeRequest.environment}
|
||||||
@ -108,7 +108,7 @@ export const FeatureChange: FC<{
|
|||||||
project={changeRequest.project}
|
project={changeRequest.project}
|
||||||
environment={changeRequest.environment}
|
environment={changeRequest.environment}
|
||||||
change={change}
|
change={change}
|
||||||
discard={discard}
|
actions={actions}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{change.action === 'reorderStrategy' && (
|
{change.action === 'reorderStrategy' && (
|
||||||
@ -117,7 +117,7 @@ export const FeatureChange: FC<{
|
|||||||
project={changeRequest.project}
|
project={changeRequest.project}
|
||||||
environment={changeRequest.environment}
|
environment={changeRequest.environment}
|
||||||
change={change}
|
change={change}
|
||||||
discard={discard}
|
actions={actions}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { FC } from 'react';
|
import { FC, ReactNode } from 'react';
|
||||||
import { Link as RouterLink } from 'react-router-dom';
|
import { Link as RouterLink } from 'react-router-dom';
|
||||||
import { Box, Card, Typography, Link } from '@mui/material';
|
import { Box, Card, Typography, Link } from '@mui/material';
|
||||||
import { ISegmentChange } from '../../../changeRequest.types';
|
import { ISegmentChange } from '../../../changeRequest.types';
|
||||||
@ -8,11 +8,13 @@ import { ConflictWarning } from './ConflictWarning';
|
|||||||
interface ISegmentChangeProps {
|
interface ISegmentChangeProps {
|
||||||
segmentChange: ISegmentChange;
|
segmentChange: ISegmentChange;
|
||||||
onNavigate?: () => void;
|
onNavigate?: () => void;
|
||||||
|
actions: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SegmentChange: FC<ISegmentChangeProps> = ({
|
export const SegmentChange: FC<ISegmentChangeProps> = ({
|
||||||
segmentChange,
|
segmentChange,
|
||||||
onNavigate,
|
onNavigate,
|
||||||
|
actions,
|
||||||
}) => (
|
}) => (
|
||||||
<Card
|
<Card
|
||||||
elevation={0}
|
elevation={0}
|
||||||
@ -64,6 +66,6 @@ export const SegmentChange: FC<ISegmentChangeProps> = ({
|
|||||||
</Link>
|
</Link>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<SegmentChangeDetails change={segmentChange} />
|
<SegmentChangeDetails change={segmentChange} actions={actions} />
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
@ -46,9 +46,9 @@ const SegmentContainer = styled(Box, {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
export const SegmentChangeDetails: VFC<{
|
export const SegmentChangeDetails: VFC<{
|
||||||
discard?: ReactNode;
|
actions?: ReactNode;
|
||||||
change: IChangeRequestUpdateSegment | IChangeRequestDeleteSegment;
|
change: IChangeRequestUpdateSegment | IChangeRequestDeleteSegment;
|
||||||
}> = ({ discard, change }) => {
|
}> = ({ actions, change }) => {
|
||||||
const { segment: currentSegment } = useSegment(change.payload.id);
|
const { segment: currentSegment } = useSegment(change.payload.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -70,7 +70,7 @@ export const SegmentChangeDetails: VFC<{
|
|||||||
/>
|
/>
|
||||||
</SegmentTooltipLink>
|
</SegmentTooltipLink>
|
||||||
</ChangeItemInfo>
|
</ChangeItemInfo>
|
||||||
<div>{discard}</div>
|
<div>{actions}</div>
|
||||||
</ChangeItemWrapper>
|
</ChangeItemWrapper>
|
||||||
)}
|
)}
|
||||||
{change.action === 'updateSegment' && (
|
{change.action === 'updateSegment' && (
|
||||||
@ -85,7 +85,7 @@ export const SegmentChangeDetails: VFC<{
|
|||||||
/>
|
/>
|
||||||
</SegmentTooltipLink>
|
</SegmentTooltipLink>
|
||||||
</ChangeItemInfo>
|
</ChangeItemInfo>
|
||||||
<div>{discard}</div>
|
<div>{actions}</div>
|
||||||
</ChangeItemCreateEditWrapper>
|
</ChangeItemCreateEditWrapper>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
@ -101,7 +101,7 @@ const EditHeader: VFC<{
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const StrategyChange: VFC<{
|
export const StrategyChange: VFC<{
|
||||||
discard?: ReactNode;
|
actions?: ReactNode;
|
||||||
change:
|
change:
|
||||||
| IChangeRequestAddStrategy
|
| IChangeRequestAddStrategy
|
||||||
| IChangeRequestDeleteStrategy
|
| IChangeRequestDeleteStrategy
|
||||||
@ -109,7 +109,7 @@ export const StrategyChange: VFC<{
|
|||||||
environmentName: string;
|
environmentName: string;
|
||||||
featureName: string;
|
featureName: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
}> = ({ discard, change, featureName, environmentName, projectId }) => {
|
}> = ({ actions, change, featureName, environmentName, projectId }) => {
|
||||||
const currentStrategy = useCurrentStrategy(
|
const currentStrategy = useCurrentStrategy(
|
||||||
change,
|
change,
|
||||||
projectId,
|
projectId,
|
||||||
@ -145,7 +145,7 @@ export const StrategyChange: VFC<{
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</ChangeItemInfo>
|
</ChangeItemInfo>
|
||||||
<div>{discard}</div>
|
<div>{actions}</div>
|
||||||
</ChangeItemCreateEditWrapper>
|
</ChangeItemCreateEditWrapper>
|
||||||
<StrategyExecution strategy={change.payload} />
|
<StrategyExecution strategy={change.payload} />
|
||||||
</>
|
</>
|
||||||
@ -169,7 +169,7 @@ export const StrategyChange: VFC<{
|
|||||||
</StrategyTooltipLink>
|
</StrategyTooltipLink>
|
||||||
)}
|
)}
|
||||||
</ChangeItemInfo>
|
</ChangeItemInfo>
|
||||||
<div>{discard}</div>
|
<div>{actions}</div>
|
||||||
</ChangeItemWrapper>
|
</ChangeItemWrapper>
|
||||||
)}
|
)}
|
||||||
{change.action === 'updateStrategy' && (
|
{change.action === 'updateStrategy' && (
|
||||||
@ -190,7 +190,7 @@ export const StrategyChange: VFC<{
|
|||||||
/>
|
/>
|
||||||
</StrategyTooltipLink>
|
</StrategyTooltipLink>
|
||||||
</ChangeItemInfo>
|
</ChangeItemInfo>
|
||||||
<div>{discard}</div>
|
<div>{actions}</div>
|
||||||
</ChangeItemCreateEditWrapper>
|
</ChangeItemCreateEditWrapper>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={
|
condition={
|
||||||
|
@ -5,12 +5,12 @@ import { ChangeItemWrapper } from './StrategyChange';
|
|||||||
|
|
||||||
interface IToggleStatusChange {
|
interface IToggleStatusChange {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
discard?: ReactNode;
|
actions?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ToggleStatusChange: VFC<IToggleStatusChange> = ({
|
export const ToggleStatusChange: VFC<IToggleStatusChange> = ({
|
||||||
enabled,
|
enabled,
|
||||||
discard,
|
actions,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<ChangeItemWrapper>
|
<ChangeItemWrapper>
|
||||||
@ -23,7 +23,7 @@ export const ToggleStatusChange: VFC<IToggleStatusChange> = ({
|
|||||||
{enabled ? ' Enabled' : 'Disabled'}
|
{enabled ? ' Enabled' : 'Disabled'}
|
||||||
</Badge>
|
</Badge>
|
||||||
</Box>
|
</Box>
|
||||||
{discard}
|
{actions}
|
||||||
</ChangeItemWrapper>
|
</ChangeItemWrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -35,7 +35,7 @@ interface IVariantPatchProps {
|
|||||||
project: string;
|
project: string;
|
||||||
environment: string;
|
environment: string;
|
||||||
change: IChangeRequestPatchVariant;
|
change: IChangeRequestPatchVariant;
|
||||||
discard?: ReactNode;
|
actions?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const VariantPatch = ({
|
export const VariantPatch = ({
|
||||||
@ -43,7 +43,7 @@ export const VariantPatch = ({
|
|||||||
project,
|
project,
|
||||||
environment,
|
environment,
|
||||||
change,
|
change,
|
||||||
discard,
|
actions,
|
||||||
}: IVariantPatchProps) => {
|
}: IVariantPatchProps) => {
|
||||||
const { feature: featureData } = useFeature(project, feature);
|
const { feature: featureData } = useFeature(project, feature);
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ export const VariantPatch = ({
|
|||||||
>
|
>
|
||||||
Updating variants to:
|
Updating variants to:
|
||||||
</TooltipLink>
|
</TooltipLink>
|
||||||
{discard}
|
{actions}
|
||||||
</StyledChangeHeader>
|
</StyledChangeHeader>
|
||||||
<EnvironmentVariantsTable variants={change.payload.variants} />
|
<EnvironmentVariantsTable variants={change.payload.variants} />
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
|
@ -110,6 +110,7 @@ export interface IChangeRequestReorderStrategy
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IChangeRequestUpdateSegment {
|
export interface IChangeRequestUpdateSegment {
|
||||||
|
id: number;
|
||||||
action: 'updateSegment';
|
action: 'updateSegment';
|
||||||
conflict?: string;
|
conflict?: string;
|
||||||
name: string;
|
name: string;
|
||||||
@ -123,6 +124,7 @@ export interface IChangeRequestUpdateSegment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface IChangeRequestDeleteSegment {
|
export interface IChangeRequestDeleteSegment {
|
||||||
|
id: number;
|
||||||
action: 'deleteSegment';
|
action: 'deleteSegment';
|
||||||
conflict?: string;
|
conflict?: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user