1
1
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" ;
3
4
4
5
import { Question } from "@app/api/models" ;
5
6
import { HookFormPFGroupController } from "@app/components/HookFormPFFields" ;
6
7
import { useFormContext } from "react-hook-form" ;
7
8
import { getQuestionFieldName } from "../../../form-utils" ;
8
9
import { AssessmentWizardValues } from "@app/pages/assessment/components/assessment-wizard/assessment-wizard" ;
10
+ import useIsArchetype from "@app/hooks/useIsArchetype" ;
11
+ import { useTranslation } from "react-i18next" ;
9
12
10
13
export interface MultiInputSelectionProps {
11
14
question : Question ;
@@ -21,6 +24,10 @@ export const MultiInputSelection: React.FC<MultiInputSelectionProps> = ({
21
24
} , [ question ] ) ;
22
25
23
26
const questionFieldName = getQuestionFieldName ( question , true ) ;
27
+
28
+ const isArchetype = useIsArchetype ( ) ;
29
+ const { t } = useTranslation ( ) ;
30
+
24
31
return (
25
32
< Stack >
26
33
{ sortedOptions . map ( ( option , i ) => (
@@ -37,7 +44,30 @@ export const MultiInputSelection: React.FC<MultiInputSelectionProps> = ({
37
44
onChange = { ( checked , e ) => {
38
45
onChange ( option . text ) ;
39
46
} }
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
+ }
41
71
value = { option . text }
42
72
/>
43
73
) }
0 commit comments