From 06bb4f95f591b50f14c61c758dff236eb0104b34 Mon Sep 17 00:00:00 2001 From: Alex Terentiev Date: Fri, 23 Mar 2018 10:33:43 -0700 Subject: [PATCH] Changes to import IFrameDialog correctly from the library --- .../docs/controls/IFrameDialog.md | 2 +- src/common/utilities/FieldRendererHelper.ts | 1 - .../FieldLookupRenderer.tsx | 2 +- src/controls/iFrameDialog/IFrameDialog.tsx | 6 +-- .../iFrameDialog/IFrameDialogContent.tsx | 4 +- .../controlsTest/components/ControlsTest.tsx | 40 +++++++++++++++++-- .../components/IControlsTestProps.ts | 1 + 7 files changed, 44 insertions(+), 12 deletions(-) diff --git a/docs/documentation/docs/controls/IFrameDialog.md b/docs/documentation/docs/controls/IFrameDialog.md index cb2de8f6e..bb686cce1 100644 --- a/docs/documentation/docs/controls/IFrameDialog.md +++ b/docs/documentation/docs/controls/IFrameDialog.md @@ -15,7 +15,7 @@ Here is an example of the control in action: import { IFrameDialog } from "@pnp/spfx-controls-react/lib/IFrameDialog"; ``` -- Use the `IFrameDialog` control in your code as follows: +- Use the `IFrameDialog` control in your code as follows (`this._onIframeLoaded` and `this._onDialogDismiss` are methods that should be implemented if you want to execute some actions when the iframe content is loaded and dialog should be closed respectively): ```TypeScript {}; + iframeOnLoad?: (iframe: any) => void; /** * iframe width */ @@ -29,7 +29,7 @@ export interface IFrameDialogState { /** * Dialog component to display content in iframe */ -export default class IFrameDialog extends React.Component { +export class IFrameDialog extends React.Component { public constructor(props: IFrameDialogProps, state: IFrameDialogState) { super(props, state); diff --git a/src/controls/iFrameDialog/IFrameDialogContent.tsx b/src/controls/iFrameDialog/IFrameDialogContent.tsx index 7d6271b3d..58b4d4c88 100644 --- a/src/controls/iFrameDialog/IFrameDialogContent.tsx +++ b/src/controls/iFrameDialog/IFrameDialogContent.tsx @@ -6,7 +6,7 @@ import styles from './IFrameDialogContent.module.scss'; export interface IIFrameDialogContentProps { url: string; close: () => void; - iframeOnLoad?: (iframe: any) => {}; + iframeOnLoad?: (iframe: any) => void; width: string; height: string; } @@ -14,7 +14,7 @@ export interface IIFrameDialogContentProps { /** * IFrame Dialog content */ -export default class IFrameDialogContent extends React.Component { +export class IFrameDialogContent extends React.Component { private _iframe: any; constructor(props: IIFrameDialogContentProps) { diff --git a/src/webparts/controlsTest/components/ControlsTest.tsx b/src/webparts/controlsTest/components/ControlsTest.tsx index 5e566c4b6..9c395765b 100644 --- a/src/webparts/controlsTest/components/ControlsTest.tsx +++ b/src/webparts/controlsTest/components/ControlsTest.tsx @@ -4,11 +4,15 @@ import { IControlsTestProps, IControlsTestState } from './IControlsTestProps'; import { escape } from '@microsoft/sp-lodash-subset'; import { FileTypeIcon, IconType, ApplicationType, ImageSize } from '../../../FileTypeIcon'; import { Dropdown, IDropdownOption } from 'office-ui-fabric-react/lib/components/Dropdown'; +import { PrimaryButton } from 'office-ui-fabric-react/lib/components/Button'; +import { DialogType } from 'office-ui-fabric-react/lib/components/Dialog'; import { Placeholder } from '../../../Placeholder'; import { ListView, IViewField, SelectionMode, GroupOrder, IGrouping } from '../../../ListView'; import { SPHttpClient } from '@microsoft/sp-http'; import { SiteBreadcrumb } from '../../../SiteBreadcrumb'; import { WebPartTitle } from '../../../WebPartTitle'; +import { IFrameDialog } from '../../../IFrameDialog'; +import { Environment, EnvironmentType } from '@microsoft/sp-core-library'; /** * Component that can be used to test out the React controls from this project @@ -19,7 +23,8 @@ export default class ControlsTest extends React.Component + title={this.props.title} + updateProperty={this.props.updateProperty} />
@@ -157,6 +170,25 @@ export default class ControlsTest extends React.Component
+
iframe dialog tester: + { this.setState({ iFrameDialogOpened: true }); }} /> + { console.log('iframe loaded'); }} + hidden={!this.state.iFrameDialogOpened} + onDismiss={() => { this.setState({ iFrameDialogOpened: false }); }} + modalProps={{ + isBlocking: true + }} + dialogContentProps={{ + type: DialogType.close, + showCloseButton: true + }} + width={'570px'} + height={'315px'} /> +
diff --git a/src/webparts/controlsTest/components/IControlsTestProps.ts b/src/webparts/controlsTest/components/IControlsTestProps.ts index e1c9b9bb3..9bf7dbef7 100644 --- a/src/webparts/controlsTest/components/IControlsTestProps.ts +++ b/src/webparts/controlsTest/components/IControlsTestProps.ts @@ -13,4 +13,5 @@ export interface IControlsTestProps { export interface IControlsTestState { imgSize: ImageSize; items: any[]; + iFrameDialogOpened?: boolean; }