Skip to content

Commit 4059987

Browse files
committed
Tab
1 parent 9e2a094 commit 4059987

File tree

1 file changed

+23
-26
lines changed
  • content/en/docs/apidocs-mxsdk/apidocs/studio-pro-10/extensibility-api/web/web-extensions-howtos

1 file changed

+23
-26
lines changed

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

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,32 @@ weight: 60
77

88
## Introduction
99

10-
This how-to shows you how to open a tab in Studio Pro from an extension. This tab will contain your web content.
10+
This how-to describes how to open a tab in Studio Pro from an extension. This tab will contain your web content.
1111

1212
## Prerequisites
1313

14-
This how-to uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-10/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-10/menu-api/).
14+
Before starting this how-to, make sure you have completed the following prerequisites:
15+
16+
* This how-to uses the results of [Get Started with the Web Extensibility API](/apidocs-mxsdk/apidocs/web-extensibility-api-10/getting-started/). Complete that how-to before starting this one.
17+
* Make sure you are familiar with creating menus as described in [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-10/menu-api/).
1518

1619
## Opening a Tab
1720

18-
Firstly, create a menu item to open the tab. This is done inside the `loaded` event in `Main`. For more information see [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-10/menu-api/).
21+
Create a menu item to open the tab. This is done inside the `loaded` event in `Main`, as described below. For more information. see [Create a Menu Using Web API](/apidocs-mxsdk/apidocs/web-extensibility-api-10/menu-api/).
1922

20-
In a listener event called `menuItemActivated` the `studioPro.ui.tabs.open(<tabinfo>, <uispec>)` call opens a new tab where:
23+
In a listener event called `menuItemActivated`, the `studioPro.ui.tabs.open(<tabinfo>, <uispec>)` call opens a new tab where:
2124

22-
* `<TabInfo>` is an object containing the `title` of the tab, which will be shown in the title bar of your tab in Studio Pro.
25+
* `<TabInfo>` is an object containing the `title` of the tab, which will be shown in the title bar of your tab in Studio Pro
2326
* `<uispec>` is an object containing two required properties:
2427

25-
* `componentName` which is the name of the extension prefixed with "extension/". For example "extension/myextension" in the following example.
26-
* `uiEntryPoint` which is the name mapped from the `manifest.json` file. See below for examples with multiple tabs.
28+
* `componentName` the name of the extension prefixed with "extension/"; for example,"extension/myextension" in the following example
29+
* `uiEntryPoint` the name mapped from the `manifest.json` file
2730

2831
{{% alert color="info" %}}
29-
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.
32+
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.
3033
{{% /alert %}}
3134

32-
An example of the class `Main` to open a tab called **My Extension Tab** looks similar to the following:
35+
To open a tab called *My Extension Tab*, add the following code to the main entry point:
3336

3437
```typescript
3538
import { IComponent, studioPro, TabHandle } from "@mendix/extensions-api";
@@ -88,11 +91,9 @@ export const component: IComponent = new Main();
8891

8992
## Filling the Tabs With Content
9093

91-
In the previous example, the `uiEntryPoint` property of the `<uispec>` object had the value "tab". This value must match the one from the manifest.
92-
93-
If you want to have multiple tabs in your extension, you need to structure the folders and set up the manifest file correctly.
94+
In the previous example, the `uiEntryPoint` property of the `<uispec>` object had the value `tab`. This value must match the one from the manifest.
9495

95-
To do this, follow these steps:
96+
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:
9697

9798
1. Add a new method `createTabSpec` in your `Main` class.
9899

@@ -108,9 +109,9 @@ To do this, follow these steps:
108109
}
109110
```
110111

111-
1. Add three folders inside the `ui` folder, one for each tab you want to display contents for.
112-
1. Create an `index.tsx` file in each folder.
113-
1. Put the following code in each `index.tsx` file (this example is for **tab3**):
112+
2. Add three folders inside the `ui` folder, one for each tab you want to display contents for.
113+
3. Create an `index.tsx` file in each folder.
114+
4. Put the following code in each `index.tsx` file (this example is for **tab3**):
114115

115116
```typescript
116117
import { StrictMode } from "react";
@@ -127,7 +128,7 @@ To do this, follow these steps:
127128

128129
{{< figure src="/attachments/apidocs-mxsdk/apidocs/extensibility-api/web/tabs/ui_folder_structure.png" >}}
129130

130-
1. Create listener events in the `Main` class to open each of the three tabs. The `Main` class will then look like this:
131+
5. Create listener events in the `Main` class to open each of the three tabs. The `Main` class will then look like this:
131132

132133
```typescript
133134
import { IComponent, studioPro, TabInfo, UISpec } from "@mendix/extensions-api";
@@ -179,7 +180,7 @@ To do this, follow these steps:
179180
export const component: IComponent = new Main();
180181
```
181182

182-
1. Ensure the tabs are added to the `manifest.json` file. Here is an example of three tabs under the `ui` property.
183+
6. Ensure the tabs are added to the `manifest.json` file. Below is an example of three tabs under the `ui` property.
183184

184185
```json
185186
{
@@ -196,7 +197,7 @@ To do this, follow these steps:
196197
}
197198
```
198199

199-
1. Update `vite.config` to match the manifest with an entry for each tab. For example:
200+
7. Update `vite.config` to match the manifest with an entry for each tab. For example:
200201

201202
```typescript
202203
import { defineConfig, ResolvedConfig, UserConfig } from "vite";
@@ -220,14 +221,10 @@ To do this, follow these steps:
220221
} satisfies UserConfig);
221222
```
222223

223-
After building and installing the extension in our Studio Pro app, each tab will display the content specified in the related `index.tsx` file.
224-
225-
## Conclusion
226-
227-
You now know how to create tabs and populate them with content.
224+
After building and installing the extension in your Studio Pro app, each tab will display the content specified in the related `index.tsx` file.
228225

229226
## Extensibility Feedback
230227

231-
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)
228+
If you would like to provide additional feedback, you can complete a small [survey](https://survey.alchemer.eu/s3/90801191/Extensibility-Feedback).
232229

233-
Any feedback is much appreciated.
230+
Any feedback is appreciated.

0 commit comments

Comments
 (0)