Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add icon in datasource table page to show the default datasource #6231

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
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
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))

zhyuanqi marked this conversation as resolved.
Show resolved Hide resolved
### 🐛 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) ? (
zhyuanqi marked this conversation as resolved.
Show resolved Hide resolved
<EuiBadge iconType="starFilled" iconSide="left">
Default
</EuiBadge>
) : null}
</>
),
dataType: 'string' as const,
Expand Down
Loading