From e056e83f835559796daa4947821a7d0f72989298 Mon Sep 17 00:00:00 2001 From: Manideep Pabba <109986843+mpabba3003@users.noreply.github.com> Date: Thu, 20 Oct 2022 14:29:59 -0500 Subject: [PATCH 1/3] [MD] Datasource management Edit/Update page UX updates (#2629) Signed-off-by: mpabba3003 --- CHANGELOG.md | 1 + .../edit_data_source.test.tsx.snap | 226 +++----- .../edit_data_source_form.test.tsx.snap | 532 +++++++----------- .../edit_form/edit_data_source_form.test.tsx | 2 + .../edit_form/edit_data_source_form.tsx | 90 +-- .../components/header/header.tsx | 1 + .../edit_data_source.test.tsx | 2 +- .../edit_data_source/edit_data_source.tsx | 64 +-- .../data_source_management/public/types.ts | 1 + 9 files changed, 365 insertions(+), 554 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 017d697c4eac..bb0680e6c9f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) * [Vis Builder] Update vislib params and misc fixes ([2610](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2610)) * [MD] Add data source param to low-level search call in Discover ([#2431](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2431)) * [Multi DataSource] Skip data source view in index pattern step when pick default ([#2574](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2574)) +* [Multi DataSource] Address UX comments on Edit Data source page ([#2629](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2629)) ### 🚞 Infrastructure diff --git a/src/plugins/data_source_management/public/components/edit_data_source/__snapshots__/edit_data_source.test.tsx.snap b/src/plugins/data_source_management/public/components/edit_data_source/__snapshots__/edit_data_source.test.tsx.snap index 85e08d85ecef..a3d004457a78 100644 --- a/src/plugins/data_source_management/public/components/edit_data_source/__snapshots__/edit_data_source.test.tsx.snap +++ b/src/plugins/data_source_management/public/components/edit_data_source/__snapshots__/edit_data_source.test.tsx.snap @@ -59,6 +59,7 @@ exports[`Datasource Management: Edit Datasource Wizard should load resources suc /> - - -

- } - title={ -

- -

- } +
- -
- -
- -

- - - Endpoint - - -

-
- -
- -
-

- - - This connection information is used for reference in tables and when adding to a data source connection - - -

-
-
-
-
-
-
- + Endpoint URL + + +
+
+ +
- -
-
- - - -
-
- - -
-
- - - - -
-
-
-
-
-
-
+ + + + +
- -
- + + + -
+ - - -

- } - title={ -

- -

- } +
- -
- -
- -

- - - Endpoint - - -

-
- -
- -
-

- - - This connection information is used for reference in tables and when adding to a data source connection - - -

-
-
-
-
-
-
- + Endpoint URL + + +
+
+ +
- -
-
- - - -
-
- - -
-
- - - - -
-
-
-
-
-
-
+ + + + +
- -
- + + + -
+ - - -

- } - title={ -

- -

- } +
- -
- -
- -

- - - Endpoint - - -

-
- -
- -
-

- - - This connection information is used for reference in tables and when adding to a data source connection - - -

