diff --git a/CHANGELOG.md b/CHANGELOG.md
index b22b5556ac33..0addb1e6d221 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### 🛡 Security
### 📈 Features/Enhancements
+- [MD]Change cluster selector component name to data source selector ([#6042](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6042))
### 🐛 Bug Fixes
diff --git a/src/plugins/data_source_management/public/components/cluster_selector/create_cluster_selector.tsx b/src/plugins/data_source_management/public/components/cluster_selector/create_cluster_selector.tsx
deleted file mode 100644
index 02696e8747f9..000000000000
--- a/src/plugins/data_source_management/public/components/cluster_selector/create_cluster_selector.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * Copyright OpenSearch Contributors
- * SPDX-License-Identifier: Apache-2.0
- */
-
-import React from 'react';
-import { ClusterSelector, ClusterSelectorProps } from './cluster_selector';
-
-export function createClusterSelector() {
- return (props: ClusterSelectorProps) => ;
-}
diff --git a/src/plugins/data_source_management/public/components/cluster_selector/__snapshots__/create_cluster_selector.test.tsx.snap b/src/plugins/data_source_management/public/components/data_source_selector/__snapshots__/create_data_source_selector.test.tsx.snap
similarity index 97%
rename from src/plugins/data_source_management/public/components/cluster_selector/__snapshots__/create_cluster_selector.test.tsx.snap
rename to src/plugins/data_source_management/public/components/data_source_selector/__snapshots__/create_data_source_selector.test.tsx.snap
index 68698f7adabe..4ce6e1bc30ab 100644
--- a/src/plugins/data_source_management/public/components/cluster_selector/__snapshots__/create_cluster_selector.test.tsx.snap
+++ b/src/plugins/data_source_management/public/components/data_source_selector/__snapshots__/create_data_source_selector.test.tsx.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`create cluster selector should render normally 1`] = `
+exports[`create data source selector should render normally 1`] = `
Object {
"asFragment": [Function],
"baseElement":
@@ -10,7 +10,7 @@ Object {
aria-haspopup="listbox"
aria-label="Select a data source"
class="euiComboBox euiComboBox--compressed"
- data-test-subj="clusterSelectorComboBox"
+ data-test-subj="dataSourceSelectorComboBox"
role="combobox"
>
`;
-exports[`ClusterSelector should render normally with local cluster not hidden 1`] = `
+exports[`DataSourceSelector should render normally with local cluster not hidden 1`] = `
`;
-exports[`ClusterSelector: check dataSource options should always place local cluster option as the first option when local cluster not hidden 1`] = `
+exports[`DataSourceSelector: check dataSource options should always place local cluster option as the first option when local cluster not hidden 1`] = `
{
+describe('create data source selector', () => {
let client: SavedObjectsClientContract;
const { toasts } = notificationServiceMock.createStartContract();
@@ -27,7 +27,7 @@ describe('create cluster selector', () => {
hideLocalCluster: false,
fullWidth: false,
};
- const TestComponent = createClusterSelector();
+ const TestComponent = createDataSourceSelector();
const component = render();
expect(component).toMatchSnapshot();
expect(client.find).toBeCalledWith({
diff --git a/src/plugins/data_source_management/public/components/data_source_selector/create_data_source_selector.tsx b/src/plugins/data_source_management/public/components/data_source_selector/create_data_source_selector.tsx
new file mode 100644
index 000000000000..ff6b7503a0bb
--- /dev/null
+++ b/src/plugins/data_source_management/public/components/data_source_selector/create_data_source_selector.tsx
@@ -0,0 +1,11 @@
+/*
+ * Copyright OpenSearch Contributors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import React from 'react';
+import { DataSourceSelector, DataSourceSelectorProps } from './data_source_selector';
+
+export function createDataSourceSelector() {
+ return (props: DataSourceSelectorProps) => ;
+}
diff --git a/src/plugins/data_source_management/public/components/cluster_selector/cluster_selector.test.tsx b/src/plugins/data_source_management/public/components/data_source_selector/data_source_selector.test.tsx
similarity index 91%
rename from src/plugins/data_source_management/public/components/cluster_selector/cluster_selector.test.tsx
rename to src/plugins/data_source_management/public/components/data_source_selector/data_source_selector.test.tsx
index 6a4448874ab9..d74f74160b22 100644
--- a/src/plugins/data_source_management/public/components/cluster_selector/cluster_selector.test.tsx
+++ b/src/plugins/data_source_management/public/components/data_source_selector/data_source_selector.test.tsx
@@ -4,13 +4,13 @@
*/
import { ShallowWrapper, shallow } from 'enzyme';
-import { ClusterSelector } from './cluster_selector';
+import { DataSourceSelector } from './data_source_selector';
import { SavedObjectsClientContract } from '../../../../../core/public';
import { notificationServiceMock } from '../../../../../core/public/mocks';
import React from 'react';
import { getDataSourcesResponse, mockResponseForSavedObjectsCalls } from '../../mocks';
-describe('ClusterSelector', () => {
+describe('DataSourceSelector', () => {
let component: ShallowWrapper, React.Component<{}, {}, any>>;
let client: SavedObjectsClientContract;
@@ -24,7 +24,7 @@ describe('ClusterSelector', () => {
it('should render normally with local cluster not hidden', () => {
component = shallow(
- {
it('should render normally with local cluster is hidden', () => {
component = shallow(
- {
});
});
-describe('ClusterSelector: check dataSource options', () => {
+describe('DataSourceSelector: check dataSource options', () => {
let component: ShallowWrapper, React.Component<{}, {}, any>>;
let client: SavedObjectsClientContract;
const { toasts } = notificationServiceMock.createStartContract();
@@ -79,7 +79,7 @@ describe('ClusterSelector: check dataSource options', () => {
it('should always place local cluster option as the first option when local cluster not hidden', async () => {
component = shallow(
- void;
+ onSelectedDataSource: (dataSourceOption: DataSourceOption[]) => void;
disabled: boolean;
hideLocalCluster: boolean;
fullWidth: boolean;
}
-interface ClusterSelectorState {
- clusterOptions: ClusterOption[];
- selectedOption: ClusterOption[];
+interface DataSourceSelectorState {
+ dataSourceOptions: DataSourceOption[];
+ selectedOption: DataSourceOption[];
}
-export interface ClusterOption {
+export interface DataSourceOption {
label: string;
id: string;
}
-export class ClusterSelector extends React.Component {
+export class DataSourceSelector extends React.Component<
+ DataSourceSelectorProps,
+ DataSourceSelectorState
+> {
private _isMounted: boolean = false;
- constructor(props: ClusterSelectorProps) {
+ constructor(props: DataSourceSelectorProps) {
super(props);
this.state = {
- clusterOptions: this.props.hideLocalCluster ? [] : [LocalCluster],
+ dataSourceOptions: this.props.hideLocalCluster ? [] : [LocalCluster],
selectedOption: this.props.hideLocalCluster ? [] : [LocalCluster],
};
}
@@ -56,19 +59,19 @@ export class ClusterSelector extends React.Component {
if (fetchedDataSources?.length) {
- const clusterOptions = fetchedDataSources.map((dataSource) => ({
+ const dataSourceOptions = fetchedDataSources.map((dataSource) => ({
id: dataSource.id,
label: dataSource.title,
}));
if (!this.props.hideLocalCluster) {
- clusterOptions.unshift(LocalCluster);
+ dataSourceOptions.unshift(LocalCluster);
}
if (!this._isMounted) return;
this.setState({
...this.state,
- clusterOptions,
+ dataSourceOptions,
});
}
})
@@ -92,23 +95,23 @@ export class ClusterSelector extends React.Component this.onChange(e)}
- prepend={i18n.translate('clusterSelectorComboBoxPrepend', {
+ prepend={i18n.translate('dataSourceSelectorComboBoxPrepend', {
defaultMessage: 'Data source',
})}
compressed
isDisabled={this.props.disabled}
fullWidth={this.props.fullWidth || false}
- data-test-subj={'clusterSelectorComboBox'}
+ data-test-subj={'dataSourceSelectorComboBox'}
/>
);
}
diff --git a/src/plugins/data_source_management/public/components/cluster_selector/index.ts b/src/plugins/data_source_management/public/components/data_source_selector/index.ts
similarity index 57%
rename from src/plugins/data_source_management/public/components/cluster_selector/index.ts
rename to src/plugins/data_source_management/public/components/data_source_selector/index.ts
index 8e65dc8dc698..a1d1d97b9828 100644
--- a/src/plugins/data_source_management/public/components/cluster_selector/index.ts
+++ b/src/plugins/data_source_management/public/components/data_source_selector/index.ts
@@ -3,4 +3,4 @@
* SPDX-License-Identifier: Apache-2.0
*/
-export { ClusterSelector } from './cluster_selector';
+export { DataSourceSelector } from './data_source_selector';
diff --git a/src/plugins/data_source_management/public/index.ts b/src/plugins/data_source_management/public/index.ts
index e58e8f9bce5e..0b12763b5a43 100644
--- a/src/plugins/data_source_management/public/index.ts
+++ b/src/plugins/data_source_management/public/index.ts
@@ -11,5 +11,5 @@ export function plugin() {
return new DataSourceManagementPlugin();
}
export { DataSourceManagementPluginStart } from './types';
-export { ClusterSelector } from './components/cluster_selector';
+export { DataSourceSelector } from './components/data_source_selector';
export { DataSourceManagementPlugin, DataSourceManagementPluginSetup } from './plugin';
diff --git a/src/plugins/data_source_management/public/plugin.ts b/src/plugins/data_source_management/public/plugin.ts
index d6144759cbb9..d5b2117e800b 100644
--- a/src/plugins/data_source_management/public/plugin.ts
+++ b/src/plugins/data_source_management/public/plugin.ts
@@ -7,7 +7,7 @@ import { DataSourcePluginSetup } from 'src/plugins/data_source/public';
import { CoreSetup, CoreStart, Plugin } from '../../../core/public';
import { PLUGIN_NAME } from '../common';
-import { createClusterSelector } from './components/cluster_selector/create_cluster_selector';
+import { createDataSourceSelector } from './components/data_source_selector/create_data_source_selector';
import { ManagementSetup } from '../../management/public';
import { IndexPatternManagementSetup } from '../../index_pattern_management/public';
@@ -18,7 +18,7 @@ import {
AuthenticationMethodRegistery,
} from './auth_registry';
import { noAuthCredentialAuthMethod, sigV4AuthMethod, usernamePasswordAuthMethod } from './types';
-import { ClusterSelectorProps } from './components/cluster_selector/cluster_selector';
+import { DataSourceSelectorProps } from './components/data_source_selector/data_source_selector';
export interface DataSourceManagementSetupDependencies {
management: ManagementSetup;
@@ -28,7 +28,7 @@ export interface DataSourceManagementSetupDependencies {
export interface DataSourceManagementPluginSetup {
registerAuthenticationMethod: (authMethodValues: AuthenticationMethod) => void;
- getDataSourcePicker: React.ComponentType;
+ getDataSourceSelector: React.ComponentType;
}
export interface DataSourceManagementPluginStart {
@@ -96,7 +96,7 @@ export class DataSourceManagementPlugin
return {
registerAuthenticationMethod,
- getDataSourcePicker: createClusterSelector(),
+ getDataSourceSelector: createDataSourceSelector(),
};
}
diff --git a/src/plugins/dev_tools/public/application.tsx b/src/plugins/dev_tools/public/application.tsx
index e9b088284537..3d3655b3bd64 100644
--- a/src/plugins/dev_tools/public/application.tsx
+++ b/src/plugins/dev_tools/public/application.tsx
@@ -44,7 +44,7 @@ import {
ScopedHistory,
} from 'src/core/public';
-import { ClusterSelector } from '../../data_source_management/public';
+import { DataSourceSelector } from '../../data_source_management/public';
import { DevToolApp } from './dev_tool';
import { DevToolsSetupDependencies } from './plugin';
import { addHelpMenuToAppChrome } from './utils/util';
@@ -132,8 +132,8 @@ function DevToolsWrapper({
))}
{dataSourceEnabled ? (
-
-
+
-
+
-
- {
),
}}
>
-