Skip to content

Commit

Permalink
Allow interactive preview of k8s resource name
Browse files Browse the repository at this point in the history
  • Loading branch information
emilys314 committed Sep 25, 2024
1 parent 7b47f42 commit da72b1d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const ConnectionTypeForm: React.FC<Props> = ({
},
}
}
onDataChange={setConnectionNameDesc ?? (() => undefined)} // onDataChange needs to be truthy to show resource name
onDataChange={setConnectionNameDesc}
/>
<ConnectionTypeFormFields
fields={connectionType?.data?.fields}
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/concepts/connectionTypes/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,14 @@ export const parseConnectionSecretValues = (
matchingField.properties.variant === 'multi'
) {
try {
response[key] = JSON.parse(decodedString);
const parsed = JSON.parse(decodedString);
if (Array.isArray(parsed)) {
response[key] = parsed.map((v) => String(v));
} else {
response[key] = [decodedString];

Check warning on line 192 in frontend/src/concepts/connectionTypes/utils.ts

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/connectionTypes/utils.ts#L191-L192

Added lines #L191 - L192 were not covered by tests
}
} catch {
response[key] = decodedString;
response[key] = [decodedString];

Check warning on line 195 in frontend/src/concepts/connectionTypes/utils.ts

View check run for this annotation

Codecov / codecov/patch

frontend/src/concepts/connectionTypes/utils.ts#L195

Added line #L195 was not covered by tests
}
} else {
response[key] = decodedString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const K8sNameDescriptionField: React.FC<K8sNameDescriptionFieldProps> = ({
value={name}
onChange={(event, value) => onDataChange?.('name', value)}
/>
{!showK8sField && !!onDataChange && !k8sName.state.immutable && (
{!showK8sField && !k8sName.state.immutable && (
<FormHelperText>
{k8sName.value && (
<HelperText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const ResourceNameField: React.FC<ResourceNameFieldProps> = ({
return <FormGroup {...formGroupProps}>{k8sName.value}</FormGroup>;
}

if (!allowEdit || !onDataChange) {
if (!allowEdit) {
return null;
}

Expand All @@ -52,7 +52,7 @@ const ResourceNameField: React.FC<ResourceNameFieldProps> = ({
name={`${dataTestId}-resourceName`}
isRequired
value={k8sName.value}
onChange={(event, value) => onDataChange('k8sName', value)}
onChange={(event, value) => onDataChange?.('k8sName', value)}
validated={validated}
/>
<HelperText>
Expand Down

0 comments on commit da72b1d

Please sign in to comment.