Merge pull request #1302 from hugoabernier/js-theme-manager-110

This commit is contained in:
Hugo Bernier 2020-06-01 00:32:41 -04:00 committed by GitHub
commit 80fc989d0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 27700 additions and 58 deletions

View File

@ -2,7 +2,7 @@
"@microsoft/generator-sharepoint": { "@microsoft/generator-sharepoint": {
"isCreatingSolution": true, "isCreatingSolution": true,
"environment": "spo", "environment": "spo",
"version": "1.7.1", "version": "1.10.0",
"libraryName": "js-theme-manager", "libraryName": "js-theme-manager",
"libraryId": "555147fb-b773-446f-aef2-1b25001f92d9", "libraryId": "555147fb-b773-446f-aef2-1b25001f92d9",
"packageManager": "npm", "packageManager": "npm",

View File

@ -26,7 +26,7 @@ NOTE: This is a great option to provide theme management of a Site Collection wi
## Used SharePoint Framework Version ## Used SharePoint Framework Version
![drop](https://img.shields.io/badge/drop-1.7.1-orange.svg) ![1.10.0](https://img.shields.io/badge/drop-1.10.0-orange.svg)
## Applies to ## Applies to
@ -38,7 +38,8 @@ NOTE: This is a great option to provide theme management of a Site Collection wi
Solution|Author(s) Solution|Author(s)
--------|--------- --------|---------
js-theme-manager | David Warner II ([@DavidWarnerII](https://twitter.com/davidwarnerii) / [Warner Digital](http://warner.digital)) js-theme-manager (Upgrade) | Hugo Bernier ([@bernierh](https://twitter.com/bernierh) / [Tahoe Ninjas](https://tahoeninjas.blog))
js-theme-manager | Beau Cameron ([@Beau__Cameron](https://twitter.com/@Beau__Cameron) / [Blog](https://beaucameron.net/))
js-theme-manager | Beau Cameron ([@Beau__Cameron](https://twitter.com/@Beau__Cameron) / [Blog](https://beaucameron.net/)) js-theme-manager | Beau Cameron ([@Beau__Cameron](https://twitter.com/@Beau__Cameron) / [Blog](https://beaucameron.net/))
## Version history ## Version history
@ -46,6 +47,7 @@ js-theme-manager | Beau Cameron ([@Beau__Cameron](https://twitter.com/@Beau__Cam
Version|Date|Comments Version|Date|Comments
-------|----|-------- -------|----|--------
1.0|February 27, 2019|Initial release 1.0|February 27, 2019|Initial release
2.0|June 1, 2020|Upgraded to SPFx 1.10.0
## Disclaimer ## Disclaimer
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.** **THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**

View File

@ -3,7 +3,7 @@
"solution": { "solution": {
"name": "js-theme-manager-client-side-solution", "name": "js-theme-manager-client-side-solution",
"id": "555147fb-b773-446f-aef2-1b25001f92d9", "id": "555147fb-b773-446f-aef2-1b25001f92d9",
"version": "1.0.0.0", "version": "2.0.0.0",
"includeClientSideAssets": true "includeClientSideAssets": true
}, },
"paths": { "paths": {

27647
samples/js-theme-manager/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
{ {
"name": "js-theme-manager", "name": "js-theme-manager",
"version": "0.0.1", "main": "lib/index.js",
"version": "2.0.0",
"private": true, "private": true,
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
@ -11,21 +12,23 @@
"test": "gulp test" "test": "gulp test"
}, },
"dependencies": { "dependencies": {
"@microsoft/sp-core-library": "1.7.1", "@microsoft/sp-core-library": "1.10.0",
"@microsoft/sp-webpart-base": "1.7.1", "@microsoft/sp-lodash-subset": "1.10.0",
"@microsoft/sp-lodash-subset": "1.7.1", "@microsoft/sp-office-ui-fabric-core": "1.10.0",
"@microsoft/sp-office-ui-fabric-core": "1.7.1", "@microsoft/sp-property-pane": "1.10.0",
"@types/webpack-env": "1.13.1", "@microsoft/sp-webpart-base": "1.10.0",
"@types/es6-promise": "0.0.33" "@types/es6-promise": "0.0.33",
"@types/webpack-env": "1.13.1"
}, },
"devDependencies": { "devDependencies": {
"@microsoft/sp-build-web": "1.7.1", "@microsoft/rush-stack-compiler-3.3": "0.3.5",
"@microsoft/sp-tslint-rules": "1.7.1", "@microsoft/sp-build-web": "1.10.0",
"@microsoft/sp-module-interfaces": "1.7.1", "@microsoft/sp-module-interfaces": "1.10.0",
"@microsoft/sp-webpart-workbench": "1.7.1", "@microsoft/sp-tslint-rules": "1.10.0",
"gulp": "~3.9.1", "@microsoft/sp-webpart-workbench": "1.10.0",
"@types/chai": "3.4.34", "@types/chai": "3.4.34",
"@types/mocha": "2.2.38", "@types/mocha": "2.2.38",
"ajv": "~5.2.2" "ajv": "~5.2.2",
"gulp": "~3.9.1"
} }
} }

View File

@ -4,21 +4,17 @@
"alias": "ModernThemeManagerWebPart", "alias": "ModernThemeManagerWebPart",
"componentType": "WebPart", "componentType": "WebPart",
// The "*" signifies that the version should be taken from the package.json
"version": "*", "version": "*",
"manifestVersion": 2, "manifestVersion": 2,
// If true, the component can only be installed on sites where Custom Script is allowed.
// Components that allow authors to embed arbitrary script code should set this to true.
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
"requiresCustomScript": false, "requiresCustomScript": false,
"supportedHosts": ["SharePointWebPart"],
"preconfiguredEntries": [{ "preconfiguredEntries": [{
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other "groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Other
"group": { "default": "Other" }, "group": { "default": "Other" },
"title": { "default": "Modern Theme Manager" }, "title": { "default": "Modern Theme Manager" },
"description": { "default": "Modern Theme Manager description" }, "description": { "default": "Modern Theme Manager description" },
"officeFabricIconFontName": "Page", "officeFabricIconFontName": "Color",
"properties": { "properties": {
"description": "Modern Theme Manager" "description": "Modern Theme Manager"
} }

View File

@ -1,9 +1,6 @@
import { Version } from '@microsoft/sp-core-library'; import { Version } from '@microsoft/sp-core-library';
import { import { BaseClientSideWebPart } from "@microsoft/sp-webpart-base";
BaseClientSideWebPart, import { IPropertyPaneConfiguration, PropertyPaneTextField } from "@microsoft/sp-property-pane";
IPropertyPaneConfiguration,
PropertyPaneTextField
} from '@microsoft/sp-webpart-base';
import { escape } from '@microsoft/sp-lodash-subset'; import { escape } from '@microsoft/sp-lodash-subset';
import styles from './ModernThemeManagerWebPart.module.scss'; import styles from './ModernThemeManagerWebPart.module.scss';
@ -118,12 +115,8 @@ export default class ModernThemeManagerWebPart extends BaseClientSideWebPart<IMo
else if (selectedValue == 'apply') { else if (selectedValue == 'apply') {
parent.displayApplyOptions(); parent.displayApplyOptions();
} }
}; };
}; }
} }
/***** ***** /***** *****
@ -163,9 +156,8 @@ public displayUpdateOptions(): void {
document.getElementById(styles.themePaletteWrapper).classList.remove(styles.hide); document.getElementById(styles.themePaletteWrapper).classList.remove(styles.hide);
document.getElementById('updateTheme').classList.remove(styles.hide); document.getElementById('updateTheme').classList.remove(styles.hide);
} }
}) });
}
};
/***** ***** /***** *****
@ -181,8 +173,6 @@ public displayCreateOptions(): void {
document.getElementById(styles.themeNameWrapper).classList.remove(styles.hide); document.getElementById(styles.themeNameWrapper).classList.remove(styles.hide);
document.getElementById(styles.themePaletteWrapper).classList.remove(styles.hide); document.getElementById(styles.themePaletteWrapper).classList.remove(styles.hide);
document.getElementById('createTheme').classList.remove(styles.hide); document.getElementById('createTheme').classList.remove(styles.hide);
} }
/***** ***** /***** *****
@ -311,7 +301,7 @@ public updateTheme(): void {
let themePalette: JSON = JSON.parse((<HTMLInputElement>document.getElementById(styles.textarea)).value); let themePalette: JSON = JSON.parse((<HTMLInputElement>document.getElementById(styles.textarea)).value);
let themePaletteJSON = { let themePaletteJSON = {
"palette": themePalette "palette": themePalette
} };
// Pass the theme properties to themeManagerExecution method // Pass the theme properties to themeManagerExecution method
this.themeManagerExecution(this.context.pageContext.site.serverRelativeUrl + "/_api/thememanager/UpdateTenantTheme", { name: themeTitle, themeJson: JSON.stringify(themePaletteJSON) }) this.themeManagerExecution(this.context.pageContext.site.serverRelativeUrl + "/_api/thememanager/UpdateTenantTheme", { name: themeTitle, themeJson: JSON.stringify(themePaletteJSON) })
@ -341,7 +331,7 @@ public applyThemeNew(): void {
let themePalette: JSON = JSON.parse((<HTMLInputElement>document.getElementById(styles.textarea)).value); let themePalette: JSON = JSON.parse((<HTMLInputElement>document.getElementById(styles.textarea)).value);
let themePaletteJSON = { let themePaletteJSON = {
"palette": themePalette "palette": themePalette
} };
const digestCache: IDigestCache = this.context.serviceScope.consume(DigestCache.serviceKey); const digestCache: IDigestCache = this.context.serviceScope.consume(DigestCache.serviceKey);
digestCache.fetchDigest(themeURL).then((digest: string): void => { digestCache.fetchDigest(themeURL).then((digest: string): void => {
@ -370,11 +360,11 @@ public themeManagerExecution(url: string, params: any): Promise<boolean> {
let options: ISPHttpClientOptions = { let options: ISPHttpClientOptions = {
body: JSON.stringify(params) body: JSON.stringify(params)
} };
return this.context.spHttpClient.post(url, SPHttpClient.configurations.v1, options) return this.context.spHttpClient.post(url, SPHttpClient.configurations.v1, options)
.then((response: SPHttpClientResponse) => { .then((response: SPHttpClientResponse) => {
return response.ok return response.ok;
}); });
} }

View File

@ -1,5 +1,9 @@
{ {
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json",
"compilerOptions": { "compilerOptions": {
"noUnusedLocals": false,
"strictNullChecks": false,
"inlineSources": false,
"target": "es5", "target": "es5",
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"module": "esnext", "module": "esnext",