-
Notifications
You must be signed in to change notification settings - Fork 777
Add runtime api's and permissions to docs for extensibility team #10915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
SofiBili
wants to merge
22
commits into
mendix:development
Choose a base branch
from
SofiBili:development
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
c77365e
Add runtime api s and permissions to docs
SofiBili 284527a
Update index
SofiBili 6901484
Permissions review
quinntracy 34510b9
Runtime Constants review
quinntracy 870322c
Controller review
quinntracy d440cf8
RN review
quinntracy 5ee80f4
Revise
quinntracy f8decb6
Update content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibil…
quinntracy 27eda1c
Update content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibil…
quinntracy d35bab4
Update content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibil…
quinntracy 035e584
Update content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibil…
quinntracy 41765e9
Update content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibil…
quinntracy 81f747a
Update content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibil…
quinntracy 89a3abb
Update content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibil…
quinntracy 344d9dc
Update content/en/docs/apidocs-mxsdk/apidocs/studio-pro-11/extensibil…
quinntracy 8cf5a00
Apply suggestion from @MarkvanMents
quinntracy f516220
Update wording
quinntracy 86aaa71
Update permissions.md
quinntracy 15c6792
Apply suggestion from @MarkvanMents
quinntracy 9a8280c
Revisions
quinntracy c28eb36
Merge branch 'development' of https://github.com/SofiBili/docs into p…
quinntracy 4bc0bfd
Additional revisions
quinntracy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...pidocs/studio-pro-11/extensibility-api/web/web-extensions-howtos/permissions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| --- | ||
| title: "Extension Permissions in Overview Pane" | ||
| linktitle: "Extension Permissions" | ||
| url: /apidocs-mxsdk/apidocs/web-extensibility-api-11/extension-permissions/ | ||
| --- | ||
|
|
||
| ## Introduction | ||
|
|
||
| This how-to describes how the permission system works for web extensions in Studio Pro. Permissions allow extensions to request access to sensitive APIs or data that require explicit user consent. | ||
|
|
||
| {{% alert color="info" %}} | ||
| Extension permissions were introduced in version 11.9.0. | ||
| {{% /alert %}} | ||
|
|
||
| ## How Permissions Work | ||
|
|
||
| Web extensions can request permissions to access sensitive functionality. The permission system follows these principles: | ||
|
|
||
| * **Opt-in by default** — Extensions cannot access protected APIs unless you request persmission and the extension user grants it | ||
| * **User control** — You decide which permissions to grant through the Extensions Overview pane in Studio Pro | ||
| * **Per-project settings** — Permission grants are stored per project, so a user’s approval for an extension applies only within that app. This gives them the flexibility to grant a permission in one project and choose different settings for the same extension in another. | ||
|
|
||
| ## Requesting Permissions | ||
|
|
||
| To request a permission, declare it in your extension's `package.json` file under the `mendix.permissions` object: | ||
|
|
||
| ```json | ||
| { | ||
| "mendixComponent": { | ||
| "entryPoints": { | ||
| "main": "main.js", | ||
| "ui": { | ||
| "tab": "tab.js" | ||
| } | ||
| }, | ||
| "permissions": { | ||
| "runtime-configuration-private": true | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Setting a permission to **true** indicates that your extension requests this permission. The user must grant it before your extension can use the protected functionality. Default: *False* | ||
|
|
||
| ## Granting Permissions (User Flow) | ||
|
|
||
| When a user installs an extension that requests permissions, they can manage those permissions through the Extensions Overview pane. Follow the steps below: | ||
|
|
||
| 1. Open Studio Pro and load an app with the extension installed. | ||
| 2. Go to **View** > **Extensions Overview** to open the Extensions Overview pane. | ||
| 3. Find the extension in the list. Under the extension details, the **Permissions** section displays the requested permissions. | ||
| 4. Check or uncheck the checkbox next to each permission to grant or revoke access. | ||
|
|
||
| ## Available Permissions | ||
|
|
||
| The following permissions are available for web extensions: | ||
|
|
||
| | Permission | Description | | ||
| |------------|-------------| | ||
| | `runtime-configuration-private` | Allows the extension to access the values of private constants from the active runtime configuration. Without this permission, private constants are returned with `isPrivate: true` and no value. | | ||
|
|
||
| ## 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. | ||
125 changes: 125 additions & 0 deletions
125
...pro-11/extensibility-api/web/web-extensions-howtos/runtime-configuration-api.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| --- | ||
| title: "Access Runtime Constants Using Web API" | ||
| linktitle: "Runtime Constants" | ||
| url: /apidocs-mxsdk/apidocs/web-extensibility-api-11/runtime-configuration-api/ | ||
| --- | ||
|
|
||
| ## Introduction | ||
|
|
||
| This how-to describes how to create a simple menu that retrieves and displays the runtime constants from the active configuration in a message box. | ||
|
|
||
quinntracy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| {{% alert color="info" %}} | ||
| Access to runtime constants using the web API was introduced in version 11.9.0. | ||
| {{% /alert %}} | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| 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/) 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 | ||
|
|
||
| Set up the extension structure by following the steps below: | ||
|
|
||
| 1. Create a menu that will display the runtime constants 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/). | ||
| 2. Replace the contents of your `src/main/index.ts` file with the following: | ||
|
|
||
| ```typescript | ||
| import { IComponent, Menu, getStudioProApi } from "@mendix/extensions-api"; | ||
|
|
||
| export const component: IComponent = { | ||
| async loaded(componentContext) { | ||
| const studioPro = getStudioProApi(componentContext); | ||
| const menuApi = studioPro.ui.extensionsMenu; | ||
| const runtimeConfigApi = studioPro.runtime.configuration; | ||
| const messageBoxApi = studioPro.ui.messageBoxes; | ||
|
|
||
| const menuId = "show-constants-menu"; | ||
| const caption = "Show Runtime Constants"; | ||
|
|
||
| // Get and show the constants when the menu item is clicked | ||
| const action = async () => { | ||
| const constants = await runtimeConfigApi.getConstants(); | ||
|
|
||
| if (constants.length === 0) { | ||
| await messageBoxApi.show("info", "No constants found in the active configuration."); | ||
| return; | ||
| } | ||
|
|
||
| const accessibleConstants = constants.filter(c => c.isPrivate === false); | ||
| const privateConstants = constants.filter(c => c.isPrivate === true); | ||
|
|
||
| let message = ""; | ||
|
|
||
| if (accessibleConstants.length > 0) { | ||
| message += "Accessible Constants:\n"; | ||
| message += accessibleConstants.map(c => ` ${c.constantName}: ${c.value}`).join("\n"); | ||
| } | ||
|
|
||
| if (privateConstants.length > 0) { | ||
| message += `\n\n${privateConstants.length} private constant(s) not accessible.`; | ||
| } | ||
|
|
||
| await messageBoxApi.show("info", `Runtime Constants:\n\n${message}`); | ||
| }; | ||
|
|
||
| const menu: Menu = { caption, menuId, action }; | ||
|
|
||
| await menuApi.add(menu); | ||
| } | ||
| }; | ||
| ``` | ||
|
|
||
| In this example, you create one menu item that will show a message box with the runtime constants from the active configuration. | ||
quinntracy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| The code uses the: | ||
|
|
||
| * `menuApi` from `studioPro.ui.extensionsMenu` to allow you to use the menu API | ||
| * `messageBoxApi` from `studioPro.ui.messageBoxes` to show a dialog | ||
| * `runtimeConfigApi` from studioPro.runtime.configuration to retrieve the runtime constants | ||
|
|
||
| {{% alert color="info" %}} The function is `async` in order for you to use `await` when executing the preview action. | ||
| {{% /alert %}} | ||
|
|
||
| The `getConstants()` function returns an array of constant objects, each with the following properties: | ||
quinntracy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| * `isPrivate` – a boolean indicating whether the constant value is hidden (true) or accessible (false) | ||
| * `constantName` – the fully qualified name of the constant (for example, `MyModule.MyConstant`) | ||
| * `value` – the constant value as a string (only present when `isPrivate` is false) | ||
|
|
||
| ## Accessing Private Constants | ||
|
|
||
| By default, private constants are not accessible and will have `isPrivate` set to true with no value. To access private constant values, your extension must request the `runtime-configuration-private` permission. | ||
|
|
||
| Add the permission to your extension's `package.json` after the entry points: | ||
|
|
||
| ```json | ||
| { | ||
| "mendixComponent": { | ||
| "entryPoints": { | ||
| "main": "main.js", | ||
| "ui": { | ||
| "tab": "tab.js" | ||
| } | ||
| }, | ||
| "permissions": { | ||
| "runtime-configuration-private": true | ||
| } | ||
| } | ||
| } | ||
|
|
||
| ``` | ||
|
|
||
| You have to set the permission to true if you want the permission to appear in the Extensions Overview pane. | ||
|
|
||
| When a user installs your extension, they can grant this permission through the Extensions Overview pane (**View** > **Extensions**) in Studio Pro. Once granted, private constants will be returned with `isPrivate` set to false and their value included. | ||
|
|
||
| You can read more about permissions in [Extension Permissions in Overview Pane](/apidocs-mxsdk/apidocs/web-extensibility-api-11/extension-permissions/). | ||
|
|
||
| ## 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. | ||
70 changes: 70 additions & 0 deletions
70
...io-pro-11/extensibility-api/web/web-extensions-howtos/runtime-controller-api.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| --- | ||
| title: "Listen for Connection Changes" | ||
| linktitle: "Runtime Controller" | ||
| url: /apidocs-mxsdk/apidocs/web-extensibility-api-11/runtime-controller-api/ | ||
| --- | ||
|
|
||
| ## Introduction | ||
|
|
||
| This how-to describes how to create a simple menu that displays when the connection changed in a message box. | ||
|
|
||
quinntracy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| {{% alert color="info" %}} | ||
| Listening for connection changes was introduced in version 11.9.0. | ||
| {{% /alert %}} | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| 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/) and message boxes as described in [Show a Message Box Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-11/messagebox-api/). | ||
| * Your app must be running locally in Studio Pro to use the Runtime Controller API. | ||
|
|
||
| ## Listening for Connection Changes | ||
|
|
||
| You can listen for runtime connection state changes to know when the app starts or stops running. To do this, follow the steps below: | ||
|
|
||
| 1. Add an event listener to respond when the connection state changes. | ||
| 2. Replace the content of your `src/main/index.ts` file with the following: | ||
|
|
||
| ```typescript | ||
| import { IComponent, getStudioProApi } from "@mendix/extensions-api"; | ||
|
|
||
| export const component: IComponent = { | ||
| async loaded(componentContext) { | ||
| const studioPro = getStudioProApi(componentContext); | ||
| const runtimeControllerApi = studioPro.runtime.controller; | ||
| const messageBoxApi = studioPro.ui.messageBoxes; | ||
|
|
||
| // Listen for connection state changes | ||
| runtimeControllerApi.addEventListener("connectionChanged", (args) => { | ||
| messageBoxApi.show( | ||
| "info", | ||
| `Runtime connection: ${args.isConnected ? "Connected" : "Disconnected"}` | ||
| ); | ||
| }); | ||
| } | ||
| }; | ||
| ``` | ||
|
|
||
| The code uses the: | ||
|
|
||
| * `menuApi` from `studioPro.ui.extensionsMenu` to allow you to use the menu API | ||
| * `messageBoxApi` from `studioPro.ui.messageBoxes` to show a dialog | ||
| * `runtimeControllerApi` from `studioPro.runtime.controller` to check if the connection changed. | ||
|
|
||
| {{% alert color="info" %}} The function is `async` in order for you to use `await` when executing the preview action. | ||
| {{% /alert %}} | ||
|
|
||
| The `connectionChanged` event returns an object with: | ||
|
|
||
| * `isConnected` – a boolean indicating whether the runtime is currently connected (true) or disconnected (false) | ||
|
|
||
| {{% alert color="info" %}} The event only detects when the runtime connects or disconnects. It cannot be used to determine when the runtime is completely initialized. | ||
| {{% /alert %}} | ||
|
|
||
| ## 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. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.