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

Migrate reporting top nav to sharing context menu #22596

Merged
merged 31 commits into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6d8b1af
migrate reporting top nav to sharing menu
nreese Aug 30, 2018
a832a5e
pass share extensions to visualize share menu
nreese Aug 30, 2018
7b754df
start creating the reporting panel component
nreese Aug 30, 2018
8f38f00
add buttons
nreese Aug 30, 2018
bb7ff10
generate report generatation URL
nreese Aug 30, 2018
359f48c
require save if url changes
nreese Aug 30, 2018
83fc635
Merge branch 'master' of https://github.com/elastic/kibana into repor…
nreese Aug 31, 2018
e551d78
add print layout UI
nreese Aug 31, 2018
6f227a6
putting it all together - generate reports from share context menu
nreese Aug 31, 2018
be93e2e
ensure copy button fills entire menu width
nreese Aug 31, 2018
a70f716
inject job params functionallity
nreese Aug 31, 2018
25c84e9
refactor print layout out of ReportingContentPanel
nreese Aug 31, 2018
052990c
CSV report generation
nreese Aug 31, 2018
de5c3b4
disable report generation when app is dirty
nreese Sep 4, 2018
a30c55b
update URL when window is resized
nreese Sep 4, 2018
ce605b6
remove all the old stuff
nreese Sep 4, 2018
1ec02f9
clean up CSV report register provider
nreese Sep 4, 2018
dd1f770
fix typescript errors
nreese Sep 4, 2018
57061ff
fix functional retests
nreese Sep 4, 2018
6fa0fa9
remove failure_debug folder
nreese Sep 4, 2018
de6b47e
close popover when generate button clicked, more work on functional t…
nreese Sep 4, 2018
784cf4b
Merge branch 'master' of https://github.com/elastic/kibana into repor…
nreese Sep 5, 2018
f1738eb
set size on button and text, do not use EuiFormRow
nreese Sep 5, 2018
1959204
use ReactElement type
nreese Sep 6, 2018
b3f3c57
move ShareContextMenuExtensionsRegistryProvider to ui/share and creat…
nreese Sep 7, 2018
56800c9
strictor typing, do not use hard coded object type name
nreese Sep 7, 2018
ef3291a
move registry files to typescript
nreese Sep 7, 2018
f5d3ca8
Merge branch 'master' of https://github.com/elastic/kibana into repor…
nreese Sep 7, 2018
168ed84
remove destructuring in the interface
nreese Sep 7, 2018
3297e37
Merge branch 'master' of https://github.com/elastic/kibana into repor…
nreese Sep 8, 2018
b1af858
convert createReportingJob to async function, remove unneeded comment
nreese Sep 11, 2018
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
16 changes: 7 additions & 9 deletions src/core_plugins/kibana/public/dashboard/dashboard_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import { showCloneModal } from './top_nav/show_clone_modal';
import { showSaveModal } from './top_nav/show_save_modal';
import { showAddPanel } from './top_nav/show_add_panel';
import { showOptionsPopover } from './top_nav/show_options_popover';
import { showShareContextMenu } from 'ui/share';
import { showShareContextMenu, ShareContextMenuExtensionsRegistryProvider } from 'ui/share';
import { migrateLegacyQuery } from 'ui/utils/migrateLegacyQuery';
import * as filterActions from 'ui/doc_table/actions/filter';
import { FilterManagerProvider } from 'ui/filter_manager';
Expand Down Expand Up @@ -86,6 +86,7 @@ app.directive('dashboardApp', function ($injector) {
const embeddableFactories = Private(EmbeddableFactoriesRegistryProvider);
const panelActionsRegistry = Private(ContextMenuActionsRegistryProvider);
const getUnhashableStates = Private(getUnhashableStatesProvider);
const shareContextMenuExtensions = Private(ShareContextMenuExtensionsRegistryProvider);

panelActionsStore.initializeFromRegistry(panelActionsRegistry);

Expand Down Expand Up @@ -133,14 +134,6 @@ app.directive('dashboardApp', function ($injector) {
dirty: !dash.id
};

this.getSharingTitle = () => {
return dash.title;
};

this.getSharingType = () => {
return 'dashboard';
};

dashboardStateManager.registerChangeListener(status => {
this.appStatus.dirty = status.dirty || !dash.id;
updateState();
Expand Down Expand Up @@ -409,6 +402,11 @@ app.directive('dashboardApp', function ($injector) {
getUnhashableStates,
objectId: dash.id,
objectType: 'dashboard',
shareContextMenuExtensions,
sharingData: {
title: dash.title,
},
isDirty: dashboardStateManager.getIsDirty(),
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,10 @@ export class DashboardStateManager {
* @returns {boolean} True if the dashboard has changed since the last save (or, is new).
*/
getIsDirty(timeFilter) {
return this.isDirty ||
// Filter bar comparison is done manually (see cleanFiltersForComparison for the reason) and time picker
// changes are not tracked by the state monitor.
this.getFiltersChanged(timeFilter);
// Filter bar comparison is done manually (see cleanFiltersForComparison for the reason) and time picker
// changes are not tracked by the state monitor.
const hasTimeFilterChanged = timeFilter ? this.getFiltersChanged(timeFilter) : false;
return this.isDirty || hasTimeFilterChanged;
}

getPanels() {
Expand Down
27 changes: 14 additions & 13 deletions src/core_plugins/kibana/public/discover/controllers/discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ import { recentlyAccessed } from 'ui/persisted_log';
import { getDocLink } from 'ui/documentation_links';
import '../components/fetch_error';
import { getPainlessError } from './get_painless_error';
import { showShareContextMenu } from 'ui/share';
import { showShareContextMenu, ShareContextMenuExtensionsRegistryProvider } from 'ui/share';
import { getUnhashableStatesProvider } from 'ui/state_management/state_hashing';
import { Inspector } from 'ui/inspector';
import { RequestAdapter } from 'ui/inspector/adapters';
Expand Down Expand Up @@ -162,6 +162,7 @@ function discoverController(
location: 'Discover'
});
const getUnhashableStates = Private(getUnhashableStatesProvider);
const shareContextMenuExtensions = Private(ShareContextMenuExtensionsRegistryProvider);
const inspectorAdapters = {
requests: new RequestAdapter()
};
Expand All @@ -179,6 +180,10 @@ function discoverController(
const savedSearch = $route.current.locals.savedSearch;
$scope.$on('$destroy', savedSearch.destroy);

const $appStatus = $scope.appStatus = this.appStatus = {
dirty: !savedSearch.id
};

$scope.topNavMenu = [{
key: 'new',
description: 'New Search',
Expand All @@ -198,13 +203,20 @@ function discoverController(
key: 'share',
description: 'Share Search',
testId: 'shareTopNavButton',
run: (menuItem, navController, anchorElement) => {
run: async (menuItem, navController, anchorElement) => {
const sharingData = await this.getSharingData();
showShareContextMenu({
anchorElement,
allowEmbed: false,
getUnhashableStates,
objectId: savedSearch.id,
objectType: 'search',
shareContextMenuExtensions,
sharingData: {
...sharingData,
title: savedSearch.title,
},
isDirty: $appStatus.dirty,
});
}
}, {
Expand Down Expand Up @@ -239,9 +251,6 @@ function discoverController(
docTitle.change(`Discover${pageTitleSuffix}`);

let stateMonitor;
const $appStatus = $scope.appStatus = this.appStatus = {
dirty: !savedSearch.id
};

const $state = $scope.state = new AppState(getStateDefaults());

Expand Down Expand Up @@ -306,14 +315,6 @@ function discoverController(
};
};

this.getSharingType = () => {
return 'search';
};

this.getSharingTitle = () => {
return savedSearch.title;
};

$scope.uiState = $state.makeStateful('uiState');

function getStateDefaults() {
Expand Down
1 change: 1 addition & 0 deletions src/core_plugins/kibana/public/kibana.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import 'uiExports/embeddableFactories';
import 'uiExports/inspectorViews';
import 'uiExports/search';
import 'uiExports/autocompleteProviders';
import 'uiExports/shareContextMenuExtensions';

import 'ui/autoload/all';
import './home';
Expand Down
26 changes: 13 additions & 13 deletions src/core_plugins/kibana/public/visualize/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { migrateLegacyQuery } from 'ui/utils/migrateLegacyQuery';
import { recentlyAccessed } from 'ui/persisted_log';
import { timefilter } from 'ui/timefilter';
import { getVisualizeLoader } from '../../../../../ui/public/visualize/loader';
import { showShareContextMenu } from 'ui/share';
import { showShareContextMenu, ShareContextMenuExtensionsRegistryProvider } from 'ui/share';
import { getUnhashableStatesProvider } from 'ui/state_management/state_hashing';

uiRoutes
Expand Down Expand Up @@ -117,6 +117,7 @@ function VisEditor(
const docTitle = Private(DocTitleProvider);
const queryFilter = Private(FilterBarQueryFilterProvider);
const getUnhashableStates = Private(getUnhashableStatesProvider);
const shareContextMenuExtensions = Private(ShareContextMenuExtensionsRegistryProvider);

// Retrieve the resolved SavedVis instance.
const savedVis = $route.current.locals.savedVis;
Expand All @@ -138,6 +139,10 @@ function VisEditor(

$scope.vis = vis;

const $appStatus = this.appStatus = {
dirty: !savedVis.id
};

$scope.topNavMenu = [{
key: 'save',
description: 'Save Visualization',
Expand All @@ -156,12 +161,19 @@ function VisEditor(
description: 'Share Visualization',
testId: 'shareTopNavButton',
run: (menuItem, navController, anchorElement) => {
const hasUnappliedChanges = vis.dirty;
const hasUnsavedChanges = $appStatus.dirty;
showShareContextMenu({
anchorElement,
allowEmbed: true,
getUnhashableStates,
objectId: savedVis.id,
objectType: 'visualization',
shareContextMenuExtensions,
sharingData: {
title: savedVis.title,
},
isDirty: hasUnappliedChanges || hasUnsavedChanges,
});
}
}, {
Expand Down Expand Up @@ -190,18 +202,6 @@ function VisEditor(

let stateMonitor;

const $appStatus = this.appStatus = {
dirty: !savedVis.id
};

this.getSharingTitle = () => {
return savedVis.title;
};

this.getSharingType = () => {
return 'visualization';
};

if (savedVis.id) {
docTitle.change(savedVis.title);
}
Expand Down
1 change: 1 addition & 0 deletions src/ui/public/chrome/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ declare class Chrome {
public getBasePath(): string;
public getXsrfToken(): string;
public getKibanaVersion(): string;
public getUiSettingsClient(): any;
}

declare const chrome: Chrome;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

exports[`should only render permalink panel when there are no other panels 1`] = `
<EuiContextMenu
data-test-subj="shareContextMenu"
initialPanelId={1}
panels={
Array [
Object {
"content": <ShareUrlContent
"content": <UrlPanelContent
getUnhashableStates={[Function]}
objectType="dashboard"
/>,
Expand All @@ -20,19 +21,20 @@ exports[`should only render permalink panel when there are no other panels 1`] =

exports[`should render context menu panel when there are more than one panel 1`] = `
<EuiContextMenu
data-test-subj="shareContextMenu"
initialPanelId={3}
panels={
Array [
Object {
"content": <ShareUrlContent
"content": <UrlPanelContent
getUnhashableStates={[Function]}
objectType="dashboard"
/>,
"id": 1,
"title": "Permalink",
},
Object {
"content": <ShareUrlContent
"content": <UrlPanelContent
getUnhashableStates={[Function]}
isEmbedded={true}
objectType="dashboard"
Expand All @@ -44,11 +46,13 @@ exports[`should render context menu panel when there are more than one panel 1`]
"id": 3,
"items": Array [
Object {
"data-test-subj": "sharePanel-Embedcode",
"icon": "console",
"name": "Embed code",
"panel": 2,
},
Object {
"data-test-subj": "sharePanel-Permalinks",
"icon": "link",
"name": "Permalinks",
"panel": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`render 1`] = `
<EuiForm
className="shareUrlContentForm"
className="sharePanelContent"
data-test-subj="shareUrlForm"
>
<EuiFormRow
Expand Down Expand Up @@ -128,14 +128,15 @@ exports[`render 1`] = `
</EuiFormRow>
<EuiCopy
afterMessage="Copied"
anchorClassName="sharePanel__copyAnchor"
textToCopy="about:blank"
/>
</EuiForm>
`;

exports[`should enable saved object export option when objectId is provided 1`] = `
<EuiForm
className="shareUrlContentForm"
className="sharePanelContent"
data-test-subj="shareUrlForm"
>
<EuiFormRow
Expand Down Expand Up @@ -260,6 +261,7 @@ exports[`should enable saved object export option when objectId is provided 1`]
</EuiFormRow>
<EuiCopy
afterMessage="Copied"
anchorClassName="sharePanel__copyAnchor"
textToCopy="about:blank"
/>
</EuiForm>
Expand Down
Loading