From 9887eadd03e6322e3e141387e1ac2cbee1ffcbf6 Mon Sep 17 00:00:00 2001 From: Ian Bolton Date: Fri, 28 Jul 2023 21:05:48 +0000 Subject: [PATCH] :bug: Hide hidden rulesets from seeded hub list (#1205) Resolves https://github.com/konveyor/tackle2-ui/issues/1093 Signed-off-by: ibolton336 --- .../analysis-wizard/set-targets.tsx | 14 +++-- .../migration-targets/migration-targets.tsx | 56 ++++++++++--------- client/src/app/queries/rulesets.ts | 34 +++++------ 3 files changed, 54 insertions(+), 50 deletions(-) diff --git a/client/src/app/pages/applications/analysis-wizard/set-targets.tsx b/client/src/app/pages/applications/analysis-wizard/set-targets.tsx index abeaa4536..5e49de677 100644 --- a/client/src/app/pages/applications/analysis-wizard/set-targets.tsx +++ b/client/src/app/pages/applications/analysis-wizard/set-targets.tsx @@ -161,9 +161,9 @@ export const SetTargets: React.FC = () => { const matchingRuleset = rulesets.find( (target) => target.id === id ); - return ( - - {matchingRuleset && ( + if (matchingRuleset) { + return ( + { }} formTargets={formTargets} /> - )} - - ); + + ); + } else { + return null; + } }) : null} diff --git a/client/src/app/pages/migration-targets/migration-targets.tsx b/client/src/app/pages/migration-targets/migration-targets.tsx index 98b48adc7..5560d4431 100644 --- a/client/src/app/pages/migration-targets/migration-targets.tsx +++ b/client/src/app/pages/migration-targets/migration-targets.tsx @@ -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"); @@ -221,28 +217,34 @@ export const MigrationTargets: React.FC = () => { > {rulesetOrderSetting.isSuccess && - rulesetOrderSetting.data.map((id) => ( - { - 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 ( + { + if (matchingRuleset) { + setCreateUpdateModalState(matchingRuleset); + } + }} + onDelete={() => { + const matchingRuleset = rulesets.find( + (Ruleset) => Ruleset.id === id + ); + if (matchingRuleset?.id) { + deleteRuleset(matchingRuleset.id); + } + }} + /> + ); + } else { + return null; + } + })}
{activeId ? : null} diff --git a/client/src/app/queries/rulesets.ts b/client/src/app/queries/rulesets.ts index c0c25dd8d..3ac031064 100644 --- a/client/src/app/queries/rulesets.ts +++ b/client/src/app/queries/rulesets.ts @@ -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 }; - }); }, } );