import * as React from 'react' ; import * as ReactDom from 'react-dom' ; import { override } from '@microsoft/decorators' ; import { Log } from '@microsoft/sp-core-library' ; import { BaseApplicationCustomizer , PlaceholderContent , PlaceholderName } from '@microsoft/sp-application-base' ; import { Dialog } from '@microsoft/sp-dialog' ; import { SPService } from '../Common/Services/SPService' ; import { IFollowedSitesProps } from './components/followedSites/IFollowedSitesProps' ; import FollowedSites from './components/followedSites/FollowedSites' ; import * as strings from 'MyFollowedSitesApplicationCustomizerStrings' ; const LOG_SOURCE = 'MyFollowedSitesApplicationCustomizer' ; /**
 * If your command set uses the ClientSideComponentProperties JSON input,
 * it will be deserialized into the BaseExtension.properties object.
 * You can define an interface to describe it.
 */ export interface IMyFollowedSitesApplicationCustomizerProperties { testMessage : string ; } /** A Custom Action which can be run during execution of a Client Side Application */ export default class MyFollowedSitesApplicationCustomizer extends BaseApplicationCustomizer < IMyFollowedSitesApplicationCustomizerProperties > { private _bottomPlaceholder : PlaceholderContent | undefined ; private _spService : SPService | undefined ; description @ override public onInit ( ) { Log . info ( LOG_SOURCE , `Initialized ${ strings . Title }` ) ; this . context . placeholderProvider . changedEvent . add ( this , this . renderPlaceholders ) ; this . renderPlaceholders ( ) ; return Promise . resolve ( ) ; } description private renderPlaceholders ( ) { try { this . _spService = new SPService ( this . context ) ; if ( ! this . _bottomPlaceholder ) { this . _bottomPlaceholder = this . context . placeholderProvider . tryCreateContent ( PlaceholderName . Bottom , { onDispose : this . _onDispose } ) ; } if ( ! this . _bottomPlaceholder ) { console . error ( 'The expected placeholder {bottom} is not available.' ) ; return ; } if ( this . _bottomPlaceholder ) { const myFollowedSiteControl = React . createElement ( FollowedSites , { spService : this . _spService , currentContext : this . context } ) ; ReactDom . render ( myFollowedSiteControl , this . _bottomPlaceholder . domElement ) ; } } catch ( error ) { console . log ( "Exception in renderPlaceholders:" + JSON . stringify ( error ) ) ; } } private _onDispose ( ) { console . log ( '[MyFollowedSitesApplicationCustomizer._onDispose] Disposed custom top and bottom placeholders.' ) ; } }