Skip to content

Commit

Permalink
Add icon in datasource table page to show the default datasource
Browse files Browse the repository at this point in the history
Signed-off-by: Yuanqi(Ella) Zhu <zhyuanqi@amazon.com>
  • Loading branch information
zhyuanqi committed Mar 21, 2024
1 parent a2ed39f commit 219414b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [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))
- [Workspace] Register a workspace dropdown menu at the top of left nav bar ([#6150](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6150))
- [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

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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<any, Readonly<{}>, React.Component<{}, {}, any>>;
const history = (scopedHistoryMock.create() as unknown) as ScopedHistory;
describe('should get datasources failed', () => {
Expand Down Expand Up @@ -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(
Expand All @@ -83,13 +86,15 @@ 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');
});
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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import {
EuiBadge,
EuiButton,
EuiButtonEmpty,
EuiConfirmModal,
Expand Down Expand Up @@ -50,6 +51,7 @@ export const DataSourceTable = ({ history }: RouteComponentProps) => {
setBreadcrumbs,
savedObjects,
notifications: { toasts },
uiSettings,
} = useOpenSearchDashboards<DataSourceManagementContext>().services;

/* Component state variables */
Expand Down Expand Up @@ -147,6 +149,11 @@ export const DataSourceTable = ({ history }: RouteComponentProps) => {
<EuiButtonEmpty size="xs" {...reactRouterNavigate(history, `${index.id}`)}>
{name}
</EuiButtonEmpty>
{index.id === uiSettings.get('defaultDataSource', null) ? (
<EuiBadge iconType="starFilled" iconSide="left">
Default
</EuiBadge>
) : null}
</>
),
dataType: 'string' as const,
Expand Down

0 comments on commit 219414b

Please sign in to comment.