Skip to content

Commit 7d3df82

Browse files
authored
[UII] Use password field for multi text secrets (elastic#266823)
1 parent 25dcb4f commit 7d3df82

2 files changed

Lines changed: 22 additions & 12 deletions

File tree

x-pack/platform/plugins/shared/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/steps/components/multi_text_input.tsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
EuiFlexItem,
1313
EuiButtonEmpty,
1414
EuiFieldText,
15+
EuiFieldPassword,
1516
EuiButtonIcon,
1617
EuiSpacer,
1718
} from '@elastic/eui';
@@ -26,6 +27,7 @@ interface Props {
2627
errors?: Array<{ message: string; index?: number }>;
2728
isInvalid?: boolean;
2829
isDisabled?: boolean;
30+
isSecret?: boolean;
2931
'data-test-subj'?: string;
3032
}
3133

@@ -38,6 +40,7 @@ interface RowProps {
3840
onBlur?: () => void;
3941
autoFocus?: boolean;
4042
isDisabled?: boolean;
43+
isSecret?: boolean;
4144
isMultiRow?: boolean;
4245
}
4346

@@ -50,6 +53,7 @@ const Row: FunctionComponent<RowProps> = ({
5053
onBlur,
5154
autoFocus,
5255
isDisabled,
56+
isSecret,
5357
isMultiRow,
5458
}) => {
5559
const onDeleteHandler = useCallback(() => {
@@ -63,28 +67,31 @@ const Row: FunctionComponent<RowProps> = ({
6367
[onChange, index]
6468
);
6569

70+
const ariaLabel = isMultiRow
71+
? i18n.translate('xpack.fleet.multiTextInput.ariaLabel', {
72+
defaultMessage: '"{fieldLabel}" input {index}',
73+
values: {
74+
fieldLabel,
75+
index: index + 1,
76+
},
77+
})
78+
: fieldLabel;
79+
80+
const InputComponent = isSecret ? EuiFieldPassword : EuiFieldText;
81+
6682
return (
6783
<EuiFlexGroup alignItems="center" gutterSize="none" responsive={false}>
6884
<EuiFlexItem>
69-
<EuiFieldText
85+
<InputComponent
7086
fullWidth
7187
value={value}
7288
onChange={onChangeHandler}
7389
autoFocus={autoFocus}
7490
disabled={isDisabled}
7591
onBlur={onBlur}
76-
aria-label={
77-
isMultiRow
78-
? i18n.translate('xpack.fleet.multiTextInput.ariaLabel', {
79-
defaultMessage: '"{fieldLabel}" input {index}',
80-
values: {
81-
fieldLabel,
82-
index: index + 1,
83-
},
84-
})
85-
: fieldLabel
86-
}
92+
aria-label={ariaLabel}
8793
data-test-subj={`multiTextInputRow-${index}`}
94+
{...(isSecret ? { type: 'dual' as const } : {})}
8895
/>
8996
</EuiFlexItem>
9097
{isMultiRow && (
@@ -119,6 +126,7 @@ export const MultiTextInput: FunctionComponent<Props> = ({
119126
onBlur,
120127
isInvalid,
121128
isDisabled,
129+
isSecret,
122130
errors,
123131
'data-test-subj': dataTestSubj,
124132
}) => {
@@ -173,6 +181,7 @@ export const MultiTextInput: FunctionComponent<Props> = ({
173181
value={row}
174182
autoFocus={autoFocus}
175183
isDisabled={isDisabled}
184+
isSecret={isSecret}
176185
isMultiRow={rows.length > 1}
177186
/>
178187
</EuiFlexItem>

x-pack/platform/plugins/shared/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/steps/components/package_policy_input_var_field.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ function getInputComponent({
233233
onChange={onChange}
234234
onBlur={() => setIsDirty(true)}
235235
isDisabled={frozen}
236+
isSecret={varDef.secret}
236237
data-test-subj={`multiTextInput-${fieldTestSelector}`}
237238
/>
238239
);

0 commit comments

Comments
 (0)