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

[7.x] Migrate share registry (#50137) #51186

Merged
merged 1 commit into from
Nov 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -6,6 +6,7 @@
"dashboardEmbeddableContainer": "src/plugins/dashboard_embeddable_container",
"data": ["src/legacy/core_plugins/data", "src/plugins/data"],
"embeddableApi": "src/plugins/embeddable",
"share": "src/plugins/share",
"esUi": "src/plugins/es_ui_shared",
"expressions": "src/plugins/expressions",
"inputControl": "src/legacy/core_plugins/input_control_vis",
Expand Down
4 changes: 1 addition & 3 deletions docs/user/reporting/development/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ However, these docs will be kept up-to-date to reflect the current implementatio
[float]
[[reporting-nav-bar-extensions]]
=== Share menu extensions
X-Pack uses the `ShareContextMenuExtensionsRegistryProvider` to register actions in the share menu.

This integration will likely be changing in the near future as we move towards a unified actions abstraction across {kib}.
X-Pack uses the `share` plugin of the Kibana platform to register actions in the share menu.

[float]
=== Generate job URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { docTitle } from 'ui/doc_title/doc_title';

import { showSaveModal, SaveResult } from 'ui/saved_objects/show_saved_object_save_modal';

import { showShareContextMenu, ShareContextMenuExtensionsRegistryProvider } from 'ui/share';
import { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';

import { timefilter } from 'ui/timefilter';
Expand All @@ -55,6 +54,7 @@ import { SaveOptions } from 'ui/saved_objects/saved_object';
import { capabilities } from 'ui/capabilities';
import { Subscription } from 'rxjs';
import { npStart } from 'ui/new_platform';
import { unhashUrl } from 'ui/state_management/state_hashing';
import { SavedObjectFinder } from 'ui/saved_objects/components/saved_object_finder';
import { Query } from '../../../../../plugins/data/public';
import { start as data } from '../../../data/public/legacy';
Expand Down Expand Up @@ -131,7 +131,6 @@ export class DashboardAppController {
}) {
const queryFilter = Private(FilterBarQueryFilterProvider);
const getUnhashableStates = Private(getUnhashableStatesProvider);
const shareContextMenuExtensions = Private(ShareContextMenuExtensionsRegistryProvider);

let lastReloadRequestTime = 0;

Expand Down Expand Up @@ -758,14 +757,13 @@ export class DashboardAppController {
});
};
navActions[TopNavIds.SHARE] = anchorElement => {
showShareContextMenu({
npStart.plugins.share.toggleShareContextMenu({
anchorElement,
allowEmbed: true,
allowShortUrl: !dashboardConfig.getHideWriteControls(),
getUnhashableStates,
shareableUrl: unhashUrl(window.location.href, getUnhashableStates()),
objectId: dash.id,
objectType: 'dashboard',
shareContextMenuExtensions: shareContextMenuExtensions.raw,
sharingData: {
title: dash.title,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import {
migrateLegacyQuery,
RequestAdapter,
showSaveModal,
showShareContextMenu,
unhashUrl,
stateMonitorFactory,
subscribeWithScope,
tabifyAggResponse,
Expand All @@ -63,7 +63,7 @@ const {
chrome,
docTitle,
FilterBarQueryFilterProvider,
ShareContextMenuExtensionsRegistryProvider,
share,
StateProvider,
timefilter,
toastNotifications,
Expand Down Expand Up @@ -190,7 +190,6 @@ function discoverController(
) {
const responseHandler = vislibSeriesResponseHandlerProvider().handler;
const getUnhashableStates = Private(getUnhashableStatesProvider);
const shareContextMenuExtensions = Private(ShareContextMenuExtensionsRegistryProvider);

const queryFilter = Private(FilterBarQueryFilterProvider);

Expand Down Expand Up @@ -323,14 +322,13 @@ function discoverController(
testId: 'shareTopNavButton',
run: async (anchorElement) => {
const sharingData = await this.getSharingData();
showShareContextMenu({
share.toggleShareContextMenu({
anchorElement,
allowEmbed: false,
allowShortUrl: uiCapabilities.discover.createShortUrl,
getUnhashableStates,
shareableUrl: unhashUrl(window.location.href, getUnhashableStates()),
objectId: savedSearch.id,
objectType: 'search',
shareContextMenuExtensions,
sharingData: {
...sharingData,
title: savedSearch.title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { SavedObjectProvider } from 'ui/saved_objects/saved_object';
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
import { FilterBarQueryFilterProvider } from 'ui/filter_manager/query_filter';
import { timefilter } from 'ui/timefilter';
import { ShareContextMenuExtensionsRegistryProvider } from 'ui/share';
// @ts-ignore
import { IndexPattern, IndexPatterns } from 'ui/index_patterns';
import { wrapInI18nContext } from 'ui/i18n';
Expand All @@ -58,6 +57,7 @@ const services = {
uiSettings: npStart.core.uiSettings,
uiActions: npStart.plugins.uiActions,
embeddable: npStart.plugins.embeddable,
share: npStart.plugins.share,
// legacy
docTitle,
docViewsRegistry,
Expand All @@ -68,7 +68,6 @@ const services = {
SavedObjectRegistryProvider,
SavedObjectProvider,
SearchSource,
ShareContextMenuExtensionsRegistryProvider,
StateProvider,
timefilter,
uiModules,
Expand Down Expand Up @@ -99,7 +98,6 @@ export { RequestAdapter } from 'ui/inspector/adapters';
export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
export { FieldList } from 'ui/index_patterns';
export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal';
export { showShareContextMenu } from 'ui/share';
export { stateMonitorFactory } from 'ui/state_management/state_monitor_factory';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
// @ts-ignore
Expand All @@ -110,6 +108,7 @@ export { getUnhashableStatesProvider } from 'ui/state_management/state_hashing';
export { tabifyAggResponse } from 'ui/agg_response/tabify';
// @ts-ignore
export { vislibSeriesResponseHandlerProvider } from 'ui/vis/response_handlers/vislib';
export { unhashUrl } from 'ui/state_management/state_hashing';

// EXPORT types
export { Vis } from 'ui/vis';
Expand Down
10 changes: 4 additions & 6 deletions src/legacy/core_plugins/kibana/public/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ import {
KibanaParsedUrl,
migrateLegacyQuery,
SavedObjectSaveModal,
showShareContextMenu,
showSaveModal,
stateMonitorFactory,
subscribeWithScope,
unhashUrl,
} from '../kibana_services';

const {
Expand All @@ -56,12 +56,12 @@ const {
docTitle,
FilterBarQueryFilterProvider,
getBasePath,
ShareContextMenuExtensionsRegistryProvider,
toastNotifications,
timefilter,
uiModules,
uiRoutes,
visualizations,
share,
} = getServices();

const { savedQueryService } = data.search.services;
Expand Down Expand Up @@ -159,7 +159,6 @@ function VisEditor(
) {
const queryFilter = Private(FilterBarQueryFilterProvider);
const getUnhashableStates = Private(getUnhashableStatesProvider);
const shareContextMenuExtensions = Private(ShareContextMenuExtensionsRegistryProvider);

// Retrieve the resolved SavedVis instance.
const savedVis = $route.current.locals.savedVis;
Expand Down Expand Up @@ -239,14 +238,13 @@ function VisEditor(
run: (anchorElement) => {
const hasUnappliedChanges = vis.dirty;
const hasUnsavedChanges = $appStatus.dirty;
showShareContextMenu({
share.toggleShareContextMenu({
anchorElement,
allowEmbed: true,
allowShortUrl: capabilities.visualize.createShortUrl,
getUnhashableStates,
shareableUrl: unhashUrl(window.location.href, getUnhashableStates()),
objectId: savedVis.id,
objectType: 'visualization',
shareContextMenuExtensions,
sharingData: {
title: savedVis.title,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { wrapInI18nContext } from 'ui/i18n';
// @ts-ignore
import { uiModules } from 'ui/modules';
import { FeatureCatalogueRegistryProvider } from 'ui/registry/feature_catalogue';
import { ShareContextMenuExtensionsRegistryProvider } from 'ui/share';
import { timefilter } from 'ui/timefilter';

// Saved objects
Expand All @@ -62,6 +61,7 @@ const services = {
toastNotifications: npStart.core.notifications.toasts,
uiSettings: npStart.core.uiSettings,

share: npStart.plugins.share,
data,
embeddables,
visualizations,
Expand All @@ -77,7 +77,6 @@ const services = {
SavedObjectProvider,
SavedObjectRegistryProvider,
SavedObjectsClientProvider,
ShareContextMenuExtensionsRegistryProvider,
timefilter,
uiModules,
uiRoutes,
Expand All @@ -99,13 +98,13 @@ export { VisEditorTypesRegistryProvider } from 'ui/registry/vis_editor_types';
// @ts-ignore
export { getUnhashableStatesProvider } from 'ui/state_management/state_hashing';
export { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal';
export { showShareContextMenu } from 'ui/share';
export { stateMonitorFactory } from 'ui/state_management/state_monitor_factory';
export { absoluteToParsedUrl } from 'ui/url/absolute_to_parsed_url';
export { KibanaParsedUrl } from 'ui/url/kibana_parsed_url';
export { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
export { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
export { unhashUrl } from 'ui/state_management/state_hashing';
export {
Container,
Embeddable,
Expand Down
6 changes: 6 additions & 0 deletions src/legacy/ui/public/new_platform/new_platform.karma_mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export const npSetup = {
}
},
},
share: {
register: () => {},
},
devTools: {
register: () => {},
},
Expand Down Expand Up @@ -162,6 +165,9 @@ export const npStart = {
},
},
},
share: {
toggleShareContextMenu: () => {},
},
inspector: {
isAvailable: () => false,
open: () => ({
Expand Down
3 changes: 3 additions & 0 deletions src/legacy/ui/public/new_platform/new_platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
import { EuiUtilsStart } from '../../../../plugins/eui_utils/public';
import { DevToolsSetup, DevToolsStart } from '../../../../plugins/dev_tools/public';
import { HomePublicPluginSetup, HomePublicPluginStart } from '../../../../plugins/home/public';
import { SharePluginSetup, SharePluginStart } from '../../../../plugins/share/public';

export interface PluginsSetup {
data: ReturnType<DataPlugin['setup']>;
Expand All @@ -38,6 +39,7 @@ export interface PluginsSetup {
home: HomePublicPluginSetup;
inspector: InspectorSetup;
uiActions: IUiActionsSetup;
share: SharePluginSetup;
devTools: DevToolsSetup;
}

Expand All @@ -49,6 +51,7 @@ export interface PluginsStart {
home: HomePublicPluginStart;
inspector: InspectorStart;
uiActions: IUiActionsStart;
share: SharePluginStart;
devTools: DevToolsStart;
}

Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/share/_index.scss
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@import './components/index';
@import './share_context_menu';
3 changes: 3 additions & 0 deletions src/legacy/ui/public/share/_share_context_menu.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.kbnShareContextMenu__finalPanel {
padding: $euiSize;
}
Loading