Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FI-3643: Check input components for auth #587

Merged
merged 7 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions client/src/components/InputsModal/AuthTypeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ export interface InputAccessProps {
}

const AuthTypeSelector: FC<InputAccessProps> = ({ input, index, inputsMap, setInputsMap }) => {
const selectorSettings = input.options?.components
? input.options?.components[0]
const authComponent = input.options?.components?.find(
(component) => component.name === 'auth_type',
);

const selectorSettings = authComponent
? authComponent
: // Default auth type settings
{
name: 'auth_type',
Expand Down
6 changes: 5 additions & 1 deletion client/src/components/InputsModal/InputAccess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ const InputAccess: FC<InputAccessProps> = ({ input, index, inputsMap, setInputsM
const [accessValuesPopulated, setAccessValuesPopulated] = React.useState<boolean>(false);

// Default auth type settings
const authComponent = input.options?.components?.find(
(component) => component.name === 'auth_type',
);
const [authType, setAuthType] = React.useState<string>(
input.options?.components ? (input.options?.components[0].default as string) : 'public',
authComponent?.default ? (authComponent.default as string) : 'public',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to check what the actual list options are and choose the first value in case public has been removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch -- updated

);

const [accessFields, setAccessFields] = React.useState<TestInput[]>(
getAccessFields(authType as AuthType, accessValues, input.options?.components || []),
);
Expand Down
5 changes: 4 additions & 1 deletion client/src/components/InputsModal/InputAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ const InputAuth: FC<InputAuthProps> = ({ input, index, inputsMap, setInputsMap }
const [authValuesPopulated, setAuthValuesPopulated] = React.useState<boolean>(false);

// Default auth type settings
const authComponent = input.options?.components?.find(
(component) => component.name === 'auth_type',
);
const [authType, setAuthType] = React.useState<string>(
input.options?.components ? (input.options?.components[0].default as string) : 'public',
authComponent?.default ? (authComponent.default as string) : 'public',
);

const [authFields, setAuthFields] = React.useState<TestInput[]>(
Expand Down
Loading