diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/_index.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/_index.md index f688d280e74..6a8b08132e9 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/_index.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/_index.md @@ -20,6 +20,6 @@ For information on new releases of the Extensibility API see: ## Introduction -Extensions are self-contained modules which users can add to Studio Pro. This means that with extensibility you can add new features and functionality to Studio Pro. The Extensibility API is an API that allows developers to interact with a curated list of internal systems of Studio Pro. This documentation provides guides and reference documentation for the Extensibility API. +Extensions are self-contained modules that enhance Studio Pro by adding new features and functionality. The Extensibility API allows developers to interact with a curated set of internal systems, making it easier to customize and expand Studio Pro’s capabilities. -The API is provided in two flavors, depending which language you are developing in. C# and web based (via Typescript): +The API is provided in two sections, depending on the language you are developing in: diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/csharp/extensibility-api-howtos/add-menu.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/csharp/extensibility-api-howtos/add-menu.md index f3615b08a81..8fd4f8f2904 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/csharp/extensibility-api-howtos/add-menu.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/csharp/extensibility-api-howtos/add-menu.md @@ -1,5 +1,5 @@ --- -title: "Add Menus and Submenus to Studio Pro Using C#" +title: "Add Menus and Sub-menus to Studio Pro Using C#" linktitle: "Structured Menus" url: /apidocs-mxsdk/apidocs/csharp-extensibility-api-11/add-menu/ weight: 15 @@ -7,15 +7,19 @@ weight: 15 ## Introduction -This how-to describes how you can add a menu that contains submenus, some of which also contain submenus of their own. Before you start this how-to, it is recommended to [Create a Menu Extension Using C#](/apidocs-mxsdk/apidocs/csharp-extensibility-api-11/create-menu-extension/) first. +This how-to describes how to add a menu that contains sub-menus, some of which also contain sub-menus of their own. You can download the example in this how-to in [this GitHub repository](https://github.com/mendix/ExtensionAPI-Samples). -## Creating Menu Extension Class +## Prerequisites -1. Open the project that you previously created when you followed [Create a Menu Extension Using C#](/apidocs-mxsdk/apidocs/csharp-extensibility-api-11/create-menu-extension/). +This how-to uses the results of [Create a Menu Extension Using C#](/apidocs-mxsdk/apidocs/csharp-extensibility-api-11/create-menu-extension/). Complete that how-to before starting this one. + +## Creating the Menu Extension Class + +1. Open the project you created when following [Create a Menu Extension Using C#](/apidocs-mxsdk/apidocs/csharp-extensibility-api-11/create-menu-extension/). 2. Add a new class to the project and name it `MyMenuExtension.cs`. -3. Replace the code in the file with the following code: +3. Replace the code in the file with the following: ```csharp using Mendix.StudioPro.ExtensionsAPI.UI.Menu; @@ -57,10 +61,41 @@ You can download the example in this how-to in [this GitHub repository](https:// } ``` -The code above creates a single menu, `Beverages`, which contains the submenus `Hot` and `Cold`, both of which contain some submenus. Note that when you are creating this menu structure, you only return the main parent menu (in this example, the `Beverages` menu) from the `GetMenus` method. You should only return the topmost parents in your list, so only the ones that do not have a parent should be returned. In the example above, there is only one. +### Menu Structure Overview + +The code above creates a single menu, `Beverages`. This menu contains the following: + +* `Beverages` contain two sub-menus: `Hot` and `Cold` +* `Hot` contains `Coffee` and `Tea` +* `Coffee` contains `Black Coffee`, `Decaf`, and `Espresso` +* `Espresso` contains `Regular Espresso` and `Ristretto` +* `Cold` contains `Soda` + +Only the top-most parent menu (`Beverages`) is returned from the `GetMenus` method. You should only return menus that do not have a parent. + +### Menu Placement + +If an app contains one or more extensions, a top-level menu named `Extensions` will appear in the main menu bar of Studio Pro. + +Menus that are created from `MenuExtension` implementations are grouped by their extension entry point name (in this example, `MyCompany`), and are placed under a dedicated sub-menu. For example, `MyMenuExtension` will be placed as follows: **Extensions** > **MyCompany** > **MyMenuExtension**. + +### Menu Properties + +A menu can either: + +* Be a parent (a menu that contains sub-menus), or +* Have an action + +You cannot create a menu that both contains sub-menus and has an action. + +#### Separators + +You can add a `MenuSeparator` to a menu using the `Separator` property. The options include: -If an app contains one or more extensions, a top-level menu named `Extensions` will appear in the main menu bar of Studio Pro. Menus that are created from `MenuExtension` implementations will be grouped by their extension entry point name (in this example, `MyCompany`), and then placed under their own dedicated submenu under the main `Extensions` top-level menu. For example, the `MyMenuExtension` above will be placed as follows: **Extensions** > **MyCompany** > **MyMenuExtension**. +* `After` +* `Before` +* `None` (default). -A menu can only be a parent (namely, a menu that contains submenus) or have an action. You cannot create a menu with an action which also contains submenus. +#### Enabling and Disabling Menus -You can add a `MenuSeparator` to a menu, via the `Separator` property. Options are `After`, `Before` or `None`. The default value is `None`. You can also disable a menu by setting its `IsEnabled` property to `false`. Menus are enabled by default. +Menus are enabled by default. To disable a menu, set its `IsEnabled` property to `false`. diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/packaging-your-extension.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/packaging-your-extension.md index 48b63611260..ae91b6d9e65 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/packaging-your-extension.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/packaging-your-extension.md @@ -4,26 +4,32 @@ url: /apidocs-mxsdk/apidocs/extensibility-api-11/packaging-your-extension weight: 30 --- -# Packaging your extension +## Packaging your Extension -Once you have finished development on your extension, you might want to package it into an add-on module so that others can start using it. Once you have created the add-on module, it can then be published to the Mendix Marketplace for your extension users to download into their Studio Pro app. +After completing development on your extension, you can package it into an add-on module so others can use it. Once packaged, the module can be published to the Mendix Marketplace, allowing other users to download it into their Studio Pro apps. -To package your extension, you will still need the `--enable-extension-development` command line option turned on. Create a new module in your Studio Pro app containing your dev extension, give it an appropriate name. Open the module's settings form and set it to be an Add-on module. In the `Extension name` dropdown, select the extension you want to package into it. +To package your extension, follow the steps below: -![Extension Add-on Module](/attachments/apidocs-mxsdk/apidocs/extensibility-api/extensionAddOnModule.png) +1. Make sure the`--enable-extension-development` command-line option is enabled. +2. In your Studio Pro app, create a new module and include your development extension. +3. Give the module a name. +4. Open the module's settings and in the **Export** tab, choose **Add-on module**. +5. In the **Extension name** drop-down, select the extension you want to package into it. -After you've created your add-on module with its extension, you can now export it, by right-clicking the module in the App Explorer and choosing `Export add-on module package`, as shown below. +{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/extensionAddOnModule.png" width="500" >}} -![Export Module](/attachments/apidocs-mxsdk/apidocs/extensibility-api/exportAddOnModule.png) +After you have created your add-on module with its extension, you can export it by right-clicking the module in the App Explorer and selecting **Export add-on module package**. + +{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/exportAddOnModule.png" width="500" >}} You can now save the add-on module to a location of your choice. -# Importing the extension add-on module +## Importing the Extension Add-on Module -Once the add-on module is available to a Studio Pro user, they are now able to add it in their application. They can so so by right-clicking the app in the App Explorer and choosing `Import module package`, as shown below. +When the add-on module is available to a Studio Pro user, they are now able to add it in their application. This is done by right-clicking the app in the App Explorer and selecting **Import module package**. -![Import Module](/attachments/apidocs-mxsdk/apidocs/extensibility-api/importAddOnModule.png) +{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/importAddOnModule.png" width="300" >}} -Once an add-on module containing an extension is imported in the app, Studio Pro will show a warning to the user, asking to trust the extension contained in it. If the user does not choose to trust, the module will still be imported but the extension inside it won't be loaded. +When an add-on module containing an extension is imported in the app, Studio Pro will show a warning to the user, asking to trust the extension contained in it. If the user does not choose to trust, the module will still be imported but the extension inside it will not be loaded. -![Trust Extension](/attachments/apidocs-mxsdk/apidocs/extensibility-api/trustExtension.png) +{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/trustExtension.png" width="500" >}} diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/_index.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/_index.md index de90aa39057..f214f1ad3c2 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/_index.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/_index.md @@ -13,35 +13,40 @@ weight: 20 ## Introduction -Extensions can be written in Typescript or other web languages, described here, or using a C# API which is documented separately in [Extensibility API for C# Developers](/apidocs-mxsdk/apidocs/csharp-extensibility-api-11/). +Extensions can be written in TypeScript or other web languages, described here, or using a C# API (for more information about the C# API, see [Extensibility API for C# Developers](/apidocs-mxsdk/apidocs/csharp-extensibility-api-11/)). {{% alert color="info" %}} -Please note that extension development is only possible by starting Studio Pro with the `--enable-extension-development` feature flag. +At this time, extension development is only possible with the `--enable-extension-development` feature flag. {{% /alert %}} For more detailed information on the web API, see the [Mendix Studio Pro Web Extensibility API reference documentation](http://apidocs.rnd.mendix.com/11/extensions-api/index.html). ## Prerequisites -* You need at least a basic understanding of the Mendix platform. -* You need some understanding of the Mendix Model. -* You need to have some TypeScript development experience. +To use the Web Extensibility API, you must have: + +* A basic understanding of the Mendix platform +* Some understanding of the Mendix Model +* Some TypeScript development experience ## Getting Started -For detailed explanation on how to get started with extensions, check out [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). +For detailed information on how to get started with extensions, see [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). ## How-tos Here is a list of how-tos for you to begin with: -* [How to Create a Dockable Pane Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/dockable-pane-api/) -* [How to Interact With Local App Files Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/local-app-files-api/) -* [How to Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/) -* [How to Show a Message Box Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/messagebox-api/) -* [How to Access a Mendix Model Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/model-api/) -* [How to Open a Tab Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/tab-api/) -* [How to Show a Popup Notification Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/notification-api/) -* [How to View User Preferences Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/preference-api/) -* [How to Show a Modal Dialog Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/dialog-api/) -* [How to Open Documents Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/editor-api/) +* [How to Use the App Explorer](/apidocs-mxsdk/apidocs/web-extensibility-api-11/app-explorer-api/) +* [How to Create a Dockable Pane](/apidocs-mxsdk/apidocs/web-extensibility-api-11/dockable-pane-api/) +* [How to Interact With Local App Files](/apidocs-mxsdk/apidocs/web-extensibility-api-11/local-app-files-api/) +* [How to Create a Menu](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/) +* [How to Show a Message Box](/apidocs-mxsdk/apidocs/web-extensibility-api-11/messagebox-api/) +* [How to Access a Mendix Model](/apidocs-mxsdk/apidocs/web-extensibility-api-11/model-api/) +* [How to Open a Tab](/apidocs-mxsdk/apidocs/web-extensibility-api-11/tab-api/) +* [How to Show a Pop-up Notification](/apidocs-mxsdk/apidocs/web-extensibility-api-11/notification-api/) +* [How to View User Preferences](/apidocs-mxsdk/apidocs/web-extensibility-api-11/preference-api/) +* [How to Show a Modal Dialog](/apidocs-mxsdk/apidocs/web-extensibility-api-11/dialog-api/) +* [How to Open a Document Editor](/apidocs-mxsdk/apidocs/web-extensibility-api-11/editor-api/) +* [How to Register a Command](/apidocs-mxsdk/apidocs/web-extensibility-api-11/command-api/) +* [How to Create a Context Menu](/apidocs-mxsdk/apidocs/web-extensibility-api-11/documents-api/) \ No newline at end of file diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/get-started.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/get-started.md index dd7e9868c62..b358d890452 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/get-started.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/get-started.md @@ -7,7 +7,7 @@ weight: 2 ## Introduction -Studio Pro extensions can be developed using TypeScript and use standard web development technologies to extend the Studio Pro development environment. This guide shows you how to set up a basic development environment for building an extension using the web extensibility API. +Studio Pro extensions can be developed using TypeScript and use standard web development technologies to extend the Studio Pro development environment. This document describes how to set up a basic development environment for building an extension using the web extensibility API. For more detailed information, see the [Mendix Studio Pro Web Extensibility API reference documentation](http://apidocs.rnd.mendix.com/11/extensions-api/index.html). @@ -16,11 +16,11 @@ For more detailed information, see the [Mendix Studio Pro Web Extensibility API You will need the following prerequisites: * [Mendix Studio Pro](https://marketplace.mendix.com/link/studiopro) version 11.2.0 or higher. -* A development IDE to develop your extensions. We recommend using [Visual Studio Code](https://code.visualstudio.com/). -* Install the latest version 22.x.x of Node: https://nodejs.org/en/download. +* A development IDE to develop your extensions. Mendix recommend using [Visual Studio Code](https://code.visualstudio.com/). +* The latest version 22.x.x of Node: https://nodejs.org/en/download. {{% alert color="info" %}} -Extensions can be built on any operating system as the underlying framework is cross-platform. +Extensions can be built on any operating system, as the underlying framework is cross-platform. {{% /alert %}} {{% alert color="info" %}} @@ -29,32 +29,28 @@ Extension development is only possible by starting Studio Pro with the `--enable ## Creating Your First Extension -This section will show you how to build and test an extension. - ### Create a Test App Create a new app using the **Blank Web App** template. -{{% alert color="info" %}} You can also open the application directory containing the application `.mpr` file by clicking the **App** menu > **Show App Directory in Explorer** (or **Show App Directory in Finder**) in Studio Pro. -{{% /alert %}} ### Creating the Extension -To accelerate your extension development, we provide an extension generator that creates a customizable sample extension. +To accelerate your extension development, Mendix provides an extension generator that creates a customizable sample extension. To use the generator, navigate to your desired source code directory and run the command `npm create @mendix/extension`. You may be prompted by `npm` to grant permission to install the generator. After installation, you will be guided through a series of questions to help configure your extension. You will be asked the following: -* Select the programming language (TypeScript is used in our tutorials) +* Select the programming language (TypeScript is used in the tutorials) * Specify the extension name -* Choose if you will use React for the extension’s UI +* Choose if you will use React for the extension’s UI -The next two questions, while optional, are highly recommended, as they enable direct debugging and deployment from Visual Studio Code. +The next two questions, while optional, are highly recommended, as they enable direct debugging and deployment from Visual Studio Code: * Specify the path to the Studio Pro executable (this allows Visual Studio Code to automatically attach to Studio Pro for debugging) -* Specify the location of the application `.mpr` package. (This allows for automatic deployment of your extension build to your app) +* Specify the location of the application `.mpr` package (this allows for automatic deployment of your extension build to your app) The final question allows you to select the Studio Pro version you are targeting; we recommend you choose version 11. @@ -73,7 +69,7 @@ containing the source code of the extension. In the following example, the name of your extension is `myextension` and you are exploring it using Visual Studio Code. -Before you begin, your extension will have to get an instance of the Studio Pro API. to do this, from the Explorer window, navigate to `src/main/index.ts` and select it to open the file. +Before you begin, your extension will have to get an instance of the Studio Pro API. To do this, from the Explorer window, navigate to `src/main/index.ts` and select it to open the file. In the source code, you should see the following: @@ -155,17 +151,8 @@ If the last two questions of the extension generator were answered and you have This will run Studio Pro in extension development mode and open the configured application. You will see a new `Extensions` item in the top menu. -## Conclusion - -Using this guide we have: - -* Created a new app -* Used the extension generator to get started with extension development -* Built the extension and installed it in our app -* Tested and debugged our extension from within Visual Studio Code - ## Extensibility Feedback -If you would like to provide us with some additional feedback you can complete a small [Survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback) +If you would like to provide additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback). -Any feedback is much appreciated. +Any feedback is appreciated. diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/_index.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/_index.md index 33fd0790a45..e3668be975e 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/_index.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/_index.md @@ -9,4 +9,4 @@ description_list: true ## Introduction -The following how-tos teach you how to use the Extensibility API for Web Developers in different use cases. +The following how-tos describe how to use the Extensibility API for Web Developers in different use cases: diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/app-explorer-api.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/app-explorer-api.md index a6954e93e3f..1a6b5f02117 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/app-explorer-api.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/app-explorer-api.md @@ -6,21 +6,26 @@ url: /apidocs-mxsdk/apidocs/web-extensibility-api-11/app-explorer-api/ ## Introduction -This how-to describes how to interact with the App Explorer in Studio Pro. +This how-to describes how to interact with the App Explorer in Studio Pro. In this example, you will create a menu which will show for each microflow in the App Explorer. ## Prerequisites -This how-to uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Please complete that how-to before starting this one. You should also be familiar with command registration as described in [Register a Command Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/command-api/). +Before starting this how-to, make sure you have completed the following prerequisites: + +* 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. +* 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/). ## Creating a Context Menu -In this example, you will create a menu which will show for each microflow in the App Explorer. 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). The documentation for these document type names can be found at [Access a Mendix Model Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/model-api/). +{{% alert color="info" %}} +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/). +{{% /alert %}} The code below does the following: -1. Registers a command through the [Command API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/command-api/). -2. Attaches the `commandId` to the new menu. -3. Uses the `appExplorer` API's `addContextMenu` method to add the menu to all `Microflow` document nodes. +1. Registers a command through the [command API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/command-api/) +2. Attaches the `commandId` to the new menu +3. Uses the `appExplorer` API's `addContextMenu` method to add the menu to all `Microflow` document nodes ```typescript import { ComponentContext, IComponent, Menu, StudioProApi, getStudioProApi } from "@mendix/extensions-api"; @@ -55,10 +60,6 @@ The payload of the command must be an object containing a document Id (`{ docume The command must be registered before creating the menu. {{% /alert %}} -## Conclusion - -You have seen how to create context menus for a document node in the App Explorer. The menu executes a previously registered command. - ## Extensibility Feedback If you would like to provide us with additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback). diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/command-api.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/command-api.md index 11bcac12f3b..3b068d5609f 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/command-api.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/command-api.md @@ -10,24 +10,23 @@ This how-to describes how to register a command in Studio Pro from an extension. ## Prerequisites -This how-to uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Please complete that how-to before starting this one. You should also be familiar with creating menus as described in [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/). +Before starting this how-to, make sure you have completed the following prerequisites: + +* 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. +* Make sure you are familiar with creating menus as described in [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/). ## Register Commands -The Commands API allows users to register a reusable command. These commands can be attached to menus and context menus. At this time, two APIs make use of this feature: +The Commands API allows you to register a reusable command that can be attached to menus and context menus. At this time, two APIs support this feature: * [Documents API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/) * [App Explorer API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/app-explorer-api/) -To register commands, you can call the Commands API `registerCommand`. - -In the sample code below, we register a command, then attach it to a menu by setting the property `commandId` to the `Menu` object. +## Using `registerCommand` API -{{% alert color="info" %}} -The `registerCommand` requires a generic type for the command payload once executed. For standalone menus that have a command without payload, you can register it with ``. When using `void`, the generic type declaration can also be left out (for example, `registerCommand(commandId...)` becomes `registerCommand(commandId...)`). -{{% /alert %}} +To register commands, use the Commands API `registerCommand`. -For commands that require payload, you must make sure you register the command with the exact expected payload object type. See the [App Explorer API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/app-explorer-api/) and [Documents API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/documents-api/) documentation for clear examples. +In the sample code below, we register a command, then attach it to a menu by setting the property `commandId` to the `Menu` object. ```typescript import { ComponentContext, IComponent, Menu, StudioProApi, getStudioProApi } from "@mendix/extensions-api"; @@ -55,20 +54,31 @@ export const component: IComponent = { } ``` -It is also possible to create a context menu that belongs to a document in the App Explorer or a document editor, and that menu can have a registered command attached to it. To do so, you can use the [App Explorer API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/app-explorer-api/) or the [Documents API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/documents-api/). +## Payloads + +`registerCommand` requires a generic type for the command payload once executed. + +* For commands without payload, use ``. When using `void`, the generic type declaration can be left out, as seen below: + * `registerCommand(commandId...)` becomes `registerCommand(commandId...)` +* For commands with payload, make sure the payload type matches the expected structure. -The command registration for commands that interact with documents are slightly different. They require a payload of type `{ documentId: string }`; the backend will return the menu when it is clicked. The `documentId` is the id of the exact document that was interacted with by the menu. +See the [App Explorer API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/app-explorer-api/) and [Documents API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/documents-api/) documentation for examples. + +## Context Menu Integration {{% alert color="info" %}} -The command must be registered before creating any menus that might be attached to it. +The command must be registered before creating any menus that use it. {{% /alert %}} -## Conclusion +You can attach registered commands to context menus in: + +* [App Explorer](/apidocs-mxsdk/apidocs/web-extensibility-api-11/app-explorer-api/) +* [Document editors](/apidocs-mxsdk/apidocs/web-extensibility-api-11/documents-api/) -You have seen how to register commands that can be attached to menus in Studio Pro. +The command registration for commands that interact with documents require a payload of type `{ documentId: string }`. The `documentId` is the id of the exact document that was interacted with by the menu. The backend identifies the menu when it is clicked. ## Extensibility Feedback -If you would like to provide us with additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback). +If you would like to provide additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback). Any feedback is appreciated. diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/dialog-api.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/dialog-api.md index c596982eec2..95f755a4f8f 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/dialog-api.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/dialog-api.md @@ -10,7 +10,10 @@ This how-to describes how to open a modal dialog in Studio Pro from an extension ## Prerequisites -This how-to uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Please complete that how-to before starting this one. You should also be familiar with creating menus as described in [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/). +Before starting this how-to, make sure you have completed the following prerequisites: + +* 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. +* Make sure you are familiar with creating menus as described in [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/). ## Opening a Modal Dialog @@ -26,7 +29,7 @@ In a listener event called `menuItemActivated`, the `studioPro.ui.dialogs.showMo * `queryParams` (optional) — a key-value pair object for passing data to your web content inside the dialog {{% alert color="info" %}} -When the dialog's API `showModal` method is called, a `Promise` of `unknown` or `null` is returned. This return value represents anything the web content determines should be returned when the dialog gets closed. It is currently unknown by the API, since it can be anything. +When the dialog's API `showModal` method is called, a `Promise` of `unknown` or `null` is returned. This return value represents anything the web content determines should be returned when the dialog is closed. It is currently unknown by the API, since it can be anything. In the example below, the dialog will contain a form where an object is modified, then returned at closing time. {{% /alert %}} @@ -93,7 +96,7 @@ In the previous example, the `uiEntryPoint` property of the `` object ha } ``` -1. Update `build-extension.mjs` to match the manifest with an entry for the new dialog entry point. Specifically, you need to add +1. Update `build-extension.mjs` to match the manifest with an entry for the new dialog entry point. Specifically, add the `src/ui/dialog.tsx` endpoint to your build script and make sure the variable `appDir` stays unaltered. For example: ```typescript{hl_lines=["16-19"]} @@ -207,7 +210,7 @@ After building and installing the extension in Studio Pro, the dialog opens when ## Modifying a Modal Dialog -You can also modify the dimensions of a dialog using the dialog API's `update` method. To do this, add a button to the form contained in `dialog.tsx` file, as follows: +You can modify the dimensions of a dialog using the dialog API's `update` method. To do this, add a button to the form contained in `dialog.tsx` file, as follows: ```typescript - - -

