UNPKG

@mikezimm/npmfunctions

Version:
285 lines 19.8 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.bannerSettingsContent = exports.TenantSiteColumns = exports.TenantContentCenter = exports.AzureDevOps = exports.TenantSearch = exports.TenantApps = exports.TenantTeams = exports.TenantHubs = exports.TenantSites = exports.NavigationElements = exports.NavigationLinks = exports.StorageMetrics = exports.GroupsLink = exports.AdminRecycleBin = exports.Permissions = exports.Contents = exports.Settings = exports.standardSettingsLink = void 0; var React = __importStar(require("react")); // For SPPermission: let addAndCustomizePages = pageContext.web.permissions.hasPermission( SPPermission.addAndCustomizePages ); var sp_page_context_1 = require("@microsoft/sp-page-context"); var Pivot_1 = require("office-ui-fabric-react/lib/Pivot"); var Icon_1 = require("office-ui-fabric-react/lib/Icon"); require('./bannerSettings.css'); function standardSettingsLink(title, iconName, iconStyles, href, color) { if (color === void 0) { color = null; } var styleName = 'grayHover'; var titleProp = ''; if (color === 'red') { styleName = 'red'; titleProp = 'You are not on your z-Account!!!'; } else if (color === 'green') { styleName = 'green'; titleProp = 'You are on your z-Account :)'; } else if (color === 'yellow') { styleName = 'yellow'; titleProp = 'Azure DevOps - you have an account?'; } return React.createElement("li", { title: titleProp, className: styleName, onClick: function () { window.open(href, '_none'); } }, iconName && iconName.length > 0 ? React.createElement(Icon_1.Icon, { iconName: iconName, style: iconStyles }) : null, React.createElement("span", null, title)); } exports.standardSettingsLink = standardSettingsLink; function getTenantAdminUrl() { var tenant = window.location.hostname.split('.'); return "https://".concat(tenant[0], "-admin.sharepoint.com"); } function Settings(siteUrl, showIcon, iconStyles) { return standardSettingsLink('Settings', showIcon === true ? 'Settings' : '', iconStyles, "".concat(siteUrl, "/_layouts/15/settings.aspx")); } exports.Settings = Settings; function Contents(siteUrl, showIcon, iconStyles) { return standardSettingsLink('Site Contents', showIcon === true ? 'BulletedList2' : '', iconStyles, "".concat(siteUrl, "/_layouts/15/viewlsts.aspx?view=14")); } exports.Contents = Contents; function Permissions(siteUrl, showIcon, iconStyles) { return standardSettingsLink('Permissions', showIcon === true ? 'Permissions' : '', iconStyles, "".concat(siteUrl, "/_layouts/15/user.aspx")); } exports.Permissions = Permissions; function AdminRecycleBin(siteUrl, showIcon, iconStyles, webLevel) { var title = "".concat(webLevel === true ? 'Web' : 'Site', " Recycle Bin"); return standardSettingsLink(title, showIcon === true ? 'RecycleBin' : '', iconStyles, "".concat(siteUrl, "/_layouts/15/AdminRecycleBin.aspx").concat(webLevel === true ? '?view=5' : '?view=13')); } exports.AdminRecycleBin = AdminRecycleBin; function GroupsLink(siteUrl, showIcon, iconStyles) { return standardSettingsLink('Groups', showIcon === true ? 'Group' : '', iconStyles, "".concat(siteUrl, "/_layouts/15/groups.aspx")); } exports.GroupsLink = GroupsLink; function StorageMetrics(siteUrl, showIcon, iconStyles) { return standardSettingsLink('Storage Metrics', showIcon === true ? 'OfflineStorage' : '', iconStyles, "".concat(siteUrl, "/_layouts/15/storman.aspx")); } exports.StorageMetrics = StorageMetrics; function NavigationLinks(siteUrl, showIcon, iconStyles) { return standardSettingsLink('Navigation', showIcon === true ? 'CompassNW' : '', iconStyles, "".concat(siteUrl, "/_layouts/15/AreaNavigationSettings.aspx")); } exports.NavigationLinks = NavigationLinks; function NavigationElements(siteUrl, showIcon, iconStyles) { return standardSettingsLink('Navigation Elements', showIcon === true ? 'CompassNW' : '', iconStyles, "".concat(siteUrl, "/_layouts/15/navoptions.aspx")); } exports.NavigationElements = NavigationElements; //https://tenant-admin.sharepoint.com/_layouts/15/online/AdminHome.aspx#/siteManagement/view/SITES%20WITHOUT%20A%20GROUP function TenantSites(siteUrl, showIcon, iconStyles, tenantColor) { return standardSettingsLink('Sites', showIcon === true ? 'SharepointLogo' : '', iconStyles, "".concat(getTenantAdminUrl(), "/_layouts/15/online/AdminHome.aspx#/siteManagement/view/SITES%20WITHOUT%20A%20GROUP"), tenantColor); } exports.TenantSites = TenantSites; function TenantHubs(siteUrl, showIcon, iconStyles, tenantColor) { return standardSettingsLink('Hubs', showIcon === true ? 'TFVCLogo' : '', iconStyles, "".concat(getTenantAdminUrl(), "/_layouts/15/online/AdminHome.aspx#/siteManagement/view/ALL%20SITES"), tenantColor); } exports.TenantHubs = TenantHubs; //https://tenant-admin.sharepoint.com/_layouts/15/online/AdminHome.aspx#/siteManagement/view/TEAMS%20CONNECTED%20SITES function TenantTeams(siteUrl, showIcon, iconStyles, tenantColor) { return standardSettingsLink('Teams', showIcon === true ? 'TeamsLogo' : '', iconStyles, "".concat(getTenantAdminUrl(), "/_layouts/15/online/AdminHome.aspx#/siteManagement/view/TEAMS%20CONNECTED%20SITES"), tenantColor); } exports.TenantTeams = TenantTeams; //https://tenant-admin.sharepoint.com/_layouts/15/online/AdminHome.aspx#/siteManagement/view/TEAMS%20CONNECTED%20SITES function TenantApps(siteUrl, showIcon, iconStyles, tenantColor) { return standardSettingsLink('Tenant Apps', showIcon === true ? 'WebAppBuilderFragment' : '', iconStyles, "".concat(getTenantAdminUrl(), "/_layouts/15/online/TenantAdminApps.aspx"), tenantColor); } exports.TenantApps = TenantApps; function TenantSearch(siteUrl, showIcon, iconStyles, tenantColor) { return standardSettingsLink('Search', showIcon === true ? 'SearchAndApps' : '', iconStyles, "".concat(getTenantAdminUrl()), tenantColor); } exports.TenantSearch = TenantSearch; function AzureDevOps(siteUrl, showIcon, iconStyles, tenantColor) { return standardSettingsLink('Azure Devops', showIcon === true ? 'ReleaseDefinition' : '', iconStyles, "https://go.microsoft.com/fwlink/?LinkId=2014676&githubsi=true", 'yellow'); } exports.AzureDevOps = AzureDevOps; //https://tenant-admin.sharepoint.com/_layouts/15/online/AdminHome.aspx#/contentTypes function TenantContentCenter(siteUrl, showIcon, iconStyles, tenantColor) { return standardSettingsLink('Content Types', showIcon === true ? 'Archive' : '', iconStyles, "".concat(getTenantAdminUrl(), "/_layouts/15/online/AdminHome.aspx#/contentTypes"), tenantColor); } exports.TenantContentCenter = TenantContentCenter; //https://tenant.sharepoint.com/sites/contentTypeHub/_layouts/15/mngfield.aspx function TenantSiteColumns(siteUrl, showIcon, iconStyles, tenantColor) { return standardSettingsLink('Site Columns', showIcon === true ? 'ReportAdd' : '', iconStyles, "".concat(siteUrl, "/_layouts/15/mngfield.aspx"), tenantColor); } exports.TenantSiteColumns = TenantSiteColumns; // forceNarrowStyles?: boolean; //If true (like when web part is pinned or in vertical section, force Gear settings to narrow mode ) function bannerSettingsContent(showTricks, pageContext, keySiteProps, bannerCommandStylesX, bannerWidth, forceNarrowStyles) { //Admin links var bannerCommandStyles = JSON.parse(JSON.stringify(bannerCommandStylesX)); if (bannerCommandStyles && bannerCommandStyles.background) { bannerCommandStyles.background = 'transparent'; } if (bannerCommandStyles && bannerCommandStyles.backgroundColor) { bannerCommandStyles.backgroundColor = 'transparent'; } var addAndCustomizePages = pageContext.web.permissions.hasPermission(sp_page_context_1.SPPermission.addAndCustomizePages); console.log('Current user can addAndCustomizePages', addAndCustomizePages); var showAdmin = pageContext.legacyPageContext.isSiteAdmin === true ? true : false; var siteUrl = pageContext.site.absoluteUrl; var contentTypeHub = "".concat(window.location.origin, "/sites/contentTypeHub"); var isFraudTenant = pageContext.legacyPageContext.isFraudTenant; var allowInfectedDownload = pageContext.legacyPageContext.allowInfectedDownload; var isNoScriptEnabled = pageContext.site.isNoScriptEnabled; var noScriptStyle = isNoScriptEnabled !== true ? 'redLabel' : 'justLabel'; var blockDownloads = pageContext.legacyPageContext.blockDownloadsExperienceEnabled; var blockDownloadStyle = blockDownloads !== true ? 'redLabel' : 'justLabel'; var disableFlows = pageContext.legacyPageContext.disableFlows; var isWebWelcomePage = pageContext.legacyPageContext.isWebWelcomePage; var hasManageWebPermissions = pageContext.legacyPageContext.hasManageWebPermissions; var guestsEnabled = pageContext.legacyPageContext.guestsEnabled; var guestStyle = guestsEnabled === true ? 'redLabel' : 'justLabel'; var isSiteOwner = pageContext.legacyPageContext.isSiteOwner; var isArchived = pageContext.legacyPageContext.isArchived; var liIsNoScriptEnabled = React.createElement("li", { className: noScriptStyle, title: 'pageContext.site.isNoScriptEnabled' }, "Scripts Disabled: ".concat(isNoScriptEnabled)); var liGuestsEnabled = React.createElement("li", { className: guestStyle, title: 'pageContext.legacyPageContext.guestsEnabled' }, "Guests Enabled: ".concat(guestsEnabled)); var liBlockDownloads = React.createElement("li", { className: blockDownloadStyle, title: 'pageContext.legacyPageContext.blockDownloadsExperienceEnabled' }, "Block Downloads: ".concat(blockDownloads)); var flowStyle = disableFlows === true ? 'redLabel' : 'justLabel'; var liDisableFlows = React.createElement("li", { className: flowStyle, title: 'pageContext.legacyPageContext.disableFlows' }, "Disable Flows: ".concat(disableFlows)); var licGuestsEnabled = React.createElement("li", { className: 'compressedLabel', title: 'pageContext.legacyPageContext.guestsEnabled' }, "Guests Enabled: ".concat(guestsEnabled)); var licBlockDownloads = React.createElement("li", { className: 'compressedLabel', title: 'pageContext.legacyPageContext.blockDownloadsExperienceEnabled' }, "Block Downloads: ".concat(blockDownloads)); // Highlight red color if you are NOT on z-Account var tenantColor = pageContext.user.loginName.indexOf('z-') === 0 ? 'green' : 'red'; var scaContent = showAdmin !== true ? null : React.createElement("div", { className: 'tileBox' }, React.createElement("h2", null, "Site - SCAs"), React.createElement("ul", { className: 'boxLinks' }, Settings(siteUrl, true, bannerCommandStyles), Contents(siteUrl, true, bannerCommandStyles), Permissions(siteUrl, true, bannerCommandStyles), GroupsLink(siteUrl, true, bannerCommandStyles), AdminRecycleBin(siteUrl, true, bannerCommandStyles, false), StorageMetrics(siteUrl, true, bannerCommandStyles), NavigationLinks(siteUrl, true, bannerCommandStyles), React.createElement("div", { style: { height: '20px' } }), liIsNoScriptEnabled, liGuestsEnabled, liBlockDownloads)); //Admin links var showOwner = pageContext.legacyPageContext.isSiteAdmin === true || pageContext.legacyPageContext.isSiteOwner === true ? true : false; var webUrl = pageContext.web.absoluteUrl; if (siteUrl === webUrl && showAdmin === true) { showOwner = false; } var ownerContent = showOwner !== true ? null : React.createElement("div", { className: 'tileBox' }, React.createElement("h2", null, "Web - Owners"), React.createElement("ul", { className: 'boxLinks' }, Settings(webUrl, true, bannerCommandStyles), Contents(webUrl, true, bannerCommandStyles), Permissions(webUrl, true, bannerCommandStyles), GroupsLink(webUrl, true, bannerCommandStyles), AdminRecycleBin(webUrl, true, bannerCommandStyles, true), StorageMetrics(siteUrl, true, bannerCommandStyles), NavigationElements(webUrl, true, bannerCommandStyles))); //Tenant links var trickyContent = showTricks !== true ? null : React.createElement("div", { className: 'tileBox' }, React.createElement("h2", null, "Tenant Links"), React.createElement("ul", { className: 'boxLinks' }, TenantSites(webUrl, true, bannerCommandStyles, tenantColor), TenantHubs(webUrl, true, bannerCommandStyles, tenantColor), TenantTeams(webUrl, true, bannerCommandStyles, tenantColor), TenantApps(webUrl, true, bannerCommandStyles, tenantColor), TenantContentCenter(webUrl, true, bannerCommandStyles, tenantColor), TenantSiteColumns(contentTypeHub, true, bannerCommandStyles, tenantColor), AzureDevOps(webUrl, true, bannerCommandStyles, tenantColor), React.createElement("div", { style: { height: '20px' } }), liIsNoScriptEnabled, liGuestsEnabled, liBlockDownloads, React.createElement("li", { className: 'justLabel', title: 'pageContext.legacyPageContext.isFraudTenant' }, "FraudTenant: ".concat(isFraudTenant)), React.createElement("li", { className: 'justLabel', title: 'pageContext.legacyPageContext.allowInfectedDownload' }, "Inf Download: ".concat(allowInfectedDownload)))); var timePrefTitle = keySiteProps.UserTimePref === true ? "You will see timestamps based on your time zone" : "YOU will see timestamps based on ???"; var timesAreSame = keySiteProps.WebTimezone === keySiteProps.UserTimezone ? true : false; var userTimeZoneTitle = timesAreSame === true ? "User Timezone: (same)" : React.createElement("span", { style: { color: 'red' } }, "User Timezone: ( Different )"); //Tenant links // _layouts/15/regionalsetng.aspx var webTime24 = pageContext.legacyPageContext.webTime24; var WebTimeTitle = "Web Timezone: ( ".concat(webTime24 === true ? 24 : 12, " hour )"); var webRegionalSettings = webUrl + '/_layouts/15/regionalsetng.aspx'; var settingsContent = React.createElement("div", { className: ['tileBox', 'summaryBox'].join(' ') }, React.createElement("h2", null, "Summary"), React.createElement("ul", { className: 'boxLinks' }, React.createElement("li", { className: 'heading', title: keySiteProps.WebTimezone, onClick: function () { window.open(webRegionalSettings, '_none'); } }, React.createElement("div", null, WebTimeTitle), "".concat(keySiteProps.WebTimezone)), React.createElement("li", { className: 'heading', title: keySiteProps.UserTimezone, style: { cursor: 'default' } }, React.createElement("div", null, userTimeZoneTitle), "".concat(keySiteProps.UserTimezone)), React.createElement("li", { className: 'heading', title: timePrefTitle, style: { cursor: 'default' } }, React.createElement("div", null, "User Time Pref:"), "".concat(keySiteProps.UserTimePref)), React.createElement("li", { className: 'heading', style: { cursor: 'default' } }, React.createElement("div", null, "Web Language:"), "".concat(keySiteProps.WebLanguage)), licBlockDownloads, licGuestsEnabled, liDisableFlows, React.createElement("li", { className: 'compressedLabel', title: 'pageContext.site.isArchived' }, "Is archived: ".concat(isArchived)), React.createElement("li", { className: 'compressedLabel', title: 'pageContext.legacyPageContext.isWebWelcomePage' }, "Is Welcome Page: ".concat(isWebWelcomePage)), React.createElement("li", { className: 'compressedLabel', title: 'pageContext.legacyPageContext.hasManageWebPermissions' }, "Can Manage Web: ".concat(hasManageWebPermissions)), React.createElement("li", { className: 'compressedLabel', title: 'pageContext.legacyPageContext.isSiteOwner' }, "Is Site Owner: ".concat(isSiteOwner)), React.createElement("li", null, "Members can edit: ".concat(keySiteProps.BrokenPermissions === null ? 'TBD' : keySiteProps.LimitedDownload)), React.createElement("li", null, "Broken permissions: ".concat(keySiteProps.BrokenPermissions === null ? 'TBD' : keySiteProps.BrokenPermissions)))); var approxWidth = 0; if (scaContent !== null) { approxWidth += 169 + 90; } if (ownerContent !== null) { approxWidth += 206 + 90; } if (trickyContent !== null) { approxWidth += 206 + 90; } approxWidth += 237 + 90; //For Summary var content = null; var showSettingsAsPivot = forceNarrowStyles === true || approxWidth > bannerWidth ? true : false; if (showSettingsAsPivot === true) { var pivotItems = []; if (ownerContent !== null) { pivotItems.push(React.createElement(Pivot_1.PivotItem, { headerText: 'Web', ariaLabel: 'Web', title: 'Web' }, ownerContent)); } if (scaContent !== null) { pivotItems.push(React.createElement(Pivot_1.PivotItem, { headerText: 'Site', ariaLabel: 'Site', title: 'Site' }, scaContent)); } if (trickyContent !== null) { pivotItems.push(React.createElement(Pivot_1.PivotItem, { headerText: 'Tenant', ariaLabel: 'Tenant', title: 'Tenant' }, trickyContent)); } if (settingsContent !== null) { pivotItems.push(React.createElement(Pivot_1.PivotItem, { headerText: 'Key Settings', ariaLabel: 'Key Settings', title: 'Key Settings' }, settingsContent)); } content = React.createElement("div", { className: 'banner-settings-component' }, React.createElement(Pivot_1.Pivot // styles={ pivotStyles } , { // styles={ pivotStyles } linkFormat: Pivot_1.PivotLinkFormat.links, linkSize: Pivot_1.PivotLinkSize.large }, pivotItems)); } else { content = React.createElement("div", { className: 'banner-settings-component' }, React.createElement("div", { className: 'flexBoxes', style: { paddingBottom: '100px' } }, ownerContent, scaContent, trickyContent, settingsContent)); } return { content: content, approxWidth: approxWidth, showSettingsAsPivot: showSettingsAsPivot }; } exports.bannerSettingsContent = bannerSettingsContent; //# sourceMappingURL=bannerGearFunctions.js.map