diff --git a/CHANGELOG.md b/CHANGELOG.md index fe54b0d0deec..61ede81df9d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - [Multiple Datasource] Add default functionality for customer to choose default datasource ([#6058](https://github.com/opensearch-project/OpenSearch-Dashboards/issues/6058)) - [Multiple Datasource] Add import support for Vega when specifying a datasource ([#6123](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6123)) - [Workspace] Validate if workspace exists when setup inside a workspace ([#6154](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6154)) +- [Multiple Datasource] Add icon in datasource table page to show the default datasource ([#6231](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6231)) ### 🐛 Bug Fixes 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 53e2fac37130..acab011f27a8 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 @@ -1927,6 +1927,46 @@ exports[`DataSourceTable should get datasources successful should render normall + + + + + + Default + + + + + + + + diff --git a/src/plugins/data_source_management/public/components/data_source_table/data_source_table.test.tsx b/src/plugins/data_source_management/public/components/data_source_table/data_source_table.test.tsx index cdb25c057844..dd33c28b6890 100644 --- a/src/plugins/data_source_management/public/components/data_source_table/data_source_table.test.tsx +++ b/src/plugins/data_source_management/public/components/data_source_table/data_source_table.test.tsx @@ -19,11 +19,13 @@ const deleteButtonIdentifier = '[data-test-subj="deleteDataSourceConnections"]'; const tableIdentifier = 'EuiInMemoryTable'; const confirmModalIdentifier = 'EuiConfirmModal'; const tableColumnHeaderIdentifier = 'EuiTableHeaderCell'; +const badgeIcon = 'EuiBadge'; const tableColumnHeaderButtonIdentifier = 'EuiTableHeaderCell .euiTableHeaderButton'; const emptyStateIdentifier = '[data-test-subj="datasourceTableEmptyState"]'; describe('DataSourceTable', () => { const mockedContext = mockManagementPlugin.createDataSourceManagementContext(); + const uiSettings = mockedContext.uiSettings; let component: ReactWrapper, React.Component<{}, {}, any>>; const history = (scopedHistoryMock.create() as unknown) as ScopedHistory; describe('should get datasources failed', () => { @@ -57,6 +59,7 @@ describe('DataSourceTable', () => { describe('should get datasources successful', () => { beforeEach(async () => { spyOn(utils, 'getDataSources').and.returnValue(Promise.resolve(getMappedDataSources)); + spyOn(uiSettings, 'get').and.returnValue('test'); await act(async () => { component = await mount( wrapWithIntl( @@ -83,6 +86,7 @@ describe('DataSourceTable', () => { }); it('should sort datasources based on description', () => { + expect(component.find(badgeIcon).exists()).toBe(true); expect(component.find(tableIdentifier).exists()).toBe(true); act(() => { component.find(tableColumnHeaderButtonIdentifier).last().simulate('click'); @@ -90,6 +94,7 @@ describe('DataSourceTable', () => { component.update(); // @ts-ignore expect(component.find(tableColumnHeaderIdentifier).last().props().isSorted).toBe(true); + expect(uiSettings.get).toHaveBeenCalled(); }); it('should enable delete button when select datasources', () => { diff --git a/src/plugins/data_source_management/public/components/data_source_table/data_source_table.tsx b/src/plugins/data_source_management/public/components/data_source_table/data_source_table.tsx index bbb2ce5f4100..b27f957fe142 100644 --- a/src/plugins/data_source_management/public/components/data_source_table/data_source_table.tsx +++ b/src/plugins/data_source_management/public/components/data_source_table/data_source_table.tsx @@ -4,6 +4,7 @@ */ import { + EuiBadge, EuiButton, EuiButtonEmpty, EuiConfirmModal, @@ -50,6 +51,7 @@ export const DataSourceTable = ({ history }: RouteComponentProps) => { setBreadcrumbs, savedObjects, notifications: { toasts }, + uiSettings, } = useOpenSearchDashboards().services; /* Component state variables */ @@ -147,6 +149,11 @@ export const DataSourceTable = ({ history }: RouteComponentProps) => { {name} + {index.id === uiSettings.get('defaultDataSource', null) ? ( + + Default + + ) : null} ), dataType: 'string' as const,