-
Notifications
You must be signed in to change notification settings - Fork 917
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MD] Add dropdown header to Data source single selector
Signed-off-by: Zhongnan Su <[email protected]>
- Loading branch information
1 parent
c89d304
commit 8b21cb1
Showing
13 changed files
with
238 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...ins/data_source_management/public/components/__snapshots__/drop_down_header.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...blic/components/data_source_selectable/__snapshots__/data_source_selectable.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/plugins/data_source_management/public/components/drop_down_header.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { DataSourceDropDownHeader } from './drop_down_header'; | ||
import { coreMock } from '../../../../../src/core/public/mocks'; | ||
import { DSM_APP_ID } from '../plugin'; | ||
|
||
describe('DataSourceDropDownHeader', () => { | ||
it('should render correctly with the provided dataSourceCount', () => { | ||
const dataSourceCount = 5; | ||
const wrapper = shallow(<DataSourceDropDownHeader dataSourceCount={dataSourceCount} />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('should call application.navigateToApp when the "Manage" link is clicked', () => { | ||
const dataSourceCount = 5; | ||
const navigateToAppMock = jest.fn(); | ||
const applicationMock = coreMock.createStart().application; | ||
|
||
const wrapper = shallow( | ||
<DataSourceDropDownHeader dataSourceCount={dataSourceCount} application={applicationMock} /> | ||
); | ||
wrapper.find('EuiLink').simulate('click'); | ||
expect(navigateToAppMock).toHaveBeenCalledWith('management', { | ||
path: `opensearch-dashboards/${DSM_APP_ID}`, | ||
}); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
src/plugins/data_source_management/public/components/drop_down_header.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiTitle, EuiFlexGroup, EuiFlexItem, EuiLink } from '@elastic/eui'; | ||
import React from 'react'; | ||
import { ApplicationStart } from 'opensearch-dashboards/public'; | ||
import { DSM_APP_ID } from '../plugin'; | ||
|
||
interface DataSourceOptionItemProps { | ||
dataSourceCount: number; | ||
application?: ApplicationStart; | ||
} | ||
|
||
export const DataSourceDropDownHeader: React.FC<DataSourceOptionItemProps> = ({ | ||
dataSourceCount, | ||
application, | ||
}) => { | ||
return ( | ||
<EuiTitle size="xxxs"> | ||
<EuiFlexGroup responsive={false}> | ||
<EuiFlexItem>DATA SOURCE({dataSourceCount})</EuiFlexItem> | ||
<div tabIndex={0} style={{ opacity: 0 }} /> | ||
<EuiFlexItem grow={false}> | ||
<EuiLink | ||
onClick={() => | ||
application?.navigateToApp('management', { | ||
path: `opensearch-dashboards/${DSM_APP_ID}`, | ||
}) | ||
} | ||
> | ||
Manage | ||
</EuiLink> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiTitle> | ||
); | ||
}; |
Oops, something went wrong.