Skip to content

Commit 83315e0

Browse files
committed
Update all tutorials to use new menus. Delete command api document and all references to it.
1 parent d6a9f45 commit 83315e0

17 files changed

Lines changed: 353 additions & 577 deletions

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/packaging-your-extension.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ After completing development on your extension, you can package it into an add-o
1010

1111
To package your extension, follow the steps below:
1212

13-
1. Make sure the`--enable-extension-development` command-line option is enabled.
13+
1. Make sure the setting for enabling extension development is checked in the Preferences form. Alternatively, you can start Studio Pro with the `--enable-extension-development` command-line option.
1414
2. In your Studio Pro app, create a new module and include your development extension.
1515
3. Give the module a name.
1616
4. Open the module's settings and in the **Export** tab, choose **Add-on module**.

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ For detailed information on how to get started with extensions, see [Get Started
3737

3838
Below is a list of how-tos for you to begin with:
3939

40+
* [How Menus Work](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu/)
4041
* [How to Create a Dockable Pane](/apidocs-mxsdk/apidocs/web-extensibility-api-11/dockable-pane-api/)
4142
* [How to Interact With Local App Files](/apidocs-mxsdk/apidocs/web-extensibility-api-11/local-app-files-api/)
4243
* [How to Create a Menu](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/)

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/get-started.md

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Extensions can be built on any operating system, as the underlying framework is
2424
{{% /alert %}}
2525

2626
{{% alert color="info" %}}
27-
Extension development is only possible by starting Studio Pro with the `--enable-extension-development` feature flag.
27+
Extension development is only possible enabling the setting in `Extension Development` under `Advanced` in the Studio Pro preferences form, or by starting Studio Pro using the `--enable-extension-development` feature flag.
2828
{{% /alert %}}
2929

3030
## Creating Your First Extension
@@ -75,54 +75,47 @@ Before you begin, your extension will have to get an instance of the Studio Pro
7575

7676
In the source code, you should see the following:
7777

78-
1. Line 6 gets an instance of the Studio Pro API by calling `getStudioProApi`.
78+
1. We get an instance of the Studio Pro API by calling `getStudioProApi`.
7979

8080
```typescript
8181
export const component: IComponent = {
8282
async loaded(componentContext) {
8383
const studioPro = getStudioProApi(componentContext);
8484

85-
2. Line 7 adds a menu:
85+
2. We add a menu that opens a tab:
8686

8787
```typescript
8888
await studioPro.ui.extensionsMenu.add({
8989
menuId: "myextension.MainMenu",
9090
caption: "MyExtension Menu",
9191
subMenus: [
92-
{ menuId: "myextension.ShowMenu", caption: "Show tab" },
92+
{
93+
menuId: "myextension.ShowMenu",
94+
caption: "Show tab",
95+
// Open a tab when the menu item is clicked
96+
action: async () => {
97+
await studioPro.ui.tabs.open(
98+
{
99+
title: "MyExtension tab"
100+
},
101+
{
102+
componentName: "extension/myextension",
103+
uiEntrypoint: "tab"
104+
}
105+
)
106+
}
107+
}
93108
],
94109
});
95110
```
96111

97-
3. Line 16 opens a tab.
98-
99-
```typescript
100-
// Open a tab when the menu item is clicked
101-
studioPro.ui.extensionsMenu.addEventListener(
102-
"menuItemActivated",
103-
(args) => {
104-
if (args.menuId === "myextension.ShowMenu") {
105-
studioPro.ui.tabs.open(
106-
{
107-
title: "MyExtension Tab"
108-
},
109-
{
110-
componentName: "extension/myextension",
111-
uiEntrypoint: "tab",
112-
}
113-
);
114-
}
115-
}
116-
);
117-
```
118-
119-
4. If you navigate to `build-extension.mjs`, you can choose the directory to which the extension will be installed to after being built by changing line 6:
112+
3. If you navigate to `build-extension.mjs`, you can choose the directory to which the extension will be installed to after being built by changing line 6:
120113

121114
```typescript
122115
const appDir = "C:\\TestApps\\AppTestExtensions"
123116
```
124117

125-
5. The file `.vscode\launch.json` specifies the launch configuration and enables debugging. The following lines specify how Studio Pro will be run:
118+
4. The file `.vscode\launch.json` specifies the launch configuration and enables debugging. The following lines specify how Studio Pro will be run:
126119

127120
```json
128121

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/app-explorer-api.md

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,46 @@ This how-to describes how to interact with the App Explorer in Studio Pro. In th
1212

1313
Before starting this how-to, make sure you have completed the following prerequisites:
1414

15-
* This how-to uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Complete that how-to before starting this one.
16-
* Make sure you are familiar with command registration, as described in [Register a Command Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/command-api/).
15+
* Read up on how menus work in the Extensibility API [here](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu/)
16+
* This how-to uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Complete that how-to before starting this one.
1717

1818
## Creating a Context Menu
1919

2020
{{% alert color="info" %}}
2121
Use the full name of the document type to specify which type of document a menu should belong to (for example, `Microflows$Microflow` for microflows or `Pages$Page` for pages). For more information about these document type names, see [Access a Mendix Model Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/model-api/).
2222
{{% /alert %}}
2323

24-
The code below does the following:
25-
26-
1. Registers a command through the [Command API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/command-api/).
27-
2. Attaches the `commandId` to the new menu.
28-
3. Uses the `appExplorer` API's `addContextMenu` method to add the menu to all `Microflow` document nodes.
24+
The code below uses the `appExplorer` API's `addContextMenu` method to add the menu to all `Microflow` document nodes. When this menu is clicked, the clicked document's ID will be sent as an argument through the `DocumentContext` argument parameter of the menu.
2925

3026
```typescript
31-
import { ComponentContext, IComponent, Menu, StudioProApi, getStudioProApi } from "@mendix/extensions-api";
27+
import { ComponentContext, DocumentContext, IComponent, Menu, getStudioProApi } from "@mendix/extensions-api";
3228

3329
const extensionId = "myextension";
3430

3531
export const component: IComponent = {
3632
async loaded(componentContext: ComponentContext) {
3733
const studioPro = getStudioProApi(componentContext);
3834

39-
const commandId = `${extensionId}.microflow.command`;
40-
const menuId = `${commandId}.menu`;
35+
const menuId = `${extensionId}.microflow.menu`;
4136

42-
await studioPro.app.commands.registerCommand<{ documentId: string }>(commandId, async (args: { documentId: string }) => {
37+
const action = async (args: DocumentContext) => {
4338
await studioPro.ui.notifications.show({
44-
title: `Microflow command executed`,
39+
title: `Microflow action executed`,
4540
message: `You clicked a context menu for a Microflow! (${args.documentId})`,
4641
displayDurationInSeconds: 4
4742
});
48-
});
43+
};
4944

50-
const microflowMenu: Menu = { caption: `Microflow command menu`, menuId, commandId };
45+
const microflowMenu: Menu<DocumentContext> = { caption: `Microflow menu`, menuId, action };
5146

5247
await studioPro.ui.appExplorer.addContextMenu(microflowMenu, "Microflows$Microflow");
5348
}
54-
}
49+
};
5550
```
5651

57-
The payload of the command must be an object containing a document Id (`{ documentId: string }`). Registering the command requires the exact type of the payload, or your extension will not compile. The `documentId` will be the Id of the document the menu is attached to (in this scenario, the exact `Microflow` node in the App Explorer).
52+
The `DocumentContext` payload for the menu action is an object containing a document Id (`{ documentId: string }`). When creating a menu for the `appExplorer`'s `addContextMenu` method, the `DocumentContext` should be used as the context of your menu. The `documentId` will be the Id of the document the menu is attached to (in this scenario, the exact `Microflow` node in the App Explorer).
5853

59-
{{% alert color="warning" %}}
60-
The command must be registered before creating the menu.
61-
{{% /alert %}}
54+
As explained in the [menu documentation](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu/), the `DocumentContext` is not necessary in order to add your menu to Studio Pro, but if it is not used, the menu will never receive the ID of the clicked document when it gets clicked.
6255

6356
## Extensibility Feedback
6457

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/command-api.md

Lines changed: 0 additions & 80 deletions
This file was deleted.

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/custom-blob-document-api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ To register a new document type, follow the steps below:
193193
import parseArgs from "minimist"
194194
195195
const outDir = `dist/myextension`
196-
const appDir = "/Users/petar.vukmirovic/Mendix/App-Guide-Test-Blob"
196+
const appDir = "/Users/<USERNAME>/Mendix/App-Guide-Test-Blob"
197197
const extensionDirectoryName = "extensions"
198198
199199
const entryPoints = [

content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/dialog-api.md

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,34 +51,23 @@ export const component: IComponent = {
5151
await studioPro.ui.extensionsMenu.add({
5252
menuId: menuId,
5353
caption: "Show modal dialog",
54-
});
54+
action: async () => {
55+
const result = await studioPro.ui.dialogs.showModal(
56+
{
57+
title: "Modal Dialog",
58+
contentSize: { height: 170, width: 400 }
59+
},
60+
{
61+
componentName: "extension/myextension",
62+
uiEntrypoint: "dialog"
63+
}
64+
);
5565

56-
// Open a modal dialog when the menu item is clicked
57-
studioPro.ui.extensionsMenu.addEventListener(
58-
"menuItemActivated",
59-
async (args) => {
60-
if (args.menuId === menuId) {
61-
const result = await studioPro.ui.dialogs.showModal(
62-
{
63-
title: "Modal Dialog",
64-
contentSize: { height: 170, width: 400 },
65-
},
66-
{
67-
componentName: "extension/myextension",
68-
uiEntrypoint: "dialog",
69-
}
70-
);
71-
72-
if (result !== null)
73-
await studioPro.ui.messageBoxes.show(
74-
"info",
75-
JSON.stringify(result)
76-
);
77-
}
66+
if (result !== null) await studioPro.ui.messageBoxes.show("info", JSON.stringify(result));
7867
}
79-
);
68+
});
8069
}
81-
}
70+
};
8271
```
8372

8473
## Filling the Dialog With Content

0 commit comments

Comments
 (0)