From 5673c0029d38d323eae707a1e3460323ae6576ca Mon Sep 17 00:00:00 2001 From: Ajay Gupta <116780042+ajygupta@users.noreply.github.com> Date: Tue, 20 Dec 2022 17:01:00 +0530 Subject: [PATCH] Point in time management plugin and empty state (#2813) * point in time management plugin and empty state Signed-off-by: Ajay Gupta * updated to new license header Signed-off-by: Ajay Gupta * [Vis Builder] Rename wizard on save modal and visualization table (#2645) * Rename wizard on save modal and visualization table Change the wizard reference in save modal title, toggle and visualization table Signed-off-by: abbyhu2000 * Save visualization on save modal, VisBuilder for chart type Signed-off-by: abbyhu2000 * No experimental flag Signed-off-by: abbyhu2000 Signed-off-by: abbyhu2000 Signed-off-by: Ajay Gupta * [@osd/cross-platform] Adds cross-platform helpers (#2681) Signed-off-by: Miki Signed-off-by: Miki Signed-off-by: Ajay Gupta * Change save object type, wizard id and name to visBuilder (#2673) * Change save object type, wizard ID and Name to visBuilder Signed-off-by: abbyhu2000 * Rename wizard in functional tests Signed-off-by: abbyhu2000 * Finalize plugin-id and plugin-name and saved-object-type Signed-off-by: abbyhu2000 * Change official name to VisBuilder Signed-off-by: abbyhu2000 * Delete migration Signed-off-by: abbyhu2000 * Fix functional test Signed-off-by: abbyhu2000 * Update snapshot Signed-off-by: abbyhu2000 Signed-off-by: abbyhu2000 Signed-off-by: Ajay Gupta * [CVE] Bump loader-utils to 2.0.3 to fix CVE-2022-37601 (#2689) * [CVE] Bump loader-utils to 2.0.3 to fix CVE-2022-37601 Signed-off-by: Zilong Xia * Update CHANGELOG.md Signed-off-by: Zilong Xia Signed-off-by: Ajay Gupta * Add extension point in saved object management to register namespaces and show filter (#2656) * Create filter registry for saved object management to make filters extensible Signed-off-by: Craig Perkins * WIP on making fetchCounts generic Signed-off-by: Craig Perkins * First step at making scroll_counts generic Signed-off-by: Craig Perkins * Work on getting other filter counts with same object count endpoint Signed-off-by: Craig Perkins * Get tenant count options to display Signed-off-by: Craig Perkins * Extend find to work with namespaces for saved objects Signed-off-by: Craig Perkins * Add missing filterFields Signed-off-by: Craig Perkins * Update jest tests Signed-off-by: Craig Perkins * Update saved_objects_table snapshot Signed-off-by: Craig Perkins * Append index to id to make unique Signed-off-by: Craig Perkins * Add semi-colon Signed-off-by: Craig Perkins * Fix saved objects table tests with new id scheme Signed-off-by: Craig Perkins * Only append idx on config type to ensure Advanced Settings have a unique id across tenants Signed-off-by: Craig Perkins * Remove itemsClone in favor of showing only Advanced Settings of current tenant Signed-off-by: Craig Perkins * Revert snapshots in table.test.tsx Signed-off-by: Craig Perkins * Add additional parse_query test Signed-off-by: Craig Perkins * Add comma Signed-off-by: Craig Perkins * Create namespaceRegistry to decouple security dashboards plugin and osd core Signed-off-by: Craig Perkins * Add ability to register an alias Signed-off-by: Craig Perkins * Update parse query and add to CHANGELOG Signed-off-by: Craig Perkins * Remove commented out code Signed-off-by: Craig Perkins * Address code review comments Signed-off-by: Craig Perkins * Override i18n if alias is regitered Signed-off-by: Craig Perkins Signed-off-by: Craig Perkins Signed-off-by: Ajay Gupta * Removed Leftover X Pack references #2517 (#2638) x-pack references in the code are removed as per the given files in #2517 Issue Resolved: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2517 Signed-off-by: vimal K Signed-off-by: Ajay Gupta * Revert "[@osd/cross-platform] Adds cross-platform helpers (#2681)" (#2694) This reverts commit 887093d2d243045029b644680a3e8d0150318143. Now that downstream plugins and projects are unblocked from builds, we want to make these changes following our standard processes and automated checks Signed-off-by: Josh Romero Signed-off-by: Josh Romero Signed-off-by: Ajay Gupta * [MD] Add design documents of multiple data source feature (#2538) * Add MD design documents, including high level design, user stories, client management detailed design Signed-off-by: Su Signed-off-by: Ajay Gupta * Adds @osd/cross-platform (#2703) * Adds helper functions, @osd/cross-platform, to work around the differences of platforms Signed-off-by: Miki Signed-off-by: Ajay Gupta * [MD]Update MD data source documentation link (#2693) Signed-off-by: Kristen Tian Signed-off-by: Kristen Tian Signed-off-by: Ajay Gupta * Add `Skip-Changelog` label to skip changelog verification on certain PRs (#2726) Signed-off-by: Miki Signed-off-by: Miki Signed-off-by: Ajay Gupta * Enable visbuilder by default (#2725) * Enable visbuilder by default Signed-off-by: Ashwin P Chandran * Adds changelog entry Signed-off-by: Ashwin P Chandran Signed-off-by: Ashwin P Chandran Signed-off-by: Ajay Gupta * [Save Object Aggregation View] Fix for export all after scroll count response changed in PR#2656 (#2696) * Fix for filterSavedObjectCounts for namespaceRegistry Signed-off-by: Craig Perkins * Fix saved_objects_table.test.tsx Signed-off-by: Craig Perkins * Add to CHANGELOG Signed-off-by: Craig Perkins * Correct reference to namespacesToInclude Signed-off-by: Craig Perkins * Use filteredTypeCounts Signed-off-by: Craig Perkins * Use namespaces similar to types for fetchObjects Signed-off-by: Craig Perkins * Use _all to represent query for all namespaces Signed-off-by: Craig Perkins * Pass all registered namespaces Signed-off-by: Craig Perkins * Switch back signature of scroll_count Signed-off-by: Craig Perkins * Change countOptions to options Signed-off-by: Craig Perkins * Use not not instead of in Signed-off-by: Craig Perkins * Filter namespaces to only include namespace that have been registered Signed-off-by: Craig Perkins * Add filterQuery with tests Signed-off-by: Craig Perkins * Update license headers and address review comments Signed-off-by: Craig Perkins Signed-off-by: Craig Perkins Signed-off-by: Ajay Gupta * Update backport workflow to ignore changelog conflicts (#2729) Signed-off-by: Miki Signed-off-by: Miki Signed-off-by: Ajay Gupta * Tweak multiple data source design doc (#2724) Signed-off-by: Kristen Tian Signed-off-by: Kristen Tian Signed-off-by: Ajay Gupta * [Chore] Refactor and improve Discover field summaries (#2391) * [Chore] Refactor and improve field summaries * Convert to typescript * Fix types * Add tests Signed-off-by: Josh Romero * [Test] Update functional test Groups are now naturally sorted by key, which requires selecting a different date filter Signed-off-by: Josh Romero * [Chore] Add changelog entry Signed-off-by: Josh Romero * [Chore] Refactor columns passing, fix bugs * pass columns explicitly as props * fix branding in core mocks * fix `toBeUndefined()` usage in tests * remove leftover comment * fix test subject * condense types Signed-off-by: Josh Romero Signed-off-by: Josh Romero Signed-off-by: Ajay Gupta * Removes Add Integration button (#2723) * Removes Add Integration button Issue Resolved: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2684 Signed-off-by: Bandini Bhopi * Adds changelog entry Signed-off-by: Bandini Bhopi Signed-off-by: Bandini Bhopi Signed-off-by: Ajay Gupta * Prevent backport workflow from running on umerged PRs (#2746) Signed-off-by: Miki Signed-off-by: Miki Signed-off-by: Ajay Gupta * [Vis Builder] Enable VisBuilder cypress tests (#2728) * Enable VisBuilder cypress tests Signed-off-by: Ashwin P Chandran * Adds changelog and fix env Signed-off-by: Ashwin P Chandran * Run all tests Signed-off-by: Ashwin P Chandran Signed-off-by: Ashwin P Chandran Signed-off-by: Ajay Gupta * [CI] update backport custom branch name (#2766) GitHub action for backporting got updated to change custom branch to head template. This was causing issues in clean up and skipping steps. Issue: n/a Signed-off-by: Kawika Avilla Signed-off-by: Ajay Gupta * [Legacy Maps Plugin] Prevent reverse-tabnabbing (#2540) Signed-off-by: Miki Signed-off-by: Miki Signed-off-by: Ajay Gupta * change geckodriver version to make consistency (#2772) * change geckodriver version to make consistency Issue Resolved: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2771 Signed-off-by: Anan Zhuang * combine https-proxy-agent in yarn.lock Signed-off-by: Anan Zhuang Signed-off-by: Anan Zhuang Signed-off-by: Ajay Gupta * [Vis Builder] Add an experimental table visualization in vis builder (#2705) * [Vis Builder] Add an experimental table visualization in vis builder In this PR, we hook up an experimental table vis in vis builder. This table vis is a refactor of previous table. It is written in React and DataGrid component. In this PR, we did two main things: * add an experimental table visualization * enable it in vis builder Issue Resolved (hook up table in vis builder): https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2704 The experimental table vis has all the features from current table, including * restore table vis in react using a Datagrid component * datagrid component does not support splitted grids. For future transfer to OUI Datagrid, we create a tableGroup in visData for splitted grids. * restore basic pagenation, sort and format. * implement datagrid columns * display column title correctly * deangular and re-use formatted column * convert formatted column to data grid column * restore filter in and filter out value functions * format table cell to show Date and percent * restore showTotal feature: it allows table vis to show total, avg, min, max and count statics on count * restore export csv feature to table vis * split table in rows and columns Beside of restoring original features, there are some changes: * [IMPROVE] remove repeated column from split tables Currently, when we split table by columns, the split column is shown both in the table title and as a separate column. This is not needed. In this PR, we remove the repeated column in split tables in col. * [NEW FEATURE] adjustable table column width In the new table visualization, customer can adjust the column width as needed. Issue Resolved: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2212 https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2213 https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2305 https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2379 https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2579 Since this is a hookup PR, we remove un-used table vis types and options because they could be defined in vis builder. We also create follow up issues for some un-resolved PR comments. Signed-off-by: Anan Zhuang * remove unused scss tyle Signed-off-by: Anan Zhuang * remove total func and percentage col total func and percentage col are two features that we might need to remove or re-invent for future table vis. For hookup purpose, it doesn't make sense to include some features that we would like to remove. this PR removes total func and percentage col in both table vis and vis builder Signed-off-by: Anan Zhuang * comment out cellActions currently filter in/out cell doesn't function in vis builder. we will coumment out cell actions for now. Signed-off-by: Anan Zhuang Signed-off-by: Anan Zhuang Signed-off-by: Ajay Gupta * Security-CVEs fixes guidelines (#2674) * Security-CVEs fixes guidelines Signed-off-by: himsgupta1122 * styling Signed-off-by: himsgupta1122 * add example Signed-off-by: himsgupta1122 * add documention Signed-off-by: himsgupta1122 Signed-off-by: himsgupta1122 Signed-off-by: Ajay Gupta * [MD] Update default audit log path (#2793) - Fix the /tmp path issue seen on windows platform. - Change audit log to disable by default. Signed-off-by: Kristen Tian Signed-off-by: Kristen Tian Signed-off-by: Ajay Gupta * [Vis Builder] Add field summary popovers (#2682) * [Vis Builder] Add field summary popovers Much of the functionality was ported from `Discover`, but largely refactored. * Add utilities to get sampled hit summaries by field * Add popover summaries * Slight refactor of special `Count` pseudofield * Use observable subscription to update sampled hits Fixes #950 Signed-off-by: Josh Romero * [Vis Builder] Add additional unit tests Signed-off-by: Josh Romero * [VisBuilder] Update naming of summary field components Signed-off-by: Josh Romero * [VisBuilder] Avoid prop passing by extracting custom hooks - refactor meta field identification Signed-off-by: Josh Romero * [VisBuilder] Add TODOs with issue links, fix test ID Restores previous test ID for count field button Signed-off-by: Josh Romero Signed-off-by: Josh Romero Signed-off-by: Ajay Gupta * Bump makelogs to remove dependency on got (#2801) * Also dusted off the lock file a bit Fixes #1764 Signed-off-by: Miki Signed-off-by: Miki Signed-off-by: Ajay Gupta * Change VisBuilder flag for docker config (#2804) Signed-off-by: Ashwin P Chandran Signed-off-by: Ashwin P Chandran Signed-off-by: Ajay Gupta * addressed review comments Signed-off-by: Ajay Gupta * addressed review comments Signed-off-by: Ajay Gupta * addressed review comments Signed-off-by: Ajay Gupta * updated unit tests Signed-off-by: Ajay Gupta * dummy commit to retry build Signed-off-by: Ajay Gupta * address suggestions Signed-off-by: Ajay Gupta Signed-off-by: Ajay Gupta Signed-off-by: abbyhu2000 Signed-off-by: Miki Signed-off-by: Zilong Xia Signed-off-by: Craig Perkins Signed-off-by: vimal K Signed-off-by: Josh Romero Signed-off-by: Su Signed-off-by: Kristen Tian Signed-off-by: Ashwin P Chandran Signed-off-by: Bandini Bhopi Signed-off-by: Kawika Avilla Signed-off-by: Miki Signed-off-by: Anan Zhuang Signed-off-by: himsgupta1122 Co-authored-by: Ajay Gupta Co-authored-by: Qingyang(Abby) Hu Co-authored-by: Miki Co-authored-by: ZilongX <99905560+ZilongX@users.noreply.github.com> Co-authored-by: Craig Perkins Co-authored-by: Vimal K <35750792+vimalMK@users.noreply.github.com> Co-authored-by: Josh Romero Co-authored-by: Zhongnan Su Co-authored-by: Kristen Tian <105667444+kristenTian@users.noreply.github.com> Co-authored-by: Ashwin P Chandran Co-authored-by: Craig Perkins Co-authored-by: Bandini <63824432+bandinib-amzn@users.noreply.github.com> Co-authored-by: Kawika Avilla Co-authored-by: Anan Zhuang Co-authored-by: himsgupta1122 <115103225+himsgupta1122@users.noreply.github.com> --- CHANGELOG.md | 1 + .../bin/opensearch-dashboards-docker | 1 + .../opensearch_dashboards.json | 10 +++ .../__snapshots__/empty_state.test.tsx.snap | 84 +++++++++++++++++++ .../empty_state/empty_state.test.tsx | 16 ++++ .../components/empty_state/empty_state.tsx | 78 +++++++++++++++++ .../public/components/empty_state/index.ts | 6 ++ .../public/components/index.ts | 6 ++ .../point_in_time_management/public/index.ts | 12 +++ .../public/management_app/index.ts | 6 ++ .../mount_management_section.tsx | 38 +++++++++ .../point_in_time_management/public/plugin.ts | 60 +++++++++++++ .../point_in_time_management/public/types.ts | 27 ++++++ .../point_in_time_management/server/index.ts | 21 +++++ .../point_in_time_management/server/plugin.ts | 40 +++++++++ .../server/routes/index.ts | 22 +++++ .../point_in_time_management/server/types.ts | 9 ++ 17 files changed, 437 insertions(+) create mode 100644 src/plugins/point_in_time_management/opensearch_dashboards.json create mode 100644 src/plugins/point_in_time_management/public/components/empty_state/__snapshots__/empty_state.test.tsx.snap create mode 100644 src/plugins/point_in_time_management/public/components/empty_state/empty_state.test.tsx create mode 100644 src/plugins/point_in_time_management/public/components/empty_state/empty_state.tsx create mode 100644 src/plugins/point_in_time_management/public/components/empty_state/index.ts create mode 100644 src/plugins/point_in_time_management/public/components/index.ts create mode 100644 src/plugins/point_in_time_management/public/index.ts create mode 100644 src/plugins/point_in_time_management/public/management_app/index.ts create mode 100644 src/plugins/point_in_time_management/public/management_app/mount_management_section.tsx create mode 100644 src/plugins/point_in_time_management/public/plugin.ts create mode 100644 src/plugins/point_in_time_management/public/types.ts create mode 100644 src/plugins/point_in_time_management/server/index.ts create mode 100644 src/plugins/point_in_time_management/server/plugin.ts create mode 100644 src/plugins/point_in_time_management/server/routes/index.ts create mode 100644 src/plugins/point_in_time_management/server/types.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a208b4f1f40..38c648238852 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - [Vis Builder] Add field summary popovers ([#2682](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2682)) - [I18n] Register ru, ru-RU locale ([#2817](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2817)) - Add yarn opensearch arg to setup plugin dependencies ([#2544](https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2544)) +- [Point in TIme] Add management plugin shell and empty state ([#2813](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2813)) ### 🐛 Bug Fixes diff --git a/src/dev/build/tasks/os_packages/docker_generator/resources/bin/opensearch-dashboards-docker b/src/dev/build/tasks/os_packages/docker_generator/resources/bin/opensearch-dashboards-docker index a5cefbc2397c..76b79e8fca9c 100755 --- a/src/dev/build/tasks/os_packages/docker_generator/resources/bin/opensearch-dashboards-docker +++ b/src/dev/build/tasks/os_packages/docker_generator/resources/bin/opensearch-dashboards-docker @@ -160,6 +160,7 @@ opensearch_dashboards_vars=( data_source.audit.appender.layout.kind data_source.audit.appender.layout.highlight data_source.audit.appender.layout.pattern + pit.enabled ) longopts='' diff --git a/src/plugins/point_in_time_management/opensearch_dashboards.json b/src/plugins/point_in_time_management/opensearch_dashboards.json new file mode 100644 index 000000000000..1757278f19a6 --- /dev/null +++ b/src/plugins/point_in_time_management/opensearch_dashboards.json @@ -0,0 +1,10 @@ +{ + "id": "pit", + "version": "1.0.0", + "opensearchDashboardsVersion": "opensearchDashboards", + "server": true, + "ui": true, + "requiredPlugins": ["navigation", "management"], + "optionalPlugins": [], + "requiredBundles": ["opensearchDashboardsReact"] +} diff --git a/src/plugins/point_in_time_management/public/components/empty_state/__snapshots__/empty_state.test.tsx.snap b/src/plugins/point_in_time_management/public/components/empty_state/__snapshots__/empty_state.test.tsx.snap new file mode 100644 index 000000000000..cc1ee347208f --- /dev/null +++ b/src/plugins/point_in_time_management/public/components/empty_state/__snapshots__/empty_state.test.tsx.snap @@ -0,0 +1,84 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`EmptyState should render normally 1`] = ` + + + + + +

+ +

+
+
+ + + +
+ +

+ +

+
+ + + + + No point in time objects have been created yet. + + + + + + + +
+
+`; diff --git a/src/plugins/point_in_time_management/public/components/empty_state/empty_state.test.tsx b/src/plugins/point_in_time_management/public/components/empty_state/empty_state.test.tsx new file mode 100644 index 000000000000..82393e830152 --- /dev/null +++ b/src/plugins/point_in_time_management/public/components/empty_state/empty_state.test.tsx @@ -0,0 +1,16 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React from 'react'; +import { EmptyState } from './empty_state'; +import { shallow } from 'enzyme'; + +describe('EmptyState', () => { + it('should render normally', () => { + const component = shallow(); + + expect(component).toMatchSnapshot(); + }); +}); diff --git a/src/plugins/point_in_time_management/public/components/empty_state/empty_state.tsx b/src/plugins/point_in_time_management/public/components/empty_state/empty_state.tsx new file mode 100644 index 000000000000..650c742c6744 --- /dev/null +++ b/src/plugins/point_in_time_management/public/components/empty_state/empty_state.tsx @@ -0,0 +1,78 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React from 'react'; +import { FormattedMessage } from '@osd/i18n/react'; +import { + EuiPageContentHeader, + EuiPageContentHeaderSection, + EuiTitle, + EuiPageContent, + EuiSpacer, + EuiText, + EuiPageContentBody, + EuiFlexItem, + EuiFlexGroup, + EuiButton, +} from '@elastic/eui'; + +export const EmptyState = () => { + return ( + <> + + + + +

+ +

+
+
+ + + +
+ +

+ +

+
+ + + + No point in time objects have been created yet. + + + + + + +
+ + ); +}; diff --git a/src/plugins/point_in_time_management/public/components/empty_state/index.ts b/src/plugins/point_in_time_management/public/components/empty_state/index.ts new file mode 100644 index 000000000000..c903066cdbb0 --- /dev/null +++ b/src/plugins/point_in_time_management/public/components/empty_state/index.ts @@ -0,0 +1,6 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export { EmptyState } from './empty_state'; diff --git a/src/plugins/point_in_time_management/public/components/index.ts b/src/plugins/point_in_time_management/public/components/index.ts new file mode 100644 index 000000000000..c903066cdbb0 --- /dev/null +++ b/src/plugins/point_in_time_management/public/components/index.ts @@ -0,0 +1,6 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export { EmptyState } from './empty_state'; diff --git a/src/plugins/point_in_time_management/public/index.ts b/src/plugins/point_in_time_management/public/index.ts new file mode 100644 index 000000000000..2c2ecadca2e3 --- /dev/null +++ b/src/plugins/point_in_time_management/public/index.ts @@ -0,0 +1,12 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { PointInTimeManagementPlugin } from './plugin'; + +export function plugin() { + return new PointInTimeManagementPlugin(); +} + +export { PointInTimeManagementPluginSetup, PointInTimeManagementPluginStart } from './types'; diff --git a/src/plugins/point_in_time_management/public/management_app/index.ts b/src/plugins/point_in_time_management/public/management_app/index.ts new file mode 100644 index 000000000000..414bc60e89cc --- /dev/null +++ b/src/plugins/point_in_time_management/public/management_app/index.ts @@ -0,0 +1,6 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +export { mountManagementSection } from './mount_management_section'; diff --git a/src/plugins/point_in_time_management/public/management_app/mount_management_section.tsx b/src/plugins/point_in_time_management/public/management_app/mount_management_section.tsx new file mode 100644 index 000000000000..96c87fc73538 --- /dev/null +++ b/src/plugins/point_in_time_management/public/management_app/mount_management_section.tsx @@ -0,0 +1,38 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import React from 'react'; +import ReactDOM from 'react-dom'; +import { I18nProvider } from '@osd/i18n/react'; +import { ManagementAppMountParams } from '../../../management/public'; +import { PointInTimeManagementStartDependencies } from '../plugin'; +import { StartServicesAccessor } from '../../../../core/public'; +import { PointInTimeManagementContext } from '../types'; +import { OpenSearchDashboardsContextProvider } from '../../../opensearch_dashboards_react/public'; +import { EmptyState } from '../components'; + +export async function mountManagementSection( + getStartServices: StartServicesAccessor, + params: ManagementAppMountParams +) { + const [{ chrome, application }] = await getStartServices(); + const deps: PointInTimeManagementContext = { + chrome, + application, + }; + ReactDOM.render( + + + + + , + params.element + ); + + return () => { + chrome.docTitle.reset(); + ReactDOM.unmountComponentAtNode(params.element); + }; +} diff --git a/src/plugins/point_in_time_management/public/plugin.ts b/src/plugins/point_in_time_management/public/plugin.ts new file mode 100644 index 000000000000..53a1421926e4 --- /dev/null +++ b/src/plugins/point_in_time_management/public/plugin.ts @@ -0,0 +1,60 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { i18n } from '@osd/i18n'; +import { CoreSetup, CoreStart, Plugin } from '../../../core/public'; +import { PointInTimeManagementPluginSetup, PointInTimeManagementPluginStart } from './types'; +import { ManagementSetup } from '../../management/public'; + +export interface PointInTimeManagementSetupDependencies { + management: ManagementSetup; +} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface PointInTimeManagementStartDependencies {} + +const sectionsHeader = i18n.translate('pointInTimeManagement.pointInTime.sectionsHeader', { + defaultMessage: 'Point In Time', +}); + +const PITM_APP_ID = 'pointInTime'; + +export class PointInTimeManagementPlugin + implements + Plugin< + PointInTimeManagementPluginSetup, + PointInTimeManagementPluginStart, + PointInTimeManagementSetupDependencies, + PointInTimeManagementStartDependencies + > { + public setup( + core: CoreSetup, + { management }: PointInTimeManagementSetupDependencies + ): PointInTimeManagementPluginSetup { + const opensearchDashboardsSection = management.sections.section.opensearchDashboards; + + if (!opensearchDashboardsSection) { + throw new Error('`opensearchDashboards` management section not found.'); + } + + opensearchDashboardsSection.registerApp({ + id: PITM_APP_ID, + title: sectionsHeader, + order: 1, + mount: async (mountParams) => { + const { mountManagementSection } = await import('./management_app'); + return mountManagementSection(core.getStartServices, mountParams); + }, + }); + + return {}; + } + + public start(core: CoreStart): PointInTimeManagementPluginStart { + return {}; + } + + public stop() {} +} diff --git a/src/plugins/point_in_time_management/public/types.ts b/src/plugins/point_in_time_management/public/types.ts new file mode 100644 index 000000000000..fc0c5b7038c8 --- /dev/null +++ b/src/plugins/point_in_time_management/public/types.ts @@ -0,0 +1,27 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { ApplicationStart, ChromeStart } from 'opensearch-dashboards/public'; +import { NavigationPublicPluginStart } from '../../navigation/public'; +import { ManagementSetup } from '../../management/public'; + +export interface PointInTimeManagementContext { + chrome: ChromeStart; + application: ApplicationStart; +} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface PointInTimeManagementPluginSetup {} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface PointInTimeManagementPluginStart {} + +export interface AppPluginStartDependencies { + navigation: NavigationPublicPluginStart; +} + +export interface SetupDependencies { + management: ManagementSetup; +} diff --git a/src/plugins/point_in_time_management/server/index.ts b/src/plugins/point_in_time_management/server/index.ts new file mode 100644 index 000000000000..bcc35da781c8 --- /dev/null +++ b/src/plugins/point_in_time_management/server/index.ts @@ -0,0 +1,21 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { schema } from '@osd/config-schema'; +import { PluginInitializerContext } from '../../../core/server'; +import { PointInTimeManagementPlugin } from './plugin'; + +export const config = { + schema: schema.object({ enabled: schema.boolean({ defaultValue: false }) }), +}; + +// This exports static code and TypeScript types, +// as well as the OpenSearch Dashboards Platform `plugin()` initializer. + +export function plugin(initializerContext: PluginInitializerContext) { + return new PointInTimeManagementPlugin(initializerContext); +} + +export { PointInTimeManagementPluginSetup, PointInTimeManagementPluginStart } from './types'; diff --git a/src/plugins/point_in_time_management/server/plugin.ts b/src/plugins/point_in_time_management/server/plugin.ts new file mode 100644 index 000000000000..876e4271d432 --- /dev/null +++ b/src/plugins/point_in_time_management/server/plugin.ts @@ -0,0 +1,40 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { + PluginInitializerContext, + CoreSetup, + CoreStart, + Plugin, + Logger, +} from '../../../core/server'; + +import { PointInTimeManagementPluginSetup, PointInTimeManagementPluginStart } from './types'; +import { defineRoutes } from './routes'; + +export class PointInTimeManagementPlugin + implements Plugin { + private readonly logger: Logger; + + constructor(initializerContext: PluginInitializerContext) { + this.logger = initializerContext.logger.get(); + } + + public setup(core: CoreSetup) { + this.logger.debug('pointInTimeManagement: Setup'); + const router = core.http.createRouter(); + + defineRoutes(router); + + return {}; + } + + public start(core: CoreStart) { + this.logger.debug('pointInTimeManagement: Started'); + return {}; + } + + public stop() {} +} diff --git a/src/plugins/point_in_time_management/server/routes/index.ts b/src/plugins/point_in_time_management/server/routes/index.ts new file mode 100644 index 000000000000..b56d1871d7dd --- /dev/null +++ b/src/plugins/point_in_time_management/server/routes/index.ts @@ -0,0 +1,22 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { IRouter } from '../../../../core/server'; + +export function defineRoutes(router: IRouter) { + router.get( + { + path: '/api/point_in_time_management/test', + validate: false, + }, + async (context, request, response) => { + return response.ok({ + body: { + time: new Date().toISOString(), + }, + }); + } + ); +} diff --git a/src/plugins/point_in_time_management/server/types.ts b/src/plugins/point_in_time_management/server/types.ts new file mode 100644 index 000000000000..d9c957b4edc3 --- /dev/null +++ b/src/plugins/point_in_time_management/server/types.ts @@ -0,0 +1,9 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface PointInTimeManagementPluginSetup {} +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface PointInTimeManagementPluginStart {}