-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a939de
commit d4fb682
Showing
20 changed files
with
342 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Folders | ||
.vscode | ||
coverage | ||
node_modules | ||
sharepoint | ||
src | ||
temp | ||
|
||
# Files | ||
*.csproj | ||
.git* | ||
.yo-rc.json | ||
gulpfile.js | ||
tsconfig.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"@microsoft/generator-sharepoint": { | ||
"version": "1.1.3", | ||
"libraryName": "js-command-clone", | ||
"libraryId": "f1506103-545d-4ec5-abdc-b9cce96df092", | ||
"environment": "spo" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## js-command-clone | ||
|
||
This is where you include your WebPart documentation. | ||
|
||
### Building the code | ||
|
||
```bash | ||
git clone the repo | ||
npm i | ||
npm i -g gulp | ||
gulp | ||
``` | ||
|
||
This package produces the following: | ||
|
||
* lib/* - intermediate-stage commonjs build artifacts | ||
* dist/* - the bundled script, along with other resources | ||
* deploy/* - all resources which should be uploaded to a CDN. | ||
|
||
### Build options | ||
|
||
gulp clean - TODO | ||
gulp test - TODO | ||
gulp serve - TODO | ||
gulp bundle - TODO | ||
gulp package-solution - TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"entries": [ | ||
{ | ||
"entry": "./lib/extensions/spfxClone/SpfxCloneCommandSet.js", | ||
"manifest": "./src/extensions/spfxClone/SpfxCloneCommandSet.manifest.json", | ||
"outputPath": "./dist/spfx-clone.bundle.js" | ||
} | ||
], | ||
"externals": {}, | ||
"localizedResources": { | ||
"spfxCloneStrings": "extensions/spfxClone/loc/{locale}.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"deployCdnPath": "temp/deploy" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"workingDir": "./temp/deploy/", | ||
"account": "<!-- STORAGE ACCOUNT NAME -->", | ||
"container": "js-command-clone", | ||
"accessKey": "<!-- ACCESS KEY -->" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"solution": { | ||
"name": "js-command-clone-client-side-solution", | ||
"id": "f1506103-545d-4ec5-abdc-b9cce96df092", | ||
"version": "1.0.0.0", | ||
"skipFeatureDeployment": true | ||
}, | ||
"paths": { | ||
"zippedPackage": "solution/js-command-clone.sppkg" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"port": 4321, | ||
"initialPage": "https://localhost:5432/workbench", | ||
"https": true, | ||
"api": { | ||
"port": 5432, | ||
"entryPath": "node_modules/@microsoft/sp-webpart-workbench/lib/api/" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
// 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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"cdnBasePath": "<!-- PATH TO CDN -->" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
|
||
const gulp = require('gulp'); | ||
const build = require('@microsoft/sp-build-web'); | ||
|
||
build.initialize(gulp); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "js-command-clone", | ||
"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/webpack-env": ">=1.12.1 <1.14.0", | ||
"@microsoft/sp-listview-extensibility": "0.1.1", | ||
"@microsoft/sp-application-base": "1.1.1" | ||
}, | ||
"devDependencies": { | ||
"@microsoft/sp-build-web": "~1.1.0", | ||
"@microsoft/sp-module-interfaces": "~1.1.1", | ||
"@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" | ||
}, | ||
"scripts": { | ||
"build": "gulp bundle", | ||
"clean": "gulp clean", | ||
"test": "gulp test" | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
samples/js-command-clone/src/extensions/spfxClone/SpfxCloneCommandSet.manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"$schema": "../../node_modules/@microsoft/sp-module-interfaces/lib/manifestSchemas/jsonSchemas/clientSideComponentManifestSchema.json", | ||
|
||
"id": "d2b98569-65e0-4e75-b7b9-5e3964cd8e5f", | ||
"alias": "SpfxCloneCommandSet", | ||
"componentType": "Extension", | ||
"extensionType": "ListViewCommandSet", | ||
|
||
// The "*" signifies that the version should be taken from the package.json | ||
"version": "*", | ||
"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, | ||
|
||
"commands": { | ||
"spfxClone": { | ||
"title": "Clone", | ||
"iconImageUrl": "icons/request.png" | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
samples/js-command-clone/src/extensions/spfxClone/SpfxCloneCommandSet.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { override } from '@microsoft/decorators'; | ||
import { Log } from '@microsoft/sp-core-library'; | ||
import { | ||
BaseListViewCommandSet, | ||
IListViewCommandSetRefreshEventParameters, | ||
IListViewCommandSetExecuteEventParameters | ||
} from '@microsoft/sp-listview-extensibility'; | ||
|
||
import * as strings from 'spfxCloneStrings'; | ||
|
||
/** | ||
* If your command set uses the ClientSideComponentProperties JSON input, | ||
* it will be deserialized into the BaseExtension.properties object. | ||
* You can define an interface to describe it. | ||
*/ | ||
export interface ISpfxCloneCommandSetProperties { | ||
// This is an example; replace with your own property | ||
disabledCommandIds: string[]; | ||
} | ||
|
||
const LOG_SOURCE: string = 'SpfxCloneCommandSet'; | ||
|
||
export default class SpfxCloneCommandSet | ||
extends BaseListViewCommandSet<ISpfxCloneCommandSetProperties> { | ||
|
||
@override | ||
public onInit(): Promise<void> { | ||
Log.info(LOG_SOURCE, 'Initialized SpfxCloneCommandSet'); | ||
return Promise.resolve<void>(); | ||
} | ||
|
||
@override | ||
public onRefreshCommand(event: IListViewCommandSetRefreshEventParameters): void { | ||
event.visible = true; // assume true by default | ||
|
||
if (this.properties.disabledCommandIds) { | ||
if (this.properties.disabledCommandIds.indexOf(event.commandId) >= 0) { | ||
Log.info(LOG_SOURCE, 'Hiding command ' + event.commandId); | ||
event.visible = false; | ||
} | ||
} | ||
} | ||
|
||
@override | ||
public onExecute(event: IListViewCommandSetExecuteEventParameters): void { | ||
switch (event.commandId) { | ||
case 'COMMAND_1': | ||
alert(`Clicked ${strings.Command1}`); | ||
break; | ||
case 'COMMAND_2': | ||
alert(`Clicked ${strings.Command2}`); | ||
break; | ||
default: | ||
throw new Error('Unknown command'); | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
samples/js-command-clone/src/extensions/spfxClone/loc/en-us.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
define([], function() { | ||
return { | ||
"Command1": "Command 1", | ||
"Command2": "Command 2" | ||
} | ||
}); |
9 changes: 9 additions & 0 deletions
9
samples/js-command-clone/src/extensions/spfxClone/loc/myStrings.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
declare interface ISpfxCloneStrings { | ||
Command1: string; | ||
Command2: string; | ||
} | ||
|
||
declare module 'spfxCloneStrings' { | ||
const strings: ISpfxCloneStrings; | ||
export = strings; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"forceConsistentCasingInFileNames": true, | ||
"module": "commonjs", | ||
"jsx": "react", | ||
"declaration": true, | ||
"sourceMap": true, | ||
"experimentalDecorators": true, | ||
"types": [ | ||
"es6-promise", | ||
"es6-collections", | ||
"webpack-env" | ||
] | ||
} | ||
} |