From a0889c88e82c315855f5c12e980a8ba622d68fb6 Mon Sep 17 00:00:00 2001 From: Harsha Vardhini Date: Mon, 18 May 2020 13:37:26 +0530 Subject: [PATCH] Delete SaveEmailToSharePoint.tsx --- .../components/SaveEmailToSharePoint.tsx | 200 ------------------ 1 file changed, 200 deletions(-) delete mode 100644 samples/react-office-add-in-save-email-to-sharepoint/src/webparts/saveEmailToSharePoint/components/SaveEmailToSharePoint.tsx diff --git a/samples/react-office-add-in-save-email-to-sharepoint/src/webparts/saveEmailToSharePoint/components/SaveEmailToSharePoint.tsx b/samples/react-office-add-in-save-email-to-sharepoint/src/webparts/saveEmailToSharePoint/components/SaveEmailToSharePoint.tsx deleted file mode 100644 index 38329217e..000000000 --- a/samples/react-office-add-in-save-email-to-sharepoint/src/webparts/saveEmailToSharePoint/components/SaveEmailToSharePoint.tsx +++ /dev/null @@ -1,200 +0,0 @@ -import * as React from 'react'; -import styles from './SaveEmailToSharePoint.module.scss'; -import { ISaveEmailToSharePointProps } from './ISaveEmailToSharePointProps'; -import { SearchResults } from "@pnp/sp/search"; -import { Icon, Dropdown, IDropdownOption, IDropdownStyles, PrimaryButton, Label, IDropdownProps, Link, MessageBar, MessageBarType, MessageBarButton } from 'office-ui-fabric-react'; -import Services from './Services/Services'; -import * as strings from 'SaveEmailToSharePointWebPartStrings'; - - -const dropdownStyles: Partial = { dropdown: { width: 300 } }; -interface SaveEmailToSharePointState { - allSites: any; - selectedSite: any; - allLibraries: any; - selectedLibrary: any; - savedLink: string; - rootURL: string; - errMsg: string; -} -export default class SaveEmailToSharePoint extends React.Component { - private services = new Services(); - constructor(props: ISaveEmailToSharePointProps, state: SaveEmailToSharePointState) { - super(props); - this.state = { - allSites: null, - selectedSite: null, - allLibraries: null, - selectedLibrary: null, - savedLink: '', - rootURL: '', - errMsg: '' - }; - } - public componentWillMount() { - this.getAllSites(); - this.getRootURL(); - } - - public getRootURL = () => { - this.services.getRootSiteURL().then((rootURL) => { - this.setState({ - rootURL: rootURL - }); - }); - } - private saveToLibrary = (file) => { - let filename = Office.context.mailbox.item.subject + ".eml"; - this.services.saveFileToSP(this.state.selectedSite.key, this.state.selectedLibrary.key, filename, file).then((result) => { - console.log(result.data.ServerRelativeUrl); - this.setState({ - savedLink: this.state.rootURL + result.data.ServerRelativeUrl + "?web=1", - errMsg:'' - }); - }).catch((err) => { - this.setState({ - errMsg: this.parseErr(err.message), - savedLink:'' - }); - }); - } - public getAllSites = () => { - this.services.getSiteNames().then((allSiteResults: SearchResults) => { - console.log(allSiteResults.PrimarySearchResults); - let allsite = []; - allSiteResults.PrimarySearchResults.forEach(element => { - let siteValue = { key: element.Path, text: element.Title }; - allsite.push(siteValue); - }); - this.setState({ - allSites: allsite - }); - }); - } - public getCurrentEmailContent = () => { - let id = Office.context.mailbox.item.itemId; - this.services.getEmailContent(this.props.context, id).then((response: any) => { - this.saveToLibrary(response); - }).catch((err) => { - this.setState({ - errMsg: "Graph API error: " + this.parseErr(err.message), - savedLink:'' - }); - }); - } - public parseErr = (msg:string) => { - return JSON.parse(msg.substring(msg.indexOf('"message"')+10,msg.length-2)).value; - } - public OnSelectSite = (event: React.FormEvent, item: IDropdownOption) => { - this.services.getAllDocumentLibary(item.key.toString()).then((libraries) => { - if (libraries.length) { - let allLib = []; - libraries.forEach(element => { - let library = { key: element.ServerRelativeUrl, text: element.Title }; - allLib.push(library); - }); - this.setState({ - selectedSite: item, - allLibraries: allLib - }); - } else { - this.setState({ - selectedSite: item, - savedLink: '', - errMsg: '' - }); - } - }); - - } - public OnSelectLibrary = (event: React.FormEvent, item: IDropdownOption) => { - this.setState({ - selectedLibrary: item, - savedLink: '' - }); - } - public render(): React.ReactElement { - return ( -
-
- {this.state.allSites ? : null} -
-
- {this.state.allLibraries ? : null} -
-
- - - { Office.context.ui.closeContainer(); }} /> -
-
- {this.state.savedLink.length ? - - window.open(this.state.savedLink,'_blank')}>OK -
- }> - {strings.PreviewMessage.replace("{libName}", this.state.selectedLibrary.text)} - - : null} - {this.state.errMsg.length ? - {this.state.errMsg} - - : null} -
- - ); - } - public onRenderforLib = (props: IDropdownProps): JSX.Element => { - return ( - - - {props.label} - - ); - } - public onRenderforSite = (props: IDropdownProps): JSX.Element => { - return ( - - - {props.label} - - ); - } -}