Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import './PlanMappingsActionsBar.scss';
type PlanMappingsActionsBarProps = {
isLoading: boolean;
dataChanged: boolean;
reset: () => void;
reset: (preserveUpdated?: boolean) => void;
onUpdate: () => void;
};

Expand Down Expand Up @@ -43,7 +43,9 @@ const PlanMappingsActionsBar: FC<PlanMappingsActionsBarProps> = ({
<FlexItem>
<Button
variant={ButtonVariant.secondary}
onClick={reset}
onClick={() => {
reset();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avivtur Can you please just fix the prototype for reset param since I'm pretty sure that it will be fixed again as part of eslint fixes...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}}
data-testid="cancel-mappings-button"
>
{t('Cancel')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export const getLabeledAndAvailableMappings = ({
updatedNetwork,
updatedStorage,
}: GetMappingsParams) => {
const labeledTargetNetworkMap = mapTargetNetworksIdsToLabels(targetNetworks, plan);
const labeledNetworkMappings: Mapping[] = updatedNetwork.map((obj) => ({
destination:
mapTargetNetworksIdsToLabels(targetNetworks, plan)[obj.destination.type] ??
obj.destination?.name ??
t('Not available'),
labeledTargetNetworkMap[obj.destination?.type] ??
`${obj.destination?.namespace}/${obj.destination?.name}`,
source: mapSourceNetworksIdsToLabels(sourceNetworks)[obj.source.id ?? obj.source.type!],
}));

Expand All @@ -64,9 +64,9 @@ export const getLabeledAndAvailableMappings = ({
),
).sort((netA, netB) => universalComparator(netA, netB, 'en'));

const availableNetworkTargets = Object.values(
mapTargetNetworksIdsToLabels(targetNetworks, plan),
).sort((netA, netB) => universalComparator(netA, netB, 'en'));
const availableNetworkTargets = Object.values(labeledTargetNetworkMap).sort((netA, netB) =>
universalComparator(netA, netB, 'en'),
);

const availableStorageSources = Object.values(
mapSourceStoragesIdsToLabels(
Expand Down
4 changes: 2 additions & 2 deletions src/plans/details/tabs/Mappings/utils/planMappingsHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const createOnAddNetworkMapping = (
newState.push(createReplacedNetworkMap(unused));
}

return { canAddMore: Boolean(unused), newState };
return { canAddMore: newState.length < sources.length, newState };
};

export const createOnAddStorageMapping = (
Expand All @@ -72,7 +72,7 @@ export const createOnAddStorageMapping = (
newState.push(createReplacedStorageMap(unused, target));
}

return { canAddMore: Boolean(unused), newState };
return { canAddMore: newState.length < sources.length, newState };
};

export const createOnDeleteMapping = <
Expand Down
Loading