Skip to content

Commit d4d2d35

Browse files
authored
Merge pull request #5 from mi-examples/pp-2668
PP-2668
2 parents 0a795f7 + df35e2a commit d4d2d35

5 files changed

Lines changed: 520 additions & 165 deletions

File tree

README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export default config;
210210
| Option | Type | Default | Description |
211211
|--------|------|---------|-------------|
212212
| `miHudLess` | boolean | `false` | Disables Metric Insights navigation bar in development |
213-
| `integrateMiTopBar` | boolean | `false` | Integrates MI Top Bar and script into the App build (requires `miHudLess: true`) |
213+
| `integrateMiTopBar` | boolean \| object | `false` | Integrates MI Top Bar and scripts into the App build (requires `miHudLess: true`). When `true`, enables both `addRootElement` and `addSharedComponentsScripts`. When an object, allows selective enabling: `{ addRootElement?: boolean, addSharedComponentsScripts?: boolean }` |
214214
| `templateLess` | boolean | `false` | Disables template variable transformation |
215215
| `enableProxyCache` | boolean | `true` | Enables caching of proxied requests |
216216
| `proxyCacheTTL` | number | `600000` | Cache TTL in milliseconds (10 minutes) |
@@ -232,7 +232,24 @@ The `integrateMiTopBar` option allows you to integrate the Metric Insights Top B
232232

233233
**Important**: This option can only be enabled when `miHudLess` is set to `true`.
234234

235-
Example configuration:
235+
#### Configuration Options
236+
237+
`integrateMiTopBar` can be configured in two ways:
238+
239+
**1. Boolean (Simple)**
240+
- `true`: Enables both `addRootElement` and `addSharedComponentsScripts`
241+
- `false`: Disables integration (default)
242+
243+
**2. Object (Advanced)**
244+
- `addRootElement`: Adds `<div id="mi-react-root">` element to the body for React mounting
245+
- `addSharedComponentsScripts`: Adds MI shared component scripts and styles:
246+
- `/auth/info.js` - Authentication info script
247+
- `/js/main.js` - Main MI JavaScript bundle
248+
- `/css/main.css` - MI stylesheet
249+
250+
#### Examples
251+
252+
**Simple boolean configuration:**
236253
```javascript
237254
// pp-dev.config.js
238255
module.exports = {
@@ -243,6 +260,34 @@ module.exports = {
243260
};
244261
```
245262

263+
**Advanced object configuration (selective features):**
264+
```javascript
265+
// pp-dev.config.js
266+
module.exports = {
267+
backendBaseURL: 'https://mi.company.com',
268+
appId: 1,
269+
miHudLess: true,
270+
integrateMiTopBar: {
271+
addRootElement: true, // Add root element for React
272+
addSharedComponentsScripts: true, // Add MI scripts and styles
273+
},
274+
};
275+
```
276+
277+
**Partial integration (scripts only, manual root element):**
278+
```javascript
279+
// pp-dev.config.js
280+
module.exports = {
281+
backendBaseURL: 'https://mi.company.com',
282+
appId: 1,
283+
miHudLess: true,
284+
integrateMiTopBar: {
285+
addRootElement: false, // Don't add root element
286+
addSharedComponentsScripts: true, // Add MI scripts and styles
287+
},
288+
};
289+
```
290+
246291
### v7Features Details
247292

248293
When enabled (`true`), this option:

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export async function getViteConfig() {
5050
normalizedPPDevConfig;
5151

5252
if (integrateMiTopBar) {
53-
plugins.push(miTopBarPlugin());
53+
plugins.push(miTopBarPlugin(integrateMiTopBar));
5454
}
5555

5656
if (imageOptimizer) {

0 commit comments

Comments
 (0)