Merge pull request #1898 from AriGunawan/features/update_react_contributors

This commit is contained in:
Hugo Bernier 2021-06-02 23:15:59 -04:00 committed by GitHub
commit 4e039226e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 21338 additions and 125 deletions

View File

@ -30,3 +30,5 @@ obj
# Styles Generated Code
*.scss.ts
release

View File

@ -1,8 +1,12 @@
{
"@microsoft/generator-sharepoint": {
"version": "1.1.1",
"version": "1.12.1",
"libraryName": "react-pagecontributors",
"libraryId": "1c18830a-4c18-4b82-a571-77863b19c66d",
"environment": "spo"
"environment": "spo",
"isDomainIsolated": false,
"isCreatingSolution": true,
"packageManager": "npm",
"componentType": "webpart"
}
}

View File

@ -22,42 +22,42 @@ Displays page contributors in reverse chronological order.
![Organisation Chart for the current user running in local Workbench](./assets/pagecontributors_mockup.PNG)
## Used SharePoint Framework Version
![drop](https://img.shields.io/badge/version-GA-green.svg)
## Compatibility
![SPFx 1.12.1](https://img.shields.io/badge/SPFx-1.12.1-green.svg)
![Node.js LTS 10.x](https://img.shields.io/badge/Node.js-LTS%2010.x-green.svg)
![SharePoint Online](https://img.shields.io/badge/SharePoint-Online-yellow.svg)
![Teams N/A: Untested with Microsoft Teams](https://img.shields.io/badge/Teams-N%2FA-lightgrey.svg "Untested with Microsoft Teams")
![Workbench Local | Hosted](https://img.shields.io/badge/Workbench-Local%20%7C%20Hosted-green.svg)
## Applies to
* [SharePoint Framework](https://docs.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
* [Office 365 tenant](https://docs.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment)
* [Microsoft 365 tenant](https://docs.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment)
## Prerequisites
PnP-JS-Core
## Solution
Solution|Author(s)
--------|---------
PageContributors | Stéphane Magne ([@SPParse](https://twitter.com/SPParse))
PageContributors | [Stéphane Magne](https://github.com/SPParseError) ([@SPParse](https://twitter.com/SPParse))
PageContributors | [Ari Gunawan](https://github.com/AriGunawan) ([@arigunawan3023](https://twitter.com/arigunawan3023))
## Version history
Version|Date|Comments
-------|----|--------
1.0|July 27, 2017|Initial release
## 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.**
---
1.0.0|July 27, 2017|Initial release
1.1.0|May 23, 2021|Update SPFx (v1.12.1) version and replace sp-pnp-js with @pnp/sp (v2.5)
## Minimal Path to Awesome
- Clone this repository
- in the command line run:
- `npm install`
- `gulp serve`
* Clone this repository
* in the command line run:
* `npm install`
* `gulp serve`
## Features
@ -70,6 +70,20 @@ This Web Part illustrates the following concepts on top of the SharePoint Framew
- Office UI Fabric
- React
- Pnp JS Core
- PNP JS
## 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.**
## Support
We do not support samples, but we do use GitHub to track issues and constantly want to improve these samples.
If you encounter any issues while using this sample, [create a new issue](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=bug-report.yml&sample=react-pagecontributors&authors=@SPParseError%20@AriGunawan&title=react-pagecontributors%20-%20).
For questions regarding this sample, [create a new question](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=question.yml&sample=react-pagecontributors&authors=@SPParseError%20@AriGunawan&title=react-pagecontributors%20-%20).
Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=suggestion.yml&sample=react-pagecontributors&authors=@SPParseError%20@AriGunawan&title=react-pagecontributors%20-%20).
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/react-pagecontributors" />

View File

@ -9,7 +9,7 @@
"Displays page contributors in reverse chronological order."
],
"creationDateTime": "2017-07-27",
"updateDateTime": "2017-07-27",
"updateDateTime": "2021-05-23",
"products": [
"SharePoint",
"Office"
@ -21,7 +21,7 @@
},
{
"key": "SPFX-VERSION",
"value": "GA"
"value": "1.12.1"
}
],
"thumbnails": [
@ -45,6 +45,12 @@
"pictureUrl": "https://github.com/SPParseError.png",
"name": "St\u00E9phane Magne",
"twitter": "SPParse"
},
{
"gitHubAccount": "AriGunawan",
"name": "Ari Gunawan",
"company": "",
"pictureUrl": "https://github.com/AriGunawan.png"
}
],
"references": [

View File

@ -1,13 +1,18 @@
{
"entries": [
{
"entry": "./lib/webparts/pageContributors/PageContributorsWebPart.js",
"manifest": "./src/webparts/pageContributors/PageContributorsWebPart.manifest.json",
"outputPath": "./dist/page-contributors.bundle.js"
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0",
"bundles": {
"page-contributors-web-part": {
"components": [
{
"entrypoint": "./lib/webparts/pageContributors/PageContributorsWebPart.js",
"manifest": "./src/webparts/pageContributors/PageContributorsWebPart.manifest.json"
}
]
}
],
},
"externals": {},
"localizedResources": {
"pageContributorsStrings": "webparts/pageContributors/loc/{locale}.js"
"pageContributorsStrings": "lib/webparts/pageContributors/loc/{locale}.js"
}
}
}

View File

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

View File

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

View File

@ -1,8 +1,19 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "react-pagecontributors-client-side-solution",
"id": "1c18830a-4c18-4b82-a571-77863b19c66d",
"version": "1.0.0.0"
"version": "1.1.0.0",
"skipFeatureDeployment": true,
"developer": {
"name": "",
"websiteUrl": "",
"privacyUrl": "",
"termsOfUseUrl": "",
"mpnId": ""
},
"isDomainIsolated": false,
"includeClientSideAssets": true
},
"paths": {
"zippedPackage": "solution/react-pagecontributors.sppkg"

View File

@ -1,4 +1,5 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/core-build/serve.schema.json",
"port": 4321,
"initialPage": "https://localhost:5432/workbench",
"https": true,

View File

@ -1,45 +0,0 @@
{
// Display errors as warnings
"displayAsWarning": true,
// The TSLint task may have been configured with several custom lint rules
// before this config file is read (for example lint rules from the tslint-microsoft-contrib
// project). If true, this flag will deactivate any of these rules.
"removeExistingRules": true,
// When true, the TSLint task is configured with some default TSLint "rules.":
"useDefaultConfigAsBase": false,
// Since removeExistingRules=true and useDefaultConfigAsBase=false, there will be no lint rules
// which are active, other than the list of rules below.
"lintConfig": {
// Opt-in to Lint rules which help to eliminate bugs in JavaScript
"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-case": true,
"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-unused-imports": true,
"no-use-before-declare": true,
"no-with-statement": true,
"semicolon": true,
"trailing-comma": false,
"typedef": false,
"typedef-whitespace": false,
"use-named-parameter": true,
"valid-typeof": true,
"variable-name": false,
"whitespace": false
}
}
}

View File

@ -1,3 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
"cdnBasePath": "<!-- PATH TO CDN -->"
}

View File

@ -3,4 +3,15 @@
const gulp = require('gulp');
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(gulp);

File diff suppressed because it is too large Load Diff

View File

@ -2,33 +2,33 @@
"name": "react-pagecontributors",
"version": "0.0.1",
"private": true,
"engines": {
"node": ">=0.10.0"
},
"dependencies": {
"@microsoft/sp-core-library": "~1.1.0",
"@microsoft/sp-webpart-base": "~1.1.1",
"@types/react": "0.14.46",
"@types/react-addons-shallow-compare": "0.14.17",
"@types/react-addons-test-utils": "0.14.15",
"@types/react-addons-update": "0.14.14",
"@types/react-dom": "0.14.18",
"@types/webpack-env": ">=1.12.1 <1.14.0",
"react": "15.4.2",
"react-dom": "15.4.2",
"sp-pnp-js": "^2.0.7"
"@microsoft/sp-core-library": "1.12.1",
"@microsoft/sp-lodash-subset": "1.12.1",
"@microsoft/sp-office-ui-fabric-core": "1.12.1",
"@microsoft/sp-property-pane": "1.12.1",
"@microsoft/sp-webpart-base": "1.12.1",
"office-ui-fabric-react": "7.156.0",
"react": "16.9.0",
"react-dom": "16.9.0",
"@pnp/sp": "^2.5.0"
},
"devDependencies": {
"@microsoft/sp-build-web": "~1.1.0",
"@microsoft/sp-module-interfaces": "~1.1.0",
"@microsoft/sp-webpart-workbench": "~1.1.0",
"gulp": "~3.9.1",
"@types/chai": ">=3.4.34 <3.6.0",
"@types/mocha": ">=2.2.33 <2.6.0"
"@microsoft/rush-stack-compiler-3.7": "0.2.3",
"@microsoft/sp-build-web": "1.12.1",
"@microsoft/sp-module-interfaces": "1.12.1",
"@microsoft/sp-tslint-rules": "1.12.1",
"@microsoft/sp-webpart-workbench": "1.12.1",
"@types/react": "16.9.36",
"@types/react-dom": "16.9.8",
"@types/webpack-env": "1.13.1",
"ajv": "~5.2.2",
"gulp": "~4.0.2"
},
"scripts": {
"build": "gulp bundle",
"clean": "gulp clean",
"test": "gulp test"
}
},
"main": "lib/index.js"
}

View File

@ -0,0 +1 @@
// A file is required to be in the root of the /src directory by the TypeScript compiler

View File

@ -1,16 +1,16 @@
{
"$schema": "../../../node_modules/@microsoft/sp-module-interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json",
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
"id": "dfb5229a-c1c3-4e98-870b-c40dd6e4ec4b",
"alias": "PageContributorsWebPart",
"componentType": "WebPart",
"version": "1.0.0",
"manifestVersion": 2,
"safeWithCustomScriptDisabled": false,
"requiresCustomScript": false,
"supportedHosts": ["SharePointWebPart"],
"preconfiguredEntries": [{
"groupId": "dfb5229a-c1c3-4e98-870b-c40dd6e4ec4b",
"group": { "default": "Under Development" },
"group": { "default": "Other" },
"title": { "default": "Page Contributors" },
"description": { "default": "Displays page contributors in reverse chronological order" },
"officeFabricIconFontName": "People",

View File

@ -1,24 +1,24 @@
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { Version } from '@microsoft/sp-core-library';
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
import {
BaseClientSideWebPart,
IPropertyPaneConfiguration,
PropertyPaneSlider,
PropertyPaneDropdown,
PropertyPaneSlider,
PropertyPaneTextField
} from '@microsoft/sp-webpart-base';
} from '@microsoft/sp-property-pane';
import * as strings from 'pageContributorsStrings';
import PageContributors from './components/PageContributors';
import { IPageContributorsWebPartProps } from './IPageContributorsWebPartProps';
import { PersonaSize } from "office-ui-fabric-react/lib/index";
import pnp from 'sp-pnp-js';
import { sp } from "@pnp/sp/presets/all";
export default class PagecontributionWebPart extends BaseClientSideWebPart<IPageContributorsWebPartProps> {
public onInit(): Promise<void> {
return super.onInit().then(_ => {
pnp.setup({
sp.setup({
spfxContext: this.context
});
});
@ -56,13 +56,13 @@ export default class PagecontributionWebPart extends BaseClientSideWebPart<IPage
PropertyPaneDropdown('personaSize', {
label: strings.PropertyPanePersonaSizeText,
options: [
{ key: PersonaSize.tiny, text: strings.PropertyPaneIconsSizeTiny },
{ key: PersonaSize.extraExtraSmall, text: strings.PropertyPaneIconsSizeEES },
{ key: PersonaSize.extraSmall, text: strings.PropertyPaneIconsSizeES },
{ key: PersonaSize.small, text: strings.PropertyPaneIconsSizeS },
{ key: PersonaSize.regular, text: strings.PropertyPaneIconsSizeR },
{ key: PersonaSize.large, text: strings.PropertyPaneIconsSizeL },
{ key: PersonaSize.extraLarge, text: strings.PropertyPaneIconsSizeEL },
{ key: PersonaSize.size8, text: strings.PropertyPaneIconsSizeTiny },
{ key: PersonaSize.size24, text: strings.PropertyPaneIconsSizeEES },
{ key: PersonaSize.size32, text: strings.PropertyPaneIconsSizeES },
{ key: PersonaSize.size40, text: strings.PropertyPaneIconsSizeS },
{ key: PersonaSize.size48, text: strings.PropertyPaneIconsSizeR },
{ key: PersonaSize.size72, text: strings.PropertyPaneIconsSizeL },
{ key: PersonaSize.size100, text: strings.PropertyPaneIconsSizeEL },
],
selectedKey: this.properties.personaSize
}),

View File

@ -5,7 +5,7 @@ import {
Environment,
EnvironmentType
} from '@microsoft/sp-core-library';
import pnp from 'sp-pnp-js';
import { sp } from '@pnp/sp';
import { IPageContributorsProps } from "./IPageContributorsProps";
export class PageContributor {
@ -56,12 +56,12 @@ export class PageContributorsMockData {
export class PageContributorsService {
public static getPageContributors(pageServerRelativeUrl: string): Promise<PageContributor[]> {
return new Promise<PageContributor[]>((resolve, reject) => {
pnp.sp.web.getFileByServerRelativeUrl(pageServerRelativeUrl)
sp.web.getFileByServerRelativeUrl(pageServerRelativeUrl)
.select('ModifiedBy')
.expand('ModifiedBy')
.get()
.then(file => {
pnp.sp.web.getFileByServerRelativeUrl(pageServerRelativeUrl)
sp.web.getFileByServerRelativeUrl(pageServerRelativeUrl)
.versions
.orderBy('Created')
.select('ID, Created, CreatedBy')
@ -71,7 +71,7 @@ export class PageContributorsService {
let history = versions.map((version) => {
return new PageContributor(version.CreatedBy);
});
history.unshift(new PageContributor(file.ModifiedBy));
history.unshift(new PageContributor(file['ModifiedBy']));
history = RemoveDuplicates(history);
resolve(history);
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

View File

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

View File

@ -1,3 +1,30 @@
{
"rulesDirectory": "./config"
"extends": "./node_modules/@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
}
}