{legacyHome}
diff --git a/src/plugins/home/public/application/home_render.tsx b/src/plugins/home/public/application/home_render.tsx
new file mode 100644
index 000000000000..2f974d281099
--- /dev/null
+++ b/src/plugins/home/public/application/home_render.tsx
@@ -0,0 +1,149 @@
+/*
+ * Copyright OpenSearch Contributors
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+import React from 'react';
+
+import { CoreStart } from 'opensearch-dashboards/public';
+import { Page } from '../../../content_management/public/services';
+import { toMountPoint } from '../../../opensearch_dashboards_react/public';
+
+export const GET_STARTED_SECTION_ID = 'homepage_get_started';
+
+/**
+ * Example: render a arbitrary component
+ */
+const renderHomeCard = () => Hello World!
;
+
+export const initHome = (page: Page, core: CoreStart) => {
+ /**
+ * init get started section
+ */
+ page.addContent('get_started', {
+ id: 'get_started_1',
+ kind: 'card',
+ order: 5000,
+ description: 'description 1',
+ title: 'title 1',
+ onClick: () => {
+ const modal = core.overlays.openModal(
+ toMountPoint(
+
+ test
+
+ )
+ );
+ },
+ });
+ page.addContent('get_started', {
+ id: 'get_started_2',
+ kind: 'card',
+ order: 2000,
+ description: 'description 2',
+ title: 'title 2',
+ onClick: () => {
+ const modal = core.overlays.openModal(
+ toMountPoint(
+
+ test
+
+ )
+ );
+ },
+ });
+ page.addContent('get_started', {
+ id: 'get_started_3',
+ kind: 'card',
+ order: 3000,
+ description: 'description 3',
+ title: 'title 3',
+ onClick: () => {
+ const modal = core.overlays.openModal(
+ toMountPoint(
+
+ test
+
+ )
+ );
+ },
+ });
+ page.addContent('get_started', {
+ id: 'get_started_4',
+ kind: 'card',
+ order: 4000,
+ description: 'description 4',
+ title: 'title 4',
+ onClick: () => {
+ const modal = core.overlays.openModal(
+ toMountPoint(
+
+ test
+
+ )
+ );
+ },
+ });
+
+ /**
+ * Example: embed a dashboard to homepage
+ */
+ page.addContent('some_dashboard', {
+ id: 'dashboard_1',
+ kind: 'dashboard',
+ order: 0,
+ input: {
+ kind: 'static',
+ id: '722b74f0-b882-11e8-a6d9-e546fe2bba5f',
+ },
+ });
+
+ /**
+ * Example: embed visualization to homepage
+ */
+ page.addContent('service_cards', {
+ id: 'vis_1',
+ order: 0,
+ kind: 'visualization',
+ input: {
+ kind: 'dynamic',
+ get: () => {
+ return new Promise((resolve) => {
+ setTimeout(() => {
+ resolve('4b3ec120-b892-11e8-a6d9-e546fe2bba5f');
+ }, 500);
+ });
+ },
+ },
+ });
+ page.addContent('service_cards', {
+ id: 'vis_2',
+ order: 10,
+ kind: 'visualization',
+ input: {
+ kind: 'dynamic',
+ get: () => {
+ return new Promise((resolve) => {
+ setTimeout(() => {
+ resolve('4b3ec120-b892-11e8-a6d9-e546fe2bba5f');
+ }, 500);
+ });
+ },
+ },
+ });
+ page.addContent('service_cards', {
+ id: 'vis_3',
+ order: 20,
+ kind: 'visualization',
+ input: {
+ kind: 'static',
+ id: '4b3ec120-b892-11e8-a6d9-e546fe2bba5f',
+ },
+ });
+ page.addContent('service_cards', {
+ id: 'vis_4',
+ order: 30,
+ kind: 'custom',
+ render: renderHomeCard,
+ });
+};
diff --git a/src/plugins/home/public/application/opensearch_dashboards_services.ts b/src/plugins/home/public/application/opensearch_dashboards_services.ts
index 727cb03c10ab..b7bf14f1f3ab 100644
--- a/src/plugins/home/public/application/opensearch_dashboards_services.ts
+++ b/src/plugins/home/public/application/opensearch_dashboards_services.ts
@@ -48,6 +48,8 @@ import { SectionTypeService } from '../services/section_type';
import { ConfigSchema } from '../../config';
import { HomePluginBranding } from '..';
import { DataSourcePluginStart } from '../../../data_source/public';
+import { EmbeddableStart } from '../../../embeddable/public';
+import { ContentManagementPluginStart } from '../../../content_management/public';
export interface HomeOpenSearchDashboardsServices {
indexPatternService: any;
@@ -56,6 +58,8 @@ export interface HomeOpenSearchDashboardsServices {
application: ApplicationStart;
uiSettings: IUiSettingsClient;
urlForwarding: UrlForwardingStart;
+ contentManagement: ContentManagementPluginStart;
+ embeddable: EmbeddableStart;
homeConfig: ConfigSchema;
featureCatalogue: FeatureCatalogueRegistry;
http: HttpStart;
diff --git a/src/plugins/home/public/plugin.ts b/src/plugins/home/public/plugin.ts
index a9e4cb263e88..d5fd8b55e1dc 100644
--- a/src/plugins/home/public/plugin.ts
+++ b/src/plugins/home/public/plugin.ts
@@ -64,17 +64,27 @@ import { PLUGIN_ID, HOME_APP_BASE_PATH, IMPORT_SAMPLE_DATA_APP_ID } from '../com
import { DataSourcePluginStart } from '../../data_source/public';
import { workWithDataSection } from './application/components/homepage/sections/work_with_data';
import { learnBasicsSection } from './application/components/homepage/sections/learn_basics';
+import {
+ ContentManagementPluginSetup,
+ ContentManagementPluginStart,
+} from '../../content_management/public';
+import { EmbeddableSetup, EmbeddableStart } from '../../embeddable/public';
+import { initHome } from './application/home_render';
export interface HomePluginStartDependencies {
data: DataPublicPluginStart;
telemetry?: TelemetryPluginStart;
urlForwarding: UrlForwardingStart;
dataSource?: DataSourcePluginStart;
+ contentManagement: ContentManagementPluginStart;
+ embeddable: EmbeddableStart;
}
export interface HomePluginSetupDependencies {
usageCollection?: UsageCollectionSetup;
urlForwarding: UrlForwardingSetup;
+ contentManagement: ContentManagementPluginSetup;
+ embeddable: EmbeddableSetup;
}
export class HomePublicPlugin
@@ -94,7 +104,7 @@ export class HomePublicPlugin
public setup(
core: CoreSetup,
- { urlForwarding, usageCollection }: HomePluginSetupDependencies
+ { urlForwarding, usageCollection, contentManagement }: HomePluginSetupDependencies
): HomePublicPluginSetup {
const setCommonService = async (
homeOpenSearchDashboardsServices?: Partial
@@ -104,7 +114,14 @@ export class HomePublicPlugin
: () => {};
const [
coreStart,
- { telemetry, data, urlForwarding: urlForwardingStart, dataSource },
+ {
+ telemetry,
+ data,
+ urlForwarding: urlForwardingStart,
+ dataSource,
+ embeddable,
+ contentManagement: contentManagementStart,
+ },
] = await core.getStartServices();
setServices({
trackUiMetric,
@@ -123,6 +140,8 @@ export class HomePublicPlugin
indexPatternService: data.indexPatterns,
environmentService: this.environmentService,
urlForwarding: urlForwardingStart,
+ contentManagement: contentManagementStart,
+ embeddable: embeddable,
homeConfig: this.initializerContext.config.get(),
tutorialService: this.tutorialService,
featureCatalogue: this.featuresCatalogueRegistry,
@@ -132,6 +151,7 @@ export class HomePublicPlugin
...homeOpenSearchDashboardsServices,
});
};
+
core.application.register({
id: PLUGIN_ID,
title: 'Home',
@@ -191,6 +211,25 @@ export class HomePublicPlugin
sectionTypes.registerSection(workWithDataSection);
sectionTypes.registerSection(learnBasicsSection);
+ const page = contentManagement.registerPage({ id: 'home', title: 'Home' });
+ page.createSection({
+ id: 'service_cards',
+ order: 3000,
+ kind: 'dashboard',
+ });
+ page.createSection({
+ id: 'some_dashboard',
+ order: 2000,
+ title: 'test dashboard',
+ kind: 'dashboard',
+ });
+ page.createSection({
+ id: 'get_started',
+ order: 1000,
+ title: 'Define your path forward with OpenSearch',
+ kind: 'card',
+ });
+
return {
featureCatalogue,
environment: { ...this.environmentService.setup() },
@@ -199,12 +238,20 @@ export class HomePublicPlugin
};
}
- public start(core: CoreStart, { data, urlForwarding }: HomePluginStartDependencies) {
+ public start(
+ core: CoreStart,
+ { data, urlForwarding, contentManagement }: HomePluginStartDependencies
+ ) {
const {
application: { capabilities, currentAppId$ },
http,
} = core;
+ const page = contentManagement.getPage('home');
+ if (page) {
+ initHome(page, core);
+ }
+
this.featuresCatalogueRegistry.start({ capabilities });
this.sectionTypeService.start({ core, data });