Skip to content

Commit 35ecb6a

Browse files
committed
UUF update
1 parent abe25fa commit 35ecb6a

File tree

1 file changed

+60
-64
lines changed

1 file changed

+60
-64
lines changed

docs/extend/develop/using-host-dialog.md

Lines changed: 60 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ai-usage: ai-assisted
88
monikerRange: '<= azure-devops'
99
ms.author: chcomley
1010
author: chcomley
11-
ms.date: 07/02/2025
11+
ms.date: 11/14/2025
1212
# customer-intent: As an Azure DevOps extension developer, I want to create modal dialogs that block user interaction with the entire page so I can collect user input, display forms, and provide focused user experiences in my extensions.
1313
---
1414

@@ -29,8 +29,6 @@ Use modal dialogs in your extensions to:
2929
3030
## Prerequisites
3131

32-
Before you can create modal dialogs in your Azure DevOps extension, ensure you have the following:
33-
3432
| Category | Requirement | Details |
3533
|----------|-------------|---------|
3634
| **Extension setup** | Working extension project | A valid `vss-extension.json` manifest file |
@@ -42,7 +40,7 @@ Before you can create modal dialogs in your Azure DevOps extension, ensure you h
4240
| **Required packages** | Extension SDK | Install: `npm install azure-devops-extension-sdk` |
4341
| | Extension API | Install: `npm install azure-devops-extension-api` |
4442
| **Extension permissions** | Manifest scopes | Include appropriate scopes in `vss-extension.json`, for example: `"vso.work"`, `"vso.project"` |
45-
| **SDK imports** | Required modules | Import SDK and services: `import * as SDK from "azure-devops-extension-sdk"` and `import { CommonServiceIds, IHostDialogService } from "azure-devops-extension-api"` |
43+
| **SDK imports** | Required modules | Import SDK and services: `import * as SDK from "azure-devops-extension-sdk"` |
4644

4745
## Dialog contents
4846

@@ -140,78 +138,76 @@ The `uri` property references a page that is rendered within the content area of
140138

141139
## Show the dialog
142140

143-
To show the dialog (for example, when a user selects an action on a toolbar or menu), call the `openDialog` function on an instance of the HostDialogService, passing the fully qualified identifier of the dialog content, for example `my-publisher.my-extension.registration-form` and any dialog options:
141+
To show the dialog (for example, when a user selects an action on a toolbar or menu), call the `openDialog` function on an instance of the HostDialogService:
144142

145143
```javascript
146-
import * as SDK from "azure-devops-extension-sdk";
147-
148-
SDK.getService<IHostDialogService>(CommonServiceIds.HostDialogService).then((dialogService) => {
149-
const extensionCtx = SDK.getExtensionContext();
150-
// Build absolute contribution ID for dialogContent
151-
const contributionId = `${extensionCtx.publisherId}.${extensionCtx.extensionId}.registration-form`;
152-
153-
// Show dialog
154-
const dialogOptions = {
155-
title: "My Dialog",
156-
width: 800,
157-
height: 600
158-
};
159-
160-
dialogService.openDialog(contributionId, dialogOptions);
161-
});
144+
import * as SDK from "azure-devops-extension-sdk";
145+
146+
SDK.getService(SDK.CommonServiceIds.HostDialogService).then((dialogService) => {
147+
const extensionCtx = SDK.getExtensionContext();
148+
// Build absolute contribution ID for dialogContent
149+
const contributionId = `${extensionCtx.publisherId}.${extensionCtx.extensionId}.registration-form`;
150+
151+
// Show dialog
152+
const dialogOptions = {
153+
title: "My Dialog",
154+
width: 800,
155+
height: 600
156+
};
157+
158+
dialogService.openDialog(contributionId, dialogOptions);
159+
});
162160
```
163161

164162
## Advanced dialog features
165163

166-
A function can be called when the OK button is selected. This function is specified by `getDialogResult` in the options you provide when showing the dialog.
164+
A function can be called when the OK button is selected. You specify this function by setting `getDialogResult` in the options you provide when showing the dialog.
167165

168166
If a call to `getDialogResult` returns a non-null value, this value is then passed to the function specified by `okCallback` (also in the options) and the dialog is closed.
169167

170168
In this example, the `attachFormChanged` callback gets called when inputs on the form change. Based on whether the form is valid or not, the OK button is enabled or disabled.
171169

172170
```javascript
173-
import * as SDK from "azure-devops-extension-sdk";
174-
import { CommonServiceIds, IHostDialogService } from "azure-devops-extension-api";
175-
176-
SDK.getService<IHostDialogService>(CommonServiceIds.HostDialogService).then((dialogService) => {
177-
let registrationForm: any;
178-
const extensionCtx = SDK.getExtensionContext();
179-
const contributionId = `${extensionCtx.publisherId}.${extensionCtx.extensionId}.registration-form`;
180-
181-
const dialogOptions = {
182-
title: "Registration Form",
183-
width: 800,
184-
height: 600,
185-
getDialogResult: () => {
186-
// Get the result from registrationForm object
187-
return registrationForm ? registrationForm.getFormData() : null;
188-
},
189-
okCallback: (result: any) => {
190-
// Log the result to the console
191-
console.log(JSON.stringify(result));
192-
}
193-
};
194-
195-
dialogService.openDialog(contributionId, dialogOptions).then((dialog) => {
196-
// Get registrationForm instance which is registered in registrationFormContent.html
197-
dialog.getContributionInstance("registration-form").then((registrationFormInstance) => {
171+
import * as SDK from "azure-devops-extension-sdk";
172+
173+
SDK.getService(SDK.CommonServiceIds.HostDialogService).then((dialogService) => {
174+
let registrationForm;
175+
const extensionCtx = SDK.getExtensionContext();
176+
const contributionId = `${extensionCtx.publisherId}.${extensionCtx.extensionId}.registration-form`;
177+
178+
const dialogOptions = {
179+
title: "Registration Form",
180+
width: 800,
181+
height: 600,
182+
getDialogResult: () => {
183+
// Get the result from registrationForm object
184+
return registrationForm ? registrationForm.getFormData() : null;
185+
},
186+
okCallback: (result) => {
187+
// Log the result to the console
188+
console.log(JSON.stringify(result));
189+
}
190+
};
191+
192+
dialogService.openDialog(contributionId, dialogOptions).then((dialog) => {
193+
// Get registrationForm instance which is registered in registrationFormContent.html
194+
dialog.getContributionInstance("registration-form").then((registrationFormInstance) => {
195+
196+
// Keep a reference of registration form instance (to be used previously in dialog options)
197+
registrationForm = registrationFormInstance;
198198

199-
// Keep a reference of registration form instance (to be used previously in dialog options)
200-
registrationForm = registrationFormInstance;
201-
202-
// Subscribe to form input changes and update the Ok enabled state
203-
registrationForm.attachFormChanged((isValid: boolean) => {
204-
dialog.updateOkButton(isValid);
205-
});
206-
207-
// Set the initial ok enabled state
208-
registrationForm.isFormValid().then((isValid: boolean) => {
209-
dialog.updateOkButton(isValid);
210-
});
211-
});
212-
});
199+
// Subscribe to form input changes and update the Ok enabled state
200+
registrationForm.attachFormChanged((isValid) => {
201+
dialog.updateOkButton(isValid);
202+
});
203+
204+
// Set the initial ok enabled state
205+
registrationForm.isFormValid().then((isValid) => {
206+
dialog.updateOkButton(isValid);
207+
});
208+
});
213209
});
214-
210+
});
215211
```
216212

217213
## Control the OK button
@@ -227,7 +223,7 @@ Initially, the OK button is disabled. However, you can enable/disable this butto
227223

228224
## Pass values to the dialog
229225

230-
It's possible to pass initial values to dialog content when it is opened in the host dialog.
226+
It's possible to pass initial values to dialog content when you open it in the host dialog.
231227

232228
```json
233229
{
@@ -241,7 +237,7 @@ It's possible to pass initial values to dialog content when it is opened in the
241237
}
242238
```
243239

244-
When the dialog is opened, following options need to be specified to pass `myId`:
240+
When the dialog opens, the following options must be specified to pass `myId`:
245241

246242
```javascript
247243
const dialogOptions = {

0 commit comments

Comments
 (0)