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 and wanglam committed Feb 22, 2024
1 parent 440a24e commit 5f09f84
Show file tree
Hide file tree
Showing 81 changed files with 635 additions and 398 deletions.
8 changes: 4 additions & 4 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'
workflow_dispatch:
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4, 5, 6, 7, 8, 9]
group: [1, 2, 3, 4, 5, 6, 7, 8, 9]
container:
image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2
options: --user 1001
Expand Down Expand Up @@ -184,7 +184,7 @@ jobs:
with:
issue-number: ${{ inputs.pr_number }}
comment-author: 'github-actions[bot]'
body-includes: "${{ env.COMMENT_TAG }}"
body-includes: '${{ env.COMMENT_TAG }}'

- name: Add comment on the PR
uses: peter-evans/create-or-update-comment@v3
Expand All @@ -205,6 +205,6 @@ jobs:
'${{ env.SPEC }}'
```
#### Link to results:
#### Link to results:
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
edit-mode: replace
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
Loading

0 comments on commit 5f09f84

Please sign in to comment.