Skip to content

Commit

Permalink
🐛 Hide hidden rulesets from seeded hub list
Browse files Browse the repository at this point in the history
Signed-off-by: ibolton336 <ibolton@redhat.com>
  • Loading branch information
ibolton336 committed Jul 28, 2023
1 parent 55cff2f commit c130a05
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ export const SetTargets: React.FC = () => {
const matchingRuleset = rulesets.find(
(target) => target.id === id
);
return (
<GalleryItem key={index}>
{matchingRuleset && (
if (matchingRuleset) {
return (
<GalleryItem key={index}>
<TargetCard
readOnly
item={matchingRuleset}
Expand All @@ -190,9 +190,11 @@ export const SetTargets: React.FC = () => {
}}
formTargets={formTargets}
/>
)}
</GalleryItem>
);
</GalleryItem>
);
} else {
return null;
}
})
: null}
</Gallery>
Expand Down
56 changes: 29 additions & 27 deletions client/src/app/pages/migration-targets/migration-targets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ export const MigrationTargets: React.FC = () => {
const { t } = useTranslation();
const { pushNotification } = React.useContext(NotificationsContext);

const {
rulesets,
isFetching: isFetchingrulesets,
refetch: refetchrulesets,
} = useFetchRulesets();
const { rulesets, refetch: refetchrulesets } = useFetchRulesets();

const rulesetOrderSetting = useSetting("ui.ruleset.order");
const rulesetOrderSettingMutation = useSettingMutation("ui.ruleset.order");
Expand Down Expand Up @@ -221,28 +217,34 @@ export const MigrationTargets: React.FC = () => {
>
<DndGrid>
{rulesetOrderSetting.isSuccess &&
rulesetOrderSetting.data.map((id) => (
<SortableItem
key={id}
id={id}
onEdit={() => {
const matchingRuleset = rulesets.find(
(Ruleset) => Ruleset.id === id
);
if (matchingRuleset) {
setCreateUpdateModalState(matchingRuleset);
}
}}
onDelete={() => {
const matchingRuleset = rulesets.find(
(Ruleset) => Ruleset.id === id
);
if (matchingRuleset?.id) {
deleteRuleset(matchingRuleset.id);
}
}}
/>
))}
rulesetOrderSetting.data.map((id) => {
const matchingRuleset = rulesets.find(
(Ruleset) => Ruleset.id === id
);
if (matchingRuleset) {
return (
<SortableItem
key={id}
id={id}
onEdit={() => {
if (matchingRuleset) {
setCreateUpdateModalState(matchingRuleset);
}
}}
onDelete={() => {
const matchingRuleset = rulesets.find(
(Ruleset) => Ruleset.id === id
);
if (matchingRuleset?.id) {
deleteRuleset(matchingRuleset.id);
}
}}
/>
);
} else {
return null;
}
})}
<div ref={targetsEndRef} />
</DndGrid>
<DragOverlay>{activeId ? <Item id={activeId} /> : null}</DragOverlay>
Expand Down
34 changes: 17 additions & 17 deletions client/src/app/queries/rulesets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ export const useFetchRulesets = () => {
{
onError: (err) => console.log(err),
select: (data) => {
return data.map((ruleset) => {
const mappedRules = ruleset.rules.map((rule) => {
if (ruleset?.name === "rule-example.yaml") {
debugger;
}
const labels = getLabels(rule.labels || []);
return data
.filter((ruleset) => !ruleset.name.startsWith("."))
.map((ruleset) => {
const mappedRules = ruleset.rules.map((rule) => {
const labels = getLabels(rule.labels || []);

const transformedMetadata: Metadata = {
source: labels.sourceLabel,
target: labels.targetLabel,
otherLabels: labels.otherLabels,
};
return {
...rule,
metadata: transformedMetadata,
};
const transformedMetadata: Metadata = {
source: labels.sourceLabel,
target: labels.targetLabel,
otherLabels: labels.otherLabels,
};

return {
...rule,
metadata: transformedMetadata,
};
});
return { ...ruleset, rules: mappedRules };
});
return { ...ruleset, rules: mappedRules };
});
},
}
);
Expand Down

0 comments on commit c130a05

Please sign in to comment.