Skip to content

Commit 3432115

Browse files
committed
SPFx extension article polishing
1 parent 1d0debf commit 3432115

7 files changed

+102
-36
lines changed

docs/spfx/extensions/guidance/migrate-from-ecb-to-spfx-extensions.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1+
---
2+
title: Tutorial - Migrating from Edit Control Block (ECB) menu item to SharePoint Framework Extension
3+
ms.date: 12/19/2017
4+
ms.prod: sharepoint
5+
---
6+
17
# Migrating from Edit Control Block (ECB) menu item to SharePoint Framework Extensions
28

39
During the last few years, most of the enterprise solutions built on top of Office 365 and SharePoint Online leveraged the site _CustomAction_ capability of the SharePoint Feature Framework to extend the UI of pages. However nowdays, within the new "modern" UI of SharePoint Online, most of those customizations are no more available. Luckily, with the new SharePoint Framework Extensions you can provide similar functionality in the "modern" UI. In this tutorial you will learn how to migrate from old "classic" customizations to the new model based on SharePoint Framework Extensions.
410

5-
> [!IMPORTANT]
6-
> We're not deprecating the "classic" experience - both "classic" and "modern" will coexist.
7-
8-
_**Applies to:** SharePoint Online_
9-
1011
## Understanding SharePoint Framework Extensions
1112
<a name="spfxExtensions"> </a>
1213
First of all, let's introduce the available options when developing SharePoint Framework Extensions:

docs/spfx/extensions/guidance/migrate-from-jslink-to-spfx-extensions.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
---
2+
title: Tutorial - Migrating from JSLink to SharePoint Framework Extensions
3+
ms.date: 12/19/2017
4+
ms.prod: sharepoint
5+
---
6+
17
# Migrating from JSLink to SharePoint Framework Extensions
28

39
Since Microsoft SharePoint version 2013, most of the enterprise solutions built on top of Office 365 and SharePoint Online leveraged the _JSLink_ property of fields and list views to customize the rendering of fields. However nowdays, within the new "modern" UI of SharePoint Online, most of those customizations are no more available. Luckily, with the new SharePoint Framework Extensions you can now provide almost the same functionality in the "modern" UI. In this tutorial you will learn how to migrate from old "classic" customizations to the new model based on SharePoint Framework Extensions.
410

5-
> [!IMPORTANT]
6-
> We're not deprecating the "classic" experience - both "classic" and "modern" will coexist.
7-
8-
_**Applies to:** SharePoint Online_
9-
1011
## Understanding SharePoint Framework Extensions
11-
<a name="spfxExtensions"> </a>
12+
1213
First of all, let's introduce the available options when developing SharePoint Framework Extensions:
1314

1415
* **Application Customizer**: extend the native "modern" UI of SharePoint Online by adding custom HTML elements and client-side code to pre-defined placeholders of "modern" pages. At the time of this writing, the available placeholders are the header and the footer of every "modern" page.
@@ -21,7 +22,7 @@ As you can argue from the above descriptions, the most useful one in our context
2122
> For further details about how to build SharePoint Framework Extensions you can read the article ["Overview of SharePoint Framework Extensions"](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/overview-extensions).
2223
2324
## Migrating a JSLink to an SPFx Field Customizer
24-
<a name="FromJSLinktoFieldCustomizer"> </a>
25+
2526
Assume that you are in SharePoint Online, and you have a custom list with a custom field called "Color", which is of type _Choice_ and which can assume the following values: _Red_, _Green_, _Blue_, _Yellow_. Then, assume that you have custom value for the _JSLink_ property of the list view rendering web part of the custom list. In the following code snippet you can see the JavaScript code referenced by the _JSLink_ property (_customColorRendering.js_).
2627

2728
```JavaScript
@@ -100,7 +101,7 @@ As you can see "Color" fields render a colored box filled with the color selecte
100101
In order to migrate the above solution to the SharePoint Framework, you will have to accomplish the following steps.
101102

102103
### Create a new SharePoint Framework solution
103-
<a name="CreateFieldCustomizer"> </a>
104+
104105
Once you have prepared you development environment to develop SharePoint Framework solutions, by following the instructions provided in the document ["Set up your SharePoint client-side web part development environment"](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-development-environment), you can start creating a SharePoint Framework extension.
105106

106107
1. Open the command line tool of your choice (PowerShell, CMD.EXE, Cmder, etc.), create a new folder for the solution (call it _spfx-custom-field-extension_), and create a new SharePoint Framework solution by running the Yeoman generator with the following command:
@@ -140,7 +141,7 @@ code .
140141
```
141142

142143
### Define the new Field Customizer with JavaScript
143-
<a name="DefineFieldCustomizerWithJavaScript"> </a>
144+
144145
In order to reproduce the same behavior of the _JSLink_ custom field rendering, you simply need to implement the same logic using client-side code, within the new SharePoint Framework solution. To accomplish this task, complete the following steps.
145146

