Skip to content

Commit

Permalink
🐛 Remove duplicate targets in advanced options screen
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Bolton <[email protected]>
  • Loading branch information
ibolton336 committed Jun 10, 2024
1 parent a316de3 commit 1ecef94
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions client/src/app/pages/applications/analysis-wizard/set-options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,29 @@ export const SetOptions: React.FC = () => {
// Remove duplicates from array of objects based on label value (label.label)
.filter((v, i, a) => a.findIndex((v2) => v2.label === v.label) === i);

const allTargetLabelsFromTargets = allLabelsFromTargets.filter((label) => {
const parsedLabel = getParsedLabel(label?.label);
if (parsedLabel.labelType === "target") {
return parsedLabel.labelValue;
}
});
const allTargetLabelsFromTargets = allLabelsFromTargets.filter(
(label) => getParsedLabel(label?.label).labelType === "target"
);

const allSourceLabelsFromTargets = allLabelsFromTargets.filter((label) => {
const parsedLabel = getParsedLabel(label?.label);
if (parsedLabel.labelType === "source") {
return parsedLabel.labelValue;
}
});
const allSourceLabelsFromTargets = allLabelsFromTargets.filter(
(label) => getParsedLabel(label?.label).labelType === "source"
);

const defaultTargetsAndTargetsLabels = [
...defaultTargets,
...allTargetLabelsFromTargets,
].sort((t1, t2) => universalComparator(t1.label, t2.label));
const defaultTargetsAndTargetsLabels = Array.from(
new Map(
defaultTargets
.concat(allTargetLabelsFromTargets)
.map((item) => [item.label, item])
).values()
).sort((t1, t2) => universalComparator(t1.label, t2.label));

const defaultSourcesAndSourcesLabels = [
...new Set(defaultSources.concat(allSourceLabelsFromTargets)),
];
const defaultSourcesAndSourcesLabels = Array.from(
new Map(
defaultSources
.concat(allSourceLabelsFromTargets)
.map((item) => [item.label, item])
).values()
).sort((t1, t2) => universalComparator(t1.label, t2.label));

return (
<Form
Expand Down

0 comments on commit 1ecef94

Please sign in to comment.