Skip to content

Commit

Permalink
remove duplicate EuiPage (opensearch-project#34)
Browse files Browse the repository at this point in the history
* remove duplicate EuiPage

Signed-off-by: Hailong Cui <[email protected]>

* fix: remove duplicate workspace template

Signed-off-by: Hailong Cui <[email protected]>

---------

Signed-off-by: Hailong Cui <[email protected]>
  • Loading branch information
Hailong-am committed Jul 18, 2023
1 parent 9837a65 commit eed2c37
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
15 changes: 5 additions & 10 deletions src/plugins/workspace/public/components/workspace_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -28,15 +27,11 @@ export const WorkspaceApp = ({ appBasePath }: { appBasePath: string }) => {

return (
<I18nProvider>
<EuiPage>
<EuiPageBody component="main">
<Switch>
{ROUTES.map(({ path, Component, exact }) => (
<Route key={path} path={path} render={() => <Component />} exact={exact ?? false} />
))}
</Switch>
</EuiPageBody>
</EuiPage>
<Switch>
{ROUTES.map(({ path, Component, exact }) => (
<Route key={path} path={path} render={() => <Component />} exact={exact ?? false} />
))}
</Switch>
</I18nProvider>
);
};
10 changes: 8 additions & 2 deletions src/plugins/workspace/public/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,27 @@ export function useWorkspaceTemplate(application: ApplicationStart) {
const applications = useObservable(application.applications$);

return useMemo(() => {
const tempWsTemplates = [] as WorkspaceTemplate[];
let workspaceTemplates = [] as WorkspaceTemplate[];
const templateFeatureMap = new Map<string, PublicAppInfo[]>();

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);
templateFeatureMap.set(template.id, features);
}
});

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));
}

Expand Down

0 comments on commit eed2c37

Please sign in to comment.