diff --git a/changelogs/fragments/8394.yml b/changelogs/fragments/8394.yml
new file mode 100644
index 00000000000..965727c8d58
--- /dev/null
+++ b/changelogs/fragments/8394.yml
@@ -0,0 +1,2 @@
+fix:
+- Fix dynamic and correct unprefixed and duplicate i18n identifiers in dataSourceManagement plugin ([#8394](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8394))
\ No newline at end of file
diff --git a/src/plugins/data_source_management/public/components/breadcrumbs.ts b/src/plugins/data_source_management/public/components/breadcrumbs.ts
index 0980e931d5f..62c8fb5af0b 100644
--- a/src/plugins/data_source_management/public/components/breadcrumbs.ts
+++ b/src/plugins/data_source_management/public/components/breadcrumbs.ts
@@ -28,16 +28,24 @@ export function getCreateBreadcrumbs() {
},
];
}
+
export function getCreateOpenSearchDataSourceBreadcrumbs(useNewUX: boolean) {
return [
...getCreateBreadcrumbs(),
{
- text: i18n.translate(
- 'dataSourcesManagement.dataSources.createOpenSearchDataSourceBreadcrumbs',
- {
- defaultMessage: useNewUX ? 'Connect OpenSearch Cluster' : 'Open Search',
- }
- ),
+ text: useNewUX
+ ? i18n.translate(
+ 'dataSourcesManagement.dataSources.createOpenSearchDataSourceBreadcrumbs',
+ {
+ defaultMessage: 'Connect OpenSearch Cluster',
+ }
+ )
+ : i18n.translate(
+ 'dataSourcesManagement.legacyUX.dataSources.createOpenSearchDataSourceBreadcrumbs',
+ {
+ defaultMessage: 'Open Search',
+ }
+ ),
href: `/configure/OpenSearch`,
},
];
@@ -47,12 +55,16 @@ export function getCreateAmazonS3DataSourceBreadcrumbs(useNewUX: boolean) {
return [
...getCreateBreadcrumbs(),
{
- text: i18n.translate(
- 'dataSourcesManagement.dataSources.createAmazonS3DataSourceBreadcrumbs',
- {
- defaultMessage: useNewUX ? 'Connect Amazon S3' : 'Amazon S3',
- }
- ),
+ text: useNewUX
+ ? i18n.translate('dataSourcesManagement.dataSources.createAmazonS3DataSourceBreadcrumbs', {
+ defaultMessage: 'Connect Amazon S3',
+ })
+ : i18n.translate(
+ 'dataSourcesManagement.legacyUX.dataSources.createAmazonS3DataSourceBreadcrumbs',
+ {
+ defaultMessage: 'Amazon S3',
+ }
+ ),
href: `/configure/AmazonS3AWSGlue`,
},
];
@@ -62,12 +74,19 @@ export function getCreatePrometheusDataSourceBreadcrumbs(useNewUX: boolean) {
return [
...getCreateBreadcrumbs(),
{
- text: i18n.translate(
- 'dataSourcesManagement.dataSources.createPrometheusDataSourceBreadcrumbs',
- {
- defaultMessage: useNewUX ? 'Connect Prometheus' : 'Prometheus',
- }
- ),
+ text: useNewUX
+ ? i18n.translate(
+ 'dataSourcesManagement.dataSources.createPrometheusDataSourceBreadcrumbs',
+ {
+ defaultMessage: 'Connect Prometheus',
+ }
+ )
+ : i18n.translate(
+ 'dataSourcesManagement.legacyUX.dataSources.createPrometheusDataSourceBreadcrumbs',
+ {
+ defaultMessage: 'Prometheus',
+ }
+ ),
href: `/configure/Prometheus`,
},
];
@@ -77,12 +96,7 @@ export function getManageDirectQueryDataSourceBreadcrumbs(directQueryDatasourceN
return [
...getListBreadcrumbs(),
{
- text: i18n.translate(
- 'dataSourcesManagement.dataSources.manageDirectQueryDataSourceBreadcrumbs',
- {
- defaultMessage: directQueryDatasourceName,
- }
- ),
+ text: directQueryDatasourceName,
href: `/manage/${directQueryDatasourceName}`,
},
];
diff --git a/src/plugins/data_source_management/public/components/constants.tsx b/src/plugins/data_source_management/public/components/constants.tsx
index 14a71eb892b..ead7f83a27a 100644
--- a/src/plugins/data_source_management/public/components/constants.tsx
+++ b/src/plugins/data_source_management/public/components/constants.tsx
@@ -5,20 +5,15 @@
import { i18n } from '@osd/i18n';
import { DataSourceOption } from './data_source_menu/types';
-import { DatasourceType } from '../types';
+import { DatasourceType } from '../../framework/types';
export const LocalCluster: DataSourceOption = {
- label: i18n.translate('dataSource.localCluster', {
+ label: i18n.translate('dataSourcesManagement.localCluster', {
defaultMessage: 'Local cluster',
}),
id: '',
};
-export const NO_DATASOURCES_CONNECTED_MESSAGE = 'No data sources connected yet.';
-export const CONNECT_DATASOURCES_MESSAGE = 'Connect your data sources to get started.';
-export const NO_COMPATIBLE_DATASOURCES_MESSAGE = 'No compatible data sources are available.';
-export const ADD_COMPATIBLE_DATASOURCES_MESSAGE = 'Add a compatible data source.';
-
export const OPENSEARCH_DOCUMENTATION_URL =
'https://opensearch.org/docs/latest/dashboards/management/data-sources/';
diff --git a/src/plugins/data_source_management/public/components/create_button/__snapshots__/create_button.test.tsx.snap b/src/plugins/data_source_management/public/components/create_button/__snapshots__/create_button.test.tsx.snap
index 03c20a8093e..13b4b0ab1d1 100644
--- a/src/plugins/data_source_management/public/components/create_button/__snapshots__/create_button.test.tsx.snap
+++ b/src/plugins/data_source_management/public/components/create_button/__snapshots__/create_button.test.tsx.snap
@@ -8,7 +8,7 @@ exports[`CreateButton should render normally 1`] = `
>
diff --git a/src/plugins/data_source_management/public/components/create_button/create_button.tsx b/src/plugins/data_source_management/public/components/create_button/create_button.tsx
index f7b65401ae6..349f441cdac 100644
--- a/src/plugins/data_source_management/public/components/create_button/create_button.tsx
+++ b/src/plugins/data_source_management/public/components/create_button/create_button.tsx
@@ -23,12 +23,17 @@ export const CreateButton = ({ history, isEmptyState, dataTestSubj, featureFlagS
fill={isEmptyState ? false : true}
onClick={() => history.push('/create')}
>
-
+ {featureFlagStatus ? (
+
+ ) : (
+
+ )}
);
};
diff --git a/src/plugins/data_source_management/public/components/create_data_source_wizard/components/create_form/create_data_source_form.tsx b/src/plugins/data_source_management/public/components/create_data_source_wizard/components/create_form/create_data_source_form.tsx
index f2eb7778e8e..c2a64399891 100644
--- a/src/plugins/data_source_management/public/components/create_data_source_wizard/components/create_form/create_data_source_form.tsx
+++ b/src/plugins/data_source_management/public/components/create_data_source_wizard/components/create_form/create_data_source_form.tsx
@@ -47,6 +47,7 @@ import {
getDefaultAuthMethod,
isValidUrl,
} from '../../../utils';
+import { DataSourceOptionalLabelSuffix } from '../../../data_source_optional_label_suffix';
export interface CreateDataSourceProps {
useNewUX: boolean;
@@ -399,36 +400,6 @@ export class CreateDataSourceForm extends React.Component<
);
};
- /* Render Section header*/
- renderSectionHeader = (i18nId: string, defaultMessage: string) => {
- return (
- <>
-
-
-
-
-
- >
- );
- };
- /* Render field label with Optional text*/
- renderFieldLabelAsOptional = (i18nId: string, defaultMessage: string) => {
- return (
- <>
- {}{' '}
-
- -{' '}
- {
-
- }
-
- >
- );
- };
-
/* Render create new credentials*/
renderCreateNewCredentialsForm = (type: AuthType) => {
switch (type) {
@@ -581,10 +552,14 @@ export class CreateDataSourceForm extends React.Component<
{this.renderHeader()}
{/* Endpoint section */}
- {this.renderSectionHeader(
- 'dataSourceManagement.connectToDataSource.connectionDetails',
- 'Connection Details'
- )}
+
+
+
+
+
{/* Title */}
@@ -613,10 +588,13 @@ export class CreateDataSourceForm extends React.Component<
{/* Description */}
}}
+ />
+ }
>
- {this.renderSectionHeader(
- 'dataSourceManagement.connectToDataSource.authenticationHeader',
- 'Authentication Method'
- )}
+
+
+
+
+
+
-
- {this.isNoAuthOptionEnabled && (
+ {this.isNoAuthOptionEnabled ? (
+ No authentication }}
+ />
+ ) : (
)}
- {this.isNoAuthOptionEnabled && (
-
-
-
- )}
diff --git a/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx b/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx
index e589d4fee72..d8b1bfb5a80 100644
--- a/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx
+++ b/src/plugins/data_source_management/public/components/create_data_source_wizard/create_data_source_wizard.tsx
@@ -11,8 +11,8 @@ import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react
import {
DataSourceAttributes,
DataSourceManagementContext,
+ DataSourceManagementToastMessageItem,
DataSourceTableItem,
- ToastMessageItem,
} from '../../types';
import { getCreateOpenSearchDataSourceBreadcrumbs } from '../breadcrumbs';
import { CreateDataSourceForm } from './components/create_form';
@@ -65,8 +65,9 @@ export const CreateDataSourceWizard: React.FunctionComponent {
+ const handleDisplayToastMessage = ({
+ message,
+ success,
+ }: DataSourceManagementToastMessageItem) => {
if (success) {
- toasts.addSuccess(i18n.translate(id, { defaultMessage }));
+ toasts.addSuccess(message);
} else {
- toasts.addDanger(i18n.translate(id, { defaultMessage }));
+ toasts.addDanger(message);
}
};
diff --git a/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.test.tsx b/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.test.tsx
index 23ed1a7a09b..8c3817acfe6 100644
--- a/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.test.tsx
+++ b/src/plugins/data_source_management/public/components/data_source_aggregated_view/data_source_aggregated_view.test.tsx
@@ -425,7 +425,8 @@ describe('DataSourceAggregatedView empty state test due to filter out with local
dataSourceFilter={filter}
/>
);
- const noCompatibleDataSourcesMessage = `${NO_COMPATIBLE_DATASOURCES_MESSAGE} ${ADD_COMPATIBLE_DATASOURCES_MESSAGE}`;
+ const noCompatibleDataSourcesMessage =
+ 'No compatible data sources are available. Add a compatible data source.';
expect(component).toMatchSnapshot();
await nextTick();
@@ -528,8 +529,10 @@ describe('DataSourceAggregatedView warning messages', () => {
const dataSourceSelection = new DataSourceSelectionService();
const nextTick = () => new Promise((res) => process.nextTick(res));
let toasts: IToasts;
- const noDataSourcesConnectedMessage = `${NO_DATASOURCES_CONNECTED_MESSAGE} ${CONNECT_DATASOURCES_MESSAGE}`;
- const noCompatibleDataSourcesMessage = `${NO_COMPATIBLE_DATASOURCES_MESSAGE} ${ADD_COMPATIBLE_DATASOURCES_MESSAGE}`;
+ const noDataSourcesConnectedMessage =
+ 'No data sources connected yet. Connect your data sources to get started.';
+ const noCompatibleDataSourcesMessage =
+ 'No compatible data sources are available. Add a compatible data source.';
beforeEach(() => {
toasts = notificationServiceMock.createStartContract().toasts;
@@ -576,11 +579,7 @@ describe('DataSourceAggregatedView warning messages', () => {
);
await nextTick();
- expect(toasts.add).toBeCalledWith(
- expect.objectContaining({
- title: i18n.translate('dataSource.noAvailableDataSourceError', { defaultMessage }),
- })
- );
+ expect(toasts.add).toBeCalledWith(expect.objectContaining({ title: defaultMessage }));
}
);
});
diff --git a/src/plugins/data_source_management/public/components/data_source_column/data_source_column.tsx b/src/plugins/data_source_management/public/components/data_source_column/data_source_column.tsx
index eba4bebd5e3..a987e72eb46 100644
--- a/src/plugins/data_source_management/public/components/data_source_column/data_source_column.tsx
+++ b/src/plugins/data_source_management/public/components/data_source_column/data_source_column.tsx
@@ -20,7 +20,7 @@ export class DataSourceColumn implements IndexPatternTableColumn
public euiColumn = {
field: 'referenceId',
- name: i18n.translate('dataSource.management.dataSourceColumn', {
+ name: i18n.translate('dataSourcesManagement.dataSourceColumn', {
defaultMessage: 'Data Source Connection',
}),
render: (referenceId: string) => {
diff --git a/src/plugins/data_source_management/public/components/data_source_error_menu/data_source_error_menu.tsx b/src/plugins/data_source_management/public/components/data_source_error_menu/data_source_error_menu.tsx
index f4bbc239ff7..1baee3794e1 100644
--- a/src/plugins/data_source_management/public/components/data_source_error_menu/data_source_error_menu.tsx
+++ b/src/plugins/data_source_management/public/components/data_source_error_menu/data_source_error_menu.tsx
@@ -44,9 +44,12 @@ export const DataSourceErrorMenu = ({ application }: DataSourceErrorMenuProps) =
}
size="s"
onClick={() => setShowPopover(!showPopover)}
diff --git a/src/plugins/data_source_management/public/components/data_source_home_panel/data_source_home_panel.tsx b/src/plugins/data_source_management/public/components/data_source_home_panel/data_source_home_panel.tsx
index 1730c2f7975..f77cd05056a 100644
--- a/src/plugins/data_source_management/public/components/data_source_home_panel/data_source_home_panel.tsx
+++ b/src/plugins/data_source_management/public/components/data_source_home_panel/data_source_home_panel.tsx
@@ -103,11 +103,13 @@ export const DataSourceHomePanel: React.FC = ({
];
const description = {
- description: i18n.translate('dataSourcesManagement.dataSourcesTable.description', {
- defaultMessage: featureFlagStatus
- ? 'Create and manage data source connections.'
- : 'Manage direct query data source connections.',
- }),
+ description: featureFlagStatus
+ ? i18n.translate('dataSourcesManagement.dataSourcesTable.descriptionWithDataSource', {
+ defaultMessage: 'Create and manage data source connections.',
+ })
+ : i18n.translate('dataSourcesManagement.dataSourcesTable.description', {
+ defaultMessage: 'Manage direct query data source connections.',
+ }),
links: [
{
href: docLinks.links.opensearchDashboards.dataSource.guide,
diff --git a/src/plugins/data_source_management/public/components/data_source_menu/__snapshots__/create_data_source_menu.test.tsx.snap b/src/plugins/data_source_management/public/components/data_source_menu/__snapshots__/create_data_source_menu.test.tsx.snap
index 37bcb8daa4f..7284248a1bb 100644
--- a/src/plugins/data_source_management/public/components/data_source_menu/__snapshots__/create_data_source_menu.test.tsx.snap
+++ b/src/plugins/data_source_management/public/components/data_source_menu/__snapshots__/create_data_source_menu.test.tsx.snap
@@ -127,7 +127,7 @@ Object {
data-label="Data source"
>