146147
1. First of all, open the file _CustomColorFieldFieldCustomizer.manifest.json_ under the _src/extensions/customColorField_ folder. Copy the value of the _id_ property and store it in a safe place, because you will need it later.
@@ -237,7 +238,7 @@ In the following figure you can see the resulting output.
237238
![The Field Customizer rendered in "modern" list](../../../images/spfx-custom-field-extension-output.png)
238239

239240
### Test the solution in debug mode
240-
<a name="DebugFieldCustomizer"> </a>
241+
241242
You are now ready to test your solution in debug mode.
242243

243244
1. Go back to the console window and run the following command:
@@ -259,7 +260,7 @@ In the above querystring, you will have to replace the GUID with the _id_ value
259260
Notice that, when executing the page request, you will be prompted with a warning message box with title "Allow debug scripts?", which asks your consent to run code from localhost, for security reasons. Of course, if you want to locally debug and test the solution, you will have to allow to "Load debug scripts".
260261

261262
### Define the new Field Customizer with TypeScript
262-
<a name="DefineFieldCustomizerWithTypeScript"> </a>
263+
263264
You are now ready to replace the JavaScript code with TypeScript, in order to benefit of the fully typed approach of TypeScript.
264265

265266
1. Open the file _CustomColorFieldFieldCustomizer.module.scss_ under the _src/extensions/customColorField_ folder. This file, which is a Sassy CSS, represents the UI style for the field customizer. Replace the content of the SCSS file with the following one.
@@ -341,7 +342,7 @@ Notice that the new method implementation uses a fully typed approach, and assig
341342
3. Run one more time in debug mode the field customizer and see the result.
342343

343344
### Package and host the solution
344-
<a name="PackageAndHostCommandSet"> </a>
345+
345346
If you are happy with the result, you are now ready to package the solution and host it in a real hosting infrastructure.
346347
Before building the bundle and the package, you need to declare an XML feature framework file to provision the extension.
347348

@@ -396,6 +397,7 @@ Now, open the _package-solution.json_ file under the _/config_ folder of the sol
396397
```
397398

398399
#### Enable the CDN in your Office 365 tenant
400+
399401
Now you need to host the extension in a hosting environment. Office 365 CDN is the easiest way to host SharePoint Framework solutions directly from your tenant while still taking advantage of the Content Delivery Network (CDN) service for faster load times of your assets.
400402

401403
1. Download the [SharePoint Online Management Shell](https://www.microsoft.com/en-us/download/details.aspx?id=35588) to ensure that you have the latest version.
@@ -445,6 +447,7 @@ Note that your newly added origin is listed as a valid CDN origin. Final configu
445447
When the origin is listed without the `(configuration pending)` text, it is ready to be used in your tenant. This indicates an on-going configuration between SharePoint Online and the CDN system.
446448
447449
#### Update the solution settings and publish it on the CDN
450+
448451
Now, you need to update the solution in order to use the just created CDN as the hosting enviroment and you will need to publish the solution bundle to the CDN. To accomplish this task, just follow the upcoming steps.
449452
450453
1. Return to the previously created solution to perform the needed URL updates.
@@ -478,7 +481,7 @@ Now, you need to update the solution in order to use the just created CDN as the
478481
7. Upload or drag-and-drop the files in the _temp/deploy_ folder to the _CDN/customcolorfield_ folder created earlier.
479482
480483
### Install and run the solution
481-
<a name="InstallFieldCustomizer"> </a>
484+
482485
You can now install the solution on any target "modern" site.
483486
484487
1. Open the browser and navigate to any target "modern" site.

docs/spfx/extensions/guidance/migrate-from-usercustomactions-to-spfx-extensions.md

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
---
2+
title: Tutorial - Migrating from UserCustomAction to SharePoint Framework Extensions
3+
ms.date: 12/19/2017
4+
ms.prod: sharepoint
5+
---
6+
17
# Migrating from UserCustomAction to SharePoint Framework Extensions
28

39
During the last few years, most of the enterprise solutions built on top of Office 365 and SharePoint Online leveraged the site _CustomAction_ capability of the SharePoint Feature Framework to extend the UI of pages. However nowdays, within the new "modern" UI of SharePoint Online, most of those customizations are no more available. Luckily, with the new SharePoint Framework Extensions you can now provide almost the same functionality in the "modern" UI. In this tutorial you will learn how to migrate from old "classic" customizations to the new model based on SharePoint Framework Extensions.
410

5-
> [!IMPORTANT]
6-
> We're not deprecating the "classic" experience - both "classic" and "modern" will coexist.
7-
8-
_**Applies to:** SharePoint Online_
9-
1011
## Understanding SharePoint Framework Extensions
11-
<a name="spfxExtensions"> </a>
12+
1213
First of all, let's introduce the available options when developing SharePoint Framework Extensions:
1314

1415
* **Application Customizer**: extend the native "modern" UI of SharePoint Online by adding custom HTML elements and client-side code to pre-defined placeholders of "modern" pages. At the time of this writing, the available placeholders are the header and the footer of every "modern" page.
@@ -21,7 +22,7 @@ As you can argue from the above descriptions, the most useful one in our context
2122
> For further details about how to build SharePoint Framework Extensions you can read the article ["Overview of SharePoint Framework Extensions"](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/overview-extensions).
2223
2324
## Migrating a UserCustomAction to an SPFx Application Customizer
24-
<a name="FromUserCustomActionToApplicationCustomizer"> </a>
25+
2526
Assume that you have a _CustomAction_ in SharePoint Online, in order to have a custom footer in all of the site's pages.
2627
In the following code snippet you can see the XML code defining that _CustomAction_ using the SharePoint Feature Framework.
2728

@@ -141,7 +142,7 @@ In the following figure you can see the output of the previous custom action, wi
141142
In order to migrate the above solution to the "modern" UI, you will have to accomplish the following steps.
142143

143144
### Create a new SharePoint Framework solution
144-
<a name="CreateApplicationCustomizer"> </a>
145+
145146
Once you have prepared you development environment to develop SharePoint Framework solutions, by following the instructions provided in the document ["Set up your SharePoint client-side web part development environment"](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-development-environment), you can start creating a SharePoint Framework extension.
146147

147148
1. Open the command line tool of your choice (PowerShell, CMD.EXE, Cmder, etc.), create a new folder for the solution (call it _spfx-react-custom-footer_), and create a new SharePoint Framework solution by running the Yeoman generator with the following command:
@@ -180,7 +181,7 @@ code .
180181
```
181182

