Skip to content

Commit 9c6a697

Browse files
authored
[7.17] [Share] Resolves bug on attempting to copy dashboard link from non-default space (#227625) (#228033)
# Backport This will backport the following commits from `main` to `7.17`: - [[Share] Resolves bug on attempting to copy dashboard link from non-default space (#227625)](#227625) <!--- Backport version: 10.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Eyo O. Eyo","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-07-15T12:56:52Z","message":"[Share] Resolves bug on attempting to copy dashboard link from non-default space (#227625)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/191090\nCloses https://github.com/elastic/kibana/issues/227976\n\nOnly pass along url intended to be shortened, when validating that we\naren't shortening some URL external to Kibana\n\n","sha":"245c8fb86326d0ac25a9a6106e5fcfec09f4fab2","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport","release_note:fix","backport:skip","Team:SharedUX","v9.2.0"],"title":"[Share] Resolves bug on attempting to copy dashboard link from non-default space","number":227625,"url":"https://github.com/elastic/kibana/pull/227625","mergeCommit":{"message":"[Share] Resolves bug on attempting to copy dashboard link from non-default space (#227625)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/191090\nCloses https://github.com/elastic/kibana/issues/227976\n\nOnly pass along url intended to be shortened, when validating that we\naren't shortening some URL external to Kibana\n\n","sha":"245c8fb86326d0ac25a9a6106e5fcfec09f4fab2"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/227625","number":227625,"mergeCommit":{"message":"[Share] Resolves bug on attempting to copy dashboard link from non-default space (#227625)\n\n## Summary\n\nCloses https://github.com/elastic/kibana/issues/191090\nCloses https://github.com/elastic/kibana/issues/227976\n\nOnly pass along url intended to be shortened, when validating that we\naren't shortening some URL external to Kibana\n\n","sha":"245c8fb86326d0ac25a9a6106e5fcfec09f4fab2"}},{"url":"https://github.com/elastic/kibana/pull/228007","number":228007,"branch":"9.0","state":"OPEN"},{"url":"https://github.com/elastic/kibana/pull/228008","number":228008,"branch":"8.18","state":"OPEN"}]}] BACKPORT-->
1 parent 7aecab4 commit 9c6a697

File tree

4 files changed

+107
-1
lines changed

4 files changed

+107
-1
lines changed

src/plugins/share/server/url_service/http/short_urls/register_create_route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const registerCreateRoute = (
9797
}
9898

9999
const urlFromParams = (params as { url: string | undefined }).url;
100-
if (urlFromParams && !isInternalURL(urlFromParams, http.basePath.get(req))) {
100+
if (urlFromParams && !isInternalURL(urlFromParams)) {
101101
return res.customError({
102102
statusCode: 400,
103103
body: 'Can not create a short URL for an external URL.',

x-pack/test/functional/apps/dashboard/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default function ({ loadTestFile }: FtrProviderContext) {
2121
loadTestFile(require.resolve('./dashboard_lens_by_value'));
2222
loadTestFile(require.resolve('./dashboard_maps_by_value'));
2323
loadTestFile(require.resolve('./panel_titles'));
24+
loadTestFile(require.resolve('./share'));
2425

2526
loadTestFile(require.resolve('./migration_smoke_tests/lens_migration_smoke_test'));
2627
loadTestFile(require.resolve('./migration_smoke_tests/visualize_migration_smoke_test'));
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import type { FtrProviderContext } from '../../../ftr_provider_context';
9+
10+
export default function ({ loadTestFile }: FtrProviderContext) {
11+
describe('Share', function () {
12+
loadTestFile(require.resolve('./share_from_custom_space'));
13+
});
14+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import expect from '@kbn/expect';
9+
import type { FtrProviderContext } from '../../../ftr_provider_context';
10+
11+
export default function sharingFromSpace({ getPageObjects, getService }: FtrProviderContext) {
12+
const kibanaServer = getService('kibanaServer');
13+
const spacesService = getService('spaces');
14+
const browser = getService('browser');
15+
const testSubjects = getService('testSubjects');
16+
const { dashboard, common, share, security, spaceSelector } = getPageObjects([
17+
'dashboard',
18+
'common',
19+
'share',
20+
'security',
21+
'spaceSelector',
22+
]);
23+
24+
const spaceId = 'another-space';
25+
26+
describe('Dashboard Custom Space share', () => {
27+
before(async () => {
28+
await kibanaServer.savedObjects.cleanStandardList();
29+
30+
await spacesService.create({
31+
id: spaceId,
32+
name: 'Another Space',
33+
disabledFeatures: [],
34+
});
35+
36+
await kibanaServer.importExport.load(
37+
'test/functional/fixtures/kbn_archiver/dashboard/current/kibana',
38+
{
39+
space: spaceId,
40+
}
41+
);
42+
43+
await kibanaServer.uiSettings.replace({
44+
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
45+
});
46+
47+
await security.forceLogout();
48+
49+
await security.login(undefined, undefined, {
50+
expectSpaceSelector: true,
51+
});
52+
53+
await spaceSelector.clickSpaceCard(spaceId);
54+
55+
await common.navigateToApp('dashboard', { basePath: `/s/${spaceId}` });
56+
await dashboard.preserveCrossAppState();
57+
await dashboard.loadSavedDashboard('few panels');
58+
await dashboard.switchToEditMode();
59+
await dashboard.waitForRenderComplete();
60+
});
61+
62+
after(async () => {
63+
await security.forceLogout();
64+
65+
await kibanaServer.importExport.unload(
66+
'test/functional/fixtures/kbn_archiver/dashboard/current/kibana',
67+
{
68+
space: spaceId,
69+
}
70+
);
71+
await spacesService.delete(spaceId);
72+
await kibanaServer.savedObjects.cleanStandardList();
73+
});
74+
75+
it('should copy the dashboard url', async () => {
76+
await share.clickShareTopNavButton();
77+
// This is required because the default position causes clicking on permalinks, to display a tooltip that blocks the click
78+
await browser
79+
.getActions()
80+
.move({
81+
origin: (await testSubjects.find('sharePanel-Permalinks'))._webElement,
82+
x: -20,
83+
y: 0,
84+
})
85+
.perform();
86+
await share.checkShortenUrl();
87+
const shareUrl = await share.getSharedUrl();
88+
expect(shareUrl).to.contain(`/s/${spaceId}/`);
89+
});
90+
});
91+
}

0 commit comments

Comments
 (0)