1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-09 00:18:26 +01:00

refactor(1-3429): makes the drag args optional, defaulting to noops (#9394)

Removes the `() => {} as any` args from the StrategyDraggableItem
invocation when you have paginated strats. Instead makes all the drag
params optional. It defaults to a no op if not provided.

Also, the reason it had to be typed as `any` before is probably because
it was missing a function. The correct empty param is `() => () => {}` 💁
This commit is contained in:
Thomas Heartman 2025-02-28 09:45:01 +01:00 committed by GitHub
parent 88c3f50073
commit 0a0d6e9e2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 12 deletions

View File

@ -298,12 +298,6 @@ export const EnvironmentAccordionBody = ({
otherEnvironments={
otherEnvironments
}
isDragging={false}
onDragStartRef={
(() => {}) as any
}
onDragOver={(() => {}) as any}
onDragEnd={(() => {}) as any}
/>
</StyledListItem>
))}

View File

@ -23,26 +23,28 @@ interface IStrategyDraggableItemProps {
index: number;
otherEnvironments?: IFeatureEnvironment['name'][];
isDragging?: boolean;
onDragStartRef: (
onDragStartRef?: (
ref: RefObject<HTMLDivElement>,
index: number,
) => DragEventHandler<HTMLButtonElement>;
onDragOver: (
onDragOver?: (
ref: RefObject<HTMLDivElement>,
index: number,
) => DragEventHandler<HTMLDivElement>;
onDragEnd: () => void;
onDragEnd?: () => void;
}
const onDragNoOp = () => () => {};
export const StrategyDraggableItem = ({
strategy,
index,
environmentName,
otherEnvironments,
isDragging,
onDragStartRef,
onDragOver,
onDragEnd,
onDragStartRef = onDragNoOp,
onDragOver = onDragNoOp,
onDragEnd = onDragNoOp,
}: IStrategyDraggableItemProps) => {
const projectId = useRequiredPathParam('projectId');
const featureId = useRequiredPathParam('featureId');