Skip to content

Commit fff3060

Browse files
authored
Fix dashboard "snapshot share" is not sharing panel state in view mode (#79837)
1 parent 5761f74 commit fff3060

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

src/plugins/dashboard/public/application/dashboard_app_controller.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ import { getDashboardTitle } from './dashboard_strings';
8181
import { DashboardAppScope } from './dashboard_app';
8282
import { convertSavedDashboardPanelToPanelState } from './lib/embeddable_saved_object_converters';
8383
import { RenderDeps } from './application';
84-
import { IKbnUrlStateStorage, unhashUrl } from '../../../kibana_utils/public';
84+
import { IKbnUrlStateStorage, setStateToKbnUrl, unhashUrl } from '../../../kibana_utils/public';
8585
import {
8686
addFatalError,
8787
AngularHttpError,
@@ -1079,7 +1079,12 @@ export class DashboardAppController {
10791079
allowEmbed: true,
10801080
allowShortUrl:
10811081
!dashboardConfig.getHideWriteControls() || dashboardCapabilities.createShortUrl,
1082-
shareableUrl: unhashUrl(window.location.href),
1082+
shareableUrl: setStateToKbnUrl(
1083+
'_a',
1084+
dashboardStateManager.getAppState(),
1085+
{ useHash: false, storeInHashQuery: true },
1086+
unhashUrl(window.location.href)
1087+
),
10831088
objectId: dash.id,
10841089
objectType: 'dashboard',
10851090
sharingData: {

test/functional/apps/dashboard/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export default function ({ getService, loadTestFile }) {
5757
loadTestFile(require.resolve('./time_zones'));
5858
loadTestFile(require.resolve('./dashboard_options'));
5959
loadTestFile(require.resolve('./data_shared_attributes'));
60+
loadTestFile(require.resolve('./share'));
6061
loadTestFile(require.resolve('./embed_mode'));
6162
loadTestFile(require.resolve('./dashboard_back_button'));
6263
loadTestFile(require.resolve('./dashboard_error_handling'));
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import expect from '@kbn/expect';
21+
import { FtrProviderContext } from '../../ftr_provider_context';
22+
23+
export default function ({ getService, getPageObjects }: FtrProviderContext) {
24+
const esArchiver = getService('esArchiver');
25+
const kibanaServer = getService('kibanaServer');
26+
const PageObjects = getPageObjects(['dashboard', 'common', 'share']);
27+
28+
describe('share dashboard', () => {
29+
before(async () => {
30+
await esArchiver.load('dashboard/current/kibana');
31+
await kibanaServer.uiSettings.replace({
32+
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
33+
});
34+
await PageObjects.common.navigateToApp('dashboard');
35+
await PageObjects.dashboard.preserveCrossAppState();
36+
await PageObjects.dashboard.loadSavedDashboard('few panels');
37+
});
38+
39+
it('has "panels" state when sharing a snapshot', async () => {
40+
await PageObjects.share.clickShareTopNavButton();
41+
const sharedUrl = await PageObjects.share.getSharedUrl();
42+
expect(sharedUrl).to.contain('panels');
43+
});
44+
});
45+
}

0 commit comments

Comments
 (0)