Skip to content

Commit f69f185

Browse files
author
Vesa Juvonen
committed
SPFx Extensions and v1.2 release changes
1 parent 81565fa commit f69f185

File tree

62 files changed

+255
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+255
-139
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Changes between Dev Preview and Release Candidate for SharePoint Framework Extensions (preview)
2+
3+
If you have created SharePoint Framework Extensions with the developer preview version (released June 2017), you'll have to perform some changes to make them work with Release Candidate (RC) version. Here's a short list of the changes, which were introduced with the latest version.
4+
5+
Release Candidate is enabled in the First Release tenants in Office 365, but is not supported yet in production use.
6+
7+
## General solution package changes
8+
9+
- Use lockstep version for all SPFx packages.
10+
- Upgrade to TypeScript 2.4.
11+
- Update to Fabric React 4.32.0.
12+
- SPFx npm package versions updated to 1.2.
13+
14+
### Application Customizer Changes
15+
16+
- Placeholder logic has been changed slightly and they have been renamed.
17+
- Typical placeholders are now called `'top'` and `'bottom'`
18+
- `onRender` method is deprecated - you should call render from the onInit, if needed and also add event handling for the possible events when placeholders should be re-rendered. See [updated placeholder].(./get-started/using-page-placeholder-with-extensions.md) tutorial for details.
19+
- Schema definition URL has been updated in the manifest file to point json schema file from the dev.office.com.
20+
21+
### Field Customizer Changes
22+
23+
- There are changes in the APIs for accessing the actual field values. You should be using `event.fieldValue`. Other options are deprecated.
24+
- API to access UI element to render the field customizer output has been changed from `event.cellDiv` to `event.domElement`.
25+
- Schema definition URL has been updated in the manifest file to point json schema file from the dev.office.com.
26+
27+
### ListView Command Set Changes
28+
29+
- `onRefreshCommand` method deprecated and replaced with `onListViewUpdated`.
30+
- Manifest json changes around the commands structure. Is using now `items` collections and changes in the title handling of the commands in the json definition.
31+
- Schema definition URL has been updated in the manifest file to point json schema file from the dev.office.com.

docs/spfx/extensions/get-started/build-a-hello-world-extension.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
66
Extensions are client-side components that run inside the context of a SharePoint page. Extensions can be deployed to SharePoint Online, and you can also use modern JavaScript tools and libraries to build them.
77

