mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-04 13:48:56 +02:00
fix: removed dupliacted component (#7013)
This commit is contained in:
parent
64c10f9eff
commit
ea9a232acc
@ -19,7 +19,6 @@ import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled';
|
|||||||
import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests';
|
import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests';
|
||||||
import usePagination from 'hooks/usePagination';
|
import usePagination from 'hooks/usePagination';
|
||||||
import type { IFeatureStrategy } from 'interfaces/strategy';
|
import type { IFeatureStrategy } from 'interfaces/strategy';
|
||||||
import { StrategyNonDraggableItem } from './StrategyDraggableItem/StrategyNonDraggableItem';
|
|
||||||
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||||
import { useUiFlag } from 'hooks/useUiFlag';
|
import { useUiFlag } from 'hooks/useUiFlag';
|
||||||
|
|
||||||
@ -251,7 +250,7 @@ const EnvironmentAccordionBody = ({
|
|||||||
</Alert>
|
</Alert>
|
||||||
<br />
|
<br />
|
||||||
{page.map((strategy, index) => (
|
{page.map((strategy, index) => (
|
||||||
<StrategyNonDraggableItem
|
<StrategyDraggableItem
|
||||||
key={strategy.id}
|
key={strategy.id}
|
||||||
strategy={strategy}
|
strategy={strategy}
|
||||||
index={index + pageIndex * pageSize}
|
index={index + pageIndex * pageSize}
|
||||||
@ -261,6 +260,10 @@ const EnvironmentAccordionBody = ({
|
|||||||
otherEnvironments={
|
otherEnvironments={
|
||||||
otherEnvironments
|
otherEnvironments
|
||||||
}
|
}
|
||||||
|
isDragging={false}
|
||||||
|
onDragStartRef={(() => {}) as any}
|
||||||
|
onDragOver={(() => {}) as any}
|
||||||
|
onDragEnd={(() => {}) as any}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
<br />
|
<br />
|
||||||
|
@ -1,131 +0,0 @@
|
|||||||
import { useRef } from 'react';
|
|
||||||
import { Box, useMediaQuery, useTheme } from '@mui/material';
|
|
||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
|
||||||
import { StrategySeparator } from 'component/common/StrategySeparator/StrategySeparator';
|
|
||||||
import type { IFeatureEnvironment } from 'interfaces/featureToggle';
|
|
||||||
import type { IFeatureStrategy } from 'interfaces/strategy';
|
|
||||||
import { StrategyItem } from './StrategyItem/StrategyItem';
|
|
||||||
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
|
||||||
import {
|
|
||||||
useStrategyChangesFromRequest,
|
|
||||||
type UseStrategyChangeFromRequestResult,
|
|
||||||
} from './StrategyItem/useStrategyChangesFromRequest';
|
|
||||||
import { ChangesScheduledBadge } from 'component/changeRequest/ModifiedInChangeRequestStatusBadge/ChangesScheduledBadge';
|
|
||||||
import type { IFeatureChange } from 'component/changeRequest/changeRequest.types';
|
|
||||||
import { Badge } from 'component/common/Badge/Badge';
|
|
||||||
import {
|
|
||||||
type ScheduledChangeRequestViewModel,
|
|
||||||
useScheduledChangeRequestsWithStrategy,
|
|
||||||
} from 'hooks/api/getters/useScheduledChangeRequestsWithStrategy/useScheduledChangeRequestsWithStrategy';
|
|
||||||
|
|
||||||
interface IStrategyItemProps {
|
|
||||||
strategy: IFeatureStrategy;
|
|
||||||
environmentName: string;
|
|
||||||
index: number;
|
|
||||||
otherEnvironments?: IFeatureEnvironment['name'][];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export const StrategyNonDraggableItem = ({
|
|
||||||
strategy,
|
|
||||||
index,
|
|
||||||
environmentName,
|
|
||||||
otherEnvironments,
|
|
||||||
}: IStrategyItemProps) => {
|
|
||||||
const projectId = useRequiredPathParam('projectId');
|
|
||||||
const featureId = useRequiredPathParam('featureId');
|
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
|
||||||
const strategyChangesFromRequest = useStrategyChangesFromRequest(
|
|
||||||
projectId,
|
|
||||||
featureId,
|
|
||||||
environmentName,
|
|
||||||
strategy.id,
|
|
||||||
);
|
|
||||||
|
|
||||||
const { changeRequests: scheduledChangesUsingStrategy } =
|
|
||||||
useScheduledChangeRequestsWithStrategy(projectId, strategy.id);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box key={strategy.id} ref={ref} sx={{ opacity: '1' }}>
|
|
||||||
<ConditionallyRender
|
|
||||||
condition={index > 0}
|
|
||||||
show={<StrategySeparator text='OR' />}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<StrategyItem
|
|
||||||
strategy={strategy}
|
|
||||||
environmentId={environmentName}
|
|
||||||
otherEnvironments={otherEnvironments}
|
|
||||||
orderNumber={index + 1}
|
|
||||||
headerChildren={renderHeaderChildren(
|
|
||||||
strategyChangesFromRequest,
|
|
||||||
scheduledChangesUsingStrategy,
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const ChangeRequestStatusBadge = ({
|
|
||||||
change,
|
|
||||||
}: {
|
|
||||||
change: IFeatureChange | undefined;
|
|
||||||
}) => {
|
|
||||||
const theme = useTheme();
|
|
||||||
const isSmallScreen = useMediaQuery(theme.breakpoints.down('sm'));
|
|
||||||
|
|
||||||
if (isSmallScreen) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Box sx={{ mr: 1.5 }}>
|
|
||||||
<ConditionallyRender
|
|
||||||
condition={change?.action === 'updateStrategy'}
|
|
||||||
show={<Badge color='warning'>Modified in draft</Badge>}
|
|
||||||
/>
|
|
||||||
<ConditionallyRender
|
|
||||||
condition={change?.action === 'deleteStrategy'}
|
|
||||||
show={<Badge color='error'>Deleted in draft</Badge>}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderHeaderChildren = (
|
|
||||||
changes?: UseStrategyChangeFromRequestResult,
|
|
||||||
scheduledChanges?: ScheduledChangeRequestViewModel[],
|
|
||||||
): JSX.Element[] => {
|
|
||||||
const badges: JSX.Element[] = [];
|
|
||||||
if (changes?.length === 0 && scheduledChanges?.length === 0) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
const draftChange = changes?.find(
|
|
||||||
({ isScheduledChange }) => !isScheduledChange,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (draftChange) {
|
|
||||||
badges.push(
|
|
||||||
<ChangeRequestStatusBadge
|
|
||||||
key={`draft-change#${draftChange.change.id}`}
|
|
||||||
change={draftChange.change}
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scheduledChanges && scheduledChanges.length > 0) {
|
|
||||||
badges.push(
|
|
||||||
<ChangesScheduledBadge
|
|
||||||
key='scheduled-changes'
|
|
||||||
scheduledChangeRequestIds={scheduledChanges.map(
|
|
||||||
(scheduledChange) => scheduledChange.id,
|
|
||||||
)}
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return badges;
|
|
||||||
};
|
|
Loading…
Reference in New Issue
Block a user