Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

chore: Auth make it more playwright friendly #141

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Changes from all 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
31 changes: 17 additions & 14 deletions src/ConfigEditor/Auth/auth-method/AuthMethodSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { ReactElement, useMemo, useState } from 'react';
import { css } from '@emotion/css';
import { useTheme2, Select } from '@grafana/ui';
import { useTheme2, Select, Field } from '@grafana/ui';
import { SelectableValue } from '@grafana/data';
import { BasicAuth, Props as BasicAuthProps } from './BasicAuth';
import { ConfigSubSection } from '../../ConfigSection';
import { AuthMethod, CustomMethod, CustomMethodId , AuthMethodSelectOption } from '../types';
import { AuthMethod, CustomMethod, CustomMethodId, AuthMethodSelectOption } from '../types';

const defaultOptions: Record<AuthMethod, SelectableValue<AuthMethod>> = {
[AuthMethod.BasicAuth]: {
Expand Down Expand Up @@ -83,7 +83,7 @@ export const AuthMethodSettings = ({
preparedDefaultOptions[k] = {
...defaultOptions[k],
...defaultOptionsOverrides?.[k],
}
};
}

const allOptions: Record<AuthMethod | CustomMethodId, SelectableValue<AuthMethod | CustomMethodId>> = {
Expand Down Expand Up @@ -119,11 +119,11 @@ export const AuthMethodSettings = ({
AuthFieldsComponent = customMethods?.find((m) => m.id === selected)?.component ?? null;
}

const title = hasSelect ? 'Authentication methods' : preparedOptions[0].label ?? '';
const title = hasSelect ? 'Authentication methods' : (preparedOptions[0].label ?? '');

const description = hasSelect
? 'Choose an authentication method to access the data source'
: preparedOptions[0].description ?? '';
: (preparedOptions[0].description ?? '');

const styles = {
authMethods: css({
Expand All @@ -142,15 +142,18 @@ export const AuthMethodSettings = ({
<ConfigSubSection title={title} description={description}>
<div className={styles.authMethods}>
{hasSelect && (
<Select
options={preparedOptions}
value={selected}
onChange={(option) => {
setAuthMethodChanged(true);
onAuthMethodSelect(option.value!);
}}
disabled={readOnly}
/>
<Field label="Authentication method">
<Select
inputId="auth-method-select"
options={preparedOptions}
value={selected}
onChange={(option) => {
setAuthMethodChanged(true);
onAuthMethodSelect(option.value!);
}}
disabled={readOnly}
/>
</Field>
)}
{AuthFieldsComponent && <div className={styles.selectedMethodFields}>{AuthFieldsComponent}</div>}
</div>
Expand Down
Loading