Skip to content

Commit

Permalink
move index pattern to Library (opensearch-project#91)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Hailong-am committed Sep 28, 2023
1 parent be0e1fa commit d1cc99f
Show file tree
Hide file tree
Showing 18 changed files with 105 additions and 85 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import { i18n } from '@osd/i18n';
import { I18nProvider } from '@osd/i18n/react';
import { StartServicesAccessor } from 'src/core/public';

import { EuiPage, EuiPageBody } from '@elastic/eui';
import { OpenSearchDashboardsContextProvider } from '../../../opensearch_dashboards_react/public';
import { ManagementAppMountParams } from '../../../management/public';
import {
Expand Down Expand Up @@ -90,26 +91,34 @@ export async function mountManagementSection(
dataSourceEnabled,
};

const router = (
<Router history={params.history}>
<Switch>
<Route path={['/create']}>
<CreateIndexPatternWizardWithRouter />
</Route>
<Route path={['/patterns/:id/field/:fieldName', '/patterns/:id/create-field/']}>
<CreateEditFieldContainer />
</Route>
<Route path={['/patterns/:id']}>
<EditIndexPatternContainer />
</Route>
<Route path={['/']}>
<IndexPatternTableWithRouter canSave={canSave} />
</Route>
</Switch>
</Router>
);

const content = (
<EuiPage restrictWidth="1200px">
<EuiPageBody component="main">{router}</EuiPageBody>
</EuiPage>
);

ReactDOM.render(
<OpenSearchDashboardsContextProvider services={deps}>
<I18nProvider>
<Router history={params.history}>
<Switch>
<Route path={['/create']}>
<CreateIndexPatternWizardWithRouter />
</Route>
<Route path={['/patterns/:id/field/:fieldName', '/patterns/:id/create-field/']}>
<CreateEditFieldContainer />
</Route>
<Route path={['/patterns/:id']}>
<EditIndexPatternContainer />
</Route>
<Route path={['/']}>
<IndexPatternTableWithRouter canSave={canSave} />
</Route>
</Switch>
</Router>
</I18nProvider>
<I18nProvider>{content}</I18nProvider>
</OpenSearchDashboardsContextProvider>,
params.element
);
Expand Down
49 changes: 42 additions & 7 deletions src/plugins/index_pattern_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@
*/

import { i18n } from '@osd/i18n';
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public';
import {
PluginInitializerContext,
CoreSetup,
CoreStart,
Plugin,
AppMountParameters,
ChromeBreadcrumb,
ScopedHistory,
} from 'src/core/public';
import { DataPublicPluginStart } from 'src/plugins/data/public';
import { DataSourcePluginStart } from 'src/plugins/data_source/public';
import { UrlForwardingSetup } from '../../url_forwarding/public';
Expand All @@ -39,7 +47,9 @@ import {
IndexPatternManagementServiceStart,
} from './service';

import { ManagementSetup } from '../../management/public';
import { ManagementAppMountParams, ManagementSetup } from '../../management/public';
import { DEFAULT_APP_CATEGORIES } from '../../../core/public';
import { reactRouterNavigate } from '../../opensearch_dashboards_react/public';

export interface IndexPatternManagementSetupDependencies {
management: ManagementSetup;
Expand Down Expand Up @@ -83,7 +93,7 @@ export class IndexPatternManagementPlugin
throw new Error('`opensearchDashboards` management section not found.');
}

const newAppPath = `management/opensearch-dashboards/${IPM_APP_ID}`;
const newAppPath = IPM_APP_ID;
const legacyPatternsPath = 'management/opensearch-dashboards/index_patterns';

urlForwarding.forwardApp(
Expand All @@ -96,14 +106,39 @@ export class IndexPatternManagementPlugin
return pathInApp && `/patterns${pathInApp}`;
});

opensearchDashboardsSection.registerApp({
// register it under Library
core.application.register({
id: IPM_APP_ID,
title: sectionsHeader,
order: 0,
mount: async (params) => {
order: 8100,
category: DEFAULT_APP_CATEGORIES.opensearchDashboards,
mount: async (params: AppMountParameters) => {
const { mountManagementSection } = await import('./management_app');

return mountManagementSection(core.getStartServices, params, () =>
const [coreStart] = await core.getStartServices();

const setBreadcrumbsScope = (
crumbs: ChromeBreadcrumb[] = [],
appHistory?: ScopedHistory
) => {
const wrapBreadcrumb = (item: ChromeBreadcrumb, scopedHistory: ScopedHistory) => ({
...item,
...(item.href ? reactRouterNavigate(scopedHistory, item.href) : {}),
});

coreStart.chrome.setBreadcrumbs([
...crumbs.map((item) => wrapBreadcrumb(item, appHistory || params.history)),
]);
};

const managementParams: ManagementAppMountParams = {
element: params.element,
history: params.history,
setBreadcrumbs: setBreadcrumbsScope,
basePath: params.appBasePath,
};

return mountManagementSection(core.getStartServices, managementParams, () =>
this.indexPatternManagementService.environmentService.getEnvironment().ml()
);
},
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
Expand Up @@ -114,11 +114,7 @@ export const GettingStarted: FC<Props> = ({ addBasePath, isDarkTheme, apps }) =>
<EuiSpacer size="xl" />

<RedirectAppLinks application={application}>
<EuiButton
fill
iconType="indexOpen"
href={addBasePath('/app/management/opensearch-dashboards/indexPatterns')}
>
<EuiButton fill iconType="indexOpen" href={addBasePath('/app/indexPatterns')}>
<FormattedMessage
defaultMessage="Add your data"
id="opensearchDashboardsOverview.gettingStarted.addDataButtonLabel"
Expand Down

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

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

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
Expand Up @@ -85,9 +85,9 @@ describe('Relationships', () => {
meta: {
title: 'MyIndexPattern*',
icon: 'indexPatternApp',
editUrl: '#/management/opensearch-dashboards/indexPatterns/patterns/1',
editUrl: '#/indexPatterns/patterns/1',
inAppUrl: {
path: '/management/opensearch-dashboards/indexPatterns/patterns/1',
path: '/indexPatterns/patterns/1',
uiCapabilitiesPath: 'management.opensearchDashboards.indexPatterns',
},
},
Expand Down Expand Up @@ -120,10 +120,10 @@ describe('Relationships', () => {
id: '1',
relationship: 'child',
meta: {
editUrl: '/management/opensearch-dashboards/indexPatterns/patterns/1',
editUrl: '/indexPatterns/patterns/1',
icon: 'indexPatternApp',
inAppUrl: {
path: '/app/management/opensearch-dashboards/indexPatterns/patterns/1',
path: '/app/indexPatterns/patterns/1',
uiCapabilitiesPath: 'management.opensearchDashboards.indexPatterns',
},
title: 'My Index Pattern',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ const defaultProps: TableProps = {
meta: {
title: `MyIndexPattern*`,
icon: 'indexPatternApp',
editUrl: '#/management/opensearch-dashboards/indexPatterns/patterns/1',
editUrl: '#/indexPatterns/patterns/1',
inAppUrl: {
path: '/management/opensearch-dashboards/indexPatterns/patterns/1',
path: '/indexPatterns/patterns/1',
uiCapabilitiesPath: 'management.opensearchDashboards.indexPatterns',
},
},
Expand Down Expand Up @@ -91,9 +91,9 @@ const defaultProps: TableProps = {
meta: {
title: `MyIndexPattern*`,
icon: 'indexPatternApp',
editUrl: '#/management/opensearch-dashboards/indexPatterns/patterns/1',
editUrl: '#/indexPatterns/patterns/1',
inAppUrl: {
path: '/management/opensearch-dashboards/indexPatterns/patterns/1',
path: '/indexPatterns/patterns/1',
uiCapabilitiesPath: 'management.opensearchDashboards.indexPatterns',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ describe('SavedObjectsTable', () => {
meta: {
title: `MyIndexPattern*`,
icon: 'indexPatternApp',
editUrl: '#/management/opensearch-dashboards/indexPatterns/patterns/1',
editUrl: '#/indexPatterns/patterns/1',
inAppUrl: {
path: '/management/opensearch-dashboards/indexPatterns/patterns/1',
path: '/indexPatterns/patterns/1',
uiCapabilitiesPath: 'management.opensearchDashboards.indexPatterns',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,7 @@ export class SavedObjectsTable extends Component<SavedObjectsTableProps, SavedOb
return null;
}
const { applications } = this.props;
const newIndexPatternUrl = applications.getUrlForApp('management', {
path: 'opensearch-dashboards/indexPatterns',
});
const newIndexPatternUrl = applications.getUrlForApp('indexPatterns');

return (
<Flyout
Expand Down
6 changes: 2 additions & 4 deletions test/api_integration/apis/saved_objects_management/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,9 @@ export default function ({ getService }: FtrProviderContext) {
expect(resp.body.saved_objects[0].meta).to.eql({
icon: 'indexPatternApp',
title: 'saved_objects*',
editUrl:
'/management/opensearch-dashboards/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
editUrl: '/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
inAppUrl: {
path:
'/app/management/opensearch-dashboards/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
path: '/app/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
uiCapabilitiesPath: 'management.opensearchDashboards.indexPatterns',
},
namespaceType: 'single',
Expand Down
Loading

0 comments on commit d1cc99f

Please sign in to comment.