diff --git a/src/plugins/workspace/public/components/workspace_form/workspace_permission_setting_panel.tsx b/src/plugins/workspace/public/components/workspace_form/workspace_permission_setting_panel.tsx
index 8ea255b83b36..845708d7ecbf 100644
--- a/src/plugins/workspace/public/components/workspace_form/workspace_permission_setting_panel.tsx
+++ b/src/plugins/workspace/public/components/workspace_form/workspace_permission_setting_panel.tsx
@@ -10,6 +10,7 @@ import {
EuiFlexItem,
EuiCompressedFormRow,
EuiSpacer,
+ EuiFormLabel,
} from '@elastic/eui';
import { i18n } from '@osd/i18n';
import { WorkspaceFormError, WorkspacePermissionSetting } from './types';
@@ -17,6 +18,9 @@ import {
WorkspacePermissionItemType,
optionIdToWorkspacePermissionModesMap,
PermissionModeId,
+ PERMISSION_TYPE_LABEL_ID,
+ PERMISSION_COLLABORATOR_LABEL_ID,
+ PERMISSION_ACCESS_LEVEL_LABEL_ID,
} from './constants';
import {
WorkspacePermissionSettingInput,
@@ -130,35 +134,30 @@ export const WorkspacePermissionSettingPanel = ({
);
return (
-
-
+ <>
+
-
+ {i18n.translate('workspaceForm.permissionSetting.typeLabel', {
defaultMessage: 'Type',
})}
- >
- <>>
-
+
-
+ {i18n.translate('workspaceForm.permissionSetting.collaboratorLabel', {
defaultMessage: 'Collaborator',
})}
- >
- <>>
-
+
-
-
+
+ {i18n.translate('workspaceForm.permissionSetting.accessLevelLabel', {
defaultMessage: 'Access level',
})}
- >
- <>>
-
+
+
{permissionSettings.map((item, index) => (
@@ -195,6 +194,6 @@ export const WorkspacePermissionSettingPanel = ({
})}
)}
-
+ >
);
};
diff --git a/src/plugins/workspace/public/utils.ts b/src/plugins/workspace/public/utils.ts
index 2620b4703670..8a137a5c173d 100644
--- a/src/plugins/workspace/public/utils.ts
+++ b/src/plugins/workspace/public/utils.ts
@@ -266,28 +266,46 @@ export const getDirectQueryConnections = async (dataSourceId: string, http: Http
return directQueryConnections;
};
-// Helper function to merge data sources with direct query connections
-export const mergeDataSourcesWithConnections = (
- assignedDataSources: DataSource[],
- directQueryConnections: DataSourceConnection[]
-): DataSourceConnection[] => {
- const dataSources: DataSourceConnection[] = [];
- assignedDataSources.forEach((ds) => {
- const relatedConnections = directQueryConnections.filter(
- (directQueryConnection) => directQueryConnection.parentId === ds.id
- );
-
- dataSources.push({
+export const convertDataSourcesToOpenSearchConnections = (
+ dataSources: DataSource[]
+): DataSourceConnection[] =>
+ dataSources.map((ds) => {
+ return {
id: ds.id,
type: ds.dataSourceEngineType,
connectionType: DataSourceConnectionType.OpenSearchConnection,
name: ds.title,
description: ds.description,
+ relatedConnections: [],
+ };
+ });
+
+export const fulfillRelatedConnections = (
+ connections: DataSourceConnection[],
+ directQueryConnections: DataSourceConnection[]
+) => {
+ return connections.map((connection) => {
+ const relatedConnections = directQueryConnections.filter(
+ (directQueryConnection) => directQueryConnection.parentId === connection.id
+ );
+ return {
+ ...connection,
relatedConnections,
- });
+ };
});
+};
- return [...dataSources, ...directQueryConnections];
+// Helper function to merge data sources with direct query connections
+export const mergeDataSourcesWithConnections = (
+ dataSources: DataSource[],
+ directQueryConnections: DataSourceConnection[]
+): DataSourceConnection[] => {
+ const openSearchConnections = convertDataSourcesToOpenSearchConnections(dataSources);
+
+ return [
+ ...fulfillRelatedConnections(openSearchConnections, directQueryConnections),
+ ...directQueryConnections,
+ ].sort((a, b) => a.name.localeCompare(b.name));
};
// If all connected data sources are serverless, will only allow to select essential use case.
@@ -474,21 +492,28 @@ export const getUseCaseUrl = (
return useCaseURL;
};
+export const fetchDataSourceConnectionsByDataSourceIds = async (
+ dataSourceIds: string[],
+ http: HttpSetup | undefined
+) => {
+ const directQueryConnectionsPromises = dataSourceIds.map((dataSourceId) =>
+ getDirectQueryConnections(dataSourceId, http!).catch(() => [])
+ );
+ const directQueryConnectionsResult = await Promise.all(directQueryConnectionsPromises);
+ return directQueryConnectionsResult.flat();
+};
+
export const fetchDataSourceConnections = async (
assignedDataSources: DataSource[],
http: HttpSetup | undefined,
notifications: NotificationsStart | undefined
) => {
try {
- const directQueryConnectionsPromises = assignedDataSources.map((ds) =>
- getDirectQueryConnections(ds.id, http!).catch(() => [])
+ const directQueryConnections = await fetchDataSourceConnectionsByDataSourceIds(
+ assignedDataSources.map((ds) => ds.id),
+ http
);
- const directQueryConnectionsResult = await Promise.all(directQueryConnectionsPromises);
- const directQueryConnections = directQueryConnectionsResult.flat();
- return mergeDataSourcesWithConnections(
- assignedDataSources,
- directQueryConnections
- ).sort((a, b) => a.name.localeCompare(b.name));
+ return mergeDataSourcesWithConnections(assignedDataSources, directQueryConnections);
} catch (error) {
notifications?.toasts.addDanger(
i18n.translate('workspace.detail.dataSources.error.message', {