Skip to content

Commit

Permalink
[data view mgmt] change urls from indexPatterns to dataViews (#114912)
Browse files Browse the repository at this point in the history
* index pattern management to data view url changes
  • Loading branch information
mattkime authored Oct 21, 2021
1 parent d831c50 commit d2dea68
Show file tree
Hide file tree
Showing 35 changed files with 145 additions and 79 deletions.
6 changes: 1 addition & 5 deletions src/plugins/data_views/common/data_views/data_views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,7 @@ export class DataViewsService {
);

if (!savedObject.version) {
throw new SavedObjectNotFound(
DATA_VIEW_SAVED_OBJECT_TYPE,
id,
'management/kibana/indexPatterns'
);
throw new SavedObjectNotFound(DATA_VIEW_SAVED_OBJECT_TYPE, id, 'management/kibana/dataViews');
}

return this.initFromSavedObject(savedObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const onRedirectNoIndexPattern =
) =>
() => {
const canManageIndexPatterns = capabilities.management.kibana.indexPatterns;
const redirectTarget = canManageIndexPatterns ? '/management/kibana/indexPatterns' : '/home';
const redirectTarget = canManageIndexPatterns ? '/management/kibana/dataViews' : '/home';
let timeoutId: NodeJS.Timeout | undefined;

if (timeoutId) {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/data_views/server/saved_objects/data_views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export const dataViewSavedObjectType: SavedObjectsType = {
return obj.attributes.title;
},
getEditUrl(obj) {
return `/management/kibana/indexPatterns/patterns/${encodeURIComponent(obj.id)}`;
return `/management/kibana/dataViews/dataView/${encodeURIComponent(obj.id)}`;
},
getInAppUrl(obj) {
return {
path: `/app/management/kibana/indexPatterns/patterns/${encodeURIComponent(obj.id)}`,
path: `/app/management/kibana/dataViews/dataView/${encodeURIComponent(obj.id)}`,
uiCapabilitiesPath: 'management.kibana.indexPatterns',
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const CreateEditField = withRouter(
name: undefined,
} as unknown as IndexPatternField);

const url = `/patterns/${indexPattern.id}`;
const url = `/dataView/${indexPattern.id}`;

if (mode === 'edit' && !spec) {
const message = i18n.translate('indexPatternManagement.editDataView.scripted.noFieldLabel', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ test('getPath() should encode "fieldName"', () => {
{ name: 'Memory: Allocated Bytes/sec' } as unknown as IndexPatternField,
{ id: 'id' } as unknown as IndexPattern
)
).toMatchInlineSnapshot(`"/patterns/id/field/Memory%3A%20Allocated%20Bytes%2Fsec"`);
).toMatchInlineSnapshot(`"/dataView/id/field/Memory%3A%20Allocated%20Bytes%2Fsec"`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function getTabs(indexPattern: IndexPattern, fieldFilter: string) {
}

export function getPath(field: IndexPatternField, indexPattern: IndexPattern) {
return `/patterns/${indexPattern?.id}/field/${encodeURIComponent(field.name)}`;
return `/dataView/${indexPattern?.id}/field/${encodeURIComponent(field.name)}`;
}

const allTypesDropDown = i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Switch, Route } from 'react-router-dom';
import { Router, Switch, Route, Redirect } from 'react-router-dom';

import { i18n } from '@kbn/i18n';
import { I18nProvider } from '@kbn/i18n/react';
Expand Down Expand Up @@ -73,12 +73,13 @@ export async function mountManagementSection(
<Route path={['/create']}>
<IndexPatternTableWithRouter canSave={canSave} showCreateDialog={true} />
</Route>
<Route path={['/patterns/:id/field/:fieldName', '/patterns/:id/create-field/']}>
<Route path={['/dataView/:id/field/:fieldName', '/dataView/:id/create-field/']}>
<CreateEditFieldContainer />
</Route>
<Route path={['/patterns/:id']}>
<Route path={['/dataView/:id']}>
<EditIndexPatternContainer />
</Route>
<Redirect path={'/patterns*'} to={'dataView*'} />
<Route path={['/']}>
<IndexPatternTableWithRouter canSave={canSave} />
</Route>
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/index_pattern_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const sectionsHeader = i18n.translate('indexPatternManagement.dataView.sectionsH
defaultMessage: 'Data Views',
});

const IPM_APP_ID = 'indexPatterns';
const IPM_APP_ID = 'dataViews';

export class IndexPatternManagementPlugin
implements
Expand Down Expand Up @@ -72,6 +72,8 @@ export class IndexPatternManagementPlugin
id: IPM_APP_ID,
title: sectionsHeader,
order: 0,
capabilitiesId: 'indexPatterns',
redirectFrom: 'kibana/indexPatterns',
mount: async (params) => {
const { mountManagementSection } = await import('./management_app');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React, { memo } from 'react';
import { Route, Router, Switch } from 'react-router-dom';
import { Route, Router, Switch, Redirect } from 'react-router-dom';
import { AppMountParameters, ChromeBreadcrumb, ScopedHistory } from 'kibana/public';
import { ManagementAppWrapper } from '../management_app_wrapper';
import { ManagementLandingPage } from '../landing';
Expand Down Expand Up @@ -43,6 +43,12 @@ export const ManagementRouter = memo(
/>
))
)}
{sections.map((section) =>
section
.getAppsEnabled()
.filter((app) => app.redirectFrom)
.map((app) => <Redirect path={`/${app.redirectFrom}*`} to={`${app.basePath}*`} />)
)}
<Route
path={'/'}
component={() => (
Expand Down
6 changes: 5 additions & 1 deletion src/plugins/management/public/management_sections_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ export class ManagementSectionsService {
if (capabilities.management.hasOwnProperty(section.id)) {
const sectionCapabilities = capabilities.management[section.id];
section.apps.forEach((app) => {
if (sectionCapabilities.hasOwnProperty(app.id) && sectionCapabilities[app.id] !== true) {
const capabilitiesId = app.capabilitiesId || app.id;
if (
sectionCapabilities.hasOwnProperty(capabilitiesId) &&
sectionCapabilities[capabilitiesId] !== true
) {
app.disable();
}
});
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/management/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,6 @@ export interface CreateManagementItemArgs {
order?: number;
euiIconType?: string; // takes precedence over `icon` property.
icon?: string; // URL to image file; fallback if no `euiIconType`
capabilitiesId?: string; // overrides app id
redirectFrom?: string; // redirects from an old app id to the current app id
}
15 changes: 14 additions & 1 deletion src/plugins/management/public/utils/management_item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,29 @@ export class ManagementItem {
public readonly order: number;
public readonly euiIconType?: string;
public readonly icon?: string;
public readonly capabilitiesId?: string;
public readonly redirectFrom?: string;

public enabled: boolean = true;

constructor({ id, title, tip, order = 100, euiIconType, icon }: CreateManagementItemArgs) {
constructor({
id,
title,
tip,
order = 100,
euiIconType,
icon,
capabilitiesId,
redirectFrom,
}: CreateManagementItemArgs) {
this.id = id;
this.title = title;
this.tip = tip;
this.order = order;
this.euiIconType = euiIconType;
this.icon = icon;
this.capabilitiesId = capabilitiesId;
this.redirectFrom = redirectFrom;
}

disable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ describe('Inspect component', () => {
meta: {
title: `MyIndexPattern*`,
icon: 'indexPatternApp',
editUrl: '#/management/kibana/indexPatterns/patterns/1',
editUrl: '#/management/kibana/dataViews/dataView/1',
inAppUrl: {
path: '/management/kibana/indexPatterns/patterns/1',
path: '/management/kibana/dataViews/dataView/1',
uiCapabilitiesPath: 'management.kibana.indexPatterns',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ describe('SavedObjectEdition', () => {
meta: {
title: `MyIndexPattern*`,
icon: 'indexPatternApp',
editUrl: '#/management/kibana/indexPatterns/patterns/1',
editUrl: '#/management/kibana/dataViews/dataView/1',
inAppUrl: {
path: '/management/kibana/indexPatterns/patterns/1',
path: '/management/kibana/dataViews/dataView/1',
uiCapabilitiesPath: 'management.kibana.indexPatterns',
},
hiddenType: false,
Expand All @@ -187,7 +187,7 @@ describe('SavedObjectEdition', () => {
const headerComponent = component.find('Header');
expect(headerComponent.prop('canViewInApp')).toBe(true);
expect(headerComponent.prop('canDelete')).toBe(true);
expect(headerComponent.prop('viewUrl')).toEqual('/management/kibana/indexPatterns/patterns/1');
expect(headerComponent.prop('viewUrl')).toEqual('/management/kibana/dataViews/dataView/1');
const inspectComponent = component.find('Inspect');
expect(inspectComponent.prop('object')).toEqual(savedObjectItem);
});
Expand Down Expand Up @@ -225,9 +225,9 @@ describe('SavedObjectEdition', () => {
meta: {
title: `MyIndexPattern*`,
icon: 'indexPatternApp',
editUrl: '#/management/kibana/indexPatterns/patterns/1',
editUrl: '#/management/kibana/dataViews/dataView/1',
inAppUrl: {
path: '/management/kibana/indexPatterns/patterns/1',
path: '/management/kibana/dataViews/dataView/1',
uiCapabilitiesPath: 'management.kibana.indexPatterns',
},
hiddenType: false,
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 @@ -74,9 +74,9 @@ describe('Relationships', () => {
meta: {
title: 'MyIndexPattern*',
icon: 'indexPatternApp',
editUrl: '#/management/kibana/indexPatterns/patterns/1',
editUrl: '#/management/kibana/dataViews/dataView/1',
inAppUrl: {
path: '/management/kibana/indexPatterns/patterns/1',
path: '/management/kibana/dataViews/dataView/1',
uiCapabilitiesPath: 'management.kibana.indexPatterns',
},
},
Expand Down Expand Up @@ -111,10 +111,10 @@ describe('Relationships', () => {
id: '1',
relationship: 'child',
meta: {
editUrl: '/management/kibana/indexPatterns/patterns/1',
editUrl: '/management/kibana/dataViews/dataView/1',
icon: 'indexPatternApp',
inAppUrl: {
path: '/app/management/kibana/indexPatterns/patterns/1',
path: '/app/management/kibana/dataViews/dataView/1',
uiCapabilitiesPath: 'management.kibana.indexPatterns',
},
title: 'My Index Pattern',
Expand Down Expand Up @@ -365,9 +365,9 @@ describe('Relationships', () => {
meta: {
title: 'MyIndexPattern*',
icon: 'indexPatternApp',
editUrl: '#/management/kibana/indexPatterns/patterns/1',
editUrl: '#/management/kibana/dataViews/dataView/1',
inAppUrl: {
path: '/management/kibana/indexPatterns/patterns/1',
path: '/management/kibana/dataViews/dataView/1',
uiCapabilitiesPath: 'management.kibana.indexPatterns',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const defaultProps: TableProps = {
meta: {
title: `MyIndexPattern*`,
icon: 'indexPatternApp',
editUrl: '#/management/kibana/indexPatterns/patterns/1',
editUrl: '#/management/kibana/dataViews/dataView/1',
inAppUrl: {
path: '/management/kibana/indexPatterns/patterns/1',
path: '/management/kibana/dataViews/dataView/1',
uiCapabilitiesPath: 'management.kibana.indexPatterns',
},
},
Expand Down Expand Up @@ -59,9 +59,9 @@ const defaultProps: TableProps = {
meta: {
title: `MyIndexPattern*`,
icon: 'indexPatternApp',
editUrl: '#/management/kibana/indexPatterns/patterns/1',
editUrl: '#/management/kibana/dataViews/dataView/1',
inAppUrl: {
path: '/management/kibana/indexPatterns/patterns/1',
path: '/management/kibana/dataViews/dataView/1',
uiCapabilitiesPath: 'management.kibana.indexPatterns',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ describe('SavedObjectsTable', () => {
meta: {
title: `MyIndexPattern*`,
icon: 'indexPatternApp',
editUrl: '#/management/kibana/indexPatterns/patterns/1',
editUrl: '#/management/kibana/dataViews/dataView/1',
inAppUrl: {
path: '/management/kibana/indexPatterns/patterns/1',
path: '/management/kibana/dataViews/dataView/1',
uiCapabilitiesPath: 'management.kibana.indexPatterns',
},
},
Expand Down
5 changes: 2 additions & 3 deletions test/api_integration/apis/saved_objects_management/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,9 @@ export default function ({ getService }: FtrProviderContext) {
icon: 'indexPatternApp',
title: 'saved_objects*',
hiddenType: false,
editUrl:
'/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
editUrl: '/management/kibana/dataViews/dataView/8963ca30-3224-11e8-a572-ffca06da1357',
inAppUrl: {
path: '/app/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
path: '/app/management/kibana/dataViews/dataView/8963ca30-3224-11e8-a572-ffca06da1357',
uiCapabilitiesPath: 'management.kibana.indexPatterns',
},
namespaceType: 'single',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,9 @@ export default function ({ getService }: FtrProviderContext) {
meta: {
title: 'saved_objects*',
icon: 'indexPatternApp',
editUrl:
'/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
editUrl: '/management/kibana/dataViews/dataView/8963ca30-3224-11e8-a572-ffca06da1357',
inAppUrl: {
path: '/app/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
path: '/app/management/kibana/dataViews/dataView/8963ca30-3224-11e8-a572-ffca06da1357',
uiCapabilitiesPath: 'management.kibana.indexPatterns',
},
namespaceType: 'single',
Expand Down Expand Up @@ -128,10 +127,9 @@ export default function ({ getService }: FtrProviderContext) {
meta: {
icon: 'indexPatternApp',
title: 'saved_objects*',
editUrl:
'/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
editUrl: '/management/kibana/dataViews/dataView/8963ca30-3224-11e8-a572-ffca06da1357',
inAppUrl: {
path: '/app/management/kibana/indexPatterns/patterns/8963ca30-3224-11e8-a572-ffca06da1357',
path: '/app/management/kibana/dataViews/dataView/8963ca30-3224-11e8-a572-ffca06da1357',
uiCapabilitiesPath: 'management.kibana.indexPatterns',
},
namespaceType: 'single',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default function ({ getService, getPageObjects }) {
return retry.try(function tryingForTime() {
return browser.getCurrentUrl().then(function (currentUrl) {
log.debug('currentUrl = ' + currentUrl);
expect(currentUrl).to.contain('management/kibana/indexPatterns');
expect(currentUrl).to.contain('management/kibana/dataViews');
});
});
});
Expand Down
Loading

0 comments on commit d2dea68

Please sign in to comment.