Initial version

This commit is contained in:
Hugo Bernier 2020-04-10 15:27:14 -04:00
parent f524f587ad
commit 6d42789c54
27 changed files with 18546 additions and 0 deletions

View File

@ -0,0 +1,25 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
# change these settings to your own preference
indent_style = space
indent_size = 2
# we recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
[{package,bower}.json]
indent_style = space
indent_size = 2

32
samples/react-versiondisplay/.gitignore vendored Normal file
View File

@ -0,0 +1,32 @@
# Logs
logs
*.log
npm-debug.log*
# Dependency directories
node_modules
# Build generated files
dist
lib
solution
temp
*.sppkg
# Coverage directory used by tools like istanbul
coverage
# OSX
.DS_Store
# Visual Studio files
.ntvs_analysis.dat
.vs
bin
obj
# Resx Generated Code
*.resx.ts
# Styles Generated Code
*.scss.ts

View File

@ -0,0 +1,12 @@
{
"@microsoft/generator-sharepoint": {
"isCreatingSolution": true,
"environment": "spo",
"version": "1.10.0",
"libraryName": "react-versiondisplay",
"libraryId": "826341a0-9c23-4f9f-9ed0-bc44ab43e2f6",
"packageManager": "npm",
"isDomainIsolated": false,
"componentType": "webpart"
}
}

View File