- - ); - }, -}; -``` +This how-to uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Make sure to complete that how-to before starting this one. -## What Does the Code Do? +## Code Descriptions -The following sections explain the various parts of the code. +The following sections explain the various parts of the code you will add in the example below. ### saveFile -The `saveFile` callback calls the `putFile` API setting the filename to `HelloWorld.txt` and the content to `Hello world from a file!`. +The `saveFile` callback calls the `putFile` API. It sets the file name to `HelloWorld.txt` and the content to `Hello world from a file!`. ```typescript const saveFile = async () => { @@ -84,7 +35,7 @@ const saveFile = async () => { ### loadFile -The loadFile callback calls the getFile API requesting to load `HelloWorld.txt`. It then shows message box displaying the content of the file. +The `loadFile` callback calls the `getFile` API. It requests to load `HelloWorld.txt`, then shows a message box that displays the content of the file. ```typescript const loadFile = async () => { @@ -98,7 +49,7 @@ const loadFile = async () => { ### deleteFile -The deleteFile callback calls the deleteFile API requesting to delete `HelloWorld.txt` +The `deleteFile` callback calls the `deleteFile` API. It requests to delete `HelloWorld.txt`. ```typescript const deleteFile = async () => { @@ -107,7 +58,7 @@ const deleteFile = async () => { }; ``` -### Adding the Buttons +### Adding Buttons The final part of the code adds three new buttons which, when clicked, call the callbacks described above. @@ -125,19 +76,69 @@ createRoot(document.getElementById("root")!).render( ); ``` -## Some Restrictions +## Example + +### Adding Interactivity + +Add all the code described in the sections above by following these steps: + +1. Open `src/ui/index.tsx`. +1. Replace the contents of the file with the following code: + +```typescript +import React, { StrictMode } from "react"; +import { createRoot } from "react-dom/client"; +import { IComponent, getStudioProApi } from "@mendix/extensions-api"; + +export const component: IComponent = { + async loaded(componentContext) { + const studioPro = getStudioProApi(componentContext); + + const saveFile = async () => { + await studioPro.app.files.putFile( + "HelloWorld.txt", + "Hello world from a file!" + ); + studioPro.ui.messageBoxes.show("info", "Saving HelloWorld.txt"); + }; + + const loadFile = async () => { + const message = await studioPro.app.files.getFile("HelloWorld.txt"); + studioPro.ui.messageBoxes.show( + "info", + `Loaded HelloWorld.txt it contained: ${message}` + ); + }; + + const deleteFile = async () => { + await studioPro.app.files.deleteFile("HelloWorld.txt"); + studioPro.ui.messageBoxes.show("info", "Deleted HelloWorld.txt"); + }; -The App files API allows you to modify files within your application's folder. It will not: + createRoot(document.getElementById("root")!).render( + +

Mendix Studio Pro Extension

+

Hello from an extension!

+

+ + + +

+
+ ); + }, +}; +``` -* serve restricted files such as the `.mpr` file or the contents of some folders such as the `.git` folder. -* allow access to files outside of the app folder. +### Restrictions -## Conclusion +The app files API allows you to modify files within your application's folder. It will not: -You can now create and extension which save, load, and delete files within the app folder. +* Serve restricted files such as the `.mpr` file, or the contents of some folders, such as the `.git` folder +* Allow access to files outside of the app folder ## Extensibility Feedback -If you would like to provide us with some additional feedback you can complete a small [Survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback) +If you would like to provide additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback). -Any feedback is much appreciated. +Any feedback is appreciated. diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/menu-api.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/menu-api.md index eeb9dc301d9..45388c79305 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/menu-api.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/menu-api.md @@ -6,20 +6,40 @@ url: /apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/ ## Introduction -This how-to shows you how to create both a simple menu item and a menu item with subsidiary items beneath it using the web extension API. +This how-to describes how to create menus using the web extensibility API. In this example, you will: + +* Create a simple menu item +* Add menu items with sub-menus +* Update a menu ## Prerequisites -This how-to uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Please complete that how-to before starting this one. +This how-to uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Make sure to complete that how-to before starting this one. -## Creating a Simple Menu +## Menu Properties -In this section, you will add a simple menu to your extension. +A menu has the following properties: -The code below will: +| Property | Description | +|----------------------|-------------------------------------------------------------------------------| +| `caption` | The text of the menu item | +| `menuId` | A unique identifier for the menu item | +| `subMenus` | A list of sub-menu items | +| `hasSeparatorBefore`
(default: `false`) | Adds a visual separator before the item | +| `hasSeparatorAfter`
(default: `false`) | Adds a visual separator after the item | +| `enabled`
(default: `true`) | Indicates that the menu item notifies the listener when clicked | -* create a menu item with the caption "My First Menu" -* show a dialog when the menu is clicked + +{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/web/menus/grouped_menus.png" width="300" >}} + +## Creating a Simple Menu + +The code below adds a simple menu to your extension. The code will: + +* Create a menu item with the caption *My First Menu* +* Show a dialog when the menu is clicked +* Import `menuApi` from `studioPro.ui.extensionsMenu` to allow you to use the menu API +* Import `messageBoxApi` from `studioPro.ui.messageBoxes` to show a dialog Replace your `src/main/index.ts` file with the following: @@ -56,43 +76,30 @@ export const component: IComponent = { } ``` -The code imports the following: - -* `menuApi` from `studioPro.ui.extensionsMenu` to allow you to use the menu API -* `messageBoxApi` from `studioPro.ui.messageBoxes` to show a dialog. +When this code is adde, it does the following: -It starts listening to the `menuItemActivated` endpoint which will notify the extension when **My First Menu** is clicked. - -The `menuItemActivated` listener event handles the actual function of the menu. The arguments `args` contain the data returned by Studio Pro to the extension, notifying it which menu item was activated (clicked). This is passed as the `menuId` that was used when creating the menu item and the `menuId` in the `if` statement is used to identify this. In this example it is `"my-menu-unique-id"` and the handler calls the `messageBoxApi` to show an information dialog. +1. Studio Pro starts listening for user interactions with the `menuItemActivated` endpoint. This notifies the extension when **My First Menu** is clicked. +2. The `args` parameter contains the information sent from Studio Pro to the extension, indicating which menu item was clicked. +3. The listener checks if the clicked `menuId` matches your defined ID. If it does, it calls `messageBoxApi.show()`. +4. Studio Pro displays an information dialog with the message you provided. Your extensions should now appear like this: {{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/web/menus/my_first_menu.png" >}} -## Menu Properties - -The menu has the following properties: - -* `caption` – the text of the menu item -* `menuId` – a unique id for the menu item -* `subMenus` – a list of menus subsidiary to this menu item -* `hasSeparatorBefore` (default: `false`) – shows a visual separator before this menu item -* `hasSeparatorAfter` (default: `false`) – shows a visual separator after this menu item -* `enabled` (default: `true`) – indicates that this menu item notifies the listener when clicked - -{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/web/menus/grouped_menus.png" >}} - ## Creating a Menu with Submenus -You can also have a number of submenus that branch out your menu. +You can also include multiple sub-menus to expand your menu structure. + +To do this, add additional menu items to your code and add them to the `subMenus` array for the relevant menu item. -To do so, add additional menu items to your code and add these to the `subMenus` array for the relevant menu item. These child menus can in turn have their own submenus, and so on. Only parent menus (menus that are not sub menus to any others) should be added through the `await menuApi.add()` call, as shown in the code sample below. +These child menus can have their own submenus, and so on. Only parent menus (menus that are not sub-menus to any others) should be added through the `await menuApi.add()` call, as shown in the code sample below. {{% alert color="info" %}} -Parent menus (with `subMenus`) do not create `menuItemActivated` events. These only get sent when a leaf menu (a menu that does not have any submenus) is clicked. +Parent menus (with `subMenus`) do not create `menuItemActivated` events. These are only sent when a leaf menu (a menu that does not have any sub-menus) is clicked. {{% /alert %}} -The following `src/main/index.ts` generates one menu item with sub menus and one menu item without sub menus. +The following `src/main/index.ts` generates one menu item with sub-menus, and one menu item without sub-menus. ```typescript import { IComponent, Menu, getStudioProApi } from "@mendix/extensions-api"; @@ -142,15 +149,15 @@ export const component: IComponent = { } ``` -The menu hierarchy will then be displayed like this: +The menu hierarchy will be displayed like this: {{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/web/menus/child_menus.png" >}} ## Updating a menu -Sometimes you might want to disable a menu or update its caption depending on a condition. You can do so by calling the menu API's `updateMenu` method. +You can disable a menu or update its caption, depending on a condition. You can do this by calling the menu API's `updateMenu` method. -An example is shown in the code below. If you click on the menu item, it will be disabled and its caption will be updated. +An example is shown in the code below. If you click the menu item, it will be disabled and its caption will be updated. {{% alert color="info" %}} Only `caption` and `enabled` can be updated. @@ -191,23 +198,18 @@ export const component: IComponent = { } ``` -The disabled state is shown in the image below. +The disabled state is seen below: -{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/web/menus/disabled_menu.png" >}} +{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/web/menus/disabled_menu.png" width="300" >}} ## Attaching a Command to the Menu Instead of listening to the `menuItemActivated` event, it is possible to register a command, then attach the `commandId` of the new command to your menu. When the menu is clicked, if its `commandId` property has been set, the backend will execute the command instead of firing the `menuItemActivated` event. -For a full explanation on how to register commands, see the [Commands API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/command-api/). - -## Conclusion - -You have seen how to create simple menu items and menu items with sub menus. -You can also dynamically change the enabled status and caption of a menu item. +For more information on how to register commands, see the [Commands API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/command-api/). ## Extensibility Feedback -If you would like to provide us with some additional feedback you can complete a small [Survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback) +If you would like to provide additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback). -Any feedback is much appreciated. +Any feedback is appreciated. diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/messagebox-api.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/messagebox-api.md index ee5ea44b793..302522f4eda 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/messagebox-api.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/messagebox-api.md @@ -6,33 +6,21 @@ url: /apidocs-mxsdk/apidocs/web-extensibility-api-11/messagebox-api/ ## Introduction -This how-to shows you how to show a message box to the Studio Pro user. +This how-to describes how to show a message box to a user. In this example, you will create three menu items that will display a dialog with text. ## Prerequisites -This how-to uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Please complete that how-to before starting this one. +This how-to uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Make sure to complete that how-to before starting this one. ## Showing a Message Box -First, create a menu which will display a dialog with text. This is done in the `loaded` method of your main entry point (`src/main/index.ts`) +Create a menu that will display a dialog with text. This is done in the `loaded` method of your main entry point (`src/main/index.ts`). For more information on how to do this, see [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/). -You can learn how to do that in [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/). - -In this example you create three menu items: - -* Show Info -* Show Error -* Show Warning - -You then need to add event listeners to receive and act upon the notifications generated by the menu items. Here the listener events show a different message box, depending on which menu item is selected. The message has the following format: - -`messageBoxApi.show(, , )` - -where +Add event listeners to receive and act upon the notifications generated by the menu items. The listener events show a different message box, depending on which menu item is selected. The message has the format `messageBoxApi.show(, , )`, where: * `` is the type of message, indicated in the pane title and indicated by an icon. Values are "information" {{% icon name="info-circle" color="blue" %}}, "warning" {{% icon name="alert-triangle" color="yellow" %}}, and "error" {{% icon name="remove-circle" color="red" %}}. * `` is the message to display. -* `` is an optional extended message which is displayed in an expandable area which is initially collapsed. +* `` is an optional extended message which is displayed in an expandable area that is initially collapsed. The full TypeScript file (`src/main/index.ts`) to implement these three menu items and message boxes is as follows. @@ -85,16 +73,12 @@ export const component: IComponent = { } ``` -For example, the **Show Info** menu item will display the following message box. +For example, the `Show Info` menu item displays the following message box: {{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/web/messageBoxes/info.png" >}} -## Conclusion - -You have seen how to implement message boxes triggered by menu items. - ## Extensibility Feedback -If you would like to provide us with some additional feedback you can complete a small [Survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback) +If you would like to provide additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback). -Any feedback is much appreciated. +Any feedback is appreciated. diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/model-api.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/model-api.md index 0433813a412..2aa60d08437 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/model-api.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/model-api.md @@ -6,12 +6,7 @@ url: /apidocs-mxsdk/apidocs/web-extensibility-api-11/model-api/ ## Introduction -The Model Access API allow access to the Mendix model. This how-to provides guidance on using the Model Access API. It is split into the following sections: - -* [Using the Model Access API](#using-api) -* [Reading the Units Info and Loading Units](#units-info-load) -* [Reading the Unit Content](#read) -* [Modifying the Unit Content](#modify) +This how-to provides guidance on using the Model Access API. The Model Access API allow access to the Mendix model. ## Using the Model Access API {#using-api} @@ -25,7 +20,7 @@ The model is split in several components exposed via `studioPro.app.model` objec You can include these components using syntax as shown below, which includes pages and domain models. -In the following, it is assumed you obtained the `studioPro` object by calling the factory function `getStudioProApi`, as in other tutorials. +In the following example, it is assumed you obtained the `studioPro` object by calling the factory function `getStudioProApi`. ```ts const studioPro = getStudioProApi(componentContext); @@ -34,7 +29,7 @@ const { pages, domainModels } = studioPro.app.model; ## Reading the Units Info and Loading Units {#units-info-load} -A unit is a Mendix document (for example, a page or a domain model) containing elements. Each element is within a container element and may contain other elements. An element is part of a Mendix model and all elements together form the logic of the model. For more information see [Mendix Metamodel](/apidocs-mxsdk/mxsdk/mendix-metamodel/). +A unit is a Mendix document (for example, a page or a domain model) containing elements. Each element resides within a container element and can itself contain other elements. Together, these elements form the logic of a Mendix model. For more information, see [Mendix Metamodel](/apidocs-mxsdk/mxsdk/mendix-metamodel/). Each component, for example pages (`studioPro.app.model.pages`) exposes the units it is responsible for. You can only access all the content of a unit once you have loaded the unit info for that unit. @@ -47,25 +42,27 @@ The unit info, described by the `UnitInfo` interface, contains the the following | `moduleName` | (Optional) The name of the module containing the unit | `MyFirstModule` | | `name` | (Optional) The name of the unit | `ExamplePage` | -For example, you can retrieve all the units managed by the `domainModels` component using the following code: - -```ts -const unitsInfo: Primitives.UnitInfo[] = await domainModels.getUnitsInfo() -``` - A unit can be loaded by supplying a function, `fn` to `component.loadAll(fn)`. The function `fn` should return `true` to load a specified unit. {{% alert color="warning" %}} Loading units is a resource intensive process. Only load units when you need them. {{% /alert %}} -For example, the following snippet loads the `domainModel` for the module named `MyFirstModule`: +### Examples + +You can retrieve all the units managed by the `domainModels` component using the following code: + +```ts +const unitsInfo: Primitives.UnitInfo[] = await domainModels.getUnitsInfo() +``` + +The following snippet loads the `domainModel` for the module named `MyFirstModule`: ```ts const [domainModel] = await domainModels.loadAll((info: Primitives.UnitInfo) => info.moduleName === 'MyFirstModule'); ``` -And this example snippet loads the page named `Home_Web` in the module named `MyFirstModule`: +The snippet below loads the page named `Home_Web` in the module named `MyFirstModule`: ```ts const [page] = await pages.loadAll((info: Primitives.UnitInfo) => info.moduleName === 'MyFirstModule' && info.name === 'Home_Web') @@ -99,12 +96,8 @@ newEntity.documentation = "New documentation"; await domainModels.save(domainModel); ``` -## Conclusion - -You now know how to interact with units and elements in the Mendix model. - ## Extensibility Feedback -If you would like to provide us with some additional feedback you can complete a small [Survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback) +If you would like to provide us with additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback). -Any feedback is much appreciated. +Any feedback is appreciated. diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/notification-api.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/notification-api.md index 34efae031d1..ff7b0143006 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/notification-api.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/notification-api.md @@ -10,7 +10,7 @@ This how-to describes how to show a simple pop-up notification in Studio Pro. ## Prerequisites -This guide uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Please complete that how-to before starting this one. +This guide uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Make sure to complete that how-to before starting this one. ## Showing a Notification @@ -56,10 +56,10 @@ With the notifications API, you can show a pop-up notification when your extensi } ``` - This code does the following: +This code does the following: - * It uses the `notificationsApi` from `studioPro.ui.notifications` to allow you to use the notifications API. - * It implements a `loaded` method, which calls the `show` method to show a pop-up notification for five seconds with the title `Extension Loaded`, a message, and the `check.png` icon you set up earlier. For more information, see the [Full Reference for Show Method](#reference) section below. +* It uses the `notificationsApi` from `studioPro.ui.notifications` to allow you to use the notifications API. +* It implements a `loaded` method, which calls the `show` method to show a pop-up notification for five seconds with the title `Extension Loaded`, a message, and the `check.png` icon you set up earlier. For more information, see the [Full Reference for Show Method](#reference) section below. Now, when the extension loads, your notification will show in the top-right corner of Studio Pro: @@ -76,6 +76,6 @@ The show method has the following parameters: ## Extensibility Feedback -If you would like to provide us additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback). +If you would like to provide additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback). Any feedback is appreciated. diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/preference-api.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/preference-api.md index 1b69a5bc476..d0431454dfa 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/preference-api.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/preference-api.md @@ -10,16 +10,16 @@ This how-to describes how to create a simple menu that shows the user's preferen ## Prerequisites -Before starting this how-to, ensure you have: +Before starting this how-to, make sure you have completed the following prerequisites: -1. Completed the steps in [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). -2. Become familiar with creating menus as described in [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/) and message boxes as described in [Show a Message Box Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/messagebox-api/). +* 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. +* Make sure you are familiar with creating menus as described in [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/) and message boxes as described in [Show a Message Box Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/messagebox-api/). ## Set Up the Extension Structure -Create a menu that will display a dialog with text. This is done in the `loaded` method in the main entry point (`src/main/index.ts`). This can be done by following the steps in [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/). +Create a menu that will display a dialog with text in the `loaded` method in the main entry point (`src/main/index.ts`). This can be done by following the steps in [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/). -In the example below, you create one menu item that will show a message box. +In the example below, you will create one menu item that will show a message box. Replace your `src/main/index.ts` file with the following: diff --git a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/tab-api.md b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/tab-api.md index d78ebbf1820..2fd75e07f41 100644 --- a/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/tab-api.md +++ b/content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/tab-api.md @@ -6,26 +6,29 @@ url: /apidocs-mxsdk/apidocs/web-extensibility-api-11/tab-api/ ## Introduction -This how-to shows you how to open a tab in Studio Pro from an extension. This tab will contain your web content. +This how-to describes how to open a tab in Studio Pro from an extension. This tab will contain your web content. ## Prerequisites -This how-to uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/getting-started/). Please complete that how-to before starting this one. You should also be familiar with creating menus as described in [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/). +Before starting this how-to, make sure you have completed the following prerequisites: + +* 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. +* Make sure you are familiar with creating menus as described in [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/). ## Opening a Tab -First, create a menu item to open the tab. This is done inside the `loaded` method in `Main` class, as described below. For more information see [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/). +Create a menu item to open the tab. This is done inside the `loaded` method in `Main` class, as described below. For more information, see [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/menu-api/). -In a listener event called `menuItemActivated` the `studioPro.ui.tabs.open(, )` call opens a new tab where: +In a listener event called `menuItemActivated`, the `studioPro.ui.tabs.open(, )` call opens a new tab where: * `` is an object containing the `title` of the tab, which will be shown in the title bar of your tab in Studio Pro. * `` is an object containing two required properties: - * `componentName` which is the name of the extension prefixed with "extension/". For example "extension/myextension" in the following example. - * `uiEntryPoint` which is the name mapped from the `manifest.json` file. See below for examples with multiple tabs. + * `componentName`, which is the name of the extension prefixed with `extension/`. For example `extension/myextension` in the following example. + * `uiEntryPoint`, which is the name mapped from the `manifest.json` file. {{% alert color="info" %}} -Whenever the tabs API `open` method is called, the `TabHandle` returned must be tracked by the extension so that it can be closed later by calling the `close` method. +Whenever the tabs API `open` method is called, the `TabHandle` returned must be tracked by the extension so it can be closed later by calling the `close` method. {{% /alert %}} To open a tab called **My Extension Tab**, add the following code to the main entry point (`src/main/index.ts`) @@ -89,9 +92,9 @@ export const component: IComponent = new Main(); ## Filling the Tabs With Content -In the previous example, the `uiEntryPoint` property of the `` object had the value "tab". This value must match the one from the manifest. +In the previous example, the `uiEntryPoint` property of the `` object had the value `tab`. This value must match the one from the manifest. -If you want to have multiple tabs in your extension, you need to structure the folders and set up the manifest file correctly. +If you want multiple tabs in your extension, you need to structure the folders and set up the manifest file correctly. To do this, follow these steps: @@ -109,9 +112,9 @@ To do this, follow these steps: } ``` -1. Add three folders inside the `ui` folder, one for each tab you want to display contents for. -1. Create an `index.tsx` file in each folder. -1. Put the following code in each `index.tsx` file (this example is for **tab3**): +2. Add three folders inside the `ui` folder, one for each tab you want to display contents for. +3. Create an `index.tsx` file in each folder. +4. Put the following code in each `index.tsx` file (this example is for **tab3**): ```typescript import React, { StrictMode } from "react"; @@ -129,11 +132,11 @@ To do this, follow these steps: }; ``` - In this example, we'll add 3 tabs: **tab1**, **tab2**, and **tab3**. + In this example, you will add three tabs: **tab1**, **tab2**, and **tab3**. - {{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/web/tabs/ui_folder_structure.png" >}} + {{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/web/tabs/ui_folder_structure.png" width="300" >}} -1. Create listener events in the `Main` class to open each of the three tabs. The `Main` class will then look like this: +5. Create listener events in the `Main` class to open each of the three tabs. The `Main` class will then look like this: ```typescript import { IComponent, getStudioProApi, TabHandle, ComponentContext, TabInfo, UISpec } from "@mendix/extensions-api"; @@ -189,7 +192,7 @@ To do this, follow these steps: export const component: IComponent = new Main(); ``` -1. Ensure the tabs are added to the `manifest.json` file. Here is an example of three tabs under the `ui` property. +6. Ensure the tabs are added to the `manifest.json` file. Below is an example of three tabs under the `ui` property. ```json { @@ -206,8 +209,7 @@ To do this, follow these steps: } ``` -1. Update `build-extension.mjs` to match the manifest with an entry for each tab. Specifically, you need to add entry points for each tab to - `entryPoints` array and make sure the variable `appDir` stays unaltered, as follows: +7. Update `build-extension.mjs` to match the manifest with an entry for each tab. Add entry points for each tab to `entryPoints` array and make sure the variable `appDir` stays unaltered, as follows: ```javascript{hl_lines=["16-20"]} import * as esbuild from 'esbuild' @@ -248,14 +250,10 @@ To do this, follow these steps: } ``` -After building and installing the extension in our Studio Pro app, each tab will display the content specified in the related `index.tsx` file. - -## Conclusion - -You now know how to create tabs and populate them with content. +After building and installing the extension in your app, each tab will display the content specified in the related `index.tsx` file. ## Extensibility Feedback -If you would like to provide us with some additional feedback you can complete a small [Survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback) +If you would like to provide additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback). -Any feedback is much appreciated. +Any feedback is appreciated.