Skip to content

Commit 0d6bb1a

Browse files
author
Shahak Yosef
committed
Merged PR 191366: Fix application context in bootstrap case
Fix application context in bootstrap case
1 parent 2a68994 commit 0d6bb1a

File tree

7 files changed

+30
-23
lines changed

7 files changed

+30
-23
lines changed

dist/powerbi-client.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// powerbi-client v2.18.4
1+
// powerbi-client v2.18.5
22
// Copyright (c) Microsoft Corporation.
33
// Licensed under the MIT License.
44
declare module "config" {

dist/powerbi.js

Lines changed: 13 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/powerbi.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "powerbi-client",
3-
"version": "2.18.4",
3+
"version": "2.18.5",
44
"description": "JavaScript library for embedding Power BI into your apps. Provides service which makes it easy to embed different types of components and an object model which allows easy interaction with these components such as changing pages, applying filters, and responding to data selection.",
55
"main": "dist/powerbi.js",
66
"types": "dist/powerbi-client.d.ts",

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/** @ignore *//** */
55
const config = {
6-
version: '2.18.4',
6+
version: '2.18.5',
77
type: 'js'
88
};
99

src/embed.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,15 +227,12 @@ export abstract class Embed {
227227
this.commands = [];
228228
this.groups = [];
229229

230-
const registerQueryCallback = !!(<IEmbedConfiguration>config).eventHooks?.applicationContextProvider;
231-
delete (<IEmbedConfiguration>config).eventHooks;
232-
233230
this.populateConfig(config, isBootstrap);
234231

235232
if (this.embedtype === 'create') {
236-
this.setIframe(false /* set EventListener to call create() on 'load' event*/, phasedRender, isBootstrap, registerQueryCallback);
233+
this.setIframe(false /* set EventListener to call create() on 'load' event*/, phasedRender, isBootstrap);
237234
} else {
238-
this.setIframe(true /* set EventListener to call load() on 'load' event*/, phasedRender, isBootstrap, registerQueryCallback);
235+
this.setIframe(true /* set EventListener to call load() on 'load' event*/, phasedRender, isBootstrap);
239236
}
240237
}
241238

@@ -540,6 +537,11 @@ export abstract class Embed {
540537
this.config.accessToken = this.getAccessToken(this.service.accessToken);
541538
}
542539

540+
const registerQueryCallback = !!(<IEmbedConfiguration>this.config).eventHooks?.applicationContextProvider;
541+
delete (<IEmbedConfiguration>this.config).eventHooks;
542+
if (registerQueryCallback && this.embedtype === "report")
543+
this.config.embedUrl = addParamToUrl(this.config.embedUrl, "registerQueryCallback", "true");
544+
543545
this.configChanged(isBootstrap);
544546
}
545547

@@ -710,9 +712,6 @@ export abstract class Embed {
710712
const iframeContent = document.createElement("iframe");
711713
let embedUrl = this.config.uniqueId ? addParamToUrl(this.config.embedUrl, 'uid', this.config.uniqueId) : this.config.embedUrl;
712714

713-
if (!isBootstrap && registerQueryCallback)
714-
embedUrl = addParamToUrl(embedUrl, "registerQueryCallback", "true");
715-
716715
iframeContent.style.width = '100%';
717716
iframeContent.style.height = '100%';
718717
iframeContent.setAttribute("src", embedUrl);

src/service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ export class Service implements IService {
326326
* @param {IBootstrapEmbedConfiguration} config: a bootstrap config which is an embed config without access token.
327327
*/
328328
bootstrap(element: HTMLElement, config: IComponentEmbedConfiguration | IBootstrapEmbedConfiguration): Embed {
329+
this.registerApplicationContextHook(config as IEmbedConfiguration);
329330
return this.embedInternal(element, config, /* phasedRender */ false, /* isBootstrap */ true);
330331
}
331332

@@ -451,6 +452,10 @@ export class Service implements IService {
451452
return;
452453
}
453454

455+
if (config?.type.toLowerCase() !== "report") {
456+
throw new Error("applicationContextProvider is only supported in report embed");
457+
}
458+
454459
if (typeof applicationContextProvider !== 'function') {
455460
throw new Error("applicationContextProvider must be a function");
456461
}

0 commit comments

Comments
 (0)