-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add assessed archetypes section in drawer (#1610)
Resolves: https://issues.redhat.com/browse/MTA-1834 [MTA-1878](https://issues.redhat.com/browse/MTA-1878) [Inconsistent hover text message for Assessment and Review columns](https://issues.redhat.com/browse/MTA-1835) <img width="1599" alt="Screenshot 2023-12-13 at 12 15 39 PM" src="https://github.com/konveyor/tackle2-ui/assets/11218376/d98747f3-685c-4117-aa74-47ffb4fb9e5e"> <img width="1624" alt="Screenshot 2023-12-13 at 12 15 32 PM" src="https://github.com/konveyor/tackle2-ui/assets/11218376/4ffb62f7-26dd-48fb-b771-6a446790ad9a"> --------- Signed-off-by: ibolton336 <[email protected]>
- Loading branch information
1 parent
3b5b3be
commit 1a2f183
Showing
7 changed files
with
192 additions
and
108 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
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
55 changes: 35 additions & 20 deletions
55
...s/applications/components/application-assessment-status/application-assessment-status.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 |
---|---|---|
@@ -1,50 +1,65 @@ | ||
import React from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { Spinner } from "@patternfly/react-core"; | ||
|
||
import { EmptyTextMessage } from "@app/components/EmptyTextMessage"; | ||
import { Application } from "@app/api/models"; | ||
import { IconedStatus } from "@app/components/IconedStatus"; | ||
import { IconedStatus, IconedStatusPreset } from "@app/components/IconedStatus"; | ||
import { useFetchAssessmentsByItemId } from "@app/queries/assessments"; | ||
import { useFetchQuestionnaires } from "@app/queries/questionnaires"; | ||
|
||
export interface ApplicationAssessmentStatusProps { | ||
import { useFetchArchetypes } from "@app/queries/archetypes"; | ||
interface ApplicationAssessmentStatusProps { | ||
application: Application; | ||
isLoading?: boolean; | ||
} | ||
|
||
export const ApplicationAssessmentStatus: React.FC< | ||
ApplicationAssessmentStatusProps | ||
> = ({ application, isLoading = false }) => { | ||
> = ({ application }) => { | ||
const { t } = useTranslation(); | ||
|
||
const { archetypes, isFetching } = useFetchArchetypes(); | ||
|
||
const applicationArchetypes = application.archetypes?.map((archetypeRef) => { | ||
return archetypes?.find((archetype) => archetype.id === archetypeRef.id); | ||
}); | ||
|
||
const hasAssessedArchetype = applicationArchetypes?.some( | ||
(archetype) => !!archetype?.assessments?.length ?? 0 > 0 | ||
); | ||
|
||
const { | ||
assessments, | ||
isFetching: isFetchingAssessmentsById, | ||
fetchError, | ||
} = useFetchAssessmentsByItemId(false, application.id); | ||
const { questionnaires } = useFetchQuestionnaires(); | ||
const requiredQuestionnaireExists = questionnaires?.some( | ||
(q) => q.required === true | ||
); | ||
//NOTE: Application.assessed is true if an app is assigned to an archetype and no required questionnaires exist | ||
if (application?.assessed && requiredQuestionnaireExists) { | ||
return <IconedStatus preset="Completed" />; | ||
} | ||
|
||
if (fetchError) { | ||
return <EmptyTextMessage message={t("terms.notAvailable")} />; | ||
} | ||
|
||
if (isLoading || isFetchingAssessmentsById) { | ||
if (isFetching || isFetchingAssessmentsById) { | ||
return <Spinner size="md" />; | ||
} | ||
|
||
if ( | ||
assessments?.some((a) => a.status === "started" || a.status === "complete") | ||
let statusPreset: IconedStatusPreset = "NotStarted"; // Default status | ||
let tooltipCount: number = 0; | ||
const isDirectlyAssessed = | ||
application.assessed && (application.assessments?.length ?? 0) > 0; | ||
if (isDirectlyAssessed) { | ||
statusPreset = "Completed"; | ||
} else if (hasAssessedArchetype) { | ||
statusPreset = "InheritedAssessments"; | ||
const assessedArchetypeCount = | ||
applicationArchetypes?.filter( | ||
(archetype) => archetype?.assessments?.length ?? 0 > 0 | ||
).length || 0; | ||
tooltipCount = assessedArchetypeCount; | ||
} else if ( | ||
assessments?.some( | ||
(assessment) => | ||
assessment.status === "started" || assessment.status === "complete" | ||
) | ||
) { | ||
return <IconedStatus preset="InProgress" />; | ||
statusPreset = "InProgress"; | ||
} | ||
|
||
return <IconedStatus preset="NotStarted" />; | ||
return <IconedStatus preset={statusPreset} tooltipCount={tooltipCount} />; | ||
}; |
Oops, something went wrong.