Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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,
PlaceholderName,
PlaceholderContent
} from "@microsoft/sp-application-base";
import { Dialog } from "@microsoft/sp-dialog";
import * as strings from "ClassificationExtensionApplicationCustomizerStrings";
import ClassificationHeader from "../../../lib/extensions/classificationExtension/components/ClassificationHeader";
import { IClassificationHeaderProps } from "./components/ClassificationHeader.types";
const LOG_SOURCE: string = "ClassificationExtensionApplicationCustomizer";
/**
* 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 IClassificationExtensionApplicationCustomizerProperties {
// this is an example; replace with your own property
testMessage: string;
}
/** A Custom Action which can be run during execution of a Client Side Application */
export default class ClassificationExtensionApplicationCustomizer
extends BaseApplicationCustomizer<IClassificationExtensionApplicationCustomizerProperties> {
private _topPlaceholder: PlaceholderContent | undefined;
@override
public onInit(): Promise<void> {
const header: PlaceholderContent = this.context.placeholderProvider.tryCreateContent(
PlaceholderName.Top,
{ onDispose: this._onDispose }
);
if (!this._topPlaceholder) {
this._topPlaceholder = this.context.placeholderProvider.tryCreateContent(
PlaceholderName.Top,
{ onDispose: this._onDispose });
// the extension should not assume that the expected placeholder is available.
if (!this._topPlaceholder) {
console.error("The header placeholder was not found.");
return;
}
const elem: React.ReactElement<IClassificationHeaderProps> = React.createElement(ClassificationHeader, {
});
ReactDom.render(elem, this._topPlaceholder.domElement);
}
}
private _onDispose(): void {
// empty
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.