Skip to content

Commit 6717879

Browse files
committed
Frontend: Fix secrets missing ARIA label & update logic
1 parent b3b39c5 commit 6717879

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

frontend/src/components/common/Resource/Resource.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,12 @@ export function DataField(props: DataFieldProps) {
499499
);
500500
}
501501

502-
export function SecretField(props: InputProps) {
503-
const { value, ...other } = props;
502+
export interface SecretFieldProps extends InputProps {
503+
nameID?: string;
504+
}
505+
506+
export function SecretField(props: SecretFieldProps) {
507+
const { value, nameID, ...other } = props;
504508
const [showPassword, setShowPassword] = React.useState(false);
505509
const [copied, setCopied] = React.useState(false);
506510
const { t } = useTranslation();
@@ -555,6 +559,7 @@ export function SecretField(props: InputProps) {
555559
</Grid>
556560
<Grid item xs>
557561
<Input
562+
aria-labelledby={nameID}
558563
readOnly={!showPassword}
559564
type="password"
560565
fullWidth

frontend/src/components/secret/Details.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,18 @@ export default function SecretDetails(props: {
100100
lastDataRef.current = _.cloneDeep(data);
101101
};
102102

103-
const mainRows: NameValueTableRow[] = Object.entries(data).map((item: unknown[]) => ({
104-
name: item[0] as string,
103+
const mainRows: NameValueTableRow[] = (
104+
Object.entries(data) as [string, unknown][]
105+
).map(([key, val]) => ({
106+
name: key,
107+
nameID: key,
105108
value: (
106109
<SecretField
107-
value={item[1]}
108-
onChange={e => handleFieldChange(item[0] as string, e.target.value)}
110+
value={val}
111+
nameID={key}
112+
onChange={(e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) =>
113+
handleFieldChange(key, e.target.value)
114+
}
109115
/>
110116
),
111117
}));

frontend/src/components/secret/__snapshots__/Details.WithBase.stories.storyshot

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@
234234
>
235235
<dt
236236
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
237+
id="storageClassName"
237238
>
238239
storageClassName
239240
</dt>
@@ -272,6 +273,7 @@
272273
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-true css-1z0dvx8-MuiGrid-root"
273274
>
274275
<div
276+
aria-labelledby="storageClassName"
275277
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-colorPrimary MuiInputBase-fullWidth Mui-readOnly MuiInputBase-readOnly css-zam05p-MuiInputBase-root-MuiInput-root"
276278
>
277279
<input
@@ -286,6 +288,7 @@
286288
</dd>
287289
<dt
288290
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
291+
id="volumeMode"
289292
>
290293
volumeMode
291294
</dt>
@@ -324,6 +327,7 @@
324327
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-true css-1z0dvx8-MuiGrid-root"
325328
>
326329
<div
330+
aria-labelledby="volumeMode"
327331
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-colorPrimary MuiInputBase-fullWidth Mui-readOnly MuiInputBase-readOnly css-zam05p-MuiInputBase-root-MuiInput-root"
328332
>
329333
<input
@@ -338,6 +342,7 @@
338342
</dd>
339343
<dt
340344
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-iqixpy-MuiGrid-root"
345+
id="volumeName"
341346
>
342347
volumeName
343348
</dt>
@@ -376,6 +381,7 @@
376381
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-true css-1z0dvx8-MuiGrid-root"
377382
>
378383
<div
384+
aria-labelledby="volumeName"
379385
class="MuiInputBase-root MuiInput-root MuiInput-underline MuiInputBase-colorPrimary MuiInputBase-fullWidth Mui-readOnly MuiInputBase-readOnly css-zam05p-MuiInputBase-root-MuiInput-root"
380386
>
381387
<input

0 commit comments

Comments
 (0)