Updated sample from 1.11.1 to 1.16.1 version

This commit is contained in:
Valeras Narbutas 2023-03-06 15:16:52 +02:00
parent 5dd0a074a0
commit 62c3880692
19 changed files with 5667 additions and 7518 deletions

View File

@ -0,0 +1,5 @@
require('@rushstack/eslint-config/patch/modern-module-resolution');
module.exports = {
extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'],
parserOptions: { tsconfigRootDir: __dirname }
};

View File

@ -5,6 +5,8 @@ npm-debug.log*
# Dependency directories # Dependency directories
node_modules node_modules
.heft
release
# Build generated files # Build generated files
dist dist

View File

@ -0,0 +1,16 @@
!dist
config
gulpfile.js
release
src
temp
tsconfig.json
tslint.json
*.log
.yo-rc.json
.vscode

View File

@ -2,11 +2,16 @@
"@microsoft/generator-sharepoint": { "@microsoft/generator-sharepoint": {
"isCreatingSolution": true, "isCreatingSolution": true,
"environment": "spo", "environment": "spo",
"version": "1.11.0", "version": "1.16.1",
"nodeVersion": "14.18.1",
"libraryName": "advanced-page-properties", "libraryName": "advanced-page-properties",
"libraryId": "daae06a2-8599-445c-93c0-3bd739305f56", "libraryId": "daae06a2-8599-445c-93c0-3bd739305f56",
"packageManager": "npm", "packageManager": "npm",
"isDomainIsolated": false, "isDomainIsolated": false,
"componentType": "webpart" "componentType": "webpart",
"sdkVersions": {
"@microsoft/microsoft-graph-client": "3.0.2",
"@microsoft/teams-js": "2.4.1"
}
} }
} }

View File

@ -1,4 +0,0 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/copy-assets.schema.json",
"deployCdnPath": "temp/deploy"
}

View File

@ -1,7 +1,7 @@
{ {
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json", "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"workingDir": "./temp/deploy/", "workingDir": "./release/assets/",
"account": "<!-- STORAGE ACCOUNT NAME -->", "account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "advanced-page-properties", "container": "advanced-page-properties",
"accessKey": "<!-- ACCESS KEY -->" "accessKey": "<!-- ACCESS KEY -->"
} }

View File

