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 25, 2023
1 parent 15e5486 commit 59e8e1e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 45 deletions.
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 @@ -45,11 +45,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 @@ -207,28 +203,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) {
openUpdateMigrationTargetModal(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) {
openUpdateMigrationTargetModal(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
36 changes: 18 additions & 18 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
.map((ruleset) => {
const mappedRules = ruleset.rules.map((rule) => {

Check warning on line 24 in client/src/app/queries/rulesets.ts

View check run for this annotation

Codecov / codecov/patch

client/src/app/queries/rulesets.ts#L22-L24

Added lines #L22 - L24 were not covered by tests
const labels = getLabels(rule.labels || []);

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

Check warning on line 27 in client/src/app/queries/rulesets.ts

View check run for this annotation

Codecov / codecov/patch

client/src/app/queries/rulesets.ts#L27

Added line #L27 was not covered by tests
source: labels.sourceLabel,
target: labels.targetLabel,
otherLabels: labels.otherLabels,
};

return {

Check warning on line 33 in client/src/app/queries/rulesets.ts

View check run for this annotation

Codecov / codecov/patch

client/src/app/queries/rulesets.ts#L33

Added line #L33 was not covered by tests
...rule,
metadata: transformedMetadata,
};
});
return { ...ruleset, rules: mappedRules };

Check warning on line 38 in client/src/app/queries/rulesets.ts

View check run for this annotation

Codecov / codecov/patch

client/src/app/queries/rulesets.ts#L38

Added line #L38 was not covered by tests
})
.filter((ruleset) => !ruleset.name.startsWith("."));

Check warning on line 40 in client/src/app/queries/rulesets.ts

View check run for this annotation

Codecov / codecov/patch

client/src/app/queries/rulesets.ts#L40

Added line #L40 was not covered by tests
},
}
);
Expand Down

0 comments on commit 59e8e1e

Please sign in to comment.