182183
### Define the new UI elements
183-
<a name="DefineApplicationCustomizerUI"> </a>
184+
184185
The UI elements of the custom footer will be rendered using React and a custom React component. Of course, you can create the UI elements of the sample footer with whatever technology you like. In this tutorial, we use React in order to leverage the Office UI Fabric components for React.
185186

186187
> [!NOTE]
@@ -328,7 +329,7 @@ In the following figure you can see the resulting output.
328329
![The custom footer rendered in a "modern" site](../../../images/spfx-react-custom-footer-output.png)
329330

330331
### Test the solution in debug mode
331-
<a name="DebugApplicationCustomizer"> </a>
332+
332333
You are now ready to test your solution in debug mode.
333334

334335
1. Go back to the console window and run the following command:
@@ -348,11 +349,12 @@ The above command will build the solution and run the local Node.js server to ho
348349
In the above querystring, you will have to replace the GUID with the _id_ value you saved from the _CustomFooterApplicationCustomizer.manifest.json_ file. Notice that, when executing the page request, you will be prompted with a warning message box with title "Allow debug scripts?", which asks your consent to run code from localhost, for security reasons. Of course, if you want to locally debug and test the solution, you will have to allow to "Load debug scripts".
349350

350351
### Package and host the solution
351-
<a name="PackageAndHostApplicationCustomizer"> </a>
352+
352353
If you are happy with the result, you are now ready to package the solution and host it in a real hosting infrastructure.
353354
Before building the bundle and the package, you need to declare an XML feature framework file to provision the extension.
354355

355356
#### Review feature framework elements
357+
356358
Within the code editor, open the _/sharepoint/assets_ sub-folder of the solution folder and edit the _elements.xml_ file.
357359
In the following code excerpt you can see how the file should look like.
358360

@@ -448,6 +450,7 @@ Note that your newly added origin is listed as a valid CDN origin. Final configu
448450
When the origin is listed without the `(configuration pending)` text, it is ready to be used in your tenant. This indicates an on-going configuration between SharePoint Online and the CDN system.
449451
450452
#### Update the solution settings and publish it on the CDN
453+
451454
Now, you need to update the solution in order to use the just created CDN as the hosting enviroment and you will need to publish the solution bundle to the CDN. To accomplish this task, just follow the upcoming steps.
452455
453456
1. Return to the previously created solution to perform the needed URL updates.
@@ -481,7 +484,7 @@ Now, you need to update the solution in order to use the just created CDN as the
481484
7. Upload or drag-and-drop the files in the _temp/deploy_ folder to the _CDN/customfooter_ folder created earlier.
482485
483486
### Install and run the solution
484-
<a name="InstallApplicationCustomizer"> </a>
487+
485488
You can now install the solution on any target "modern" site.
486489
487490
1. Open the browser and navigate to any target "modern" site.

0 commit comments

Comments
 (0)