@ -12,7 +12,29 @@
"privacyUrl": "", "privacyUrl": "",
"termsOfUseUrl": "", "termsOfUseUrl": "",
"mpnId": "990019737" "mpnId": "990019737"
} },
"metadata": {
"shortDescription": {
"default": "advanced-page-properties description"
},
"longDescription": {
"default": "advanced-page-properties description"
},
"screenshotPaths": [],
"videoUrl": "",
"categories": []
},
"features": [
{
"title": "advanced-page-properties AdvancedPagePropertiesWebPart Feature",
"description": "The feature that activates AdvancedPagePropertiesWebPart from the advanced-page-properties solution.",
"id": "bdbcb04e-9c90-4adb-b0f0-d025e4eb6cb5",
"version": "1.0.3.0",
"componentIds": [
"bdbcb04e-9c90-4adb-b0f0-d025e4eb6cb5"
]
}
]
}, },
"paths": { "paths": {
"zippedPackage": "solution/advanced-page-properties.sppkg" "zippedPackage": "solution/advanced-page-properties.sppkg"

View File

@ -0,0 +1,3 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json"
}

View File

@ -1,10 +1,6 @@
{ {
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json", "$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
"port": 4321, "port": 4321,
"https": true, "https": true,
"initialPage": "https://localhost:5432/workbench", "initialPage": "https://macaw.sharepoint.com/sites/valerasn_dev/_layouts/workbench.aspx"
"api": {
"port": 5432,
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
}
} }

View File

@ -1,7 +1,16 @@
'use strict'; 'use strict';
const build = require('@microsoft/sp-build-web'); const build = require('@microsoft/sp-build-web');
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`); build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
build.initialize(require('gulp')); var getTasks = build.rig.getTasks;
build.rig.getTasks = function () {
var result = getTasks.call(build.rig);
result.set('serve', result.get('serve-deprecated'));
return result;
};
build.initialize(require('gulp'));

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
"private": true, "private": true,
"main": "lib/index.js", "main": "lib/index.js",
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=16.13.0 <17.0.0"
}, },
"scripts": { "scripts": {
"build": "gulp bundle", "build": "gulp bundle",
@ -13,31 +13,36 @@
}, },
"dependencies": { "dependencies": {
"@fluentui/react": "^8.7.0", "@fluentui/react": "^8.7.0",
"@microsoft/sp-core-library": "1.11.0", "@microsoft/sp-adaptive-card-extension-base": "1.16.1",
"@microsoft/sp-lodash-subset": "1.11.0", "@microsoft/sp-core-library": "1.16.1",
"@microsoft/sp-office-ui-fabric-core": "1.11.0", "@microsoft/sp-lodash-subset": "1.16.1",
"@microsoft/sp-property-pane": "1.11.0", "@microsoft/sp-office-ui-fabric-core": "1.16.1",
"@microsoft/sp-webpart-base": "1.11.0", "@microsoft/sp-property-pane": "1.16.1",
"@pnp/sp": "^2.3.0", "@microsoft/sp-tslint-rules": "^1.16.1",
"@microsoft/sp-webpart-base": "1.16.1",
"@pnp/logging": "^3.12.1",
"@pnp/sp": "^3.9.0",
"@pnp/spfx-property-controls": "^3.0.0", "@pnp/spfx-property-controls": "^3.0.0",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"office-ui-fabric-react": "6.214.0", "office-ui-fabric-react": "7.199.1",
"react": "16.8.5", "react": "17.0.1",
"react-dom": "16.8.5" "react-dom": "17.0.1",
"tslib": "2.3.1"
}, },
"devDependencies": { "devDependencies": {
"@types/react": "16.8.8", "@microsoft/eslint-config-spfx": "1.16.1",
"@types/react-dom": "16.8.3", "@microsoft/eslint-plugin-spfx": "1.16.1",
"@microsoft/rush-stack-compiler-4.5": "0.2.2",
"@microsoft/sp-build-web": "1.16.1", "@microsoft/sp-build-web": "1.16.1",
"@microsoft/sp-tslint-rules": "1.11.0", "@microsoft/sp-module-interfaces": "1.16.1",
"@microsoft/sp-module-interfaces": "1.11.0", "@rushstack/eslint-config": "2.5.1",
"@microsoft/sp-webpart-workbench": "1.12.1", "@types/react": "17.0.45",
"@microsoft/rush-stack-compiler-3.3": "0.3.5", "@types/react-dom": "17.0.17",
"gulp": "~3.9.1", "@types/webpack-env": "1.15.2",
"@types/chai": "3.4.34", "ajv": "6.12.5",
"@types/mocha": "2.2.38", "eslint": "8.7.0",
"ajv": "~5.2.2", "eslint-plugin-react-hooks": "4.3.0",
"@types/webpack-env": "1.13.1", "gulp": "4.0.2",
"@types/es6-promise": "0.0.33" "typescript": "4.5.5"
} }
} }

View File

@ -10,9 +10,9 @@ import * as strings from 'AdvancedPagePropertiesWebPartStrings';
import AdvancedPageProperties from './components/AdvancedPageProperties'; import AdvancedPageProperties from './components/AdvancedPageProperties';
import { IAdvancedPagePropertiesProps } from './components/IAdvancedPagePropertiesProps'; import { IAdvancedPagePropertiesProps } from './components/IAdvancedPagePropertiesProps';
//import { PropertyFieldMultiSelect } from '@pnp/spfx-property-controls/lib/PropertyFieldMultiSelect'; //import { PropertyFieldMultiSelect } from '@pnp/spfx-property-controls/lib/PropertyFieldMultiSelect';
import "@pnp/sp/fields"; import { getSP } from './utilities/pnpjs-config';
import "@pnp/sp/fields/list"; import { SPFI } from '@pnp/sp';
import { FieldTypes, sp } from "@pnp/sp/presets/all";
import { Log } from './utilities/Log'; import { Log } from './utilities/Log';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { import {
@ -28,7 +28,8 @@ export interface IAdvancedPagePropertiesWebPartProps {
export default class AdvancedPagePropertiesWebPart extends BaseClientSideWebPart<IAdvancedPagePropertiesWebPartProps> { export default class AdvancedPagePropertiesWebPart extends BaseClientSideWebPart<IAdvancedPagePropertiesWebPartProps> {
private availableProperties: IPropertyPaneDropdownOption[] = []; private _availableProperties: IPropertyPaneDropdownOption[] = [];
private _themeProvider: ThemeProvider; private _themeProvider: ThemeProvider;
private _themeVariant: IReadonlyTheme | undefined; private _themeVariant: IReadonlyTheme | undefined;
@ -37,8 +38,13 @@ export default class AdvancedPagePropertiesWebPart extends BaseClientSideWebPart
this.render(); this.render();
} }
/**
* Private variable to store the SharePoint Factory Instance
*/
private _sp: SPFI;
protected async onInit(): Promise<void> { protected async onInit(): Promise<void> {
sp.setup({ spfxContext: this.context }); this._sp = getSP(this.context);
// Consume the new ThemeProvider service // Consume the new ThemeProvider service
this._themeProvider = this.context.serviceScope.consume(ThemeProvider.serviceKey); this._themeProvider = this.context.serviceScope.consume(ThemeProvider.serviceKey);
@ -68,17 +74,17 @@ export default class AdvancedPagePropertiesWebPart extends BaseClientSideWebPart
private async getPageProperties(): Promise<void> { private async getPageProperties(): Promise<void> {
Log.Write("Getting Site Page fields..."); Log.Write("Getting Site Page fields...");
const list = await sp.web.lists.ensureSitePagesLibrary(); const list = await this._sp.web.lists.ensureSitePagesLibrary();
const fi = await list.fields(); const _fields = await list.fields();
this._availableProperties = [];
this.availableProperties = []; Log.Write(`${_fields.length.toString()} fields retrieved!`);
Log.Write(`${fi.length.toString()} fields retrieved!`); _fields.forEach((field: any) => {
fi.forEach((f) => { if (!field.FromBaseType && !field.Hidden && field.SchemaXml.indexOf("ShowInListSettings=\"FALSE\"") === -1
if (!f.FromBaseType && !f.Hidden && f.SchemaXml.indexOf("ShowInListSettings=\"FALSE\"") === -1 && field.TypeAsString !== "Boolean" && field.TypeAsString !== "Note") {
&& f.TypeAsString !== "Boolean" && f.TypeAsString !== "Note") { const internalFieldName = field.InternalName == "LinkTitle" ? "Title" : field.InternalName;
const internalFieldName = f.InternalName == "LinkTitle" ? "Title" : f.InternalName; this._availableProperties.push({ key: internalFieldName, text: field.Title });
this.availableProperties.push({ key: internalFieldName, text: f.Title }); Log.Write(field.TypeAsString);
Log.Write(f.TypeAsString);
} }
}); });
} }
@ -92,7 +98,7 @@ export default class AdvancedPagePropertiesWebPart extends BaseClientSideWebPart
} }
protected onAddButtonClick (value: any) { protected onAddButtonClick (value: any) {
this.properties.selectedProperties.push(this.availableProperties[0].key.toString()); this.properties.selectedProperties.push(this._availableProperties[0].key.toString());
} }
protected onDeleteButtonClick (value: any) { protected onDeleteButtonClick (value: any) {
@ -129,7 +135,7 @@ export default class AdvancedPagePropertiesWebPart extends BaseClientSideWebPart
propDrops.push(PropertyPaneDropdown(`selectedProperty${index.toString()}`, propDrops.push(PropertyPaneDropdown(`selectedProperty${index.toString()}`,
{ {
label: strings.SelectedPropertiesFieldLabel, label: strings.SelectedPropertiesFieldLabel,
options: this.availableProperties, options: this._availableProperties,
selectedKey: prop, selectedKey: prop,
})); }));
// Every drop down gets its own delete button // Every drop down gets its own delete button

View File

@ -1,4 +1,4 @@
@import '~office-ui-fabric-react/dist/sass/References.scss'; @import '~@fluentui/react/dist/sass/References.scss';
.advancedPageProperties { .advancedPageProperties {
.container { .container {

View File

@ -6,7 +6,7 @@ import * as _ from 'lodash';
import { useState, useEffect, useRef } from 'react'; import { useState, useEffect, useRef } from 'react';
import { PageProperty } from '../models'; import { PageProperty } from '../models';
import { sp } from "@pnp/sp"; import { getSP } from '../utilities/pnpjs-config';
import { DateTimeFieldFormatType, DateTimeFieldFriendlyFormatType, FieldTypes, IField, IFieldInfo } from "@pnp/sp/fields/types"; import { DateTimeFieldFormatType, DateTimeFieldFriendlyFormatType, FieldTypes, IField, IFieldInfo } from "@pnp/sp/fields/types";
import "@pnp/sp/webs"; import "@pnp/sp/webs";
import "@pnp/sp/lists"; import "@pnp/sp/lists";
@ -28,7 +28,7 @@ const AdvancedPageProperties: React.FunctionComponent<IAdvancedPagePropertiesPro
propsRef.current = props; propsRef.current = props;
sp.setup({ spfxContext: props.context }); const _sp = getSP(propsRef.current.context);
/** /**
* refreshProperties * refreshProperties
@ -42,7 +42,7 @@ const AdvancedPageProperties: React.FunctionComponent<IAdvancedPagePropertiesPro
// Get the value(s) for the field from the list item itself // Get the value(s) for the field from the list item itself
var allValues: any = {}; var allValues: any = {};
const sitePagesList = await sp.web.lists.ensureSitePagesLibrary(); const sitePagesList = await _sp.web.lists.ensureSitePagesLibrary();
if (props.context.pageContext.listItem !== undefined && props.context.pageContext.listItem !== null) { if (props.context.pageContext.listItem !== undefined && props.context.pageContext.listItem !== null) {
allValues = await sitePagesList.items.getById(props.context.pageContext.listItem.id).select(...props.selectedProperties).fieldValuesAsText(); allValues = await sitePagesList.items.getById(props.context.pageContext.listItem.id).select(...props.selectedProperties).fieldValuesAsText();
} }

View File

@ -0,0 +1,22 @@
import { WebPartContext } from "@microsoft/sp-webpart-base";
// import pnp, pnp logging system, and any other selective imports needed
import { spfi, SPFI, SPFx } from "@pnp/sp";
import { LogLevel, PnPLogging } from "@pnp/logging";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/fields";
import "@pnp/sp/items";
import "@pnp/sp/regional-settings/web";
let _sp: SPFI = null;
export const getSP = (context?: WebPartContext): SPFI => {
if (context != null) {
//You must add the @pnp/logging package to include the PnPLogging behavior it is no longer a peer dependency
// The LogLevel set's at what level a message will be written to the console
_sp = spfi().using(SPFx(context)).using(PnPLogging(LogLevel.Warning));
}
return _sp;
};

View File

@ -1,39 +1,37 @@
{ {
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.3/includes/tsconfig-web.json", "extends": "./node_modules/@microsoft/sp-tslint-rules/base-tslint.json",
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "es5",
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"module": "esnext", "module": "esnext",
"moduleResolution": "node", "moduleResolution": "node",
"jsx": "react", "jsx": "react",
"declaration": true, "declaration": true,
"sourceMap": true, "sourceMap": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"skipLibCheck": true, "skipLibCheck": true,
"outDir": "lib", "outDir": "lib",
"inlineSources": false, "inlineSources": false,
"strictNullChecks": false, "strictNullChecks": false,
"noUnusedLocals": false, "noUnusedLocals": false,
"typeRoots": [ "noImplicitAny": true,
"./node_modules/@types", "typeRoots": [
"./node_modules/@microsoft" "./node_modules/@types",
], "./node_modules/@microsoft"
"types": [ ],
"es6-promise", "types": [
"webpack-env" "webpack-env"
], ],
"lib": [ "lib": [
"es5", "es5",
"dom", "dom",
"es2015.collection" "es2015.collection",
] "es2015.promise"
}, ],
"include": [ },
"src/**/*.ts", "include": [
"src/**/*.tsx" "src/**/*.ts",
], "src/**/*.tsx"
"exclude": [ ],
"node_modules",
"lib" }
]
}

View File

@ -1,30 +0,0 @@
{
"extends": "@microsoft/sp-tslint-rules/base-tslint.json",
"rules": {
"class-name": false,
"export-name": false,
"forin": false,
"label-position": false,
"member-access": true,
"no-arg": false,
"no-console": false,
"no-construct": false,
"no-duplicate-variable": true,
"no-eval": false,
"no-function-expression": true,
"no-internal-module": true,
"no-shadowed-variable": true,
"no-switch-case-fall-through": true,
"no-unnecessary-semicolons": true,
"no-unused-expression": true,
"no-use-before-declare": true,
"no-with-statement": true,
"semicolon": true,
"trailing-comma": false,
"typedef": false,
"typedef-whitespace": false,
"use-named-parameter": true,
"variable-name": false,
"whitespace": false
}
}

View File

@ -0,0 +1 @@
Project doesn't need to be upgraded