@ -0,0 +1,115 @@
## Version Display
## Summary
Display your SharePoint solution version within your web parts.
![Version Display](./assets/VersionDisplay.gif)
## Used SharePoint Framework Version
![1.10.0](https://img.shields.io/badge/version-1.10.0-green.svg)
## Applies to
* [SharePoint Framework](https:/dev.office.com/sharepoint)
* [Office 365 tenant](https://dev.office.com/sharepoint/docs/spfx/set-up-your-development-environment)
## Prerequisites
There are no pre-requisites.
## Solution
Solution|Author(s)
--------|---------
react-versiondisplay | Hugo Bernier ([Tahoe Ninjas](https://tahoeninjas.blog), [@bernier](https://twitter.com/bernierh))
## Version history
Version|Date|Comments
-------|----|--------
1.0|March 31, 2020|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.**
---
## Minimal Path to Awesome
* Clone this repository
* Set the `version` node in the `package.json` file, or by using `npm version major`, `npm version minor` or `npm version patch`
* in the command line run:
* `npm install`
* `gulp serve`
## Features
The sample uses a custom `gulp` task to synchronize the `version` node from the NodeJS `package.json` to the SharePoint solution's `package-solution.json`.
The solution demonstrates how to import the `package-solution.json` into a web part using a static `import` and a `require` statement.
### Using npm version to set the version
To change the `package.json` version (which will also change your SharePoint solution version), use [`npm version`](https://docs.npmjs.com/cli/version), using one of the following parameters:
```cmd
npm version major
npm version minor
npm version patch
```
The following table shows when you should call which `npm version` command, depending on the types of changes you're making to your solution:
|Type of change|Stage|Versioning rule|Example version| NPM command
|---|---|---|---|---|
|First release|New solution|Start with 1.0.0|1.0.0| `npm version major`
|Backward compatible bug fixes|Patch release|Increment the third digit|1.0.1| `npm version patch`
|Backward compatible new features|Minor release|Increment the middle digit and reset last digit to zero|1.1.0| `npm version minor`
|Changes that break backward compatibility|Major release|Increment the first digit and reset middle and last digits to zero|2.0.0| `npm version major`
### To use the custom gulp task in your solutions
If you'd like to use the custom `gulp` task in your solutions, copy the code from this solution's `gulpfile.js` between:
```javascript
// BEGIN: Add custom version sync task
```
and
```javascript
// END: Add custom version sync task
```
To your own `gulpfile.js`.
### To use the version using a static import
1. Copy the content of this solution's `src\typings.d.ts` to your own `src` folder in your own project.
2. In the code where you want to insert the solution version, add the following `import` statement:
```typescript
import * as packageSolution from '../../../config/package-solution.json';
```
Keep in mind that you may have to adjust the path to your `package-solution.json` depending on where you're adding the code within your solution.
### To use the version using a require
In the code where you want to insert the solution version, add the following `require` statement:
```typescript
const packageSolution: any = require("../../../config/package-solution.json");
```
Keep in mind that you may have to adjust the path to your `package-solution.json` depending on where you're adding the code within your solution.
## For More Information
If you'd like to read more about the concepts illustrated in this sample, please refer to the following links:
* [Semantic Versioning](https://semver.org/)
* [npm version](https://docs.npmjs.com/cli/version)
* [PropertyPaneWebPartInformation](https://sharepoint.github.io/sp-dev-fx-property-controls/controls/PropertyPaneWebPartInformation/)
* [Displaying the solution version in your web part](https://tahoeninjas.blog/2020/03/30/display-the-solution-version-in-your-web-part/)
* [How to version new SharePoint Framework projects](https://n8d.at/how-to-version-new-sharepoint-framework-projects/)
<img src="https://telemetry.sharepointpnp.com/sp-dev-fx-webparts/samples/react-versiondisplay" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 MiB

View File

@ -0,0 +1,19 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
"version": "2.0",
"bundles": {
"version-display-web-part": {
"components": [
{
"entrypoint": "./lib/webparts/versionDisplay/VersionDisplayWebPart.js",
"manifest": "./src/webparts/versionDisplay/VersionDisplayWebPart.manifest.json"
}
]
}
},
"externals": {},
"localizedResources": {
"VersionDisplayWebPartStrings": "lib/webparts/versionDisplay/loc/{locale}.js",
"PropertyControlStrings": "node_modules/@pnp/spfx-property-controls/lib/loc/{locale}.js"
}
}

View File

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

View File

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

View File

@ -0,0 +1,13 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
"solution": {
"name": "react-versiondisplay-client-side-solution",
"id": "826341a0-9c23-4f9f-9ed0-bc44ab43e2f6",
"version": "1.0.0.0",
"includeClientSideAssets": true,
"isDomainIsolated": false
},
"paths": {
"zippedPackage": "solution/react-versiondisplay.sppkg"
}
}

View File

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

View File

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

View File

@ -0,0 +1,53 @@
'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.`);
// BEGIN: Add custom version sync task
// This section is inspired by Stefan Bauer's article at https://n8d.at/how-to-version-new-sharepoint-framework-projects/
// Stefan rocks!
let syncVersionsSubtask = build.subTask('version-sync', function (gulp, buildOptions, done) {
this.log('Synching versions');
// import gulp utilits to write error messages
const gutil = require('gulp-util');
// import file system utilities form nodeJS
const fs = require('fs');
// read package.json
var pkgConfig = require('./package.json');
// read configuration of web part solution file
var pkgSolution = require('./config/package-solution.json');
// log old version
this.log('package-solution.json version:\t' + pkgSolution.solution.version);
// Generate new MS compliant version number
var newVersionNumber = pkgConfig.version.split('-')[0] + '.0';
if (pkgSolution.solution.version !== newVersionNumber) {
// assign newly generated version number to web part version
pkgSolution.solution.version = newVersionNumber;
// log new version
this.log('New package-solution.json version:\t' + pkgSolution.solution.version);
// write changed package-solution file
fs.writeFile('./config/package-solution.json', JSON.stringify(pkgSolution, null, 4));
}
else {
this.log('package-solution.json version is up-to-date');
}
done();
});
let syncVersionTask = build.task('version-sync', syncVersionsSubtask);
build.rig.addPreBuildTask(syncVersionTask);
// END: Add custom version sync task
build.initialize(require('gulp'));

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,43 @@
{
"name": "react-versiondisplay",
"version": "1.0.0",
"private": true,
"main": "lib/index.js",
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"build": "gulp bundle",
"clean": "gulp clean",
"test": "gulp test"
},
"dependencies": {
"@microsoft/sp-core-library": "1.10.0",
"@microsoft/sp-lodash-subset": "1.10.0",
"@microsoft/sp-office-ui-fabric-core": "1.10.0",
"@microsoft/sp-property-pane": "1.10.0",
"@microsoft/sp-webpart-base": "1.10.0",
"@pnp/spfx-property-controls": "1.17.0",
"@types/es6-promise": "0.0.33",
"@types/react": "16.8.8",
"@types/react-dom": "16.8.3",
"@types/webpack-env": "1.13.1",
"office-ui-fabric-react": "6.189.2",
"react": "16.8.5",
"react-dom": "16.8.5"
},
"resolutions": {
"@types/react": "16.8.8"
},
"devDependencies": {
"@microsoft/sp-build-web": "1.10.0",
"@microsoft/sp-tslint-rules": "1.10.0",
"@microsoft/sp-module-interfaces": "1.10.0",
"@microsoft/sp-webpart-workbench": "1.10.0",
"@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"
}
}

View File

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

View File

@ -0,0 +1,4 @@
declare module "*.json" {
const value: any;
export default value;
}

View File

@ -0,0 +1,23 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
"id": "1f2cbf1e-b43a-475d-beda-35cdad7ff4f7",
"alias": "VersionDisplayWebPart",
"componentType": "WebPart",
"version": "*",
"manifestVersion": 2,
"requiresCustomScript": false,
"supportedHosts": ["SharePointWebPart"],
"preconfiguredEntries": [{
"groupId": "5c03119e-3074-46fd-976b-c60198311f70",
"group": { "default": "Other" },
"title": { "default": "Version Display" },
"description": { "default": "Demonstrates how to update and display the version number of a web part" },
"iconImageUrl": "data:image/svg+xml,%3Csvg id='Layer_1' data-name='Layer 1' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 148.38 93.2'%3E%3Cdefs%3E%3Cstyle%3E.cls-1%7Bfill:%23231f20;%7D%3C/style%3E%3C/defs%3E%3Ctitle%3EUntitled-1-01%3C/title%3E%3Cpath class='cls-1' d='M74.73,91.19l-9.57,24H61.39l-9.09-24h4.22l6.09,17.44a15.86,15.86,0,0,1,.84,3.35h.1a15.16,15.16,0,0,1,.75-3.26l6.37-17.53Z' transform='translate(-52.3 -80.11)'/%3E%3Cpath class='cls-1' d='M98.14,104.15H81.2a9,9,0,0,0,2.15,6.19A7.46,7.46,0,0,0,89,112.52a11.81,11.81,0,0,0,7.46-2.67v3.61a14,14,0,0,1-8.37,2.29,10.13,10.13,0,0,1-8-3.27q-2.91-3.27-2.91-9.19a13.1,13.1,0,0,1,3.18-9.13,10.13,10.13,0,0,1,7.88-3.53,9,9,0,0,1,7.29,3.05q2.58,3,2.58,8.46Zm-3.94-3.26a7.84,7.84,0,0,0-1.6-5.18,5.49,5.49,0,0,0-4.4-1.85,6.18,6.18,0,0,0-4.61,2,8.83,8.83,0,0,0-2.35,5.08Z' transform='translate(-52.3 -80.11)'/%3E%3Cpath class='cls-1' d='M116.47,95.08a4.74,4.74,0,0,0-2.91-.77,4.89,4.89,0,0,0-4.11,2.32A10.76,10.76,0,0,0,107.8,103v12.23H104v-24h3.85v5h.09a8.33,8.33,0,0,1,2.51-4,5.68,5.68,0,0,1,3.77-1.42,6.26,6.26,0,0,1,2.3.33Z' transform='translate(-52.3 -80.11)'/%3E%3Cpath class='cls-1' d='M119.19,114.32V110.2a11.35,11.35,0,0,0,6.91,2.32c3.38,0,5.06-1.13,5.06-3.38a2.88,2.88,0,0,0-.43-1.62,4.4,4.4,0,0,0-1.17-1.19,8.85,8.85,0,0,0-1.74-.92c-.66-.28-1.37-.56-2.14-.86a26.9,26.9,0,0,1-2.8-1.28,8.38,8.38,0,0,1-2-1.45,5.48,5.48,0,0,1-1.22-1.84,6.57,6.57,0,0,1-.41-2.41,5.7,5.7,0,0,1,.78-3,6.7,6.7,0,0,1,2.06-2.18A9.62,9.62,0,0,1,125,91.07a13.34,13.34,0,0,1,3.41-.44A13.75,13.75,0,0,1,134,91.71V95.6a10.86,10.86,0,0,0-6.09-1.74,7.32,7.32,0,0,0-2,.25,4.66,4.66,0,0,0-1.49.69,3.26,3.26,0,0,0-1,1.07,2.87,2.87,0,0,0-.34,1.37,3,3,0,0,0,1.34,2.69,7.44,7.44,0,0,0,1.59.89q.95.41,2.13.87a29.27,29.27,0,0,1,2.86,1.26,9.58,9.58,0,0,1,2.16,1.45,5.75,5.75,0,0,1,1.37,1.86,6,6,0,0,1,.48,2.51,5.91,5.91,0,0,1-.78,3.09,6.83,6.83,0,0,1-2.1,2.18,9.57,9.57,0,0,1-3,1.29,15.08,15.08,0,0,1-3.59.42A13.52,13.52,0,0,1,119.19,114.32Z' transform='translate(-52.3 -80.11)'/%3E%3Cpath class='cls-1' d='M143,85.1a2.43,2.43,0,0,1-1.76-.71,2.34,2.34,0,0,1-.73-1.78,2.46,2.46,0,0,1,2.49-2.5,2.46,2.46,0,0,1,1.79.71,2.5,2.5,0,0,1,0,3.55A2.44,2.44,0,0,1,143,85.1Zm1.87,30.09H141v-24h3.84Z' transform='translate(-52.3 -80.11)'/%3E%3Cpath class='cls-1' d='M162.66,115.75a11.14,11.14,0,0,1-8.49-3.36,12.44,12.44,0,0,1-3.18-8.92q0-6,3.31-9.44a11.86,11.86,0,0,1,8.93-3.4,10.79,10.79,0,0,1,8.38,3.3q3,3.31,3,9.17a12.88,12.88,0,0,1-3.25,9.2A11.39,11.39,0,0,1,162.66,115.75ZM163,93.86a7.3,7.3,0,0,0-5.86,2.52,10.34,10.34,0,0,0-2.16,7,9.8,9.8,0,0,0,2.18,6.73,7.41,7.41,0,0,0,5.84,2.46,7.06,7.06,0,0,0,5.73-2.41q2-2.42,2-6.87t-2-6.94A7,7,0,0,0,163,93.86Z' transform='translate(-52.3 -80.11)'/%3E%3Cpath class='cls-1' d='M200.68,115.19h-3.84V101.5q0-7.64-5.58-7.64A6.08,6.08,0,0,0,186.49,96a8,8,0,0,0-1.89,5.47v13.69h-3.84v-24h3.84v4h.1a8.64,8.64,0,0,1,7.87-4.55,7.34,7.34,0,0,1,6,2.54q2.08,2.55,2.09,7.35Z' transform='translate(-52.3 -80.11)'/%3E%3Cpath class='cls-1' d='M89.75,148.79l-8.06,12.14,7.92,11.86H85.13L80.42,165c-.29-.48-.65-1.09-1-1.83h-.1c-.07.14-.44.75-1.1,1.83l-4.8,7.78H68.94L77.12,161l-7.83-12.24h4.48l4.64,8.2c.34.61.68,1.24,1,1.88h.1l6-10.08Z' transform='translate(-52.3 -80.11)'/%3E%3Cpath class='cls-1' d='M95.59,173.31a2.46,2.46,0,0,1-1.84-.78,2.53,2.53,0,0,1-.77-1.85,2.57,2.57,0,0,1,.77-1.86,2.44,2.44,0,0,1,1.84-.79,2.5,2.5,0,0,1,1.87.79,2.53,2.53,0,0,1,.77,1.86,2.49,2.49,0,0,1-.77,1.85A2.53,2.53,0,0,1,95.59,173.31Z' transform='translate(-52.3 -80.11)'/%3E%3Cpath class='cls-1' d='M122.19,148.79l-8.06,12.14,7.92,11.86h-4.48L112.86,165c-.3-.48-.65-1.09-1.06-1.83h-.09c-.08.14-.44.75-1.1,1.83l-4.81,7.78h-4.42L109.55,161l-7.82-12.24h4.47l4.64,8.2c.35.61.68,1.24,1,1.88h.1l6-10.08Z' transform='translate(-52.3 -80.11)'/%3E%3Cpath class='cls-1' d='M128,173.31a2.48,2.48,0,0,1-1.84-.78,2.56,2.56,0,0,1-.76-1.85,2.6,2.6,0,0,1,.76-1.86A2.45,2.45,0,0,1,128,168a2.52,2.52,0,0,1,1.88.79,2.57,2.57,0,0,1,.77,1.86,2.65,2.65,0,0,1-2.65,2.63Z' transform='translate(-52.3 -80.11)'/%3E%3Cpath class='cls-1' d='M154.63,148.79l-8.07,12.14,7.92,11.86H150L145.3,165c-.3-.48-.65-1.09-1.06-1.83h-.09l-1.1,1.83-4.81,7.78h-4.43L142,161l-7.83-12.24h4.48l4.64,8.2c.35.61.68,1.24,1,1.88h.09l6-10.08Z' transform='translate(-52.3 -80.11)'/%3E%3Cpath class='cls-1' d='M160.46,173.31a2.48,2.48,0,0,1-1.84-.78,2.52,2.52,0,0,1-.76-1.85,2.56,2.56,0,0,1,.76-1.86,2.45,2.45,0,0,1,1.84-.79,2.52,2.52,0,0,1,1.88.79,2.57,2.57,0,0,1,.77,1.86,2.65,2.65,0,0,1-2.65,2.63Z' transform='translate(-52.3 -80.11)'/%3E%3Cpath class='cls-1' d='M187.06,148.79,179,160.93l7.92,11.86h-4.47L177.73,165q-.43-.72-1-1.83h-.09L175.48,165l-4.8,7.78h-4.43L174.43,161l-7.83-12.24h4.48l4.64,8.2c.34.61.68,1.24,1,1.88h.09l6-10.08Z' transform='translate(-52.3 -80.11)'/%3E%3C/svg%3E",
"properties": {
"description": "Version Display"
}
}]
}

View File

@ -0,0 +1,83 @@
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { Version } from '@microsoft/sp-core-library';
import {
IPropertyPaneConfiguration,
PropertyPaneTextField
} from '@microsoft/sp-property-pane';
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
import * as strings from 'VersionDisplayWebPartStrings';
import VersionDisplay from './components/VersionDisplay';
import { IVersionDisplayProps } from './components/IVersionDisplayProps';
// Used to display version information
import { PropertyPaneWebPartInformation } from '@pnp/spfx-property-controls/lib/PropertyPaneWebPartInformation';
// Import package version
const requirePackage: any = require("../../../config/package-solution.json");
// Static import
import * as packageSolution from '../../../config/package-solution.json';
export interface IVersionDisplayWebPartProps {
description: string;
}
export default class VersionDisplayWebPart extends BaseClientSideWebPart<IVersionDisplayWebPartProps> {
public render(): void {
const element: React.ReactElement<IVersionDisplayProps> = React.createElement(
VersionDisplay,
{
requireVersion: requirePackage.solution.version,
staticImportVersion: (<any>packageSolution).solution.version,
manifestVersion: this.context.manifest.version
}
);
ReactDom.render(element, this.domElement);
}
protected onDispose(): void {
ReactDom.unmountComponentAtNode(this.domElement);
}
protected get dataVersion(): Version {
return Version.parse('1.0');
}
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
return {
pages: [
{
header: {
description: strings.PropertyPaneDescription
},
groups: [
{
groupName: strings.AboutGroupName,
groupFields: [
// Using a static import
PropertyPaneWebPartInformation({
description: strings.ManifestVersionLabel + this.context.manifest.version,
key: 'webPartInfoStaticId'
}),
// Using a require statement
PropertyPaneWebPartInformation({
description: strings.WebPartVersionLabel + requirePackage.solution.version,
key: 'webPartInfoId'
}),
// Using a the web part's manifest
PropertyPaneWebPartInformation({
description: strings.StaticImportVersionLabel + (<any>packageSolution).solution.version,
key: 'webPartInfoStaticId'
})
]
}
]
}
]
};
}
}

View File

@ -0,0 +1,5 @@
export interface IVersionDisplayProps {
requireVersion: string;
staticImportVersion: string;
manifestVersion: string;
}

View File

@ -0,0 +1,74 @@
@import '~office-ui-fabric-react/dist/sass/References.scss';
.versionDisplay {
.container {
max-width: 700px;
margin: 0px auto;
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1);
}
.row {
@include ms-Grid-row;
@include ms-fontColor-white;
background-color: $ms-color-themeDark;
padding: 20px;
}
.column {
@include ms-Grid-col;
@include ms-lg10;
@include ms-xl8;
@include ms-xlPush2;
@include ms-lgPush1;
}
.title {
@include ms-font-xl;
@include ms-fontColor-white;
}
.subTitle {
@include ms-font-l;
@include ms-fontColor-white;
}
.description {
@include ms-font-l;
@include ms-fontColor-white;
}
.button {
// Our button
text-decoration: none;
height: 32px;
// Primary Button
min-width: 80px;
background-color: $ms-color-themePrimary;
border-color: $ms-color-themePrimary;
color: $ms-color-white;
// Basic Button
outline: transparent;
position: relative;
font-family: "Segoe UI WestEuropean","Segoe UI",-apple-system,BlinkMacSystemFont,Roboto,"Helvetica Neue",sans-serif;
-webkit-font-smoothing: antialiased;
font-size: $ms-font-size-m;
font-weight: $ms-font-weight-regular;
border-width: 0;
text-align: center;
cursor: pointer;
display: inline-block;
padding: 0 16px;
.label {
font-weight: $ms-font-weight-semibold;
font-size: $ms-font-size-m;
height: 32px;
line-height: 32px;
margin: 0 4px;
vertical-align: top;
display: inline-block;
}
}
}

View File

@ -0,0 +1,24 @@
import * as React from 'react';
import styles from './VersionDisplay.module.scss';
import { IVersionDisplayProps } from './IVersionDisplayProps';
import { escape } from '@microsoft/sp-lodash-subset';
export default class VersionDisplay extends React.Component<IVersionDisplayProps, {}> {
public render(): React.ReactElement<IVersionDisplayProps> {
return (
<div className={ styles.versionDisplay }>
<div className={ styles.container }>
<div className={ styles.row }>
<div className={ styles.column }>
<span className={ styles.title }>Version Display</span>
<p className={ styles.subTitle }>This web part displays the solution version.</p>
<p className={ styles.description }>Version (using require): {escape(this.props.requireVersion)}</p>
<p className={ styles.description }>Version (using static import): {escape(this.props.staticImportVersion)}</p>
<p className={ styles.description }>Version (using manifest): {escape(this.props.manifestVersion)}</p>
</div>
</div>
</div>
</div>
);
}
}

View File

@ -0,0 +1,9 @@
define([], function() {
return {
ManifestVersionLabel: "Version (from manifest):",
StaticImportVersionLabel: "Version (using static import): ",
WebPartVersionLabel: "Version (using require): ",
AboutGroupName: "About",
PropertyPaneDescription: "This web part displays the current version of the solution",
}
});

View File

@ -0,0 +1,12 @@
declare interface IVersionDisplayWebPartStrings {
ManifestVersionLabel: string;
StaticImportVersionLabel: string;
WebPartVersionLabel: string;
AboutGroupName: string;
PropertyPaneDescription: string;
}
declare module 'VersionDisplayWebPartStrings' {
const strings: IVersionDisplayWebPartStrings;
export = strings;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,38 @@
{
"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"
],
"exclude": [
"node_modules",
"lib"
]
}

View File

@ -0,0 +1,30 @@
{
"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
}
}