forked from konveyor/tackle2-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Exclude non-required questionnaires in assessed calculation (konvey…
…or#1666) Resolves https://issues.redhat.com/browse/MTA-1967 Addresses an issue where the assessed boolean for archetypes is set to true when all questionnaires are marked as not-required. Uses the new assessment.required boolean surfaced in konveyor/tackle2-hub@2552233 to filter out these false positives. --------- Signed-off-by: ibolton336 <[email protected]>
- Loading branch information
1 parent
8f83736
commit 3cf032f
Showing
5 changed files
with
112 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...ages/applications/components/application-detail-drawer/components/assessed-archetypes.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from "react"; | ||
import { Application } from "@app/api/models"; | ||
import { Label, LabelGroup, Spinner } from "@patternfly/react-core"; | ||
import { EmptyTextMessage } from "@app/components/EmptyTextMessage"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useFetchArchetypes } from "@app/queries/archetypes"; | ||
import { useFetchAllAssessmentsWithArchetypes } from "@app/queries/assessments"; | ||
|
||
interface IAssessedArchetypesProps { | ||
application: Application | null; | ||
} | ||
|
||
export const AssessedArchetypes: React.FC<IAssessedArchetypesProps> = ({ | ||
application, | ||
}) => { | ||
const { t } = useTranslation(); | ||
const { | ||
archetypes: applicationArchetypes, | ||
isFetching: isFetchingArchetypes, | ||
} = useFetchArchetypes(application); | ||
|
||
const { | ||
assessmentsWithArchetypes, | ||
isLoading: isFetchingAllAssessmentsWithArchetypesLoading, | ||
} = useFetchAllAssessmentsWithArchetypes(applicationArchetypes); | ||
|
||
const assessedArchetypesWithARequiredAssessment = assessmentsWithArchetypes | ||
?.filter((assessmentsWithArchetype) => { | ||
return ( | ||
assessmentsWithArchetype.archetype.assessed && | ||
assessmentsWithArchetype.assessments.some( | ||
(assessment) => assessment?.required === true | ||
) | ||
); | ||
}) | ||
.map((assessmentsWithArchetype) => assessmentsWithArchetype.archetype); | ||
|
||
if (isFetchingArchetypes || isFetchingAllAssessmentsWithArchetypesLoading) { | ||
return <Spinner size="md" />; | ||
} | ||
return ( | ||
<LabelGroup> | ||
{assessedArchetypesWithARequiredAssessment?.length ? ( | ||
assessedArchetypesWithARequiredAssessment?.map((archetype) => ( | ||
<Label key={archetype?.id}>{archetype?.name}</Label> | ||
)) | ||
) : ( | ||
<EmptyTextMessage message={t("terms.none")} /> | ||
)} | ||
</LabelGroup> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters