Skip to content

Commit edfe0d5

Browse files
LauragraVesaJuvonen
authored andcommitted
Edit pass to update dialog box terminology. (SharePoint#726)
* Edit pass. * A few more edits.
1 parent 60f1a12 commit edfe0d5

File tree

1 file changed

+51
-49
lines changed

1 file changed

+51
-49
lines changed

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

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
# Using Custom Dialogs with SharePoint Framework Extensions
1+
# Use custom dialog boxes with SharePoint Framework Extensions
22

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.
3+
You can use custom dialog boxes, available from the **@microsoft/sp-dialog** package, within the context of SharePoint Framework Extensions or client-side web parts.
44

5-
This tutorial demonstrates the creation of a custom dialog and using it within the context of a ListView Command Set extension.
5+
This article describes how to create a custom dialog box and use it within the context of a ListView Command Set extension.
66

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).
7+
>**Note:** The custom dialog box feature is currently in preview. We are looking for your feedback before we release. To provide feedback, [file an issue in our GitHub repo](https://github.com/SharePoint/sp-dev-docs/issues).
88
99
> 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-
> 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.
1211

13-
## Setup your Environment
12+
You can access the sample code that this article is based on in the [](https://github.com/SharePoint/sp-dev-fx-extensions/tree/master/samples/react-command-dialog) repo.
1413

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.
14+
## Set up your development environment
1715

18-
> You can update your SharePoint Framework Yeoman templates by running the following command:
19-
> ```sh
20-
> npm install -g @microsoft/generator-sharepoint`
21-
> ```
16+
To create a custom dialog box, you'll need to follow the steps in the [Set up your development environment](https://dev.office.com/sharepoint/docs/spfx/set-up-your-development-environment). Make sure that you're using the latest SharePoint Framework Yeoman templates.
2217

23-
## Create a New Project
18+
To update your SharePoint Framework Yeoman templates, run the following command:
2419

25-
Start by creating a new folder for the project using your console of choice:
20+
```sh
21+
npm install -g @microsoft/generator-sharepoint`
22+
```
23+
24+
## Create a new project
25+
26+
Create a new folder for the project using your console of choice:
2627

2728
```sh
2829
md dialog-cmd
@@ -34,7 +35,7 @@ Then enter that folder:
3435
cd dialog-cmd
3536
```
3637

37-
Then run the Yeoman generator for the SharePoint Framework:
38+
Run the Yeoman generator for the SharePoint Framework:
3839

3940
```sh
4041
yo @microsoft/sharepoint
@@ -59,17 +60,17 @@ When the scaffold is complete, you should see the following message indicating a
5960

6061
![SharePoint client-side solution scaffolded successfully](../../../../images/ext-com-dialog-yeoman-complete.png)
6162

62-
> For information about troubleshooting any errors, see [Known issues](../basics/known-issues).
63+
>**Note:** For information about troubleshooting any errors, see [Known issues](../basics/known-issues).
6364

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:
65+
When the scaffolding is complete, 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:
6566

6667
```sh
6768
code .
6869
```
6970

7071
![Initial Visual Studio Code structure after scaffolding](../../../../images/ext-com-dialog-vs-code-initial.png)
7172

72-
## Modify the Extension Manifest
73+
## Modify the extension manifest
7374

7475
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:
7576

@@ -85,24 +86,25 @@ In the extension manifest, configure the extension to have only one button. In t
8586
}
8687
```
8788

88-
## Adding the sp-dialog Package to the Solution
89+
## Add the sp-dialog package to the solution
8990

90-
Return to the console and execute the following command to include the dialog API in your solution:
91+
Return to the console and run the following command to include the dialog API in your solution:
9192

9293
```sh
9394
npm install @microsoft/sp-dialog --save
9495
```
9596

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).
97+
Because you're using the `--save` option, this dependency will be added to the **package.json** file. This ensures that it will be installed automatically when the `npm install` command runs (this is important when you restore or clone your project elsewhere).
9798
9899
Return to Visual Studio Code (or your preferred editor).
99100
100-
## Creating a Custom Dialog
101+
## Create a custom dialog box
102+
101103
Create a new file called **ColorPickerDialog.tsx** in the **./src/extensions/dialogDemo/** folder.
102104
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.
105+
Add the following import statements at the top of the newly created file. You're creating your custom dialog box using the [Office UI Fabric React components](https://dev.office.com/fabric#/components), so the implementation will be in React.
104106

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.
107+
> **Note:** Currently the `DialogContent` component is coming from `@microsoft/sp-dialog`, but it will be included as part of the Office UI Fabric React components soon.
106108

107109
```ts
108110
import * as React from 'react';
@@ -121,7 +123,7 @@ import {
121123
import { DialogContent } from '@microsoft/sp-dialog';
122124
```
123125
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.
126+
Add the following interface definition just below the import statements. This will be used to pass information and functions between your ListView Command Set extension and your custom dialog box.
125127
126128
```ts
127129
interface IColorPickerDialogContentProps {
@@ -132,7 +134,7 @@ interface IColorPickerDialogContentProps {
132134
}
133135
```
134136
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.
137+
Add the following class just below the interface definition. This React class is responsible for rendering the UI experiences inside the custom dialog box. Notice that you use the Office UI Fabric React components for actual rendering and just pass the needed properties.
136138
137139
```ts
138140
class ColorPickerDialogContent extends React.Component<IColorPickerDialogContentProps, {}> {
@@ -165,7 +167,7 @@ class ColorPickerDialogContent extends React.Component<IColorPickerDialogContent
165167
}
166168
}
167169
```
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`.
170+
Add the following class definition for your custom dialog box under the `ColorPickerDialogContent` class that you just added. This is the actual custom dialog box that will be called from the ListView Command Set button click and is inherited from the `BaseDialog`.
169171

170172
```ts
171173
export default class ColorPickerDialog extends BaseDialog {
@@ -195,32 +197,32 @@ export default class ColorPickerDialog extends BaseDialog {
195197
}
196198
```
197199

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.
200+
## Associate the custom dialog box with the ListView Command Set button click
201+
To associate the custom dialog box with your custom ListView Command Set, add the code to initiate the dialog box within the button click operation.
200202

201203
In the code editor, open the **DialogDemoCommandSet.ts** file from the **./src/extensions/dialogDemo/** folder.
202204

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.
205+
Add the following import statements under the existing **strings** import. These are for using the custom dialog box in the context of your ListView Command Set.
204206

205207
```ts
206208
import { Dialog } from '@microsoft/sp-dialog';
207209
import ColorPickerDialog from './ColorPickerDialog';
208210
```
209211
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.
212+
Add the following `_colorCode` variable definition above the `onInit` function in the `DialogDemoCommandSet` class. This is used to store the color picker dialog box result.
211213
212214
```ts
213215
private _colorCode: string;
214216
```
215217
216-
Update the `onExecute` function as follows. In this code we are doing the following:
218+
Update the `onExecute` function as follows. This code does the following:
217219
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
220+
* Initiates the custom dialog box.
221+
* Passes a message for the dialog box, which is used for the title.
222+
* Passed a color code for the dialog box with a default value, if not yet set.
223+
* Shows the custom dialog box.
224+
* Receives and stores the return value from the dialog box.
225+
* Shows the received value in a default dialog box using the `Dialog.alert()` function.
224226
225227
```ts
226228
@override
@@ -242,44 +244,44 @@ Update the `onExecute` function as follows. In this code we are doing the follow
242244
}
243245
```
244246
245-
## Testing the Custom Dialog in your Tenant
247+
## Test the custom dialog box in your tenant
246248
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.
249+
Open the **DialogDemoCommandSet.manifest.json** file in the **./src/extensions/dialogDemo/** folder and copy the **id** value, which will be used in the debug query parameter.
248250
249-
Return to the console and execute the following command:
251+
Return to the console and run the following command:
250252
251253
```sh
252254
gulp serve --nobrowser
253255
```
254256
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.
257+
Notice that you use the `--nobrowser` option. You don't need to launch the local workbench because you currently cannot debug extensions locally.
256258
257259
This will start the bundling of your solution and will serve the resulting manifest from the `localhost` address.
258260
259261
![Initial Visual Studio Code structure after scaffolding](../../../../images/ext-com-dialog-gulp-serve.png)
260262
261-
To test your extension, navigate to a site in your SharePoint Online developer tenant.
263+
To test your extension, go to a site in your SharePoint Online developer tenant.
262264
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.
265+
Go to an existing custom list within the site that contains some items, or create a new list and add a few items to it for testing purposes.
264266
265267
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:
266268
267269
```
268270
?loadSpfx=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"8701f44c-8c81-4e54-999d-62763e8f34d2":{"___location":"ClientSideExtension.ListViewCommandSet.CommandBar"}}
269271
```
270272
271-
Accept the loading of Debug Manifests by clicking **Load debug scripts** when prompted:
273+
Accept the loading of Debug Manifests by choosing **Load debug scripts** when prompted.
272274
273275
![Allow debug scripts warning](../../../../images/ext-com-dialog-debug-scripts.png)
274276
275-
Notice the new button is visible in the toolbar of the list with the text *Open Custom Dialog*.
277+
Notice that the new button is visible in the toolbar of the list with the text *Open Custom Dialog box*.
276278
277279
![Allow debug scripts warning](../../../../images/ext-com-dialog-button-in-toolbar.png)
278280
279-
Click the *Open Custom Dialog* button to see your custom dialog rendered within the list view.
281+
Choose the *Open Custom Dialog box* button to see your custom dialog box rendered within the list view.
280282
281283
![Allow debug scripts warning](../../../../images/ext-com-dialog-visible-dialog.png)
282284
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.
285+
Choose a color in the *Color Picker* and choose **OK** to test how the code is returning the selected value back to the caller. The selection is then shown using the default alert dialog box.
284286
285-
![Out-of-the-box alert dialog](../../../../images/ext-com-dialog-oob-alert-dialog.png)
287+
![Default alert dialog box](../../../../images/ext-com-dialog-oob-alert-dialog.png)

0 commit comments

Comments
 (0)