-
-
-
-
-
-
- + Endpoint URL + + +
+
+ +
- -
-
- - - -
-
- - -
-
- - - - -
-
-
-
-
-
-
+ + + + +
- -
- + + + -
+ { existingDatasourceNamesList={existingDatasourceNamesList} onDeleteDataSource={mockFn} handleSubmit={mockFn} + displayToastMessage={mockFn} /> ), { @@ -229,6 +230,7 @@ describe('Datasource Management: Edit Datasource Form', () => { existingDatasourceNamesList={existingDatasourceNamesList} onDeleteDataSource={mockFn} handleSubmit={mockFn} + displayToastMessage={mockFn} /> ), { diff --git a/src/plugins/data_source_management/public/components/edit_data_source/components/edit_form/edit_data_source_form.tsx b/src/plugins/data_source_management/public/components/edit_data_source/components/edit_form/edit_data_source_form.tsx index 00c205fa1ade..bda8709cf509 100644 --- a/src/plugins/data_source_management/public/components/edit_data_source/components/edit_form/edit_data_source_form.tsx +++ b/src/plugins/data_source_management/public/components/edit_data_source/components/edit_form/edit_data_source_form.tsx @@ -29,6 +29,7 @@ import { credentialSourceOptions, DataSourceAttributes, DataSourceManagementContextValue, + ToastMessageItem, UsernamePasswordTypedContent, } from '../../../../types'; import { context as contextType } from '../../../../../../opensearch_dashboards_react/public'; @@ -45,6 +46,7 @@ export interface EditDataSourceProps { existingDatasourceNamesList: string[]; handleSubmit: (formValues: DataSourceAttributes) => void; onDeleteDataSource?: () => void; + displayToastMessage: (info: ToastMessageItem) => void; } export interface EditDataSourceState { formErrorsByField: CreateEditDataSourceValidation; @@ -57,6 +59,7 @@ export interface EditDataSourceState { }; showUpdatePasswordModal: boolean; showUpdateOptions: boolean; + isLoading: boolean; } export class EditDataSourceForm extends React.Component { @@ -81,6 +84,7 @@ export class EditDataSourceForm extends React.Component { + onClickUpdateDataSource = async () => { if (this.isFormValid()) { // update data source endpoint is currently not supported/allowed const formValues: DataSourceAttributes = { @@ -225,7 +229,19 @@ export class EditDataSourceForm extends React.Component { + updatePassword = async (password: string) => { const { title, description, auth } = this.props.existingDataSource; const updateAttributes: DataSourceAttributes = { title, @@ -261,8 +277,21 @@ export class EditDataSourceForm extends React.Component - - - { - - } - - } - description={ -

- { - - } -

- } + {/* Endpoint */} + - {/* Endpoint */} - - - -
+ + ); }; @@ -653,6 +660,7 @@ export class EditDataSourceForm extends React.Component diff --git a/src/plugins/data_source_management/public/components/edit_data_source/components/header/header.tsx b/src/plugins/data_source_management/public/components/edit_data_source/components/header/header.tsx index 88e050394b89..8a73bcccc275 100644 --- a/src/plugins/data_source_management/public/components/edit_data_source/components/header/header.tsx +++ b/src/plugins/data_source_management/public/components/edit_data_source/components/header/header.tsx @@ -80,6 +80,7 @@ export const Header = ({ confirmButtonText={i18n.translate('dataSourcesManagement.editDataSource.delete', { defaultMessage: 'Delete', })} + buttonColor="danger" defaultFocusedButton="confirm" data-test-subj="editDatasourceDeleteConfirmModal" > diff --git a/src/plugins/data_source_management/public/components/edit_data_source/edit_data_source.test.tsx b/src/plugins/data_source_management/public/components/edit_data_source/edit_data_source.test.tsx index d8bd006f9dc1..d11f8c8bc9da 100644 --- a/src/plugins/data_source_management/public/components/edit_data_source/edit_data_source.test.tsx +++ b/src/plugins/data_source_management/public/components/edit_data_source/edit_data_source.test.tsx @@ -103,7 +103,7 @@ describe('Datasource Management: Edit Datasource Wizard', () => { expect(history.push).toBeCalledWith(''); }); test('should fail to update datasource', async () => { - spyOn(utils, 'updateDataSourceById').and.throwError('error'); + spyOn(utils, 'updateDataSourceById').and.returnValue(new Error('')); await act(async () => { // @ts-ignore await component.find(formIdentifier).first().prop('handleSubmit')( diff --git a/src/plugins/data_source_management/public/components/edit_data_source/edit_data_source.tsx b/src/plugins/data_source_management/public/components/edit_data_source/edit_data_source.tsx index 24e6448df35a..9bbaecfccce4 100644 --- a/src/plugins/data_source_management/public/components/edit_data_source/edit_data_source.tsx +++ b/src/plugins/data_source_management/public/components/edit_data_source/edit_data_source.tsx @@ -51,49 +51,48 @@ export const EditDataSource: React.FunctionComponent { (async function () { - setIsLoading(true); - try { - const fetchDataSourceById = await getDataSourceById(dataSourceID, savedObjects.client); - const listOfDataSources: DataSourceTableItem[] = await getDataSources(savedObjects.client); - if (fetchDataSourceById) { - setDataSource(fetchDataSourceById); - setBreadcrumbs(getEditBreadcrumbs(fetchDataSourceById)); - } - if (Array.isArray(listOfDataSources) && listOfDataSources.length) { - setExistingDatasourceNamesList( - listOfDataSources.map((datasource) => datasource.title?.toLowerCase()) - ); - } - } catch (e) { - setDataSource(defaultDataSource); - handleDisplayToastMessage({ - id: 'dataSourcesManagement.editDataSource.editDataSourceFailMsg', - defaultMessage: 'Unable to find the Data Source.', - }); - props.history.push(''); - } finally { - setIsLoading(false); - } + await fetchDataSourceDetailsByID(); })(); }); - /* Handle submit - create data source*/ - const handleSubmit = async (attributes: DataSourceAttributes) => { + const fetchDataSourceDetailsByID = async () => { setIsLoading(true); try { - await updateDataSourceById(savedObjects.client, dataSourceID, attributes); - props.history.push(''); + const fetchDataSourceById = await getDataSourceById(dataSourceID, savedObjects.client); + const listOfDataSources: DataSourceTableItem[] = await getDataSources(savedObjects.client); + if (fetchDataSourceById) { + setDataSource(fetchDataSourceById); + setBreadcrumbs(getEditBreadcrumbs(fetchDataSourceById)); + } + if (Array.isArray(listOfDataSources) && listOfDataSources.length) { + setExistingDatasourceNamesList( + listOfDataSources.map((datasource) => datasource.title?.toLowerCase()) + ); + } } catch (e) { - setIsLoading(false); + setDataSource(defaultDataSource); handleDisplayToastMessage({ - id: 'dataSourcesManagement.editDataSource.editDataSourceFailMsg', - defaultMessage: 'Updating the Data Source failed with some errors. Please try it again.', + id: 'dataSourcesManagement.editDataSource.fetchDataSourceFailMsg', + defaultMessage: 'Unable to find the Data Source.', }); + props.history.push(''); + } finally { + setIsLoading(false); } }; - const handleDisplayToastMessage = ({ id, defaultMessage }: ToastMessageItem) => { - toasts.addWarning(i18n.translate(id, { defaultMessage })); + /* Handle submit - create data source*/ + const handleSubmit = async (attributes: DataSourceAttributes) => { + await updateDataSourceById(savedObjects.client, dataSourceID, attributes); + await fetchDataSourceDetailsByID(); + }; + + const handleDisplayToastMessage = ({ id, defaultMessage, success }: ToastMessageItem) => { + if (success) { + toasts.addSuccess(i18n.translate(id, { defaultMessage })); + } else { + toasts.addWarning(i18n.translate(id, { defaultMessage })); + } }; /* Handle delete - data source*/ @@ -124,6 +123,7 @@ export const EditDataSource: React.FunctionComponent ) : null} {isLoading || !dataSource?.endpoint ? : null} diff --git a/src/plugins/data_source_management/public/types.ts b/src/plugins/data_source_management/public/types.ts index a689cb4a593e..fe52466df1e5 100644 --- a/src/plugins/data_source_management/public/types.ts +++ b/src/plugins/data_source_management/public/types.ts @@ -42,6 +42,7 @@ export interface DataSourceTableItem { export interface ToastMessageItem { id: string; defaultMessage: string; + success?: boolean; } export type DataSourceManagementContextValue = OpenSearchDashboardsReactContextValue< From fb4bdfa7bfd10878481814862fc794debeac272e Mon Sep 17 00:00:00 2001 From: Yibo Wang <109543558+yibow98@users.noreply.github.com> Date: Thu, 20 Oct 2022 13:25:24 -0700 Subject: [PATCH 2/3] [MD]Address comments from UX signoff meeting-Datasource list and create page (#2625) Signed-off-by: Yibo Wang --- CHANGELOG.md | 1 + .../create_button/create_button.test.tsx | 3 +- .../create_button/create_button.tsx | 8 ++-- .../create_data_source_wizard.test.tsx.snap | 22 +++++++-- .../create_data_source_form.test.tsx.snap | 44 ++++++++++++++---- .../create_form/create_data_source_form.tsx | 3 +- .../create_data_source_wizard.tsx | 2 +- .../data_source_table.test.tsx.snap | 46 ++++++++++--------- .../data_source_table/data_source_table.tsx | 16 +++++-- .../experimental_callout.tsx | 4 +- 10 files changed, 104 insertions(+), 45 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb0680e6c9f2..e3135bd2d397 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) * [Multi DataSource] Make text content dynamically translated & update unit tests ([#2570](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2570)) * [Vis Builder] Change classname prefix wiz to vb ([#2581](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2581/files)) * [Vis Builder] Change wizard to vis_builder in file names and paths ([#2587](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2587)) +* [Multi DataSource] Address UX comments on Data source list and create page ([#2625](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2625)) ### 🐛 Bug Fixes * [Vis Builder] Fixes auto bounds for timeseries bar chart visualization ([2401](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2401)) diff --git a/src/plugins/data_source_management/public/components/create_button/create_button.test.tsx b/src/plugins/data_source_management/public/components/create_button/create_button.test.tsx index 64906045b004..f54aef129df3 100644 --- a/src/plugins/data_source_management/public/components/create_button/create_button.test.tsx +++ b/src/plugins/data_source_management/public/components/create_button/create_button.test.tsx @@ -13,10 +13,11 @@ const createButtonIdentifier = `[data-test-subj="createDataSourceButton"]`; describe('CreateButton', () => { const history = (scopedHistoryMock.create() as unknown) as ScopedHistory; + const dataTestSubj = 'createDataSourceButton'; let component: ShallowWrapper, React.Component<{}, {}, any>>; beforeEach(() => { - component = shallow(); + component = shallow(); }); it('should render normally', () => { diff --git a/src/plugins/data_source_management/public/components/create_button/create_button.tsx b/src/plugins/data_source_management/public/components/create_button/create_button.tsx index 072eb8af6029..7c893af0209d 100644 --- a/src/plugins/data_source_management/public/components/create_button/create_button.tsx +++ b/src/plugins/data_source_management/public/components/create_button/create_button.tsx @@ -11,13 +11,15 @@ import { FormattedMessage } from '@osd/i18n/react'; interface Props { history: History; + isEmptyState?: boolean; + dataTestSubj: string; } -export const CreateButton = ({ history }: Props) => { +export const CreateButton = ({ history, isEmptyState, dataTestSubj }: Props) => { return ( history.push('/create')} > + +
+ @@ -401,7 +408,7 @@ exports[`Datasource Management: Create Datasource Wizard case1: should load reso onBlur={[Function]} onChange={[Function]} onFocus={[Function]} - placeholder="Sample URL: https://connectionurl.com" + placeholder="https://connectionurl.com" value="" > @@ -1079,6 +1086,13 @@ exports[`Datasource Management: Create Datasource Wizard case2: should fail to l
+ +
+ @@ -1368,7 +1382,7 @@ exports[`Datasource Management: Create Datasource Wizard case2: should fail to l onBlur={[Function]} onChange={[Function]} onFocus={[Function]} - placeholder="Sample URL: https://connectionurl.com" + placeholder="https://connectionurl.com" value="" > diff --git a/src/plugins/data_source_management/public/components/create_data_source_wizard/components/create_form/__snapshots__/create_data_source_form.test.tsx.snap b/src/plugins/data_source_management/public/components/create_data_source_wizard/components/create_form/__snapshots__/create_data_source_form.test.tsx.snap index 1006968b632f..fcd197cc0827 100644 --- a/src/plugins/data_source_management/public/components/create_data_source_wizard/components/create_form/__snapshots__/create_data_source_form.test.tsx.snap +++ b/src/plugins/data_source_management/public/components/create_data_source_wizard/components/create_form/__snapshots__/create_data_source_form.test.tsx.snap @@ -140,6 +140,13 @@ exports[`Datasource Management: Create Datasource form should create data source
+ +
+ @@ -429,7 +436,7 @@ exports[`Datasource Management: Create Datasource form should create data source onBlur={[Function]} onChange={[Function]} onFocus={[Function]} - placeholder="Sample URL: https://connectionurl.com" + placeholder="https://connectionurl.com" value="https://test.com" > @@ -867,6 +874,13 @@ exports[`Datasource Management: Create Datasource form should create data source
+ +
+ @@ -1156,7 +1170,7 @@ exports[`Datasource Management: Create Datasource form should create data source onBlur={[Function]} onChange={[Function]} onFocus={[Function]} - placeholder="Sample URL: https://connectionurl.com" + placeholder="https://connectionurl.com" value="https://test.com" > @@ -1792,6 +1806,13 @@ exports[`Datasource Management: Create Datasource form should render normally 1`
+ +
+ @@ -2081,7 +2102,7 @@ exports[`Datasource Management: Create Datasource form should render normally 1` onBlur={[Function]} onChange={[Function]} onFocus={[Function]} - placeholder="Sample URL: https://connectionurl.com" + placeholder="https://connectionurl.com" value="" > @@ -2717,6 +2738,13 @@ exports[`Datasource Management: Create Datasource form should throw validation e
+ +
+ @@ -3023,7 +3051,7 @@ exports[`Datasource Management: Create Datasource form should throw validation e onBlur={[Function]} onChange={[Function]} onFocus={[Function]} - placeholder="Sample URL: https://connectionurl.com" + placeholder="https://connectionurl.com" value="https://test.com" > diff --git a/src/plugins/data_source_management/public/components/create_data_source_wizard/components/create_form/create_data_source_form.tsx b/src/plugins/data_source_management/public/components/create_data_source_wizard/components/create_form/create_data_source_form.tsx index e5d779296a58..429790231a5c 100644 --- a/src/plugins/data_source_management/public/components/create_data_source_wizard/components/create_form/create_data_source_form.tsx +++ b/src/plugins/data_source_management/public/components/create_data_source_wizard/components/create_form/create_data_source_form.tsx @@ -287,6 +287,7 @@ export class CreateDataSourceForm extends React.Component< return ( {this.renderHeader()} + {/* Endpoint section */} {this.renderSectionHeader( @@ -354,7 +355,7 @@ export class CreateDataSourceForm extends React.Component< placeholder={i18n.translate( 'dataSourcesManagement.createDataSource.endpointPlaceholder', { - defaultMessage: 'Sample URL: https://connectionurl.com', + defaultMessage: 'https://connectionurl.com', } )} isInvalid={!!this.state.formErrorsByField.endpoint.length} diff --git a/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx b/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx index aaa50435d5e3..08ac198c7561 100644 --- a/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx +++ b/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx @@ -75,7 +75,7 @@ export const CreateDataSourceWizard: React.FunctionComponent { - toasts.addWarning(i18n.translate(id, { defaultMessage })); + toasts.addDanger(i18n.translate(id, { defaultMessage })); }; /* Render the creation wizard */ diff --git a/src/plugins/data_source_management/public/components/data_source_table/__snapshots__/data_source_table.test.tsx.snap b/src/plugins/data_source_management/public/components/data_source_table/__snapshots__/data_source_table.test.tsx.snap index abd6fc95c88d..53e2fac37130 100644 --- a/src/plugins/data_source_management/public/components/data_source_table/__snapshots__/data_source_table.test.tsx.snap +++ b/src/plugins/data_source_management/public/components/data_source_table/__snapshots__/data_source_table.test.tsx.snap @@ -108,6 +108,7 @@ exports[`DataSourceTable should get datasources failed should render empty table className="euiFlexItem euiFlexItem--flexGrowZero" >