Skip to content

Commit cea0000

Browse files
authored
✨ Add tooltip for auto-answered assessment questions (#1380)
Resolves #1367 ![Screenshot 2023-09-20 at 2 05 25 PM](https://github.com/konveyor/tackle2-ui/assets/811963/79c79259-1ecb-4c0d-8bfe-8336eb079ad2) --------- Signed-off-by: Mike Turley <[email protected]>
1 parent 734b8ac commit cea0000

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

client/public/locales/en/translation.json

+2
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@
176176
"reasonForError": "The reported reason for the error:",
177177
"reviewInstructions": "Use this section to provide your assessment of the possible migration/modernization plan and effort estimation.",
178178
"savingSelection": "Saving selection",
179+
"selectedBecauseArchetypeTags": "Selected because the archetype's tags include {{tags}}",
180+
"selectedBecauseAppOrArchetypeTags": "Selected because the application or archetype's tags include {{tags}}",
179181
"selectOwnerFromStakeholdersList": "Select owner from list of stakeholders",
180182
"suggestedAdoptionPlanHelpText": "The suggested approach to migration based on effort, priority, and dependencies.",
181183
"taskInProgressForTags": "A new analysis is in-progress. Tags may be updated upon completion.",

client/src/app/api/models.ts

+1
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ export interface Answer {
682682
mitigation?: string;
683683
applyTags?: CategorizedTag[];
684684
autoAnswerFor?: CategorizedTag[];
685+
autoAnswered?: boolean;
685686
selected?: boolean;
686687
}
687688
export interface Thresholds {

client/src/app/pages/assessment/components/questionnaire-form/multi-input-selection/multi-input-selection.tsx

+32-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import React, { useMemo } from "react";
2-
import { Radio, Stack, StackItem } from "@patternfly/react-core";
2+
import { Icon, Radio, Stack, StackItem, Tooltip } from "@patternfly/react-core";
3+
import InfoCircleIcon from "@patternfly/react-icons/dist/esm/icons/info-circle-icon";
34

45
import { Question } from "@app/api/models";
56
import { HookFormPFGroupController } from "@app/components/HookFormPFFields";
67
import { useFormContext } from "react-hook-form";
78
import { getQuestionFieldName } from "../../../form-utils";
89
import { AssessmentWizardValues } from "@app/pages/assessment/components/assessment-wizard/assessment-wizard";
10+
import useIsArchetype from "@app/hooks/useIsArchetype";
11+
import { useTranslation } from "react-i18next";
912

1013
export interface MultiInputSelectionProps {
1114
question: Question;
@@ -21,6 +24,10 @@ export const MultiInputSelection: React.FC<MultiInputSelectionProps> = ({
2124
}, [question]);
2225

2326
const questionFieldName = getQuestionFieldName(question, true);
27+
28+
const isArchetype = useIsArchetype();
29+
const { t } = useTranslation();
30+
2431
return (
2532
<Stack>
2633
{sortedOptions.map((option, i) => (
@@ -37,7 +44,30 @@ export const MultiInputSelection: React.FC<MultiInputSelectionProps> = ({
3744
onChange={(checked, e) => {
3845
onChange(option.text);
3946
}}
40-
label={option.text}
47+
aria-label={option.text}
48+
label={
49+
<>
50+
{option.autoAnswered && option.autoAnswerFor?.length ? (
51+
<Tooltip
52+
content={t(
53+
isArchetype
54+
? "message.selectedBecauseArchetypeTags"
55+
: "message.selectedBecauseAppOrArchetypeTags",
56+
{
57+
tags: option.autoAnswerFor
58+
.map((t) => `"${t.tag}"`)
59+
.join(", "),
60+
}
61+
)}
62+
>
63+
<Icon status="info">
64+
<InfoCircleIcon />
65+
</Icon>
66+
</Tooltip>
67+
) : null}{" "}
68+
{option.text}
69+
</>
70+
}
4171
value={option.text}
4272
/>
4373
)}

0 commit comments

Comments
 (0)