Skip to content

Commit 74eb9e6

Browse files
thechriskentVesaJuvonen
authored andcommitted
Minor Grammatical Updates (SharePoint#680)
1 parent 35dce15 commit 74eb9e6

File tree

1 file changed

+57
-51
lines changed

1 file changed

+57
-51
lines changed

docs/spfx/extensions/guidance/using-custom-dialogs-with-spfx.md

Lines changed: 57 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
# Using Custom Dialogs with SharePoint Framework Extensions
22

3-
Custom dialogs are available from `@microsoft/sp-dialog`package and can be used within the context of SharePoint Framework Extensions or client-side web parts.
3+
Custom dialogs are available from the **@microsoft/sp-dialog** package and can be used within the context of SharePoint Framework Extensions or client-side web parts.
44

5-
This tutorial demonstrates creation of a custom dialog and using that in the context of ListView Command Set extension.
5+
This tutorial demonstrates the creation of a custom dialog and using it within the context of a ListView Command Set extension.
66

7-
> Notice that the SharePoint Framework dialog is currently in preview status and we are looking to collect feedback before it's officially released. Please provide us feedback by using the [sp-dev-docs repository Issue list](https://github.com/SharePoint/sp-dev-docs/issues).
7+
> The SharePoint Framework dialog is currently in preview status and we are looking to collect feedback before it's officially released. Please provide feedback by using the [sp-dev-docs repository Issue list](https://github.com/SharePoint/sp-dev-docs/issues).
88
9-
> Notice that debugging Custom ListView Sets in the SharePoint Online is currently only available from modern list experience in classic team sites hosted on dev tenant.
9+
> Please note that debugging Custom ListView Command Sets in SharePoint Online is currently only available from the modern list experience within classic team sites hosted in a **developer tenant**.
1010
11-
> End result of this tutorial is also available as source code at https://github.com/SharePoint/sp-dev-fx-extensions/tree/master/samples/react-command-dialog.
11+
> The end result of this tutorial is available as source code at https://github.com/SharePoint/sp-dev-fx-extensions/tree/master/samples/react-command-dialog.
1212
1313
## Setup your Environment
1414

15-
Before you can complete this guide you will need to ensure you have [setup your environment](https://dev.office.com/sharepoint/docs/spfx/set-up-your-development-environment) for development
16-
using SharePoint Framework and that you are using latest SharePoint Framework Yeoman templates.
15+
Before you can complete this guide, you will need to ensure you have [setup your environment](https://dev.office.com/sharepoint/docs/spfx/set-up-your-development-environment) for development
16+
using the SharePoint Framework (SPFx) and that you are using the latest SharePoint Framework Yeoman templates.
1717

18-
> You can update your SharePoint Framework Yeoman templates by running following command `npm install -g @microsoft/generator-sharepoint`.
18+
> You can update your SharePoint Framework Yeoman templates by running the following command:
19+
> ```sh
20+
> npm install -g @microsoft/generator-sharepoint`
21+
> ```
1922
2023
## Create a New Project
2124
@@ -25,13 +28,13 @@ Start by creating a new folder for the project using your console of choice:
2528
md dialog-cmd
2629
```
2730
28-
And enter that folder
31+
Then enter that folder:
2932
3033
```sh
3134
cd dialog-cmd
3235
```
3336
34-
The run the Yeoman generator for SharePoint Framework
37+
Then run the Yeoman generator for the SharePoint Framework:
3538
3639
```sh
3740
yo @microsoft/sharepoint
@@ -45,30 +48,30 @@ When prompted:
4548
4649
The next set of prompts will ask for specific information about your extension:
4750
48-
* Accept the default value of **DialogDemo** as your extension name and press **Enter**.
51+
* Use the value of **DialogDemo** as your extension name and press **Enter**.
4952
* Accept the default value of **DialogDemo description** as your extension description and press **Enter**.
5053
5154
![Yeoman SharePoint generator prompts to create an extension solution](../../../../images/ext-com-dialog-yeoman-prompts.png)
5255
53-
At this point, Yeoman will install the required dependencies and scaffold the solution files along with the *HelloWorld* extension. This might take a few minutes.
56+
At this point, Yeoman will install the required dependencies and scaffold the solution files along with the *DialogDemo* extension. This might take a few minutes.
5457
5558
When the scaffold is complete, you should see the following message indicating a successful scaffold:
5659
5760
![SharePoint client-side solution scaffolded successfully](../../../../images/ext-com-dialog-yeoman-complete.png)
5861
59-
For information about troubleshooting any errors, see [Known issues](../basics/known-issues).
62+
> For information about troubleshooting any errors, see [Known issues](../basics/known-issues).
6063
61-
Once the scaffolding completes, open your project folder in your code editor. This article uses Visual Studio Code in the steps and screenshots but you can use any editor you prefer.
64+
Once the scaffolding completes, open your project folder in your code editor. This article uses Visual Studio Code in the steps and screenshots, but you can use any editor you prefer. To open the folder in Visual Studio Code use the following command in the console:
6265
63-
```
66+
```sh
6467
code .
6568
```
6669
6770
![Initial Visual Studio Code structure after scaffolding](../../../../images/ext-com-dialog-vs-code-initial.png)
6871
69-
## Modify extension manifest based on requirements
72+
## Modify the Extension Manifest
7073
71-
In the extension manifest, configure extension to have only one button. In the code editor, open the **./src/extensions/dialogDemo/DialogDemoCommandSet.manifest.json** file. Replace the commands section with the following JSON:
74+
In the extension manifest, configure the extension to have only one button. In the code editor, open the **./src/extensions/dialogDemo/DialogDemoCommandSet.manifest.json** file. Replace the commands section with the following JSON:
7275
7376
```json
7477
{
@@ -80,26 +83,26 @@ In the extension manifest, configure extension to have only one button. In the c
8083
}
8184
}
8285
}
83-
8486
```
8587
86-
## Adding sp-dialog package to solution
87-
Return to the console and execute the following command to include the dialog API in our solution.
88+
## Adding the sp-dialog Package to the Solution
8889
89-
```
90+
Return to the console and execute the following command to include the dialog API in your solution:
91+
92+
```sh
9093
npm install @microsoft/sp-dialog --save
9194
```
9295
93-
Since we are using the `--save` option, this dependency will be added to *package.json* file and would be automatically installed when `npm install` command is executed.
96+
Since we are using the `--save` option, this dependency will be added to the **package.json** file. This will ensure that it will be automatically installed when the `npm install` command is executed (this is important when restoring or cloning your project elsewhere).
9497
9598
Return to Visual Studio Code (or your preferred editor).
9699
97-
## Creating your custom dialog
98-
Create a new file called **ColorPickerDialog.tsx** to **./src/extensions/dialogDemo/** folder.
100+
## Creating a Custom Dialog
101+
Create a new file called **ColorPickerDialog.tsx** in the **./src/extensions/dialogDemo/** folder.
99102
100-
Add following import statements on the start of the newly created file. We are creating our custom dialog using Office UI Fabric React components, so the implementation will be in React.
103+
Add the following import statements at the top of the newly created file. We are creating our custom dialog using the [Office UI Fabric React components](https://dev.office.com/fabric#/components), so the implementation will be in React.
101104
102-
> Notice that currently DialogContent component is coming from `@microsoft/sp-dialog`, but will be included in Office UI Fabric React components soon, like mentioned in the code comments.
105+
> Currently the `DialogContent` component is coming from `@microsoft/sp-dialog`, but will be included as part of the Office UI Fabric React components soon, as mentioned in the code comments below.
103106
104107
```ts
105108
import * as React from 'react';
@@ -118,7 +121,7 @@ import {
118121
import { DialogContent } from '@microsoft/sp-dialog';
119122
```
120123
121-
Add following interface definition just below the import statements. This wil be used to bypass needed information and functions between the ListView Command Set extension and custom dialog.
124+
Add the following interface definition just below the import statements. This wil be used to pass information and functions between your ListView Command Set extension and your custom dialog.
122125
123126
```ts
124127
interface IColorPickerDialogContentProps {
@@ -129,7 +132,7 @@ interface IColorPickerDialogContentProps {
129132
}
130133
```
131134
132-
Add following class just below the interface definition. This React class is responsible for rendering the UI experiences inside of the custom dialog. Notice that we use the Office UI Fabric React components for actual rendering and just bypass the needed properties.
135+
Add the following class just below the interface definition. This React class is responsible for rendering the UI experiences inside of the custom dialog. Notice that we use the Office UI Fabric React components for actual rendering and just pass the needed properties.
133136
134137
```ts
135138
class ColorPickerDialogContent extends React.Component<IColorPickerDialogContentProps, {}> {
@@ -162,7 +165,7 @@ class ColorPickerDialogContent extends React.Component<IColorPickerDialogContent
162165
}
163166
}
164167
```
165-
Add following class definition for our custom dialog under the just added class code. This one is the actual custom dialog, which will be called from the button click and which is inherited from the **BaseDialog**.
168+
Add the following class definition for our custom dialog under the just added `ColorPickerDialogContent` class. This is the actual custom dialog which will be called from the ListView Command Set button click and is inherited from the `BaseDialog`.
166169
167170
```ts
168171
export default class ColorPickerDialog extends BaseDialog {
@@ -192,32 +195,32 @@ export default class ColorPickerDialog extends BaseDialog {
192195
}
193196
```
194197
195-
## Associating custom dialog to button click
196-
To associate the custom dialog button to custom ListView Command Set, the code to initiate the dialog has to be added for the button click operation.
198+
## Associating the Custom Dialog with the ListView Command Set Button Click
199+
To associate the custom dialog with your custom ListView Command Set, the code to initiate the dialog has to be added within the button click operation.
197200
198-
In the code editor, open the **DialogDemoCommandSet.ts** file from **./src/extensions/dialogDemo/** folder.
201+
In the code editor, open the **DialogDemoCommandSet.ts** file from the **./src/extensions/dialogDemo/** folder.
199202
200-
Add following import statements under the existing **strings** import. These are for using the just created custom dialog in the context of ListView Command Set.
203+
Add the following import statements under the existing **strings** import. These are for using the just created custom dialog in the context of your ListView Command Set.
201204
202205
```ts
203206
import { Dialog } from '@microsoft/sp-dialog';
204207
import ColorPickerDialog from './ColorPickerDialog';
205208
```
206209
207-
Add following **_colorCode** variable definition above **onInit** function in the **DialogDemoCommandSet** class. This is used to store teh color picker dialog result.
210+
Add the following `_colorCode` variable definition above the `onInit` function in the `DialogDemoCommandSet` class. This is used to store the color picker dialog result.
208211
209212
```ts
210213
private _colorCode: string;
211214
```
212215
213-
Update the **onExecute** function as follows. In this code we are doing following steps
216+
Update the `onExecute` function as follows. In this code we are doing the following:
214217
215-
* Initiate custom dialog
216-
* Bypass message for the dialog, which will be used as title
217-
* Bypass color code for the dialog with default value, if not yet set
218-
* Show the custom dialog
219-
* Receive and store return value from the dialog
220-
* Show received value in out-of-the-box dialog using `Dialog.alert()` function
218+
* Initiate our custom dialog
219+
* Pass a message for the dialog, which will be used as the title
220+
* Pass a color code for the dialog with a default value, if not yet set
221+
* Show our custom dialog
222+
* Receive and store the return value from the dialog
223+
* Show the received value in an out-of-the-box dialog using the `Dialog.alert()` function
221224
222225
```ts
223226
@override
@@ -239,24 +242,27 @@ Update the **onExecute** function as follows. In this code we are doing followin
239242
}
240243
```
241244
242-
## Testing custom dialog in your tenant
243-
Move to **DialogDemoCommandSet.manifest.json** file in **./src/extensions/dialogDemo/** folder and copy **id** value, which will be used in the debug query parameter.
245+
## Testing the Custom Dialog in your Tenant
244246
245-
Move to console side and execute following command. We use `--nobrowser` option, since local workbench cannot be currently used for debugging, so there's no reason to start that.
247+
Open the **DialogDemoCommandSet.manifest.json** file in **./src/extensions/dialogDemo/** folder and copy the **id** value, which will be used in the debug query parameter.
248+
249+
Return to the console and execute the following command:
246250
247251
```sh
248252
gulp serve --nobrowser
249253
```
250254
251-
This will start bundling and will serve the resulting manifest from `localhost` address.
255+
Notice that we used the `--nobrowser` option, since there's no value in launching the local workbench since you currently cannot debug extensions locally.
256+
257+
This will start the bundling of your solution and will serve the resulting manifest from the `localhost` address.
252258
253259
![Initial Visual Studio Code structure after scaffolding](../../../../images/ext-com-dialog-gulp-serve.png)
254260
255-
To test your extension, navigate to a site in your SharePoint Online tenant.
261+
To test your extension, navigate to a site in your SharePoint Online developer tenant.
256262
257-
Move to an existing custom list in the site with some items or create a new list and add few items to it for testing purposes.
263+
Navigate to an existing custom list within the site with some items or create a new list and add a few items to it for testing purposes.
258264
259-
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 **DialogDemoCommandSet.manifest.json** file:
265+
Append the following query string parameters to the URL. Notice that you will need to update the **id** to match your own extension identifier as listed in the **DialogDemoCommandSet.manifest.json** file:
260266
261267
```
262268
?loadSpfx=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"8701f44c-8c81-4e54-999d-62763e8f34d2":{"___location":"ClientSideExtension.ListViewCommandSet.CommandBar"}}
@@ -266,14 +272,14 @@ Accept the loading of Debug Manifests by clicking **Load debug scripts** when pr
266272
267273
![Allow debug scripts warning](../../../../images/ext-com-dialog-debug-scripts.png)
268274
269-
Notice new button being visible in the toolbar of the list with test *Open Custom Dialog*.
275+
Notice the new button is visible in the toolbar of the list with the text *Open Custom Dialog*.
270276
271277
![Allow debug scripts warning](../../../../images/ext-com-dialog-button-in-toolbar.png)
272278
273-
Click *Open Custom Dialog* button to see custom dialog rendered in the list view.
279+
Click the *Open Custom Dialog* button to see your custom dialog rendered within the list view.
274280
275281
![Allow debug scripts warning](../../../../images/ext-com-dialog-visible-dialog.png)
276282
277-
Choose a color in the *Color Picker* and click **OK** to test how the code is returning selected value back to caller, which is then shown using out-of-the-box alert dialog.
283+
Choose a color in the *Color Picker* and click **OK** to test how the code is returning the selected value back to the caller. The selection is then shown using the out-of-the-box alert dialog.
278284
279285
![Out-of-the-box alert dialog](../../../../images/ext-com-dialog-oob-alert-dialog.png)

0 commit comments

Comments
 (0)