Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Part IV of the Security Classification Extension
import * as React from "react";
import { IClassificationHeaderProps, IClassificationHeaderState, DefaultClassification } from "./ClassificationHeader.types";
import { MessageBar, MessageBarType } from "office-ui-fabric-react/lib/MessageBar";
import { Link } from "office-ui-fabric-react/lib/Link";
import { Web } from "sp-pnp-js/lib/pnp";
import { ClassificationPropertyBag } from "../../../../lib/extensions/classificationExtension/components/ClassificationHeader.types";
export default class ClassificationHeader extends React.Component<IClassificationHeaderProps, IClassificationHeaderState> {
constructor(props: IClassificationHeaderProps) {
super(props);
this.state = {
isLoading: true,
businessImpact: null
};
}
public componentDidMount(): void {
this.setState({
isLoading: true,
businessImpact: null
});
const web: Web = new Web(this.props.context.pageContext.web.absoluteUrl);
web.select("Title", "AllProperties")
.expand("AllProperties")
.get()
.then(r => {
var businessImpact:string = DefaultClassification;
// handle the default situation where there is no classification
if (r.AllProperties && r.AllProperties[ClassificationPropertyBag]) {
businessImpact = r.AllProperties[ClassificationPropertyBag];
}
this.setState({
isLoading: false,
businessImpact: businessImpact
});
console.log("All properties results", r);
});
}
public render(): React.ReactElement<IClassificationHeaderProps> {
return (
<MessageBar
messageBarType={MessageBarType.warning}
>
This site is classified as {this.state.businessImpact}. <Link href="www.bing.com">Learn more about the proper handling procedures.</Link>
</MessageBar>
);
}
}
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.