8-
>**Note:** Before following the steps in this article, be sure to [Set up your development environment](../../set-up-your-development-environment). Notice that extensions are currently **ONLY** available from Office 365 developer tenants.
8+
You can also follow these steps by watching the video on the [SharePoint PnP YouTube Channel](https://www.youtube.com/watch?v=0BeS0HukW24&list=PLR9nK3mnD-OXtWO5AIIr7nCR3sWutACpV).
9+
10+
<a href="https://www.youtube.com/watch?v=0BeS0HukW24&list=PLR9nK3mnD-OXtWO5AIIr7nCR3sWutACpV">
11+
<img src="../../../../images/spfx-ext-youtube-tutorial1.png" alt="Screenshot of the YouTube video player for this tutorial" />
12+
</a>
913

1014
## Create an extension project
1115
Create a new project directory in your favorite ___location.
@@ -29,6 +33,8 @@ yo @microsoft/sharepoint
2933
When prompted:
3034

3135
* Accept the default **app-extension** as your solution name and press **Enter**.
36+
* Choose **Use the current folder** and press **Enter**
37+
* Choose **N** to require extension to be installed on each site explicitly when it's being used
3238
* Choose **Extension (Preview)** as the client-side component type to be created.
3339
* Choose **Application Customizer (Preview)** as the extension type to be created.
3440

@@ -74,16 +80,15 @@ Notice that base class for the Application Customizer is imported from the **sp-
7480

7581
![import statement for BaseApplicationCustomizer from @microsoft/sp-application-base](../../../../images/ext-app-vscode-app-base.png)
7682

77-
The logic for your Application Customizer is contained in the two methods **onInit** and **onRender**.
83+
The logic for your Application Customizer is contained in the **onInit** method.
7884

79-
- **onInit()** is where you should perform any setup needed for your extension. This event occurs after ```this.context``` and ```this.properties``` are assigned, but before the page DOM is ready. As with web parts, ```onInit()``` returns a promise that you can use to perform asynchronous operations; ```onRender()``` will not be called until your promise has resolved. If you don’t need that, simply return ```super.onInit()```.
80-
- **onRender()** is where your extension can interact with the UI. This event occurs after the application’s initial page DOM structure has been created (although some parts of the UI may not have finished rendering yet).
85+
- **onInit()** is called when the client-side extension is first activated on the page. This event occurs after ```this.context``` and ```this.properties``` are assigned. As with web parts, ```onInit()``` returns a promise that you can use to perform asynchronous operations.
8186

8287
> Notice. The class constructor is called at an early stage, when ```this.context``` and ```this.properties``` are undefined. We do not support including custom initiation logic here.
8388
84-
Below are the contents of **onInit()** and **onRender()** in the default solution. This default solution simply writes a log to the Dev Dashboard, and then displays a simple JavaScript alert when the page renders.
89+
Below is the contents of **onInit()** in the default solution. This default solution simply writes a log to the Dev Dashboard, and then displays a simple JavaScript alert when the page renders.
8590

86-
![default onInit and onRender methods in the code](../../../../images/ext-app-vscode-methods.png)
91+
![default onInit method in the code](../../../../images/ext-app-vscode-methods.png)
8792

8893
> If your application customizer uses the ClientSideComponentProperties JSON input, it will be deserialized into the BaseExtension.properties object. You can define an interface to describe it. The default template is looking for a property called testMessage, and if it's provided, outputting it in an alert message.
8994
@@ -95,17 +100,17 @@ First, compile your code and host the compiled files from your local machine by
95100
gulp serve --nobrowser
96101
```
97102

98-
>**Note:** If you do not have the SPFx developer certificate installed, then Workbench will notify you that it is configured not to load scripts from localhost. Stop currently running process in the console window, execute `gulp trust-dev-cert` command in your project directory console to install the developer certificate before running `gulp serve --nobrowser`command again.
103+
>**Note:** If you do not have the SPFx developer certificate installed, then Workbench will notify you that it is configured not to load scripts from localhost. Stop currently running process in the console window, execute `gulp trust-dev-cert` command in your project directory console to install the developer certificate before running `gulp serve --nobrowser` command again.
99104
100105
Notice that we used the ```--nobrowser``` option, since there's no value in launching the local workbench since you currently cannot debug extensions locally.
101106

102107
Once it compiles the code without errors, it will serve the resulting manifest from http://localhost:4321.
103108

104109
![gulp serve](../../../../images/ext-app-gulp-serve.png)
105110

106-
To test your extension, navigate to a modern list view page in your SharePoint environment and append the following query string parameters to the URL:
111+
To test your extension, navigate to a modern list view page in your SharePoint environment and append the following query string parameters to the URL. Notice that you will need to update the id to match your own extension identifier available from the **HelloWorldApplicationCustomizer.manifest.json** file:
107112
```
108-
?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"d03ae0c2-bbbf-4cf5-9ff7-0986904553da":{"___location":"ClientSideExtension.ApplicationCustomizer","properties":{"testMessage":"Hello as property!"}}}
113+
?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"e5625e23-5c5a-4007-a335-e6c2c3afa485":{"___location":"ClientSideExtension.ApplicationCustomizer","properties":{"testMessage":"Hello as property!"}}}
109114
```
110115

111116
More detail about the URL query parameters:
@@ -115,7 +120,7 @@ More detail about the URL query parameters:
115120
* **debugManifestsFile:** specifies that we want to load SPFx components that are being locally served. Normally the loader only looks for components in the App Catalog (for your deployed solution) and the SharePoint manifest server (for the system libraries).
116121

117122
* **customActions:** this URL query parameter simulates a custom action. When we actually deploy and register this component in a site later in this lab, we’ll create this CustomAction object for real and describe all the different properties you can set on it.
118-
* **Key:** use the Guid of the extension as the key to associate with the custom action
123+
* **Key:** use the Guid of the extension as the key to associate with the custom action. This has to match on the id value of your extension available from the extension manifest.json.
119124
* **Location:** the type of custom action, use "ClientSideExtension.ApplicationCustomizer" for the Application Customizer extension
120125
* **Properties:** an optional JSON object containing properties that will be available via the this.properties member. In this HelloWorld example, it defined a ‘testMessage’ property.
121126

@@ -127,14 +132,14 @@ Extend the URL with the additional query parameters defined above. Notice that y
127132
The full URL should look similar to the following depending on your tenant URL:
128133

129134
```
130-
contoso.sharepoint.com/Lists/Contoso/AllItems.aspx?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"5fc73e12-8085-4a4b-8743-f6d02ffe1240":{"___location":"ClientSideExtension.ApplicationCustomizer","properties":{"testMessage":"Hello as property!"}}}
135+
contoso.sharepoint.com/Lists/Contoso/AllItems.aspx?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"e5625e23-5c5a-4007-a335-e6c2c3afa485":{"___location":"ClientSideExtension.ApplicationCustomizer","properties":{"testMessage":"Hello as property!"}}}
131136
```
132137

133138
![Allow Debug Manifest question from the page](../../../../images/ext-app-debug-manifest-message.png)
134139

135140
Click the "**Load debug scripts**" button to continue loading scripts from your local host.
136141

137-
You should now see the alert message on your page.
142+
You should now see the alert message on your page.
138143

139144
![Allow Debug Manifest question from the page](../../../../images/ext-app-alert-sp-page.png)
140145

docs/spfx/extensions/get-started/building-simple-cmdset-with-dialog-api.md

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
55
Extensions are client-side components that run inside the context of a SharePoint page. Extensions can be deployed to SharePoint Online and you can use modern JavaScript tools and libraries to build them.
66

7-
>**Note:** Before following the steps in this article, be sure to [Set up your development environment](../../set-up-your-development-environment). Notice that extensions are currently **ONLY** available from Office 365 developer tenants.
7+
You can also follow these steps by watching the video on the [SharePoint PnP YouTube Channel](https://www.youtube.com/watch?v=iW0LQQqAY0Y&list=PLR9nK3mnD-OXtWO5AIIr7nCR3sWutACpV).
88

9-
>**Note:** Currently ListView Command Set Extension can only be debugged with the modern experience in classic SharePoint sites. Please ensure that you use a classic team site with modern list experience for the testing.
9+
<a href="https://www.youtube.com/watch?v=iW0LQQqAY0Y&list=PLR9nK3mnD-OXtWO5AIIr7nCR3sWutACpV">
10+
<img src="../../../../images/spfx-ext-youtube-tutorialcommand.png" alt="Screenshot of the YouTube video player for this tutorial" />
11+
</a>
1012

1113
## Create an extension project
1214
Create a new project directory in your favorite ___location.
@@ -30,6 +32,8 @@ yo @microsoft/sharepoint
3032
When prompted:
3133

3234
* Accept the default value of **command-extension** as your solution name and press **Enter**.
35+
* Choose **Use the current folder** and press **Enter**.
36+
* Choose **N** to require extension to be installed on each site explicitly when it's being used.
3337
* Choose **Extension (Preview)** as the client-side component type to be created.
3438
* Choose **ListView Command Set (Preview)** as the extension type to be created.
3539

@@ -75,21 +79,33 @@ Open the **HelloWorldCommandSet.ts** file in the **src\extensions\helloWorld** f
7579

7680
Notice that the base class for the ListView Command Set is imported from the **sp-listview-extensibility** package, which contains SharePoint framework code required by the ListView Command Set.
7781

78-
![import statement for BaseListViewCommandSet from @microsoft/sp-listview-extensibility](../../../../images/ext-com-vscode-base.png)
82+
```ts
83+
import { override } from '@microsoft/decorators';
84+
import { Log } from '@microsoft/sp-core-library';
85+
import {
86+
BaseListViewCommandSet,
87+
Command,
88+
IListViewCommandSetListViewUpdatedParameters,
89+
IListViewCommandSetExecuteEventParameters
90+
} from '@microsoft/sp-listview-extensibility';
91+
```
92+
93+
The behavior for your custom buttons is contained in the **onListViewUpdated()** and **OnExecute()** methods.
7994

80-
The behavior for your custom buttons is contained in the **onRefreshCommand()** and **OnExecute()** methods.
95+
The **onListViewUpdated()** event occurs separately for each command (e.g. menu item), whenever a change happens in the ListView and the UI needs to be re-rendered. The `“event”` function parameter represents information about the command being rendered. The handler can use this information to customize the title or adjust the visibility. For example, if a command should only be shown when a certain number of items are selected in the list view. Here's the default implementation:
8196

82-
The **onRefreshCommand()** event occurs separately for each command (e.g. menu item), whenever the application attempts to display it in the UI. The `“event”` function parameter represents information about the command being rendered. The handler can use this information to customize the title or adjust the visibility. For example, if a command should only be shown when a certain number of items are selected in the list view. Here's the default implementation:
97+
When using the method `“tryGetCommand”` you’ll get a Command object, which is a representation of the command that shows in the UI. You can modify its values, like `“title”`, or `“visible”` in order to modify the UI element. SPFx will use this information when re-rendering the commands. These objects keep the state from the last render, so if a command is set to `“visible = false”` it will remain invisible until is set back to `“visible = true”`.
8398

8499
```ts
85100
@override
86-
public onRefreshCommand(event: IListViewCommandSetRefreshEventParameters): void {
87-
event.visible = true; // assume true by default
88-
101+
public onListViewUpdated(event: IListViewCommandSetListViewUpdatedParameters): void {
89102
if (this.properties.disabledCommandIds) {
90-
if (this.properties.disabledCommandIds.indexOf(event.commandId) >= 0) {
91-
Log.info(LOG_SOURCE, 'Hiding command ' + event.commandId);
92-
event.visible = false;
103+
for (const commandId of this.properties.disabledCommandIds) {
104+
const command: Command | undefined = this.tryGetCommand(commandId);
105+
if (command && command.visible) {
106+
Log.info(LOG_SOURCE, `Hiding command ${commandId}`);
107+
command.visible = false;
108+
}
93109
}
94110
}
95111
}
@@ -132,7 +148,7 @@ Since our ListView Command Set is hosted from localhost and is running, we can u
132148
Append the following query string parameters to the URL. Notice that you will need to update the GUID to match the ID of your list view command set extension available in the **HelloWorldCommandSet.manifest.json** file:
133149

134150
```
135-
?loadSpfx=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"81b6a3d7-e408-43a4-8ef1-180d0f2582cc":{"___location":"ClientSideExtension.ListViewCommandSet.CommandBar"}}
151+
?loadSpfx=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"6a6ac29e-258e-4a2c-8de3-6bdd358cdb54":{"___location":"ClientSideExtension.ListViewCommandSet.CommandBar"}}
136152
```
137153

138154
* **loadSPFX=true:** ensures that the SharePoint Framework is loaded on the page. For performance reasons, the framework is not normally loaded unless at least one extension is registered. Since no components are registered yet, we must explicitly load the framework.
@@ -148,7 +164,7 @@ Append the following query string parameters to the URL. Notice that you will ne
148164
The full URL should look similar to the following, depending on your tenant URL and the ___location of the list.
149165

150166
```
151-
contoso.sharepoint.com/Lists/Orders/AllItems.aspx?loadSpfx=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"81b6a3d7-e408-43a4-8ef1-180d0f2582cc":{"___location":"ClientSideExtension.ListViewCommandSet.CommandBar"}}
167+
contoso.sharepoint.com/Lists/Orders/AllItems.aspx?loadSpfx=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"6a6ac29e-258e-4a2c-8de3-6bdd358cdb54":{"___location":"ClientSideExtension.ListViewCommandSet.CommandBar"}}
152168
```
153169

154170
Accept the loading of Debug Manifests, by clicking **Load debug scripts** when prompted.
@@ -172,10 +188,10 @@ Return to Visual Studio Code (or your preferred editor).
172188

173189
Open **HelloWorldCommandSet.ts** from the **src\extensions\helloWorld** folder.
174190

175-
Add the following import statement for the `Dialog` class from `@microsoft/sp-dialog/lib/index` after the existing import statements.
191+
Add the following import statement for the `Dialog` class from `@microsoft/sp-dialog` after the existing import statements.
176192

177193
```ts
178-
import { Dialog } from '@microsoft/sp-dialog/lib/index';
194+
import { Dialog } from '@microsoft/sp-dialog';
179195
```
180196

181197
Update the **onExecute** method as follows
@@ -224,7 +240,7 @@ We'll first need to create an **assets** folder where we will place all feature
224240

225241
Your solution structure should look similar to the following picture:
226242

227-
![assets folder in solution structure](../../../../images/ext-app-assets-folder.png)
243+
![assets folder in solution structure](../../../../images/ext-com-assets-folder.png)
228244

229245
### Add an elements.xml file for SharePoint definitions
230246

@@ -265,7 +281,8 @@ Open **package-solution.json** from the **config** folder. The **package-solutio
265281
"solution": {
266282
"name": "command-extension-client-side-solution",
267283
"id": "dfffbe21-e422-4c0f-a302-d7d62a30c1bf",
268-
"version": "1.0.0.0"
284+
"version": "1.0.0.0",
285+
"skipFeatureDeployment": false,
269286
},
270287
"paths": {
271288
"zippedPackage": "solution/command-extension.sppkg"
@@ -281,6 +298,7 @@ To ensure that our newly added **elements.xml** file is taken into account while
281298
"name": "command-extension-client-side-solution",
282299
"id": "dfffbe21-e422-4c0f-a302-d7d62a30c1bf",
283300
"version": "1.0.0.0",
301+
"skipFeatureDeployment": false,
284302
"features": [{
285303
"title": "ListView Command Set - Deployment of custom action.",
286304
"description": "Deploys a custom action with ClientSideComponentId association",
@@ -341,15 +359,15 @@ Go to the site where you want to test SharePoint asset provisioning. This could
341359

342360
Chose the gear icon on the top navigation bar on the right and choose **Add an app** to go to your Apps page.
343361

344-
In the **Search** box, enter '**command**' and press *Enter* to filter your apps.
362+
In the **Search** box, enter '**extension**' and press *Enter* to filter your apps.
345363

346364
![installing the listview command set to a site](../../../../images/ext-com-install-solution-to-site.png)
347365

348366
Choose the **command-extension-client-side-solution** app to install the solution on the site. When the installation is completed, refresh the page by pressing **F5**.
349367

350368
When the application has been successfully installed, Click **New** from the toolbar on the **Site Contents** page and choose **List**
351369

352-
![Creating a new list](../../../../images/ext-field-create-new-list.png)
370+
![Creating a new list](../../../../images/ext-com-create-new-list.png)
353371

354372
Provide the name as **Sample** and click **Create**.
355373

0 commit comments

Comments
 (0)