UNPKG

@mikezimm/npmfunctions

Version:
258 lines (192 loc) 12.2 kB
/** * The purpose of this file is to build the FPS Banner props in a standard way. * To benefit from typescript, it's meant to be copied to the specific webpart using it */ import { WebPartContext } from '@microsoft/sp-webpart-base'; // import { DisplayMode, Version } from '@microsoft/sp-core-library'; import { IPropertyFieldGroupOrPerson } from "@pnp/spfx-property-controls/lib/PropertyFieldPeoplePicker"; // For SPPermission: let addAndCustomizePages = pageContext.web.permissions.hasPermission( SPPermission.addAndCustomizePages ); // import { SPPermission } from '@microsoft/sp-page-context'; import "@pnp/sp/webs"; import "@pnp/sp/site-groups/web"; /*** * d888888b .88b d88. d8888b. .d88b. d8888b. d888888b d8b db d8888b. .88b d88. d88888b db db d8b db .o88b. d888888b d888888b .d88b. d8b db .d8888. * `88' 88'YbdP`88 88 `8D .8P Y8. 88 `8D `~~88~~' 888o 88 88 `8D 88'YbdP`88 88' 88 88 888o 88 d8P Y8 `~~88~~' `88' .8P Y8. 888o 88 88' YP * 88 88 88 88 88oodD' 88 88 88oobY' 88 88V8o 88 88oodD' 88 88 88 88ooo 88 88 88V8o 88 8P 88 88 88 88 88V8o 88 `8bo. * 88 88 88 88 88~~~ 88 88 88`8b 88 88 V8o88 88~~~ 88 88 88 88~~~ 88 88 88 V8o88 8b 88 88 88 88 88 V8o88 `Y8b. * .88. 88 88 88 88 `8b d8' 88 `88. 88 88 V888 88 88 88 88 88 88b d88 88 V888 Y8b d8 88 .88. `8b d8' 88 V888 db 8D * Y888888P YP YP YP 88 `Y88P' 88 YD YP VP V8P 88 YP YP YP YP ~Y8888P' VP V8P `Y88P' YP Y888888P `Y88P' VP V8P `8888Y' * * */ // import { createStyleFromString, getReactCSSFromString, ICurleyBraceCheck } from '../../Services/PropPane/StringToReactCSS'; // import { IWebpartBannerProps,} from './bannerProps'; // import { baseBannerCmdStyles, baseBannerStyles} from './defaults'; import { EveryoneAudienceChoices, IEveryoneAudience, PageEditorAudienceChoices, IPageEditorAudience } from '../../Services/PropPane/Audiences' ; // import { getHelpfullError, getHelpfullErrorV2 } from '../../Services/Logging/ErrorHandler'; import { IRepoLinks } from '../../Links/CreateLinks'; // import { verifyAudienceVsUser } from '../../Services/Users/CheckPermissions'; import { IFPSUser, } from '../../Services/Users/IUserInterfaces'; import { IWebpartHistory, } from '../../Services/PropPane/WebPartHistory/Interface'; import { ISupportedHost } from '../../Services/PropPane/FPSInterfaces'; import { IPinMeState } from "../../Services/DOM/PinMe/FPSPinMenu"; //, exportIgnoreProps, importBlockProps, importBlockPropsDev //These props will not be exported even if they are in one of the change arrays above (fail-safe) //This was done to always insure these values are not exported to the user //Common props to Ignore export export const exportIgnorePropsFPS : string[] = [ 'analyticsList', 'analyticsWeb', ]; //Common props to block import export const importBlockPropsFPS : string[] = [ 'scenario', 'analyticsList', 'analyticsWeb', 'lastPropDetailChange', 'showBanner' , 'showTricks', 'showRepoLinks', 'showExport', 'fpsImportProps', 'fullPanelAudience', 'documentationIsValid', 'requireDocumentation', 'requireContacts', 'currentWeb', 'loadPerformance', 'webpartHistory', 'pageLayout' ]; export interface IMinBannerUIProps { // Added number due to ALVFinManWebPartProps [key: string]: string | number |boolean | IEveryoneAudience | IPageEditorAudience; showBanner: boolean; showBannerGear: boolean; // Not in Prop Pane - enables the site settings links showGoToHome: boolean; //defaults to true showGoToParent: boolean; //defaults to true homeParentGearAudience: IEveryoneAudience; bannerTitle: string; infoElementChoice: string; infoElementText: string; //For CoreFPSVisitorPanelComponent.tsx feedbackEmail: string; //For email icon right in banner. beAUserAudience: IPageEditorAudience; // For BeAUserAudience - but never use Readers or Everyone } export const changeBannerBasics : string[] = [ 'searchShow', 'showBanner', 'bannerTitle', 'infoElementChoice', 'infoElementText', 'feedbackEmail', 'beAUserAudience' ]; export const changeBannerNav : string[] = [ 'showGoToHome', 'showGoToParent', 'homeParentGearAudience', 'showBannerGear' ]; // ####################################################### ####################################################### // ####################################################### ####################################################### export interface IMinPinMeProps { // When I add this set of key types, erros in ALVFinMan go away. // error TS2430: Interface 'IAlvFinManWebPartProps' incorrectly extends interface 'IMinPinMeProps'. // [key: string]: string | IPinMeState | boolean | number | string[] | IWebpartHistory | ILoadPerformanceALVFM | IPropertyFieldGroupOrPerson[] ; [key: string]: string | IPinMeState | boolean ; //Added string because of error on IMinWPBannerProps // For FPS Pin Me function defPinState: IPinMeState; forcePinState: boolean; } //Should match keys of IMinWPBannerProps in src\HelpPanelOnNPM\onNpm\BannerInterface.ts export const changePinMe : string[] = [ 'defPinState', 'forcePinState' ]; // ####################################################### ####################################################### // ####################################################### ####################################################### export interface IMinPandoramicProps { [key: string]: string | boolean | number | IEveryoneAudience | any | undefined ; //2022-02-17: Added these for expandoramic mode enableExpandoramic: boolean; expandoDefault: boolean; expandoStyle: any; expandoPadding: number; expandoAudience: IEveryoneAudience; } export const changeExpando : string[] = [ 'enableExpandoramic','expandoDefault','expandoStyle', 'expandoPadding', 'expandoAudience', ]; // ####################################################### ####################################################### // ####################################################### ####################################################### export interface IMinBannerThemeProps { [key: string]: string | boolean; bannerStyleChoice: string; bannerStyle: string; bannerCmdStyle: string; lockStyles: boolean; bannerHoverEffect: boolean; } export const changeBannerTheme : string[] = [ 'bannerStyleChoice', 'bannerStyle', 'bannerCmdStyle', 'lockStyles', 'bannerHoverEffect', ]; // ####################################################### ####################################################### // ####################################################### ####################################################### export interface IMinCustomHelpProps { [key: string]: string | boolean | IPropertyFieldGroupOrPerson[] | any | undefined ; showCustomHelp: boolean; fullPanelAudience : IEveryoneAudience; replacePanelHTML : any; //This is the jsx sent to panel for User controled information (aka what reader will see when clicking 'info' button) //These are added for the minimum User Panel component ( which turns into the replacePanelHTML component ) panelMessageDescription1: string; // panelMessageSupport: string; panelMessageDocumentation: string; panelMessageIfYouStill: string; requireDocumentation: boolean; //Should be adjusted using PreConfiguredPresets if needed on WP or site basis documentationLinkDesc: string; documentationLinkUrl: string; documentationIsValid: boolean; requireContacts: boolean; //This is used to throw an error if it is required but there are no contacts. supportContacts: IPropertyFieldGroupOrPerson[]; } export const changeCustomHelp : string[] = [ 'panelMessageDescription1', 'panelMessageSupport', 'panelMessageDocumentation', 'panelMessageIfYouStill', 'documentationLinkDesc', 'documentationLinkUrl', 'documentationIsValid', 'supportContacts', 'requireDocumentation', 'requireContacts' ]; // ####################################################### ####################################################### // ####################################################### ####################################################### export interface IMinPageStyleProps { [key: string]: string | number | boolean ; //Added string because of error on IMinWPBannerProps //FPS Options part II quickLaunchHide: boolean; pageHeaderHide: boolean; allSectionMaxWidthEnable: boolean; allSectionMaxWidth: number; allSectionMarginEnable: boolean; allSectionMargin: number; toolBarHide: boolean; } export const changePageStyle : string[] = [ 'quickLaunchHide', 'pageHeaderHide', 'allSectionMaxWidthEnable', 'allSectionMaxWidth', 'allSectionMarginEnable', 'allSectionMargin', 'toolBarHide', ]; // ####################################################### ####################################################### // ####################################################### ####################################################### export interface IMinBannerUtilityProps { [key: string]: string | ISupportedHost | boolean | IWebpartHistory ; uniqueId: string; pageLayout: ISupportedHost ;// like SinglePageApp etc... this.context[_pageLayout]; showRepoLinks: boolean; showExport: boolean; fpsImportProps: string; //ADDED FOR WEBPART HISTORY: webpartHistory: IWebpartHistory; showTricks: boolean; } export const changeBannerUtility : string[] = [ 'showRepoLinks', 'showExport', ]; // ####################################################### ####################################################### // ####################################################### ####################################################### export interface IMinFPSLegacyProps { [key: string]: string | boolean ; //Section 16 - FPS Options group searchShow: boolean; fpsPageStyle: string; fpsContainerMaxWidth: string; } export const changefpsOptions2 : string[] = [ 'fpsPageStyle', 'fpsContainerMaxWidth' ]; export const changeBanner : string[] = [ ...changeBannerBasics, ...changeBannerNav, ...changeBannerTheme, ...changeBannerUtility ]; /** * Usage: export interface FutureMailable extends IMinWPBannerProps { */ export interface IMinWPBannerProps extends IMinBannerUIProps, IMinPinMeProps, IMinPandoramicProps, IMinBannerThemeProps, IMinCustomHelpProps, IMinPageStyleProps, IMinBannerUtilityProps, IMinFPSLegacyProps { [key: string]: any; } export interface IBuildBannerSettings { //this. related info context: WebPartContext; clientWidth: number; exportProps: any; //Webpart related info panelTitle: string; modifyBannerTitle: boolean; repoLinks: IRepoLinks; //These were added to be able to surpress banner click or replace panel content with something else for Secure Script webpart replacePanelWarning: any; //Hard-coded Banner settings on webpart itself forceBanner: boolean; earyAccess: boolean; wideToggle: boolean; expandAlert: boolean; expandConsole: boolean; //Error info errMessage: string; errorObjArray: any []; //In the case of Pivot Tiles, this is manualLinks[]; expandoErrorObj: any; FPSUser: IFPSUser; beAUser: boolean; //This is true if someone presses the beAUser button showBeAUserIcon: boolean; // this would be true if the banner has any audience targetting in any way that is not 'Everyone' }