-
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.
- Loading branch information
1 parent
2004213
commit 4141e60
Showing
4 changed files
with
88 additions
and
12 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
49 changes: 49 additions & 0 deletions
49
...app/pages/applications/components/application-review-status/application-review-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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from "react"; | ||
import { Application, Archetype } from "@app/api/models"; | ||
import { IconedStatus, IconedStatusPreset } from "@app/components/IconedStatus"; | ||
import { Spinner } from "@patternfly/react-core"; | ||
import { EmptyTextMessage } from "@app/components/EmptyTextMessage"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
export interface ApplicationReviewStatusProps { | ||
application: Application; | ||
archetypes?: Archetype[]; | ||
isLoading?: boolean; | ||
} | ||
|
||
export const ApplicationReviewStatus: React.FC< | ||
ApplicationReviewStatusProps | ||
> = ({ application, archetypes, isLoading = false }) => { | ||
const { t } = useTranslation(); | ||
const isAppReviewed = !!application.review; | ||
|
||
const applicationArchetypes = application.archetypes?.map((archetypeRef) => { | ||
return archetypes?.find((archetype) => archetype.id === archetypeRef.id); | ||
}); | ||
|
||
const reviewedArchetypeCount = | ||
applicationArchetypes?.filter((archetype) => !!archetype?.review).length || | ||
0; | ||
|
||
let statusPreset: IconedStatusPreset; | ||
let tooltipCount = 0; | ||
|
||
if (isAppReviewed) { | ||
statusPreset = "Completed"; | ||
} else if (reviewedArchetypeCount > 0) { | ||
statusPreset = "Inherited"; | ||
tooltipCount = reviewedArchetypeCount; | ||
} else { | ||
statusPreset = "NotStarted"; | ||
} | ||
|
||
if (isLoading) { | ||
return <Spinner size="md" />; | ||
} | ||
|
||
if (!applicationArchetypes || applicationArchetypes.length === 0) { | ||
return <EmptyTextMessage message={t("terms.notAvailable")} />; | ||
} | ||
|
||
return <IconedStatus preset={statusPreset} tooltipCount={tooltipCount} />; | ||
}; |