Skip to content

Commit

Permalink
[PowerBI] Decouple addin settings, default "Show zoom bar" to true (#…
Browse files Browse the repository at this point in the history
…2342)

<!-- Thank you for submitting a Pull Request. If you're new to
contributing to BCApps please read our pull request guideline below
* https://github.com/microsoft/BCApps/Contributing.md
-->
#### Summary <!-- Provide a general summary of your changes -->
The Power BI Embedded control add-in currently supports a bunch of
different settings that change the embed experience making it richer and
more customizable.
These settings are currently controlled with the `SetSettings` add-in
function, which takes a bunch of booleans. This is of course not very
readable nor very extensible.

This PR cleans up the code for these settings by having a different
function to set up each setting. It also flips the default for the "Show
Status Bar" setting to true; this is for accessibility reasons, as
full-page reports might not be accessible or "navigable" without the
zoom controls.

#### Work Item(s) <!-- Add the issue number here after the #. The issue
needs to be open and approved. Submitting PRs with no linked issues or
unapproved issues is highly discouraged. -->
Fixes
[AB#556723](https://dynamicssmb2.visualstudio.com/1fcb79e7-ab07-432a-a3c6-6cf5a88ba4a5/_workitems/edit/556723)
  • Loading branch information
encimita authored Nov 29, 2024
1 parent f9210ad commit 9b1c029
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var pbiAuthToken = null;
var _showBookmarkSelection = false;
var _showFilters = false;
var _showPageSelection = false;
var _showZoomBar = false;
var _showZoomBar = true;
var _forceTransparentBackground = false;
var _forceFitToPage = false;
var _addBottomPadding = false;
Expand Down Expand Up @@ -147,6 +147,17 @@ function InitializeFrame(fullpage, ratio) {
}
}

function SetSettings(showBookmarkSelection, showFilters, showPageSelection, showZoomBar, forceTransparentBackground, forceFitToPage, addBottomPadding) {
// OBSOLETE
_showBookmarkSelection = showBookmarkSelection;
_showFilters = showFilters;
_showPageSelection = showPageSelection;
_showZoomBar = showZoomBar;
_forceTransparentBackground = forceTransparentBackground;
_addBottomPadding = addBottomPadding;
_forceFitToPage = forceFitToPage;
}

// Exposed Functions

function EmbedPowerBIReport(reportLink, reportId, pageName) {
Expand Down Expand Up @@ -345,14 +356,24 @@ function SetToken(authToken) {
pbiAuthToken = authToken;
}

function SetSettings(showBookmarkSelection, showFilters, showPageSelection, showZoomBar, forceTransparentBackground, forceFitToPage, addBottomPadding) {
_showBookmarkSelection = showBookmarkSelection;
_showFilters = showFilters;
_showPageSelection = showPageSelection;
_showZoomBar = showZoomBar;
_forceTransparentBackground = forceTransparentBackground;
_forceFitToPage = forceFitToPage;
_addBottomPadding = addBottomPadding;
function SetBookmarksVisible(visible) {
_showBookmarkSelection = visible;
}

function SetFiltersVisible(visible) {
_showFilters = visible;
}

function SetPageSelectionVisible(visible) {
_showPageSelection = visible;
}

function SetTransparentBackground(transparent) {
_forceTransparentBackground = transparent;
}

function AddBottomPadding(addPadding) {
_addBottomPadding = addPadding;
}

// Internal functions
Expand Down Expand Up @@ -504,14 +525,18 @@ function LogErrorToConsole(operation, error) {
}

function GetErrorMessage(error) {
if (error && error.message) {
return error.message;
if (error && error.detail && error.detail.detailedMessage) {
return error.detail.detailedMessage;
}

if (error && error.detail && error.detail.message) {
return error.detail.message;
}

if (error && error.message) {
return error.message;
}

return error.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,37 @@ controladdin PowerBIManagement
/// <param name="NewLocale">The locale to use, for example "en-us".</param>
procedure SetLocale(NewLocale: Text);

/// <summary>
/// Controls whether the bookmark selection pane will be visible in the embed experience. Defaults to false.
/// </summary>
/// <param name="Visible">Whether bookmarks should be visible.</param>
procedure SetBookmarksVisible(Visible: Boolean);

/// <summary>
/// Controls whether the filter pane will be visible in the embed experience. Defaults to false.
/// </summary>
/// <param name="Visible">Whether filters should be visible.</param>
procedure SetFiltersVisible(Visible: Boolean);

/// <summary>
/// Controls whether the page selection bar will be visible in the embed experience. Defaults to false.
/// </summary>
/// <param name="Visible">Whether page selection should be visible.</param>
procedure SetPageSelectionVisible(Visible: Boolean);

/// <summary>
/// Controls whether the report background should be set to transparent regardless of the actual color. Defaults to false.
/// </summary>
/// <param name="Visible">Whether the background should be force to transparent.</param>
procedure SetTransparentBackground(Transparent: Boolean);

/// <summary>
/// Controls whether the addin includes a bottom padding that makes it look nicer in some embedded scenarios. Defaults to false.
/// </summary>
/// <param name="AddPadding">Whether the bottom padding should be added.</param>
procedure AddBottomPadding(AddPadding: Boolean);

#if not CLEAN26
/// <summary>
/// Sets the properties for the embed experience
/// </summary>
Expand All @@ -140,7 +171,9 @@ controladdin PowerBIManagement
///<param name="ForceTransparentBackground">Forces a transparent background to the embed.</param>
///<param name="ForceFitToPage">Forces the Fit To Page behaviour for the embed.</param>
///<param name="AddBottomPadding">Controls whether a padding is needed on the bottom of the page (useful in case the embed is the only element displayed on the page).</param>
[Obsolete('Use SetBookmarksVisible, SetFiltersVisible, AddBottomPadding, SetTransparentBackground, and SetPageSelectionVisible instead. The other options are no longer supported.', '26.0')]
procedure SetSettings(ShowBookmarkSelection: Boolean; ShowFilters: Boolean; ShowPageSelection: Boolean; ShowZoomBar: Boolean; ForceTransparentBackground: Boolean; ForceFitToPage: Boolean; AddBottomPadding: Boolean);
#endif

#if not CLEAN25
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var pbiAuthToken = null;
var _showBookmarkSelection = false;
var _showFilters = false;
var _showPageSelection = false;
var _showZoomBar = false;
var _showZoomBar = true;
var _forceTransparentBackground = false;
var _forceFitToPage = false;
var _addBottomPadding = false;
Expand Down Expand Up @@ -147,6 +147,17 @@ function InitializeFrame(fullpage, ratio) {
}
}

function SetSettings(showBookmarkSelection, showFilters, showPageSelection, showZoomBar, forceTransparentBackground, forceFitToPage, addBottomPadding) {
// OBSOLETE
_showBookmarkSelection = showBookmarkSelection;
_showFilters = showFilters;
_showPageSelection = showPageSelection;
_showZoomBar = showZoomBar;
_forceTransparentBackground = forceTransparentBackground;
_addBottomPadding = addBottomPadding;
_forceFitToPage = forceFitToPage;
}

// Exposed Functions

function EmbedPowerBIReport(reportLink, reportId, pageName) {
Expand Down Expand Up @@ -345,14 +356,24 @@ function SetToken(authToken) {
pbiAuthToken = authToken;
}

function SetSettings(showBookmarkSelection, showFilters, showPageSelection, showZoomBar, forceTransparentBackground, forceFitToPage, addBottomPadding) {
_showBookmarkSelection = showBookmarkSelection;
_showFilters = showFilters;
_showPageSelection = showPageSelection;
_showZoomBar = showZoomBar;
_forceTransparentBackground = forceTransparentBackground;
_forceFitToPage = forceFitToPage;
_addBottomPadding = addBottomPadding;
function SetBookmarksVisible(visible) {
_showBookmarkSelection = visible;
}

function SetFiltersVisible(visible) {
_showFilters = visible;
}

function SetPageSelectionVisible(visible) {
_showPageSelection = visible;
}

function SetTransparentBackground(transparent) {
_forceTransparentBackground = transparent;
}

function AddBottomPadding(addPadding) {
_addBottomPadding = addPadding;
}

// Internal functions
Expand Down Expand Up @@ -504,14 +525,18 @@ function LogErrorToConsole(operation, error) {
}

function GetErrorMessage(error) {
if (error && error.message) {
return error.message;
if (error && error.detail && error.detail.detailedMessage) {
return error.detail.detailedMessage;
}

if (error && error.detail && error.detail.message) {
return error.detail.message;
}

if (error && error.message) {
return error.message;
}

return error.toString();
}

Expand Down

0 comments on commit 9b1c029

Please sign in to comment.