Skip to content

Commit

Permalink
feat: draft version
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed May 13, 2024
1 parent 06af0a4 commit 1edbb40
Show file tree
Hide file tree
Showing 2 changed files with 132 additions and 17 deletions.
6 changes: 0 additions & 6 deletions public/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,6 @@ export default class Main extends Component<MainProps, MainState> {
<ModalRoot services={services} />
<EuiPage restrictWidth="100%">
{/* Hide side navigation bar when creating or editing rollup job*/}
{!HIDDEN_NAV_ROUTES.includes(pathname) &&
!HIDDEN_NAV_STARTS_WITH_ROUTE.some((item) => pathname.startsWith(item)) ? (
<EuiPageSideBar style={{ minWidth: 200 }}>
<EuiSideNav style={{ width: 200 }} items={sideNav} />
</EuiPageSideBar>
) : null}
<EuiPageBody>
<Switch>
<Route
Expand Down
143 changes: 132 additions & 11 deletions public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { i18n } from "@osd/i18n";
import { IndexManagementPluginStart, IndexManagementPluginSetup } from ".";
import {
AppCategory,
AppMountParameters,
CoreSetup,
CoreStart,
Expand All @@ -24,6 +25,34 @@ interface IndexManagementSetupDeps {
dataSourceManagement?: DataSourceManagementPluginSetup;
}

const DATA_ADMINISTRATION: AppCategory = {
id: "DATA_ADMINISTRATION",
label: "Data administration",
order: 8000,
euiIconType: "wrench",
};

const ISM_category: Record<string, AppCategory & { group?: AppCategory }> = {
indexes: {
id: "indexes",
label: i18n.translate("core.ui.indexesNavList.label", {
defaultMessage: "Indexes",
}),
order: 9000,
euiIconType: "managementApp",
group: DATA_ADMINISTRATION,
},
backup: {
id: "backup",
label: i18n.translate("core.ui.backupNavList.label", {
defaultMessage: "Index backup and recovery",
}),
order: 9010,
euiIconType: "managementApp",
group: DATA_ADMINISTRATION,
},
};

export class IndexManagementPlugin implements Plugin<IndexManagementPluginSetup, IndexManagementPluginStart, IndexManagementSetupDeps> {
constructor(private readonly initializerContext: PluginInitializerContext) {
// can retrieve config from initializerContext
Expand Down Expand Up @@ -52,27 +81,119 @@ export class IndexManagementPlugin implements Plugin<IndexManagementPluginSetup,
});
}

const mountWrapper = async (params: AppMountParameters, defaultRoutes: string) => {
const { renderApp } = await import("./index_management_app");
const [coreStart, depsStart] = await core.getStartServices();
return renderApp(coreStart, depsStart, params, defaultRoutes, dataSourceManagement);
};

core.application.register({
id: "opensearch_index_management_dashboards",
title: "Index Management",
id: `opensearch_index_management_dashboards_${encodeURIComponent(ROUTES.INDEX_POLICIES)}`,
title: "Indexes",
order: 8040,
category: ISM_category.indexes,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.INDICES);
},
});

core.application.register({
id: `opensearch_index_management_dashboards_${encodeURIComponent(ROUTES.DATA_STREAMS)}`,
title: "Data streams",
order: 8050,
category: ISM_category.indexes,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.DATA_STREAMS);
},
});

core.application.register({
id: `opensearch_index_management_dashboards_${encodeURIComponent(ROUTES.ALIASES)}`,
title: "Index alias",
order: 8060,
category: ISM_category.indexes,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.ALIASES);
},
});

core.application.register({
id: `opensearch_index_management_dashboards`,
title: "Index state management policies",
order: 9010,
category: DEFAULT_APP_CATEGORIES.management,
category: ISM_category.indexes,
mount: async (params: AppMountParameters) => {
const { renderApp } = await import("./index_management_app");
const [coreStart, depsStart] = await core.getStartServices();
return renderApp(coreStart, depsStart, params, ROUTES.INDEX_POLICIES, dataSourceManagement);
return mountWrapper(params, ROUTES.INDEX_POLICIES);
},
});

core.application.register({
id: `opensearch_index_management_dashboards_${encodeURIComponent(ROUTES.TEMPLATES)}`,
title: "Index templates",
order: 9011,
category: ISM_category.indexes,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.TEMPLATES);
},
});

core.application.register({
id: `opensearch_index_management_dashboards_${encodeURIComponent(ROUTES.NOTIFICATIONS)}`,
title: "Index notification settings",
order: 9012,
category: ISM_category.indexes,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.NOTIFICATIONS);
},
});

core.application.register({
id: `opensearch_index_management_dashboards_${encodeURIComponent(ROUTES.ROLLUPS)}`,
title: "Rollup jobs",
order: 9013,
category: ISM_category.indexes,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.ROLLUPS);
},
});

core.application.register({
id: `opensearch_index_management_dashboards_${encodeURIComponent(ROUTES.TRANSFORMS)}`,
title: "Transform jobs",
order: 9014,
category: ISM_category.indexes,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.TRANSFORMS);
},
});

core.application.register({
id: "opensearch_snapshot_management_dashboards",
title: "Snapshot Management",
title: "Index snapshots",
order: 9020,
category: DEFAULT_APP_CATEGORIES.management,
category: ISM_category.backup,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.SNAPSHOT_POLICIES);
},
});

core.application.register({
id: `opensearch_index_management_dashboards_${encodeURIComponent(ROUTES.SNAPSHOT_POLICIES)}`,
title: "Index snapshot policies",
order: 9030,
category: ISM_category.backup,
mount: async (params: AppMountParameters) => {
return mountWrapper(params, ROUTES.SNAPSHOT_POLICIES);
},
});

core.application.register({
id: `opensearch_index_management_dashboards_${encodeURIComponent(ROUTES.REPOSITORIES)}`,
title: "Index snapshot repositories",
order: 9040,
category: ISM_category.backup,
mount: async (params: AppMountParameters) => {
const { renderApp } = await import("./index_management_app");
const [coreStart, depsStart] = await core.getStartServices();
return renderApp(coreStart, depsStart, params, ROUTES.SNAPSHOT_POLICIES, dataSourceManagement);
return mountWrapper(params, ROUTES.REPOSITORIES);
},
});

Expand Down

0 comments on commit 1edbb40

Please sign in to comment.