Merged PR 136535: Use new embed configs interfaces

### Reason for PR:
Users are facing issue with old IEmbedConfig interface.
Refer this [GH issue](https://github.com/microsoft/powerbi-client-react/issues/29)

### Change Log:
1. Used new embedding config interfaces
1. Updated the demo app to use new IReportEmbedConfig interface
1. Updated README with new configs
1. Bump version to 1.3.1

Related work items: #510378
This commit is contained in:
Anant Singh 2021-01-13 12:56:16 +00:00
Родитель 8d9d175b38
Коммит ae6539f1db
5 изменённых файлов: 28 добавлений и 13 удалений

Просмотреть файл

@ -99,7 +99,13 @@ __Note__: To use this library in IE browser, use [react-app-polyfill](https://ww
interface EmbedProps {
// Configuration for embedding the PowerBI entity (required)
embedConfig: IEmbedConfiguration | IQnaEmbedConfiguration | IVisualEmbedConfiguration
embedConfig:
| IReportEmbedConfiguration
| IDashboardEmbedConfiguration
| ITileEmbedConfiguration
| IQnaEmbedConfiguration
| IVisualEmbedConfiguration
| IEmbedConfiguration
// Callback method to get the embedded PowerBI entity object (optional)
getEmbed?: { (embeddedComponent: Embed): void }

Просмотреть файл

@ -2,7 +2,7 @@
// Licensed under the MIT License.
import React, { useState } from 'react';
import { models, Report, Embed, IEmbedConfiguration, service, Page } from 'powerbi-client';
import { models, Report, Embed, service, Page } from 'powerbi-client';
import { PowerBIEmbed } from 'powerbi-client-react';
import 'powerbi-report-authoring';
import './DemoApp.css';
@ -18,7 +18,7 @@ function DemoApp (): JSX.Element {
// Report config useState hook
// Values for properties like embedUrl, accessToken and settings will be set on click of buttons below
const [sampleReportConfig, setReportConfig] = useState<IEmbedConfiguration>({
const [sampleReportConfig, setReportConfig] = useState<models.IReportEmbedConfiguration>({
type: 'report',
embedUrl: undefined,
tokenType: models.TokenType.Embed,

Просмотреть файл

@ -7,7 +7,7 @@
},
"license": "MIT",
"dependencies": {
"powerbi-client-react": "^1.3.0",
"powerbi-client-react": "^1.3.1",
"powerbi-report-authoring": "^1.1",
"react-app-polyfill": "^1.0.6"
},

Просмотреть файл

@ -1,6 +1,6 @@
{
"name": "powerbi-client-react",
"version": "1.3.0",
"version": "1.3.1",
"description": "React wrapper for powerbi-client library",
"main": "dist/powerbi-client-react.js",
"types": "dist/powerbi-client-react.d.ts",
@ -30,7 +30,7 @@
"license": "MIT",
"dependencies": {
"lodash.isequal": "^4.5.0",
"powerbi-client": "^2.15.1"
"powerbi-client": "^2.16.5"
},
"peerDependencies": {
"react": ">= 16"

Просмотреть файл

@ -10,11 +10,14 @@ import {
Dashboard,
Tile,
Qna,
IEmbedConfiguration,
Visual,
IQnaEmbedConfiguration,
IEmbedSettings,
IEmbedConfiguration,
IQnaEmbedConfiguration,
IVisualEmbedConfiguration,
IReportEmbedConfiguration,
IDashboardEmbedConfiguration,
ITileEmbedConfiguration,
} from 'powerbi-client';
import isEqual from 'lodash.isequal';
import { stringifyMap } from './utils';
@ -31,8 +34,14 @@ export type EventHandler = {
*/
export interface EmbedProps {
// Configuration for embedding the PowerBI entity
embedConfig: IEmbedConfiguration | IQnaEmbedConfiguration | IVisualEmbedConfiguration;
// Configuration for embedding the PowerBI entity (Required)
embedConfig:
| IReportEmbedConfiguration
| IDashboardEmbedConfiguration
| ITileEmbedConfiguration
| IQnaEmbedConfiguration
| IVisualEmbedConfiguration
| IEmbedConfiguration;
// Callback method to get the embedded PowerBI entity object (Optional)
getEmbeddedComponent?: { (embeddedComponent: Embed): void };
@ -140,9 +149,9 @@ export class PowerBIEmbed extends React.Component<EmbedProps> {
// Update pageName and filters for a report
if (this.props.embedConfig.type === EmbedType.Report) {
// Typecasting to IEmbedConfiguration as IQnAEmbedConfiguration does not have pageName
const embedConfig = this.props.embedConfig as IEmbedConfiguration;
const prevEmbedConfig = prevProps.embedConfig as IEmbedConfiguration;
// Typecasting to IReportEmbedConfiguration
const embedConfig = this.props.embedConfig as IReportEmbedConfiguration;
const prevEmbedConfig = prevProps.embedConfig as IReportEmbedConfiguration;
// Set new page if available and different from the previous page
if (embedConfig.pageName && embedConfig.pageName !== prevEmbedConfig.pageName) {