-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dashboard] Fix share dashboard iframe embed code incorrectly (#194366)
## Summary Fixes [#192980](#193447) Maybe related pr: #179037 After fix it, having an URL that is like this: ``` ?embed=true&_g=(refreshInterval%3A(pause%3A!t%2Cvalue%3A60000)%2Ctime%3A(from%3Anow-15m%2Cto%3Anow))&hide-filter-bar=true ``` **Screenshot** <img width="1918" alt="image" src="https://github.com/user-attachments/assets/de069fdb-895e-479a-b868-891bbb55594e"> --------- Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Tim Sullivan <[email protected]>
- Loading branch information
1 parent
af53714
commit e4ff3bb
Showing
6 changed files
with
73 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/plugins/share/public/components/tabs/embed/embed_content.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { mountWithIntl } from '@kbn/test-jest-helpers'; | ||
import { EmbedContent } from './embed_content'; | ||
import React from 'react'; | ||
import { ReactWrapper } from 'enzyme'; | ||
|
||
describe('Share modal embed content tab', () => { | ||
describe('share url embedded', () => { | ||
let component: ReactWrapper; | ||
|
||
beforeEach(() => { | ||
component = mountWithIntl( | ||
<EmbedContent | ||
objectType="dashboard" | ||
setIsNotSaved={() => jest.fn()} | ||
shareableUrl="/home#/" | ||
/> | ||
); | ||
}); | ||
|
||
it('works for simple url', async () => { | ||
component.setProps({ shareableUrl: 'http://localhost:5601/app/home#/' }); | ||
component.update(); | ||
|
||
const shareUrl = component | ||
.find('button[data-test-subj="copyEmbedUrlButton"]') | ||
.prop('data-share-url'); | ||
expect(shareUrl).toBe( | ||
'<iframe src="http://localhost:5601/app/home#/?embed=true&_g=" height="600" width="800"></iframe>' | ||
); | ||
}); | ||
|
||
it('works if the url has a query string', async () => { | ||
component.setProps({ | ||
shareableUrl: | ||
'http://localhost:5601/app/dashboards#/create?_g=(refreshInterval%3A(pause%3A!t%2Cvalue%3A60000)%2Ctime%3A(from%3Anow-15m%2Cto%3Anow))', | ||
}); | ||
component.update(); | ||
|
||
const shareUrl = component | ||
.find('button[data-test-subj="copyEmbedUrlButton"]') | ||
.prop('data-share-url'); | ||
expect(shareUrl).toBe( | ||
'<iframe src="http://localhost:5601/app/dashboards#/create?embed=true&_g=(refreshInterval%3A(pause%3A!t%2Cvalue%3A60000)%2Ctime%3A(from%3Anow-15m%2Cto%3Anow))" height="600" width="800"></iframe>' | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters