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
node_modules
.heft
release
# Build generated files
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": {
"isCreatingSolution": true,
"environment": "spo",
"version": "1.11.0",
"version": "1.16.1",
"nodeVersion": "14.18.1",
"libraryName": "advanced-page-properties",
"libraryId": "daae06a2-8599-445c-93c0-3bd739305f56",
"packageManager": "npm",
"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",
"workingDir": "./temp/deploy/",
"account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "advanced-page-properties",
"accessKey": "<!-- ACCESS KEY -->"
}
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
"workingDir": "./release/assets/",
"account": "<!-- STORAGE ACCOUNT NAME -->",
"container": "advanced-page-properties",
"accessKey": "<!-- ACCESS KEY -->"
}

View File

@ -12,7 +12,29 @@
"privacyUrl": "",
"termsOfUseUrl": "",
"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": {
"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,
"https": true,
"initialPage": "https://localhost:5432/workbench",
"api": {
"port": 5432,
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/"
}
"initialPage": "https://macaw.sharepoint.com/sites/valerasn_dev/_layouts/workbench.aspx"
}

View File

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

View File

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

View File

@ -6,7 +6,7 @@ import * as _ from 'lodash';
import { useState, useEffect, useRef } from 'react';
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 "@pnp/sp/webs";
import "@pnp/sp/lists";
@ -28,7 +28,7 @@ const AdvancedPageProperties: React.FunctionComponent<IAdvancedPagePropertiesPro
propsRef.current = props;
sp.setup({ spfxContext: props.context });
const _sp = getSP(propsRef.current.context);
/**
* refreshProperties
@ -42,7 +42,7 @@ const AdvancedPageProperties: React.FunctionComponent<IAdvancedPagePropertiesPro
// Get the value(s) for the field from the list item itself
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) {
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",
"compilerOptions": {
"target": "es5",
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"jsx": "react",
"declaration": true,
"sourceMap": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"outDir": "lib",
"inlineSources": false,
"strictNullChecks": false,
"noUnusedLocals": false,
"typeRoots": [
"./node_modules/@types",
"./node_modules/@microsoft"
],
"types": [
"es6-promise",
"webpack-env"
],
"lib": [
"es5",
"dom",
"es2015.collection"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx"
],
"exclude": [
"node_modules",
"lib"
]
}
{
"extends": "./node_modules/@microsoft/sp-tslint-rules/base-tslint.json",
"compilerOptions": {
"target": "es5",
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"jsx": "react",
"declaration": true,
"sourceMap": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"outDir": "lib",
"inlineSources": false,
"strictNullChecks": false,
"noUnusedLocals": false,
"noImplicitAny": true,
"typeRoots": [
"./node_modules/@types",
"./node_modules/@microsoft"
],
"types": [
"webpack-env"
],
"lib": [
"es5",
"dom",
"es2015.collection",
"es2015.promise"
],
},
"include": [
"src/**/*.ts",
"src/**/*.tsx"
],
}

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