mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
* Fix saved object view path * Add additional check
This commit is contained in:
parent
3fc8860a28
commit
40c01fc159
4 changed files with 30 additions and 22 deletions
|
@ -11,11 +11,12 @@ import { SimpleSavedObject } from '../../../../core/public';
|
|||
import { castEsToKbnFieldTypeName } from '../../../data/public';
|
||||
import { ObjectField } from '../management_section/types';
|
||||
import { SavedObjectLoader } from '../../../saved_objects/public';
|
||||
import { SavedObjectWithMetadata } from '../types';
|
||||
|
||||
const maxRecursiveIterations = 20;
|
||||
|
||||
export function createFieldList(
|
||||
object: SimpleSavedObject,
|
||||
object: SimpleSavedObject | SavedObjectWithMetadata,
|
||||
service?: SavedObjectLoader
|
||||
): ObjectField[] {
|
||||
let fields = Object.entries(object.attributes as Record<string, any>).reduce(
|
||||
|
|
|
@ -19,14 +19,15 @@ import { set } from '@elastic/safer-lodash-set';
|
|||
import { cloneDeep } from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
import { SimpleSavedObject, SavedObjectsClientContract } from '../../../../../../core/public';
|
||||
import { SavedObjectsClientContract } from '../../../../../../core/public';
|
||||
import { SavedObjectLoader } from '../../../../../saved_objects/public';
|
||||
import { Field } from './field';
|
||||
import { ObjectField, FieldState, SubmittedFormData } from '../../types';
|
||||
import { createFieldList } from '../../../lib';
|
||||
import { SavedObjectWithMetadata } from '../../../types';
|
||||
|
||||
interface FormProps {
|
||||
object: SimpleSavedObject;
|
||||
object: SavedObjectWithMetadata;
|
||||
service: SavedObjectLoader;
|
||||
savedObjectsClient: SavedObjectsClientContract;
|
||||
editionEnabled: boolean;
|
||||
|
|
|
@ -14,16 +14,18 @@ import {
|
|||
SavedObjectsClientContract,
|
||||
OverlayStart,
|
||||
NotificationsStart,
|
||||
SimpleSavedObject,
|
||||
ScopedHistory,
|
||||
HttpSetup,
|
||||
} from '../../../../../core/public';
|
||||
import { ISavedObjectsManagementServiceRegistry } from '../../services';
|
||||
import { Header, NotFoundErrors, Intro, Form } from './components';
|
||||
import { canViewInApp } from '../../lib';
|
||||
import { canViewInApp, findObject } from '../../lib';
|
||||
import { SubmittedFormData } from '../types';
|
||||
import { SavedObjectWithMetadata } from '../../types';
|
||||
|
||||
interface SavedObjectEditionProps {
|
||||
id: string;
|
||||
http: HttpSetup;
|
||||
serviceName: string;
|
||||
serviceRegistry: ISavedObjectsManagementServiceRegistry;
|
||||
capabilities: Capabilities;
|
||||
|
@ -36,7 +38,7 @@ interface SavedObjectEditionProps {
|
|||
|
||||
interface SavedObjectEditionState {
|
||||
type: string;
|
||||
object?: SimpleSavedObject<any>;
|
||||
object?: SavedObjectWithMetadata<any>;
|
||||
}
|
||||
|
||||
export class SavedObjectEdition extends Component<
|
||||
|
@ -56,9 +58,9 @@ export class SavedObjectEdition extends Component<
|
|||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { id, savedObjectsClient } = this.props;
|
||||
const { http, id } = this.props;
|
||||
const { type } = this.state;
|
||||
savedObjectsClient.get(type, id).then((object) => {
|
||||
findObject(http, type, id).then((object) => {
|
||||
this.setState({
|
||||
object,
|
||||
});
|
||||
|
@ -70,7 +72,7 @@ export class SavedObjectEdition extends Component<
|
|||
capabilities,
|
||||
notFoundType,
|
||||
serviceRegistry,
|
||||
id,
|
||||
http,
|
||||
serviceName,
|
||||
savedObjectsClient,
|
||||
} = this.props;
|
||||
|
@ -80,7 +82,7 @@ export class SavedObjectEdition extends Component<
|
|||
string,
|
||||
boolean
|
||||
>;
|
||||
const canView = canViewInApp(capabilities, type);
|
||||
const canView = canViewInApp(capabilities, type) && Boolean(object?.meta.inAppUrl?.path);
|
||||
const service = serviceRegistry.get(serviceName)!.service;
|
||||
|
||||
return (
|
||||
|
@ -91,7 +93,7 @@ export class SavedObjectEdition extends Component<
|
|||
canViewInApp={canView}
|
||||
type={type}
|
||||
onDeleteClick={() => this.delete()}
|
||||
viewUrl={service.urlFor(id)}
|
||||
viewUrl={http.basePath.prepend(object?.meta.inAppUrl?.path || '')}
|
||||
/>
|
||||
{notFoundType && (
|
||||
<>
|
||||
|
|
|
@ -11,6 +11,7 @@ import { useParams, useLocation } from 'react-router-dom';
|
|||
import { parse } from 'query-string';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { CoreStart, ChromeBreadcrumb, ScopedHistory } from 'src/core/public';
|
||||
import { RedirectAppLinks } from '../../../kibana_react/public';
|
||||
import { ISavedObjectsManagementServiceRegistry } from '../services';
|
||||
import { SavedObjectEdition } from './object_view';
|
||||
|
||||
|
@ -50,17 +51,20 @@ const SavedObjectsEditionPage = ({
|
|||
}, [setBreadcrumbs, service]);
|
||||
|
||||
return (
|
||||
<SavedObjectEdition
|
||||
id={id}
|
||||
serviceName={serviceName}
|
||||
serviceRegistry={serviceRegistry}
|
||||
savedObjectsClient={coreStart.savedObjects.client}
|
||||
overlays={coreStart.overlays}
|
||||
notifications={coreStart.notifications}
|
||||
capabilities={capabilities}
|
||||
notFoundType={query.notFound as string}
|
||||
history={history}
|
||||
/>
|
||||
<RedirectAppLinks application={coreStart.application}>
|
||||
<SavedObjectEdition
|
||||
id={id}
|
||||
http={coreStart.http}
|
||||
serviceName={serviceName}
|
||||
serviceRegistry={serviceRegistry}
|
||||
savedObjectsClient={coreStart.savedObjects.client}
|
||||
overlays={coreStart.overlays}
|
||||
notifications={coreStart.notifications}
|
||||
capabilities={capabilities}
|
||||
notFoundType={query.notFound as string}
|
||||
history={history}
|
||||
/>
|
||||
</RedirectAppLinks>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue