UNPKG

@mikezimm/fps-core-v7

Version:

Library of reusable core interfaces, types and constants migrated from fps-library-v2

105 lines 6.6 kB
import { checkDeepProperty } from "../../../logic/Objects/deep"; import { check4SiteTheme } from "../../../common/commandStyles/ISiteThemeChoices"; import { check4Gulp } from "../../../logic/Links/CheckGulping"; import { CurrentOrigin, CurrentPathname } from "../../../components/molecules/source-props/WindowLocationConstants"; // import { CurrentOrigin, CurrentPathname } from "../../../logic/Strings/getSiteCollectionUrlFromLink"; export function createFPSEnviroOnWindow(thisWPClass, Environment) { const { context } = thisWPClass; const pageContext = context.pageContext; const legacyPageContext = pageContext.legacyPageContext; const pageLayout = context[`_pageLayoutType`] ? context[`_pageLayoutType`] : context[`pageLayoutType`]; const pageName = CurrentPathname.substring(CurrentPathname.lastIndexOf("/") + 1); const FPSEnviro = { tenantUrl: CurrentOrigin, siteUrl: pageContext.site.absoluteUrl, webUrl: pageContext.web.absoluteUrl, webServerRelativeUrl: pageContext.web.serverRelativeUrl, siteServerRelativeUrl: pageContext.site.absoluteUrl.replace(CurrentOrigin, ''), departmentId: pageContext.legacyPageContext.departmentId, SiteID: pageContext.site.id['_guid'] ? pageContext.site.id['_guid'] : pageContext.site.id, WebID: pageContext.web.id['_guid'] ? pageContext.web.id['_guid'] : pageContext.web.id, environmentType: Environment ? Environment.type : -79, environmentString: Environment.type === 3 ? 'Classic' : Environment.type === 2 ? 'Modern' : Environment.type === 1 ? 'Local' : Environment.type === 0 ? 'Test' : 'UNK', SiteTitle: pageContext.web.title, WebTitle: pageContext.web.title, ListID: pageContext.list.id, ListTitle: pageContext.list.title, pageLayout: pageLayout, isSPA: pageLayout === 'SingleWebPartAppPageLayout' ? true : false, pageName: pageName, onHomePage: legacyPageContext.isWebWelcomePage === true ? true : false, SiteLogoUrl: pageContext.web.logoUrl, themeChoice: thisWPClass.properties.bannerStyleChoice, useSiteTheme: check4SiteTheme(thisWPClass.properties.bannerStyleChoice), trickyEmailsAll: thisWPClass._trickyEmailsAll, language: pageContext.web.language, languageName: pageContext.web.languageName, LimitedDownload: null, WebTimezone: checkDeepProperty(pageContext, ['web', 'timeZoneInfo', 'description'], 'ShortError'), WebLanguage: `${checkDeepProperty(pageContext, ['cultureInfo', 'currentCultureName'], 'ShortError')} - ${checkDeepProperty(pageContext, ['web', 'language'], 'ShortError')}`, UserTimezone: checkDeepProperty(pageContext, ['user', 'timeZoneInfo', 'description'], 'ShortError'), UserTimePref: checkDeepProperty(pageContext, ['user', 'preferUserTimeZone'], 'ShortError'), BrokenPermissions: null, repoLink: thisWPClass._repoLink, theme: null, legacyPageContext: { isSiteAdmin: legacyPageContext.isSiteAdmin, userId: legacyPageContext.userId, isWebWelcomePage: legacyPageContext.isWebWelcomePage, isSiteOwner: legacyPageContext.isSiteOwner, isFraudTenant: legacyPageContext.isFraudTenant, allowInfectedDownload: legacyPageContext.allowInfectedDownload, blockDownloadFileTypePolicyEnabled: legacyPageContext.blockDownloadFileTypePolicyEnabled, blockDownloadsExperienceEnabled: legacyPageContext.blockDownloadsExperienceEnabled, currentCultureName: legacyPageContext.currentCultureName, currentLanguage: legacyPageContext.currentLanguage, groupColor: legacyPageContext.groupColor, groupId: legacyPageContext.groupId, groupType: legacyPageContext.groupType, hubSiteId: legacyPageContext.hubSiteId, isDocumentLibraryDefaultLabellingEnabled: legacyPageContext.isDocumentLibraryDefaultLabellingEnabled, isEmailAuthenticationGuestUser: legacyPageContext.isEmailAuthenticationGuestUser, isExternalGuestUser: legacyPageContext.isExternalGuestUser, isHubSite: legacyPageContext.isHubSite, isMultiGeoODBMode: legacyPageContext.isMultiGeoODBMode, isMultiGeoTenant: legacyPageContext.isMultiGeoTenant, isNoScriptEnabled: legacyPageContext.isNoScriptEnabled, labelPrivacy: legacyPageContext.labelPrivacy, listBaseTemplate: legacyPageContext.listBaseTemplate, listBaseType: legacyPageContext.listBaseType, listItemCount: legacyPageContext.listItemCount, listTitle: legacyPageContext.listTitle, listUrl: legacyPageContext.listUrl, m365GroupsBlockDownloadsExperienceEnabled: legacyPageContext.m365GroupsBlockDownloadsExperienceEnabled, pagePermsMask: legacyPageContext.pagePermsMask, preferUserTimeZone: legacyPageContext.preferUserTimeZone, siteAbsoluteUrl: legacyPageContext.siteAbsoluteUrl, siteClassification: legacyPageContext.siteClassification, siteServerRelativeUrl: legacyPageContext.siteServerRelativeUrl, userLoginName: legacyPageContext.userLoginName, userPhotoCdnBaseUrl: legacyPageContext.userPhotoCdnBaseUrl, webAbsoluteUrl: legacyPageContext.webAbsoluteUrl, disableFlows: legacyPageContext.disableFlows, hasManageWebPermissions: legacyPageContext.hasManageWebPermissions, guestsEnabled: legacyPageContext.guestsEnabled, isArchived: legacyPageContext.isArchived, webTime24: legacyPageContext.webTime24, departmentId: legacyPageContext.departmentId, serverRequestPath: legacyPageContext.serverRequestPath, // Added for PivotTiles } }; // Doing this to ensure it is always going to be available even if something downstream over-writes the object on the class const FPSEnviroCopy = JSON.parse(JSON.stringify(FPSEnviro)); const thisWindow = window; thisWindow.FPSEnviro = FPSEnviroCopy; if (check4Gulp() === true) console.log(`createFPSEnviroOnWindow FPSEnviro:`, thisWindow.FPSEnviro); return FPSEnviroCopy; } export function retrieveFPSEnviro() { const thisWindow = window; const FPSEnviro = thisWindow.FPSEnviro; return FPSEnviro; } //# sourceMappingURL=FPSEnviro.js.map