Skip to content

Commit

Permalink
select from assessments; set donut colors
Browse files Browse the repository at this point in the history
Signed-off-by: Gilles Dubreuil <[email protected]>
  • Loading branch information
gildub committed Sep 19, 2023
1 parent c26f557 commit 856f452
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 28 deletions.
7 changes: 2 additions & 5 deletions client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"orange": "Orange",
"purple": "Purple",
"red": "Red",
"teal": "Teal"
"teal": "Teal",
"yellow": "Yellow"
},
"composed": {
"add": "Add {{what}}",
Expand Down Expand Up @@ -238,7 +239,6 @@
"businessServices": "Business services",
"canceled": "Canceled",
"category": "Category",
"cloudNativeReady": "Cloud-native ready",
"color": "Color",
"comments": "Comments",
"completed": "Completed",
Expand Down Expand Up @@ -306,7 +306,6 @@
"member(s)": "Member(s)",
"memberCount": "Member count",
"message": "Message",
"modernizable": "Modernizable",
"migrationWave": "Migration wave",
"migrationWaves": "Migration waves",
"migrationWave(s)": "Migration wave(s)",
Expand All @@ -316,7 +315,6 @@
"notConnected": "Not connected",
"notReviewed": "Not reviewed",
"notStarted": "Not started",
"notYetAssessed": "Not yet assessed",
"notYetReviewed": "Not yet reviewed",
"other": "Other",
"owner": "Owner",
Expand Down Expand Up @@ -375,7 +373,6 @@
"unassessed": "Unassessed",
"unassigned": "Not yet assigned",
"unknown": "Unknown",
"unsuitableForContainers": "Unsuitable for containers",
"uploadApplicationFile": "Upload your application file",
"uploadYamlFile": "Upload your YAML file",
"url": "URL",
Expand Down
7 changes: 2 additions & 5 deletions client/public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"green": "Verde",
"orange": "Naranja",
"purple": "Morado",
"red": "Rojo"
"red": "Rojo",
"yellow": "Amarillo"
},
"composed": {
"add": "Agregar {{what}}",
Expand Down Expand Up @@ -194,7 +195,6 @@
"businessServices": "Servicios de negocio",
"canceled": "Cancelado",
"category": "Categoría",
"cloudNativeReady": "Listo para Cloud-native",
"color": "Color",
"comments": "Comentarios",
"completed": "Completado",
Expand Down Expand Up @@ -247,13 +247,11 @@
"member(s)": "Miembro(s)",
"memberCount": "Número de miembros",
"message": "Mensaje",
"modernizable": "Modernizable",
"name": "Nombre",
"northboundDependencies": "Dependencias del norte",
"notAvailable": "No disponible",
"notReviewed": "No revisado",
"notStarted": "No empezado",
"notYetAssessed": "No evaluado todavía",
"notYetReviewed": "No revisado todavía",
"other": "Otro",
"owner": "Propietario",
Expand Down Expand Up @@ -304,7 +302,6 @@
"trivialButMigratable": "Trivial pero migrable",
"unassessed": "No evaluado",
"unknown": "Desconocido",
"unsuitableForContainers": "No apto para contenedores",
"uploadApplicationFile": "Carga tu archivo con aplicaciones",
"user": "Usuario",
"version": "Versión",
Expand Down
3 changes: 3 additions & 0 deletions client/src/app/api/rest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ export const getApplicationSummaryCSV = (id: string): AxiosPromise => {
});
};

export const getAssessments = (): Promise<Assessment[]> =>
axios.get(ASSESSMENTS).then((response) => response.data);

Check warning on line 209 in client/src/app/api/rest.ts

View check run for this annotation

Codecov / codecov/patch

client/src/app/api/rest.ts#L209

Added line #L209 was not covered by tests

