@@ -31,7 +31,7 @@ export type EmbedDashboardParams = {
31
31
/** The id provided by the embed configuration UI in Superset */
32
32
id : string
33
33
/** The domain where Superset can be located, with protocol, such as: https://abc123.us1a.preset.io */
34
- supersetDomain : string // todo remove this option? after migrating to the preset frontend sdk
34
+ supersetDomain : string
35
35
/** The html element within which to mount the iframe */
36
36
mountPoint : HTMLElement
37
37
/** A function to fetch a guest token from the Host App's backend server */
@@ -40,6 +40,12 @@ export type EmbedDashboardParams = {
40
40
dashboardUiConfig ?: UiConfigType
41
41
/** Enables extra logging */
42
42
debug ?: boolean
43
+ /** The iframe title attribute */
44
+ iframeTitle ?: string
45
+ /** additional iframe sandbox attributes ex (allow-top-navigation, allow-popups-to-escape-sandbox) **/
46
+ iframeSandboxExtras ?: string [ ]
47
+ /** force a specific refererPolicy to be used in the iframe request **/
48
+ referrerPolicy ?: ReferrerPolicy
43
49
}
44
50
45
51
export type Size = {
@@ -60,7 +66,10 @@ export async function embedDashboard({
60
66
mountPoint,
61
67
fetchGuestToken,
62
68
dashboardUiConfig,
63
- debug = false
69
+ debug = false ,
70
+ iframeTitle = "Embedded Dashboard" ,
71
+ iframeSandboxExtras = [ ] ,
72
+ referrerPolicy,
64
73
} : EmbedDashboardParams ) : Promise < EmbeddedDashboard > {
65
74
function log ( ...info : unknown [ ] ) {
66
75
if ( debug ) {
@@ -112,7 +121,15 @@ export async function embedDashboard({
112
121
iframe . sandbox . add ( "allow-downloads" ) ; // for downloading charts as image
113
122
iframe . sandbox . add ( "allow-top-navigation" ) ; // for links to open
114
123
iframe . sandbox . add ( "allow-forms" ) ; // for forms to submit
115
- iframe . sandbox . add ( "allow-popups" ) ; // for exporting charts as csv
124
+ iframe . sandbox . add ( "allow-popups" ) ; // for exporting charts as csv
125
+ // additional sandbox props
126
+ iframeSandboxExtras . forEach ( ( key : string ) => {
127
+ iframe . sandbox . add ( key ) ;
128
+ } ) ;
129
+ // force a specific refererPolicy to be used in the iframe request
130
+ if ( referrerPolicy ) {
131
+ iframe . referrerPolicy = referrerPolicy ;
132
+ }
116
133
117
134
// add the event listener before setting src, to be 100% sure that we capture the load event
118
135
iframe . addEventListener ( 'load' , ( ) => {
@@ -122,6 +139,7 @@ export async function embedDashboard({
122
139
} ) ;
123
140
124
141
iframe . src = `${ supersetDomain } /embedded/${ id } ${ urlParamsString } ` ;
142
+ iframe . title = iframeTitle ;
125
143
mountPoint ?. replaceChildren ( iframe ) ;
126
144
log ( 'placed the iframe' )
127
145
} ) ;
0 commit comments