Skip to content

Commit

Permalink
use input options for auth selection if they exist (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyssaWang authored Nov 20, 2024
1 parent af1e650 commit 050f4e8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
58 changes: 29 additions & 29 deletions client/src/components/InputsModal/AuthTypeSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
import React, { FC } from 'react';
import { TestInput } from '~/models/testSuiteModels';
import { InputOption, TestInput } from '~/models/testSuiteModels';
import InputCombobox from './InputCombobox';

export interface InputAccessProps {
requirement: TestInput;
input: TestInput;
index: number;
inputsMap: Map<string, unknown>;
setInputsMap: (map: Map<string, unknown>, edited?: boolean) => void;
}

const AuthTypeSelector: FC<InputAccessProps> = ({
requirement,
index,
inputsMap,
setInputsMap,
}) => {
const selectorSettings = requirement.options?.components
? requirement.options?.components[0]
const AuthTypeSelector: FC<InputAccessProps> = ({ input, index, inputsMap, setInputsMap }) => {
const selectorSettings = input.options?.components
? input.options?.components[0]
: // Default auth type settings
{
name: 'auth_type',
default: 'public',
};

const selectorOptions: InputOption[] =
input.options?.components?.find((component) => component.name === 'auth_type')?.options
?.list_options ||
([
{
label: 'Public',
value: 'public',
},
{
label: 'Confidential Symmetric',
value: 'symmetric',
},
{
label: 'Confidential Asymmetric',
value: 'asymmetric',
},
{
label: 'Backend Services',
value: 'backend_services',
},
] as InputOption[]);

const selectorModel: TestInput = {
name: 'auth_type',
type: 'select',
title: 'Auth Type',
description: requirement.description,
description: input.description,
default: selectorSettings.default || 'public',
optional: selectorSettings.optional,
locked: selectorSettings.locked,
options: {
list_options: [
{
label: 'Public',
value: 'public',
},
{
label: 'Confidential Symmetric',
value: 'symmetric',
},
{
label: 'Confidential Asymmetric',
value: 'asymmetric',
},
{
label: 'Backend Services',
value: 'backend_services',
},
],
list_options: selectorOptions,
},
};

Expand Down
2 changes: 1 addition & 1 deletion client/src/components/InputsModal/InputAccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const InputAccess: FC<InputAccessProps> = ({ requirement, index, inputsMap, setI
)}
<List>
<AuthTypeSelector
requirement={requirement}
input={requirement}
index={index}
inputsMap={accessValues}
setInputsMap={updateAuthType}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/InputsModal/InputAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const InputAuth: FC<InputAuthProps> = ({ requirement, index, inputsMap, setInput
)}
<List>
<AuthTypeSelector
requirement={requirement}
input={requirement}
index={index}
inputsMap={authValues}
setInputsMap={updateAuthType}
Expand Down

0 comments on commit 050f4e8

Please sign in to comment.