export const getAssessmentsByItemId = (
isArchetype: boolean,
itemId?: number | string
Expand Down
3 changes: 0 additions & 3 deletions client/src/app/pages/reports/components/landscape/donut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ export interface IDonutProps {
total: number;
color: string;
riskLabel: string;
riskDescription: string;
}

export const Donut: React.FC<IDonutProps> = ({
value,
total,
color,
riskLabel,
riskDescription,
}) => {
const { t } = useTranslation();

Expand All @@ -44,7 +42,6 @@ export const Donut: React.FC<IDonutProps> = ({
<StackItem>
<TextContent className="pf-v5-u-text-align-center">
<Text component="h3">{riskLabel}</Text>
<Text component="small">{riskDescription}</Text>
</TextContent>
</StackItem>
</Stack>
Expand Down
16 changes: 6 additions & 10 deletions client/src/app/pages/reports/components/landscape/landscape.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,36 +91,32 @@ export const Landscape: React.FC = () => {
<Donut
value={landscapeData.low}
total={applications.length}
color={RISK_LIST["green"].hexColor}
riskLabel={t("terms.lowRisk")}
riskDescription={t("terms.cloudNativeReady")}
color={RISK_LIST["red"].hexColor}
riskLabel={t("colors.red")}
/>
</SplitItem>
<SplitItem>
<Donut
value={landscapeData.medium}
total={applications.length}
color={RISK_LIST["yellow"].hexColor}
riskLabel={t("terms.mediumRisk")}
riskDescription={t("terms.modernizable")}
riskLabel={t("colors.yellow")}
/>
</SplitItem>
<SplitItem>
<Donut
value={landscapeData.high}
total={applications.length}
color={RISK_LIST["red"].hexColor}
riskLabel={t("terms.highRisk")}
riskDescription={t("terms.unsuitableForContainers")}
color={RISK_LIST["green"].hexColor}
riskLabel={t("colors.green")}
/>
</SplitItem>
<SplitItem>
<Donut
value={landscapeData.unassessed}
total={applications.length}
color={RISK_LIST["unknown"].hexColor}
riskLabel={t("terms.unassessed")}
riskDescription={t("terms.notYetAssessed")}
riskLabel={`${t("terms.unassessed")}/${t("terms.unknown")}`}
/>
</SplitItem>
</Split>
Expand Down
10 changes: 5 additions & 5 deletions client/src/app/pages/reports/reports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { Landscape } from "./components/landscape";
import { AdoptionPlan } from "./components/adoption-plan";
import { IdentifiedRisksTable } from "./components/identified-risks-table";
import { useFetchApplications } from "@app/queries/applications";
import { useFetchQuestionnaires } from "@app/queries/questionnaires";
import { useFetchAssessments } from "@app/queries/assessments";

export const Reports: React.FC = () => {
// i18
Expand All @@ -49,7 +49,7 @@ export const Reports: React.FC = () => {
const [selectedQuestionnaire, setSelectedQuestionnaire] =
React.useState<string>("All questionnaires");

const { questionnaires } = useFetchQuestionnaires();
const { assessments } = useFetchAssessments();

// Cards
const [isAdoptionCandidateTable, setIsAdoptionCandidateTable] =
Expand Down Expand Up @@ -137,12 +137,12 @@ export const Reports: React.FC = () => {
<SelectOption key={0} value="All questionnaires">
All questionnaires
</SelectOption>
{questionnaires.map((questionnaire, index) => (
{assessments.map((assessment, index) => (
<SelectOption
key={index}
value={questionnaire.name}
value={assessment.questionnaire.name}
>
{questionnaire.name}
{assessment.questionnaire.name}
</SelectOption>
))}
</Select>
Expand Down
13 changes: 13 additions & 0 deletions client/src/app/queries/assessments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
createAssessment,
deleteAssessment,
getAssessmentById,
getAssessments,
getAssessmentsByItemId,
updateAssessment,
} from "@app/api/rest";
Expand All @@ -15,6 +16,18 @@ export const assessmentsQueryKey = "assessments";
export const assessmentQueryKey = "assessment";
export const assessmentsByItemIdQueryKey = "assessmentsByItemId";

export const useFetchAssessments = () => {
const { isLoading, data, error } = useQuery({

Check warning on line 20 in client/src/app/queries/assessments.ts

View check run for this annotation

Codecov / codecov/patch

client/src/app/queries/assessments.ts#L20

Added line #L20 was not covered by tests
queryKey: [QuestionnairesQueryKey],
queryFn: getAssessments,
onError: (error: AxiosError) => console.log("error, ", error),

Check warning on line 23 in client/src/app/queries/assessments.ts

View check run for this annotation

Codecov / codecov/patch

client/src/app/queries/assessments.ts#L23

Added line #L23 was not covered by tests
});
return {

Check warning on line 25 in client/src/app/queries/assessments.ts

View check run for this annotation

Codecov / codecov/patch

client/src/app/queries/assessments.ts#L25

Added line #L25 was not covered by tests
assessments: data || [],
isFetching: isLoading,
fetchError: error,
};
};
export const useCreateAssessmentMutation = (
isArchetype: boolean,
onSuccess: (name: string) => void,
Expand Down

0 comments on commit 856f452

Please sign in to comment.