Skip to content

Commit

Permalink
Point in time management plugin and empty state (opensearch-project#2813
Browse files Browse the repository at this point in the history
)

* point in time management plugin and empty state

Signed-off-by: Ajay Gupta <[email protected]>

* updated to new license header

Signed-off-by: Ajay Gupta <[email protected]>

* [Vis Builder] Rename wizard on save modal and visualization table (opensearch-project#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 <[email protected]>

* Save visualization on save modal, VisBuilder for chart type

Signed-off-by: abbyhu2000 <[email protected]>

* No experimental flag

Signed-off-by: abbyhu2000 <[email protected]>

Signed-off-by: abbyhu2000 <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* [@osd/cross-platform] Adds cross-platform helpers (opensearch-project#2681)

Signed-off-by: Miki <[email protected]>

Signed-off-by: Miki <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* Change save object type, wizard id and name to visBuilder (opensearch-project#2673)

* Change save object type, wizard ID and Name to visBuilder

Signed-off-by: abbyhu2000 <[email protected]>

* Rename wizard in functional tests

Signed-off-by: abbyhu2000 <[email protected]>

* Finalize plugin-id and plugin-name and saved-object-type

Signed-off-by: abbyhu2000 <[email protected]>

* Change official name to VisBuilder

Signed-off-by: abbyhu2000 <[email protected]>

* Delete migration

Signed-off-by: abbyhu2000 <[email protected]>

* Fix functional test

Signed-off-by: abbyhu2000 <[email protected]>

* Update snapshot

Signed-off-by: abbyhu2000 <[email protected]>

Signed-off-by: abbyhu2000 <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* [CVE] Bump loader-utils to 2.0.3 to fix CVE-2022-37601 (opensearch-project#2689)

* [CVE] Bump loader-utils to 2.0.3 to fix CVE-2022-37601

Signed-off-by: Zilong Xia <[email protected]>

* Update CHANGELOG.md

Signed-off-by: Zilong Xia <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* Add extension point in saved object management to register namespaces and show filter (opensearch-project#2656)

* Create filter registry for saved object management to make filters extensible

Signed-off-by: Craig Perkins <[email protected]>

* WIP on making fetchCounts generic

Signed-off-by: Craig Perkins <[email protected]>

* First step at making scroll_counts generic

Signed-off-by: Craig Perkins <[email protected]>

* Work on getting other filter counts with same object count endpoint

Signed-off-by: Craig Perkins <[email protected]>

* Get tenant count options to display

Signed-off-by: Craig Perkins <[email protected]>

* Extend find to work with namespaces for saved objects

Signed-off-by: Craig Perkins <[email protected]>

* Add missing filterFields

Signed-off-by: Craig Perkins <[email protected]>

* Update jest tests

Signed-off-by: Craig Perkins <[email protected]>

* Update saved_objects_table snapshot

Signed-off-by: Craig Perkins <[email protected]>

* Append index to id to make unique

Signed-off-by: Craig Perkins <[email protected]>

* Add semi-colon

Signed-off-by: Craig Perkins <[email protected]>

* Fix saved objects table tests with new id scheme

Signed-off-by: Craig Perkins <[email protected]>

* Only append idx on config type to ensure Advanced Settings have a unique id across tenants

Signed-off-by: Craig Perkins <[email protected]>

* Remove itemsClone in favor of showing only Advanced Settings of current tenant

Signed-off-by: Craig Perkins <[email protected]>

* Revert snapshots in table.test.tsx

Signed-off-by: Craig Perkins <[email protected]>

* Add additional parse_query test

Signed-off-by: Craig Perkins <[email protected]>

* Add comma

Signed-off-by: Craig Perkins <[email protected]>

* Create namespaceRegistry to decouple security dashboards plugin and osd core

Signed-off-by: Craig Perkins <[email protected]>

* Add ability to register an alias

Signed-off-by: Craig Perkins <[email protected]>

* Update parse query and add to CHANGELOG

Signed-off-by: Craig Perkins <[email protected]>

* Remove commented out code

Signed-off-by: Craig Perkins <[email protected]>

* Address code review comments

Signed-off-by: Craig Perkins <[email protected]>

* Override i18n if alias is regitered

Signed-off-by: Craig Perkins <[email protected]>

Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* Removed Leftover X Pack references opensearch-project#2517 (opensearch-project#2638)

x-pack references in the code are removed as per the given files in opensearch-project#2517

Issue Resolved:
opensearch-project#2517

Signed-off-by: vimal K <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* Revert "[@osd/cross-platform] Adds cross-platform helpers (opensearch-project#2681)" (opensearch-project#2694)

This reverts commit 887093d.

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 <[email protected]>

Signed-off-by: Josh Romero <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* [MD] Add design documents of multiple data source feature (opensearch-project#2538)

* Add MD design documents, including high level design, user stories, client management detailed design

Signed-off-by: Su <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* Adds @osd/cross-platform (opensearch-project#2703)

* Adds helper functions, @osd/cross-platform, to work around the differences of platforms

Signed-off-by: Miki <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* [MD]Update MD data source documentation link (opensearch-project#2693)

Signed-off-by: Kristen Tian <[email protected]>

Signed-off-by: Kristen Tian <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* Add `Skip-Changelog` label to skip changelog verification on certain PRs (opensearch-project#2726)

Signed-off-by: Miki <[email protected]>

Signed-off-by: Miki <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* Enable visbuilder by default (opensearch-project#2725)

* Enable visbuilder by default

Signed-off-by: Ashwin P Chandran <[email protected]>

* Adds changelog entry

Signed-off-by: Ashwin P Chandran <[email protected]>

Signed-off-by: Ashwin P Chandran <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* [Save Object Aggregation View] Fix for export all after scroll count response changed in PR#2656 (opensearch-project#2696)

* Fix for filterSavedObjectCounts for namespaceRegistry

Signed-off-by: Craig Perkins <[email protected]>

* Fix saved_objects_table.test.tsx

Signed-off-by: Craig Perkins <[email protected]>

* Add to CHANGELOG

Signed-off-by: Craig Perkins <[email protected]>

* Correct reference to namespacesToInclude

Signed-off-by: Craig Perkins <[email protected]>

* Use filteredTypeCounts

Signed-off-by: Craig Perkins <[email protected]>

* Use namespaces similar to types for fetchObjects

Signed-off-by: Craig Perkins <[email protected]>

* Use _all to represent query for all namespaces

Signed-off-by: Craig Perkins <[email protected]>

* Pass all registered namespaces

Signed-off-by: Craig Perkins <[email protected]>

* Switch back signature of scroll_count

Signed-off-by: Craig Perkins <[email protected]>

* Change countOptions to options

Signed-off-by: Craig Perkins <[email protected]>

* Use not not instead of in

Signed-off-by: Craig Perkins <[email protected]>

* Filter namespaces to only include namespace that have been registered

Signed-off-by: Craig Perkins <[email protected]>

* Add filterQuery with tests

Signed-off-by: Craig Perkins <[email protected]>

* Update license headers and address review comments

Signed-off-by: Craig Perkins <[email protected]>

Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* Update backport workflow to ignore changelog conflicts (opensearch-project#2729)

Signed-off-by: Miki <[email protected]>

Signed-off-by: Miki <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* Tweak multiple data source design doc (opensearch-project#2724)

Signed-off-by: Kristen Tian <[email protected]>

Signed-off-by: Kristen Tian <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* [Chore] Refactor and improve Discover field summaries (opensearch-project#2391)

* [Chore] Refactor and improve field summaries

* Convert to typescript
* Fix types
* Add tests

Signed-off-by: Josh Romero <[email protected]>

* [Test] Update functional test

Groups are now naturally sorted by key, which requires selecting a different date filter

Signed-off-by: Josh Romero <[email protected]>

* [Chore] Add changelog entry

Signed-off-by: Josh Romero <[email protected]>

* [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 <[email protected]>

Signed-off-by: Josh Romero <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* Removes Add Integration button (opensearch-project#2723)

* Removes Add Integration button

Issue Resolved:
opensearch-project#2684

Signed-off-by: Bandini Bhopi <[email protected]>

* Adds changelog entry

Signed-off-by: Bandini Bhopi <[email protected]>

Signed-off-by: Bandini Bhopi <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* Prevent backport workflow from running on umerged PRs (opensearch-project#2746)

Signed-off-by: Miki <[email protected]>

Signed-off-by: Miki <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* [Vis Builder] Enable VisBuilder cypress tests (opensearch-project#2728)

* Enable VisBuilder cypress tests

Signed-off-by: Ashwin P Chandran <[email protected]>

* Adds changelog and fix env

Signed-off-by: Ashwin P Chandran <[email protected]>

* Run all tests

Signed-off-by: Ashwin P Chandran <[email protected]>

Signed-off-by: Ashwin P Chandran <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* [CI] update backport custom branch name (opensearch-project#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 <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* [Legacy Maps Plugin] Prevent reverse-tabnabbing (opensearch-project#2540)

Signed-off-by: Miki <[email protected]>

Signed-off-by: Miki <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* change geckodriver version to make consistency (opensearch-project#2772)

* change geckodriver version to make consistency

Issue Resolved:
opensearch-project#2771

Signed-off-by: Anan Zhuang <[email protected]>

* combine https-proxy-agent in yarn.lock

Signed-off-by: Anan Zhuang <[email protected]>

Signed-off-by: Anan Zhuang <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* [Vis Builder] Add an experimental table visualization in vis builder (opensearch-project#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):
opensearch-project#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:
opensearch-project#2212
opensearch-project#2213
opensearch-project#2305
opensearch-project#2379
opensearch-project#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 <[email protected]>

* remove unused scss tyle

Signed-off-by: Anan Zhuang <[email protected]>

* 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 <[email protected]>

* 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 <[email protected]>

Signed-off-by: Anan Zhuang <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* Security-CVEs fixes guidelines (opensearch-project#2674)

* Security-CVEs fixes guidelines

Signed-off-by: himsgupta1122 <[email protected]>

* styling

Signed-off-by: himsgupta1122 <[email protected]>

* add example

Signed-off-by: himsgupta1122 <[email protected]>

* add documention

Signed-off-by: himsgupta1122 <[email protected]>

Signed-off-by: himsgupta1122 <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* [MD] Update default audit log path (opensearch-project#2793)

- Fix the /tmp path issue seen on windows platform.
- Change audit log to disable by default.

Signed-off-by: Kristen Tian <[email protected]>

Signed-off-by: Kristen Tian <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* [Vis Builder] Add field summary popovers (opensearch-project#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 opensearch-project#950

Signed-off-by: Josh Romero <[email protected]>

* [Vis Builder] Add additional unit tests

Signed-off-by: Josh Romero <[email protected]>

* [VisBuilder] Update naming of summary field components

Signed-off-by: Josh Romero <[email protected]>

* [VisBuilder] Avoid prop passing by extracting custom hooks

- refactor meta field identification

Signed-off-by: Josh Romero <[email protected]>

* [VisBuilder] Add TODOs with issue links, fix test ID

Restores previous test ID for count field button

Signed-off-by: Josh Romero <[email protected]>

Signed-off-by: Josh Romero <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* Bump makelogs to remove dependency on got (opensearch-project#2801)

* Also dusted off the lock file a bit

Fixes opensearch-project#1764

Signed-off-by: Miki <[email protected]>

Signed-off-by: Miki <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* Change VisBuilder flag for docker config (opensearch-project#2804)

Signed-off-by: Ashwin P Chandran <[email protected]>

Signed-off-by: Ashwin P Chandran <[email protected]>
Signed-off-by: Ajay Gupta <[email protected]>

* addressed review comments

Signed-off-by: Ajay Gupta <[email protected]>

* addressed review comments

Signed-off-by: Ajay Gupta <[email protected]>

* addressed review comments

Signed-off-by: Ajay Gupta <[email protected]>

* updated unit tests

Signed-off-by: Ajay Gupta <[email protected]>

* dummy commit to retry build

Signed-off-by: Ajay Gupta <[email protected]>

* address suggestions

Signed-off-by: Ajay Gupta <[email protected]>

Signed-off-by: Ajay Gupta <[email protected]>
Signed-off-by: abbyhu2000 <[email protected]>
Signed-off-by: Miki <[email protected]>
Signed-off-by: Zilong Xia <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: vimal K <[email protected]>
Signed-off-by: Josh Romero <[email protected]>
Signed-off-by: Su <[email protected]>
Signed-off-by: Kristen Tian <[email protected]>
Signed-off-by: Ashwin P Chandran <[email protected]>
Signed-off-by: Bandini Bhopi <[email protected]>
Signed-off-by: Kawika Avilla <[email protected]>
Signed-off-by: Miki <[email protected]>
Signed-off-by: Anan Zhuang <[email protected]>
Signed-off-by: himsgupta1122 <[email protected]>
Co-authored-by: Ajay Gupta <[email protected]>
Co-authored-by: Qingyang(Abby) Hu <[email protected]>
Co-authored-by: Miki <[email protected]>
Co-authored-by: ZilongX <[email protected]>
Co-authored-by: Craig Perkins <[email protected]>
Co-authored-by: Vimal K <[email protected]>
Co-authored-by: Josh Romero <[email protected]>
Co-authored-by: Zhongnan Su <[email protected]>
Co-authored-by: Kristen Tian <[email protected]>
Co-authored-by: Ashwin P Chandran <[email protected]>
Co-authored-by: Craig Perkins <[email protected]>
Co-authored-by: Bandini <[email protected]>
Co-authored-by: Kawika Avilla <[email protected]>
Co-authored-by: Anan Zhuang <[email protected]>
Co-authored-by: himsgupta1122 <[email protected]>
Signed-off-by: Arpit Bandejiya <[email protected]>
  • Loading branch information
16 people authored and Arpit-Bandejiya committed Mar 8, 2023
1 parent 42eeb0c commit 06fbeff
Show file tree
Hide file tree
Showing 17 changed files with 437 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Make build scripts find and use the latest version of Node.js that satisfies `engines.node` ([#3467](https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3467))
- [Multiple DataSource] Refactor test connection to support SigV4 auth type ([#3456](https://github.com/opensearch-project/OpenSearch-Dashboards/issues/3456))
- [Darwin] Add support for Darwin for running OpenSearch snapshots with `yarn opensearch snapshot` ([#3537](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3537))
- [Point in TIme] Add management plugin shell and empty state ([#2813](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2813))

### 🐛 Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,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=''
Expand Down
10 changes: 10 additions & 0 deletions src/plugins/point_in_time_management/opensearch_dashboards.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "pit",
"version": "1.0.0",
"opensearchDashboardsVersion": "opensearchDashboards",
"server": true,
"ui": true,
"requiredPlugins": ["navigation", "management"],
"optionalPlugins": [],
"requiredBundles": ["opensearchDashboardsReact"]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -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(<EmptyState />);

expect(component).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -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 (
<>
<EuiPageContent
className="pitEmptyState"
grow={false}
style={{ minHeight: '70vh' }}
horizontalPosition="center"
data-test-subj="pointInTimeEmptyState"
>
<EuiPageContentHeader>
<EuiPageContentHeaderSection>
<EuiTitle>
<h1>
<FormattedMessage
id="pointInTimeManagement.header.pointInTimeTitle"
defaultMessage="Point in Time"
/>
</h1>
</EuiTitle>
</EuiPageContentHeaderSection>
<EuiButton fill={true} iconType="plusInCircle" data-test-subj="createPITBtnInHeader">
<FormattedMessage
id="pointInTimeManagement.header.createPointInTimeButton"
defaultMessage="Create point in time"
/>
</EuiButton>
</EuiPageContentHeader>
<EuiText size="s">
<p>
<FormattedMessage
id="pointInTimeManagement.pointInTimeDescription"
defaultMessage="Create and manage point in time objects to help you retrieve data from OpenSearch."
/>
</p>
</EuiText>
<EuiSpacer size="m" />
<EuiPageContentBody>
<EuiFlexGroup
style={{ minHeight: '50vh' }}
alignItems="center"
justifyContent="center"
direction="column"
>
<EuiFlexItem grow={false}>No point in time objects have been created yet.</EuiFlexItem>
<EuiSpacer />
<EuiButton data-test-subj="createPITBtnInBody">
<FormattedMessage
id="pointInTimeManagement.createPointInTimeButton"
defaultMessage="Create point in time"
/>
</EuiButton>
</EuiFlexGroup>
</EuiPageContentBody>
</EuiPageContent>
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export { EmptyState } from './empty_state';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export { EmptyState } from './empty_state';
12 changes: 12 additions & 0 deletions src/plugins/point_in_time_management/public/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export { mountManagementSection } from './mount_management_section';
Original file line number Diff line number Diff line change
@@ -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<PointInTimeManagementStartDependencies>,
params: ManagementAppMountParams
) {
const [{ chrome, application }] = await getStartServices();
const deps: PointInTimeManagementContext = {
chrome,
application,
};
ReactDOM.render(
<OpenSearchDashboardsContextProvider services={deps}>
<I18nProvider>
<EmptyState />
</I18nProvider>
</OpenSearchDashboardsContextProvider>,
params.element
);

return () => {
chrome.docTitle.reset();
ReactDOM.unmountComponentAtNode(params.element);
};
}
60 changes: 60 additions & 0 deletions src/plugins/point_in_time_management/public/plugin.ts
Original file line number Diff line number Diff line change
@@ -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<PointInTimeManagementStartDependencies, PointInTimeManagementPluginStart>,
{ 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() {}
}
27 changes: 27 additions & 0 deletions src/plugins/point_in_time_management/public/types.ts
Original file line number Diff line number Diff line change
@@ -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;
}
21 changes: 21 additions & 0 deletions src/plugins/point_in_time_management/server/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Loading

0 comments on commit 06fbeff

Please sign in to comment.