Skip to content

Commit

Permalink
Register Advance Settings, Data Source management,Index Pattern manag…
Browse files Browse the repository at this point in the history
…ement and SavedObject management as standalone app, retire dashboard management (opensearch-project#208)

* feat: init retire dashboard management

Signed-off-by: tygao <tygao@amazon.com>

* move index pattern to Library (opensearch-project#91)

* move index pattern to libaray

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* Remove it from Dashboards management when workspace is on

Signed-off-by: Hailong Cui <ihailong@amazon.com>

---------

Signed-off-by: Hailong Cui <ihailong@amazon.com>

index pattern always show under library

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* functional test

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* feat: move data source / advanced settings / saved objects management out of Dashboard management

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update test

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update snapshot

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update snapshot

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* fix: fix failed overview header ut

Signed-off-by: tygao <tygao@amazon.com>

* fix: deeplink inside saved objects management page

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* fix: unit test fail

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add unit test for each page wrapper

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: some optimization

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* remove management dependency

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* test: update cypress config to use workspace branch

Signed-off-by: tygao <tygao@amazon.com>

* Replace ManagementAppMountParams with AppMountParameters

Signed-off-by: Hailong Cui <ihailong@amazon.com>

---------

Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: Hailong Cui <ihailong@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Co-authored-by: Hailong Cui <ihailong@amazon.com>
Co-authored-by: SuZhou-Joe <suzhou@amazon.com>
  • Loading branch information
3 people authored Oct 10, 2023
1 parent c05b434 commit 87c0c8a
Show file tree
Hide file tree
Showing 83 changed files with 635 additions and 399 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cypress_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Run cypress tests
# trigger on every PR for all branches
on:
pull_request:
branches: [ '**' ]
branches: ['**']
paths-ignore:
- '**/*.md'

Expand Down Expand Up @@ -54,8 +54,8 @@ jobs:
uses: actions/checkout@v2
with:
path: ${{ env.FTR_PATH }}
repository: ruanyl/opensearch-dashboards-functional-test
ref: '${{ github.base_ref }}'
repository: opensearch-project/opensearch-dashboards-functional-test
ref: 'workspace'

- name: Get Cypress version
id: cypress_version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const loginPage = new LoginPage(cy);

describe('verify the advanced settings are saved', () => {
beforeEach(() => {
miscUtils.visitPage('app/management/opensearch-dashboards/settings');
miscUtils.visitPage('app/settings');
loginPage.enterUserName('admin');
loginPage.enterPassword('admin');
loginPage.submit();
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/with-security/helpers/generate_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const loginPage = new LoginPage(cy);

describe('Generating BWC test data with security', () => {
beforeEach(() => {
miscUtils.visitPage('app/management/opensearch-dashboards/settings');
miscUtils.visitPage('app/settings');
loginPage.enterUserName('admin');
loginPage.enterPassword('admin');
loginPage.submit();
Expand All @@ -29,7 +29,7 @@ describe('Generating BWC test data with security', () => {
});

it('adds advanced settings', () => {
miscUtils.visitPage('app/management/opensearch-dashboards/settings');
miscUtils.visitPage('app/settings');
cy.get('[data-test-subj="advancedSetting-editField-theme:darkMode"]').click();
cy.get('[data-test-subj="advancedSetting-editField-timeline:max_buckets"]').type(
'{selectAll}4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const miscUtils = new MiscUtils(cy);

describe('verify the advanced settings are saved', () => {
beforeEach(() => {
miscUtils.visitPage('app/management/opensearch-dashboards/settings');
miscUtils.visitPage('app/settings');
});

it('the dark mode is on', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Generating BWC test data without security', () => {
miscUtils.visitPage('app');
});
it('adds advanced settings', () => {
miscUtils.visitPage('app/management/opensearch-dashboards/settings');
miscUtils.visitPage('app/settings');
cy.get('[data-test-subj="advancedSetting-editField-theme:darkMode"]').click();
cy.get('[data-test-subj="advancedSetting-editField-timeline:max_buckets"]').type(
'{selectAll}4'
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/core_app/errors/url_overflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('url overflow detection', () => {
</code>
option in
<a
href="/test-123/app/management/opensearch-dashboards/settings"
href="/test-123/app/settings"
>
advanced settings
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/core_app/errors/url_overflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const setupUrlOverflowDetection = ({ basePath, history, toasts, uiSetting
values={{
storeInSessionStorageParam: <code>state:storeInSessionStorage</code>,
advancedSettingsLink: (
<a href={basePath.prepend('/app/management/opensearch-dashboards/settings')}>
<a href={basePath.prepend('/app/settings')}>
<FormattedMessage
id="core.ui.errorUrlOverflow.bigUrlWarningNotificationMessage.advancedSettingsLinkText"
defaultMessage="advanced settings"
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/core_app/errors/url_overflow_ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const UrlOverflowUi: React.FC<{ basePath: IBasePath }> = ({ basePath }) =
values={{
storeInSessionStorageConfig: <code>state:storeInSessionStorage</code>,
opensearchDashboardsSettingsLink: (
<a href={basePath.prepend('/app/management/opensearch-dashboards/settings')}>
<a href={basePath.prepend('/app/settings')}>
<FormattedMessage
id="core.ui.errorUrlOverflow.optionsToFixError.enableOptionText.advancedSettingsLinkText"
defaultMessage="Advanced Settings"
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/ui_settings/saved_objects/ui_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const uiSettingsType: SavedObjectsType = {
importableAndExportable: true,
getInAppUrl() {
return {
path: `/app/management/opensearch-dashboards/settings`,
path: `/app/settings`,
uiCapabilitiesPath: 'advancedSettings.show',
};
},
Expand Down

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,6 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

export { PageWrapper } from './page_wrapper';
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 { render } from '@testing-library/react';
import { PageWrapper } from './page_wrapper';

describe('PageWrapper', () => {
it('should render normally', async () => {
const { findByText, container } = render(<PageWrapper>Foo</PageWrapper>);
await findByText('Foo');
expect(container).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { EuiPageContent } from '@elastic/eui';
import React from 'react';

export const PageWrapper = (props: { children?: React.ReactChild }) => {
return (
<EuiPageContent
style={{ maxWidth: '75%', marginTop: '20px' }}
hasShadow={false}
hasBorder={false}
panelPaddingSize="none"
horizontalPosition="center"
color="transparent"
{...props}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,24 @@ import { Router, Switch, Route } from 'react-router-dom';

import { i18n } from '@osd/i18n';
import { I18nProvider } from '@osd/i18n/react';
import { StartServicesAccessor } from 'src/core/public';
import {
AppMountParameters,
ChromeBreadcrumb,
ScopedHistory,
StartServicesAccessor,
} from 'src/core/public';

import { AdvancedSettings } from './advanced_settings';
import { ManagementAppMountParams } from '../../../management/public';
import { ComponentRegistry } from '../types';
import { reactRouterNavigate } from '../../../opensearch_dashboards_react/public';
import { PageWrapper } from './components/page_wrapper';

import './index.scss';

const title = i18n.translate('advancedSettings.advancedSettingsLabel', {
defaultMessage: 'Advanced settings',
});
const crumb = [{ text: title }];
const crumb: ChromeBreadcrumb[] = [{ text: title }];

const readOnlyBadge = {
text: i18n.translate('advancedSettings.badge.readOnly.text', {
Expand All @@ -57,13 +63,18 @@ const readOnlyBadge = {
iconType: 'glasses',
};

export async function mountManagementSection(
export async function mountAdvancedSettingsManagementSection(
getStartServices: StartServicesAccessor,
params: ManagementAppMountParams,
params: AppMountParameters,
componentRegistry: ComponentRegistry['start']
) {
params.setBreadcrumbs(crumb);
const [{ uiSettings, notifications, docLinks, application, chrome }] = await getStartServices();
chrome.setBreadcrumbs([
...crumb.map((item) => ({
...item,
...(item.href ? reactRouterNavigate(params.history, item.href) : {}),
})),
]);

const canSave = application.capabilities.advancedSettings.save as boolean;

Expand All @@ -72,21 +83,23 @@ export async function mountManagementSection(
}

ReactDOM.render(
<I18nProvider>
<Router history={params.history}>
<Switch>
<Route path={['/:query', '/']}>
<AdvancedSettings
enableSaving={canSave}
toasts={notifications.toasts}
dockLinks={docLinks.links}
uiSettings={uiSettings}
componentRegistry={componentRegistry}
/>
</Route>
</Switch>
</Router>
</I18nProvider>,
<PageWrapper>
<I18nProvider>
<Router history={params.history}>
<Switch>
<Route path={['/:query', '/']}>
<AdvancedSettings
enableSaving={canSave}
toasts={notifications.toasts}
dockLinks={docLinks.links}
uiSettings={uiSettings}
componentRegistry={componentRegistry}
/>
</Route>
</Switch>
</Router>
</I18nProvider>
</PageWrapper>,
params.element
);
return () => {
Expand Down
24 changes: 14 additions & 10 deletions src/plugins/advanced_settings/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
*/

import { i18n } from '@osd/i18n';
import { CoreSetup, Plugin } from 'opensearch-dashboards/public';
import { AppMountParameters, CoreSetup, Plugin } from 'opensearch-dashboards/public';
import { FeatureCatalogueCategory } from '../../home/public';
import { ComponentRegistry } from './component_registry';
import { AdvancedSettingsSetup, AdvancedSettingsStart, AdvancedSettingsPluginSetup } from './types';
import { DEFAULT_APP_CATEGORIES } from '../../../core/public';

const component = new ComponentRegistry();

Expand All @@ -42,18 +43,21 @@ const title = i18n.translate('advancedSettings.advancedSettingsLabel', {

export class AdvancedSettingsPlugin
implements Plugin<AdvancedSettingsSetup, AdvancedSettingsStart, AdvancedSettingsPluginSetup> {
public setup(core: CoreSetup, { management, home }: AdvancedSettingsPluginSetup) {
const opensearchDashboardsSection = management.sections.section.opensearchDashboards;

opensearchDashboardsSection.registerApp({
public setup(core: CoreSetup, { home }: AdvancedSettingsPluginSetup) {
core.application.register({
id: 'settings',
title,
order: 3,
async mount(params) {
const { mountManagementSection } = await import(
order: 99,
category: DEFAULT_APP_CATEGORIES.management,
async mount(params: AppMountParameters) {
const { mountAdvancedSettingsManagementSection } = await import(
'./management_app/mount_management_section'
);
return mountManagementSection(core.getStartServices, params, component.start);
return mountAdvancedSettingsManagementSection(
core.getStartServices,
params,
component.start
);
},
});

Expand All @@ -66,7 +70,7 @@ export class AdvancedSettingsPlugin
'Customize your OpenSearch Dashboards experience — change the date format, turn on dark mode, and more.',
}),
icon: 'gear',
path: '/app/management/opensearch-dashboards/settings',
path: '/app/settings',
showOnHomePage: false,
category: FeatureCatalogueCategory.ADMIN,
});
Expand Down
4 changes: 1 addition & 3 deletions src/plugins/dashboard/server/saved_objects/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export const dashboardSavedObjectType: SavedObjectsType = {
return obj.attributes.title;
},
getEditUrl(obj) {
return `/management/opensearch-dashboards/objects/savedDashboards/${encodeURIComponent(
obj.id
)}`;
return `/objects/savedDashboards/${encodeURIComponent(obj.id)}`;
},
getInAppUrl(obj) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,7 @@ export class IndexPatternsService {
);

if (!savedObject.version) {
throw new SavedObjectNotFound(
savedObjectType,
id,
'management/opensearch-dashboards/indexPatterns'
);
throw new SavedObjectNotFound(savedObjectType, id, 'indexPatterns');
}

const spec = this.savedObjectToSpec(savedObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ export const onRedirectNoIndexPattern = (
overlays: CoreStart['overlays']
) => () => {
const canManageIndexPatterns = capabilities.management.opensearchDashboards.indexPatterns;
const redirectTarget = canManageIndexPatterns
? '/management/opensearch-dashboards/indexPatterns'
: '/home';
const redirectTarget = canManageIndexPatterns ? '/indexPatterns' : '/home';
let timeoutId: NodeJS.Timeout | undefined;

if (timeoutId) {
Expand Down Expand Up @@ -72,8 +70,8 @@ export const onRedirectNoIndexPattern = (
if (redirectTarget === '/home') {
navigateToApp('home');
} else {
navigateToApp('management', {
path: `/opensearch-dashboards/indexPatterns?bannerMessage=${bannerMessage}`,
navigateToApp('indexPatterns', {
path: `?bannerMessage=${bannerMessage}`,
});
}

Expand Down
4 changes: 1 addition & 3 deletions src/plugins/data/public/search/errors/painless_error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ export class PainlessError extends OsdError {

public getErrorMessage(application: ApplicationStart) {
function onClick() {
application.navigateToApp('management', {
path: `/opensearch-dashboards/indexPatterns`,
});
application.navigateToApp('indexPatterns');
}

return (
Expand Down
8 changes: 2 additions & 6 deletions src/plugins/data/server/saved_objects/index_patterns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,11 @@ export const indexPatternSavedObjectType: SavedObjectsType = {
return obj.attributes.title;
},
getEditUrl(obj) {
return `/management/opensearch-dashboards/indexPatterns/patterns/${encodeURIComponent(
obj.id
)}`;
return `/indexPatterns/patterns/${encodeURIComponent(obj.id)}`;
},
getInAppUrl(obj) {
return {
path: `/app/management/opensearch-dashboards/indexPatterns/patterns/${encodeURIComponent(
obj.id
)}`,
path: `/app/indexPatterns/patterns/${encodeURIComponent(obj.id)}`,
uiCapabilitiesPath: 'management.opensearchDashboards.indexPatterns',
};
},
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data_source/server/saved_objects/data_source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export const dataSource: SavedObjectsType = {
return obj.attributes.title;
},
getEditUrl(obj) {
return `/management/opensearch-dashboards/dataSources/${encodeURIComponent(obj.id)}`;
return `/dataSources/${encodeURIComponent(obj.id)}`;
},
getInAppUrl(obj) {
return {
path: `/app/management/opensearch-dashboards/dataSources/${encodeURIComponent(obj.id)}`,
path: `/app/dataSources/${encodeURIComponent(obj.id)}`,
uiCapabilitiesPath: 'management.opensearchDashboards.dataSources',
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "opensearchDashboards",
"server": false,
"ui": true,
"requiredPlugins": ["management", "dataSource", "indexPatternManagement"],
"requiredPlugins": ["dataSource", "indexPatternManagement"],
"optionalPlugins": [],
"requiredBundles": ["opensearchDashboardsReact"],
"extraPublicDirs": ["public/components/utils"]
Expand Down
Loading

0 comments on commit 87c0c8a

Please sign in to comment.