Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NP] Move saved object modal into new platform #56383

Merged
merged 23 commits into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d0f0ea6
Move saved object modal into new platform
maryia-lapata Jan 29, 2020
3b49800
Merge remote-tracking branch 'kibana/master' into save-object-modal
maryia-lapata Jan 30, 2020
f2f9f5e
Fix TS
maryia-lapata Jan 30, 2020
26f1398
Revert "Fix TS"
maryia-lapata Jan 30, 2020
b8e736a
Revert "Move saved object modal into new platform"
maryia-lapata Jan 30, 2020
b4e2c56
Move save_object_save_modal
maryia-lapata Jan 30, 2020
e9ff0e9
Move show_saved_object_save_modal.tsx
maryia-lapata Jan 30, 2020
3b365d1
Move save_object_finder.tsx
maryia-lapata Jan 30, 2020
053c675
Remove unused export
maryia-lapata Jan 30, 2020
8d9573b
Pass I18nContext to showSaveModal
maryia-lapata Jan 30, 2020
9e5a5e0
Merge remote-tracking branch 'kibana/master' into save-object-modal
maryia-lapata Feb 3, 2020
d0e3f99
Update i18n ids
maryia-lapata Feb 3, 2020
255b505
Fix map save
maryia-lapata Feb 3, 2020
0d6f078
Refactoring
maryia-lapata Feb 3, 2020
b2855df
Load styles
maryia-lapata Feb 3, 2020
e1861a2
Revert importing styles
maryia-lapata Feb 4, 2020
6b0bf65
Merge remote-tracking branch 'kibana/master' into save-object-modal
maryia-lapata Feb 4, 2020
3507f21
Update snapshot
maryia-lapata Feb 4, 2020
8c883c0
Update snapshot
maryia-lapata Feb 4, 2020
ec3d6a7
Merge branch 'master' into save-object-modal
elasticmachine Feb 5, 2020
91bc118
Structural refactoring
maryia-lapata Feb 5, 2020
f1faec4
Fix path
maryia-lapata Feb 5, 2020
0cf3fc8
Merge remote-tracking branch 'kibana/master' into save-object-modal
maryia-lapata Feb 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"navigation": "src/plugins/navigation",
"newsfeed": "src/plugins/newsfeed",
"regionMap": "src/legacy/core_plugins/region_map",
"savedObjects": "src/plugins/saved_objects",
"server": "src/legacy/server",
"statusPage": "src/legacy/core_plugins/status_page",
"telemetry": "src/legacy/core_plugins/telemetry",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ export const legacyChrome = chrome;
export { SavedObjectSaveOpts } from 'ui/saved_objects/types';
export { npSetup, npStart } from 'ui/new_platform';
export { IPrivate } from 'ui/private';
export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
// @ts-ignore
export { ConfirmationButtonTypes } from 'ui/modals/confirm_modal';
export { showSaveModal, SaveResult } from 'ui/saved_objects/show_saved_object_save_modal';
export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
export { KbnUrl } from 'ui/url/kbn_url';
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import {
ConfirmationButtonTypes,
migrateLegacyQuery,
SavedObjectSaveOpts,
SaveResult,
showSaveModal,
subscribeWithScope,
} from '../legacy_imports';
import {
Expand All @@ -45,6 +43,11 @@ import {
syncAppFilters,
syncQuery,
} from '../../../../../../plugins/data/public';
import {
SaveResult,
showSaveModal,
getSavedObjectFinder,
} from '../../../../../../plugins/saved_objects/public';

import {
DASHBOARD_CONTAINER_TYPE,
Expand Down Expand Up @@ -74,10 +77,6 @@ import { getDashboardTitle } from './dashboard_strings';
import { DashboardAppScope } from './dashboard_app';
import { convertSavedDashboardPanelToPanelState } from './lib/embeddable_saved_object_converters';
import { RenderDeps } from './application';
import {
SavedObjectFinderProps,
SavedObjectFinderUi,
} from '../../../../../../plugins/kibana_react/public';
import {
IKbnUrlStateStorage,
removeQueryParam,
Expand Down Expand Up @@ -114,7 +113,16 @@ export class DashboardAppController {
share,
dashboardCapabilities,
npDataStart: { query: queryService },
core: { notifications, overlays, chrome, injectedMetadata, uiSettings, savedObjects, http },
core: {
notifications,
overlays,
chrome,
injectedMetadata,
uiSettings,
savedObjects,
http,
i18n: i18nStart,
},
history,
kbnUrlStateStorage,
}: DashboardAppControllerDependencies) {
Expand Down Expand Up @@ -777,7 +785,7 @@ export class DashboardAppController {
showCopyOnSave={dash.id ? true : false}
/>
);
showSaveModal(dashboardSaveModal);
showSaveModal(dashboardSaveModal, i18nStart.Context);
};
navActions[TopNavIds.CLONE] = () => {
const currentTitle = dashboardStateManager.getTitle();
Expand Down Expand Up @@ -806,17 +814,13 @@ export class DashboardAppController {
};
navActions[TopNavIds.ADD] = () => {
if (dashboardContainer && !isErrorEmbeddable(dashboardContainer)) {
const SavedObjectFinder = (props: SavedObjectFinderProps) => (
<SavedObjectFinderUi {...props} savedObjects={savedObjects} uiSettings={uiSettings} />
);

openAddPanelFlyout({
embeddable: dashboardContainer,
getAllFactories: embeddables.getEmbeddableFactories,
getFactory: embeddables.getEmbeddableFactory,
notifications,
overlays,
SavedObjectFinder,
SavedObjectFinder: getSavedObjectFinder(savedObjects, uiSettings),
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import React from 'react';
import { shallowWithI18nProvider } from 'test_utils/enzyme_helpers';

jest.mock('../../legacy_imports', () => ({
jest.mock('../../../../../../../plugins/saved_objects/public', () => ({
SavedObjectSaveModal: () => null,
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import React, { Fragment } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiFormRow, EuiTextArea, EuiSwitch } from '@elastic/eui';

import { SavedObjectSaveModal } from '../../legacy_imports';
import { SavedObjectSaveModal } from '../../../../../../../plugins/saved_objects/public';

interface SaveOptions {
newTitle: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ export { getRequestInspectorStats, getResponseInspectorStats } from '../../../da
export { intervalOptions } from 'ui/agg_types';
// @ts-ignore
export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal';
export { stateMonitorFactory } from 'ui/state_management/state_monitor_factory';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import { i18n } from '@kbn/i18n';
import '../components/field_chooser/field_chooser';

import { RequestAdapter } from '../../../../../../../plugins/inspector/public';
import {
SavedObjectSaveModal,
showSaveModal,
} from '../../../../../../../plugins/saved_objects/public';
// doc table
import './doc_table';
import { getSortArray } from './doc_table/lib/get_sort';
Expand All @@ -47,12 +51,10 @@ import {
hasSearchStategyForIndexPattern,
intervalOptions,
migrateLegacyQuery,
showSaveModal,
unhashUrl,
stateMonitorFactory,
subscribeWithScope,
tabifyAggResponse,
SavedObjectSaveModal,
getAngularModule,
ensureDefaultIndexPattern,
registerTimefilterWithGlobalStateFactory,
Expand Down Expand Up @@ -310,7 +312,7 @@ function discoverController(
})}
/>
);
showSaveModal(saveModal);
showSaveModal(saveModal, core.i18n.Context);
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
EuiFlyoutBody,
EuiTitle,
} from '@elastic/eui';
import { SavedObjectFinderUi } from '../../../../../../../../plugins/kibana_react/public';
import { SavedObjectFinderUi } from '../../../../../../../../plugins/saved_objects/public';
import { getServices } from '../../../kibana_services';

const SEARCH_OBJECT_TYPE = 'search';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
SavedObjectsClientContract,
ToastsStart,
IUiSettingsClient,
I18nStart,
} from 'kibana/public';

import { NavigationPublicPluginStart as NavigationStart } from '../../../../../plugins/navigation/public';
Expand Down Expand Up @@ -57,6 +58,7 @@ export interface VisualizeKibanaServices {
visualizeCapabilities: any;
visualizations: VisualizationsStart;
usageCollection?: UsageCollectionSetup;
I18nContext: I18nStart['Context'];
}

let services: VisualizeKibanaServices | null = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ export { IPrivate } from 'ui/private';
// @ts-ignore
export { PrivateProvider } from 'ui/private/private';

export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal';

export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import { getEditBreadcrumbs } from '../breadcrumbs';
import { addHelpMenuToAppChrome } from '../help_menu/help_menu_util';
import { FilterStateManager } from '../../../../../data/public';
import { unhashUrl } from '../../../../../../../plugins/kibana_utils/public';
import {
SavedObjectSaveModal,
showSaveModal,
} from '../../../../../../../plugins/saved_objects/public';

import { initVisEditorDirective } from './visualization_editor';
import { initVisualizationDirective } from './visualization';
Expand All @@ -40,8 +44,6 @@ import {
absoluteToParsedUrl,
KibanaParsedUrl,
migrateLegacyQuery,
SavedObjectSaveModal,
showSaveModal,
stateMonitorFactory,
DashboardConstants,
} from '../../legacy_imports';
Expand Down Expand Up @@ -94,6 +96,7 @@ function VisualizeAppController(
core: { docLinks },
savedQueryService,
uiSettings,
I18nContext,
} = getServices();

const filterStateManager = new FilterStateManager(globalState, getAppState, filterManager);
Expand Down Expand Up @@ -192,7 +195,7 @@ function VisualizeAppController(
description={savedVis.description}
/>
);
showSaveModal(saveModal);
showSaveModal(saveModal, I18nContext);
},
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';
import { IUiSettingsClient, SavedObjectsStart } from 'kibana/public';

import { SavedObjectFinderUi } from '../../../../../../../../plugins/kibana_react/public';
import { SavedObjectFinderUi } from '../../../../../../../../plugins/saved_objects/public';
import { VisType } from '../../../legacy_imports';

interface SearchSelectionProps {
Expand Down
1 change: 1 addition & 0 deletions src/legacy/core_plugins/kibana/public/visualize/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export class VisualizePlugin implements Plugin {
visualizeCapabilities: contextCore.application.capabilities.visualize,
visualizations,
usageCollection,
I18nContext: contextCore.i18n.Context,
};
setServices(deps);

Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/saved_objects/_index.scss
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@import '../../../../plugins/kibana_react/public/saved_objects/index';
@import '../../../../plugins/saved_objects/public/index';
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
*/

import { i18n } from '@kbn/i18n';
import { SavedObjectMetaData } from '../../../saved_objects/public';
import { SavedObjectAttributes } from '../../../../core/public';
import { SavedObjectMetaData } from '../types';
import {
ContainerOutput,
EmbeddableFactory,
Expand Down
14 changes: 2 additions & 12 deletions src/plugins/dashboard_embeddable_container/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ import { CONTEXT_MENU_TRIGGER, IEmbeddableSetup, IEmbeddableStart } from './embe
import { ExpandPanelAction, ReplacePanelAction } from '.';
import { DashboardContainerFactory } from './embeddable/dashboard_container_factory';
import { Start as InspectorStartContract } from '../../../plugins/inspector/public';
import { getSavedObjectFinder } from '../../../plugins/saved_objects/public';
import {
SavedObjectFinderUi,
SavedObjectFinderProps,
ExitFullScreenButton as ExitFullScreenButtonUi,
ExitFullScreenButtonProps,
} from '../../../plugins/kibana_react/public';
Expand Down Expand Up @@ -61,16 +60,7 @@ export class DashboardEmbeddableContainerPublicPlugin
const { application, notifications, overlays } = core;
const { embeddable, inspector, uiActions } = plugins;

const SavedObjectFinder: React.FC<Exclude<
SavedObjectFinderProps,
'savedObjects' | 'uiSettings'
>> = props => (
<SavedObjectFinderUi
{...props}
savedObjects={core.savedObjects}
uiSettings={core.uiSettings}
/>
);
const SavedObjectFinder = getSavedObjectFinder(core.savedObjects, core.uiSettings);

const useHideChrome = () => {
React.useEffect(() => {
Expand Down
9 changes: 0 additions & 9 deletions src/plugins/dashboard_embeddable_container/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

import { IconType } from '@elastic/eui';
import { SavedObject as SavedObjectType, SavedObjectAttributes } from '../../../core/public';

export interface DashboardCapabilities {
Expand Down Expand Up @@ -50,14 +49,6 @@ export interface SimpleSavedObject<T extends SavedObjectAttributes> {
delete(): void;
}

export interface SavedObjectMetaData<T extends SavedObjectAttributes> {
type: string;
name: string;
getIconForSavedObject(savedObject: SimpleSavedObject<T>): IconType;
getTooltipForSavedObject?(savedObject: SimpleSavedObject<T>): string;
showSavedObject?(savedObject: SimpleSavedObject<T>): boolean;
}

interface FieldSubType {
multi?: { parent: string };
nested?: { path: string };
Expand Down
1 change: 0 additions & 1 deletion src/plugins/embeddable/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export {
PanelNotFoundError,
PanelState,
PropertySpec,
SavedObjectMetaData,
ViewMode,
isErrorEmbeddable,
openAddPanelFlyout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { SavedObjectAttributes } from 'src/core/public';
import { SavedObjectMetaData } from '../types';
import { SavedObjectMetaData } from '../../../../saved_objects/public';
import { EmbeddableInput, EmbeddableOutput, IEmbeddable } from './i_embeddable';
import { ErrorEmbeddable } from './error_embeddable';
import { IContainer } from '../containers/i_container';
Expand All @@ -40,7 +40,7 @@ export interface OutputSpec {
[key: string]: PropertySpec;
}

export interface EmbeddableFactoryOptions<T> {
export interface EmbeddableFactoryOptions<T extends SavedObjectAttributes> {
savedObjectMetaData?: SavedObjectMetaData<T>;
}

Expand Down
11 changes: 0 additions & 11 deletions src/plugins/embeddable/public/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,5 @@ export enum ViewMode {

export { Adapters };

// import { SavedObjectMetaData } from 'ui/saved_objects/components/saved_object_finder';
// TODO: Figure out how to do this import in New Platform.
export interface SavedObjectMetaData<T> {
type: string;
name: string;
getIconForSavedObject(savedObject: any): any;
getTooltipForSavedObject?(savedObject: any): any;
showSavedObject?(savedObject: any): boolean;
includeFields?: string[];
}

export type GetEmbeddableFactory = (id: string) => EmbeddableFactory | undefined;
export type GetEmbeddableFactories = () => IterableIterator<EmbeddableFactory>;
1 change: 0 additions & 1 deletion src/plugins/kibana_react/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

export * from './code_editor';
export * from './saved_objects';
export * from './exit_full_screen_button';
export * from './context';
export * from './overlays';
Expand Down
1 change: 1 addition & 0 deletions src/plugins/saved_objects/public/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import './save_modal/index';
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
* under the License.
*/

export * from './saved_object_finder';
export * from './saved_object_save_modal';
export {
SavedObjectMetaData,
SavedObjectFinderUi,
getSavedObjectFinder,
} from './saved_object_finder';
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { shallow } from 'enzyme';
import React from 'react';
import * as sinon from 'sinon';
import { SavedObjectFinderUi as SavedObjectFinder } from './saved_object_finder';
// eslint-disable-next-line
import { coreMock } from '../../../../core/public/mocks';

describe('SavedObjectsFinder', () => {
Expand Down
Loading