Skip to content

Commit

Permalink
Fix dashboard "snapshot share" is not sharing panel state in view mode (
Browse files Browse the repository at this point in the history
  • Loading branch information
Dosant authored Oct 8, 2020
1 parent d0049d2 commit ffeb180
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import { getDashboardTitle } from './dashboard_strings';
import { DashboardAppScope } from './dashboard_app';
import { convertSavedDashboardPanelToPanelState } from './lib/embeddable_saved_object_converters';
import { RenderDeps } from './application';
import { IKbnUrlStateStorage, unhashUrl } from '../../../kibana_utils/public';
import { IKbnUrlStateStorage, setStateToKbnUrl, unhashUrl } from '../../../kibana_utils/public';
import {
addFatalError,
AngularHttpError,
Expand Down Expand Up @@ -1079,7 +1079,12 @@ export class DashboardAppController {
allowEmbed: true,
allowShortUrl:
!dashboardConfig.getHideWriteControls() || dashboardCapabilities.createShortUrl,
shareableUrl: unhashUrl(window.location.href),
shareableUrl: setStateToKbnUrl(
'_a',
dashboardStateManager.getAppState(),
{ useHash: false, storeInHashQuery: true },
unhashUrl(window.location.href)
),
objectId: dash.id,
objectType: 'dashboard',
sharingData: {
Expand Down
1 change: 1 addition & 0 deletions test/functional/apps/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default function ({ getService, loadTestFile }) {
loadTestFile(require.resolve('./time_zones'));
loadTestFile(require.resolve('./dashboard_options'));
loadTestFile(require.resolve('./data_shared_attributes'));
loadTestFile(require.resolve('./share'));
loadTestFile(require.resolve('./embed_mode'));
loadTestFile(require.resolve('./dashboard_back_button'));
loadTestFile(require.resolve('./dashboard_error_handling'));
Expand Down
45 changes: 45 additions & 0 deletions test/functional/apps/dashboard/share.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const PageObjects = getPageObjects(['dashboard', 'common', 'share']);

describe('share dashboard', () => {
before(async () => {
await esArchiver.load('dashboard/current/kibana');
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.preserveCrossAppState();
await PageObjects.dashboard.loadSavedDashboard('few panels');
});

it('has "panels" state when sharing a snapshot', async () => {
await PageObjects.share.clickShareTopNavButton();
const sharedUrl = await PageObjects.share.getSharedUrl();
expect(sharedUrl).to.contain('panels');
});
});
}

0 comments on commit ffeb180

Please sign in to comment.