Skip to content

Commit

Permalink
Add icon in datasource table page to show the default datasource (#6231
Browse files Browse the repository at this point in the history
…) (#6235)

Signed-off-by: Yuanqi(Ella) Zhu <zhyuanqi@amazon.com>
(cherry picked from commit 4a8e3e8)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 887c21c commit fcf1dbb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.

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 fcf1dbb

Please sign in to comment.