Skip to content

Commit

Permalink
[AuthType Config] provide default auth types when types array is empty
Browse files Browse the repository at this point in the history
Signed-off-by: Xinrui Bai <xinruiba@amazon.com>
  • Loading branch information
xinruiba committed Feb 20, 2024
1 parent 333987f commit 5327710
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,13 @@ export class CreateDataSourceForm extends React.Component<
static contextType = contextType;
public readonly context!: DataSourceManagementContextValue;

enabledAuthTypes: string[];

constructor(props: CreateDataSourceProps, context: DataSourceManagementContextValue) {
super(props, context);

this.enabledAuthTypes = context.services.enabledAuthTypes;

this.state = {
formErrorsByField: { ...defaultValidation },
title: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ManagementAppMountParams } from '../../../management/public';
import { OpenSearchDashboardsContextProvider } from '../../../opensearch_dashboards_react/public';
import { CreateDataSourceWizardWithRouter } from '../components/create_data_source_wizard';
import { DataSourceTableWithRouter } from '../components/data_source_table';
import { DataSourceManagementContext } from '../types';
import { AuthType, DataSourceManagementContext } from '../types';
import { EditDataSourceWithRouter } from '../components/edit_data_source';

export interface DataSourceManagementStartDependencies {
Expand All @@ -32,6 +32,8 @@ export async function mountManagementSection(
{ chrome, application, savedObjects, uiSettings, notifications, overlays, http, docLinks },
] = await getStartServices();

const allSupportedAuthTypes = Object.keys(AuthType);

const deps: DataSourceManagementContext = {
chrome,
application,
Expand All @@ -42,7 +44,10 @@ export async function mountManagementSection(
http,
docLinks,
setBreadcrumbs: params.setBreadcrumbs,
enabledAuthTypes: dataSource.enabledAuthTypes,
enabledAuthTypes:
dataSource.enabledAuthTypes.length === 0
? allSupportedAuthTypes
: dataSource.enabledAuthTypes,
};

ReactDOM.render(
Expand Down

0 comments on commit 5327710

Please sign in to comment.