diff --git a/src/plugins/workspace/public/components/workspace_app.tsx b/src/plugins/workspace/public/components/workspace_app.tsx
index 54c326bc551f..ae2720d75b30 100644
--- a/src/plugins/workspace/public/components/workspace_app.tsx
+++ b/src/plugins/workspace/public/components/workspace_app.tsx
@@ -4,7 +4,6 @@
*/
import React, { useEffect } from 'react';
-import { EuiPage, EuiPageBody } from '@elastic/eui';
import { I18nProvider } from '@osd/i18n/react';
import { Route, Switch, useLocation } from 'react-router-dom';
@@ -28,15 +27,11 @@ export const WorkspaceApp = ({ appBasePath }: { appBasePath: string }) => {
return (
-
-
-
- {ROUTES.map(({ path, Component, exact }) => (
- } exact={exact ?? false} />
- ))}
-
-
-
+
+ {ROUTES.map(({ path, Component, exact }) => (
+ } exact={exact ?? false} />
+ ))}
+
);
};
diff --git a/src/plugins/workspace/public/hooks.ts b/src/plugins/workspace/public/hooks.ts
index 636a00742146..1132aac04e73 100644
--- a/src/plugins/workspace/public/hooks.ts
+++ b/src/plugins/workspace/public/hooks.ts
@@ -23,13 +23,14 @@ export function useWorkspaceTemplate(application: ApplicationStart) {
const applications = useObservable(application.applications$);
return useMemo(() => {
+ const tempWsTemplates = [] as WorkspaceTemplate[];
let workspaceTemplates = [] as WorkspaceTemplate[];
const templateFeatureMap = new Map();
if (applications) {
applications.forEach((app) => {
const { workspaceTemplate: templates = [] } = app;
- workspaceTemplates.push(...templates);
+ tempWsTemplates.push(...templates);
for (const template of templates) {
const features = templateFeatureMap.get(template.id) || [];
features.push(app);
@@ -37,7 +38,12 @@ export function useWorkspaceTemplate(application: ApplicationStart) {
}
});
- workspaceTemplates = [...new Set(workspaceTemplates)];
+ workspaceTemplates = tempWsTemplates.reduce((list, curr) => {
+ if (!list.find((ws) => ws.id === curr.id)) {
+ list.push(curr);
+ }
+ return list;
+ }, [] as WorkspaceTemplate[]);
workspaceTemplates.sort((a, b) => (a.order || 0) - (b.order || 0));
}