@equinor/fusion-framework-cli 10.6.1 → 10.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +52 -0
- package/dist/bin/dev-portal/useAppContextNavigation.js +20 -14
- package/dist/bin/dev-portal/useAppContextNavigation.js.map +1 -1
- package/dist/bin/public/assets/{index-HFqOt241.js → index-C22xbTbG.js} +12 -11
- package/dist/bin/public/index.html +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 10.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2930](https://github.com/equinor/fusion-framework/pull/2930) [`5da6b2d`](https://github.com/equinor/fusion-framework/commit/5da6b2d4cb7fb93ff3784753a0052d3362ab828d) Thanks [@odinr](https://github.com/odinr)! - **@equinor/fusion-framework-react:**
|
|
8
|
+
|
|
9
|
+
- Enhanced `useAppContextNavigation` to support custom context path extraction and generation. This allows for more flexible navigation handling based on application-specific requirements.
|
|
10
|
+
|
|
11
|
+
**@equinor/fusion-framework-module-context:**
|
|
12
|
+
|
|
13
|
+
- Added support for custom context path extraction and generation in `ContextConfigBuilder`, `ContextProvider`, and `ContextModuleConfigurator`.
|
|
14
|
+
- Introduced `setContextPathExtractor` and `setContextPathGenerator` methods in `ContextConfigBuilder` to allow developers to define custom logic for extracting and generating context paths.
|
|
15
|
+
- Updated `ContextProvider` to utilize `extractContextIdFromPath` and `generatePathFromContext` from the configuration, enabling dynamic path handling.
|
|
16
|
+
- Enhanced `ContextModuleConfigurator` to include `extractContextIdFromPath` and `generatePathFromContext` in the module configuration.
|
|
17
|
+
|
|
18
|
+
If you are using `@equinor/fusion-framework-module-context` and need custom logic for context path handling:
|
|
19
|
+
|
|
20
|
+
1. Use `setContextPathExtractor` to define how to extract context IDs from paths.
|
|
21
|
+
2. Use `setContextPathGenerator` to define how to generate paths based on context items.
|
|
22
|
+
|
|
23
|
+
Example:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
builder.setContextPathExtractor((path) => {
|
|
27
|
+
// Custom logic to extract context ID from path
|
|
28
|
+
return path.match(/\/custom\/(.+)/)?.[1];
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
builder.setContextPathGenerator((context, path) => {
|
|
32
|
+
// Custom logic to generate path from context
|
|
33
|
+
return path.replace(/^(\/)?custom\/[^/]+(.*)$/, `/app/${item.id}$2`);
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
If your portal is generating context paths based on context items, you can now define custom logic for context path handling:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
contextProvider.currentContext$
|
|
41
|
+
.pipe(
|
|
42
|
+
map((context) => {
|
|
43
|
+
// Custom logic to generate path from context
|
|
44
|
+
const path = contextProvider.generatePathFromContext?.(
|
|
45
|
+
context,
|
|
46
|
+
location.pathname
|
|
47
|
+
);
|
|
48
|
+
return path ?? fallbackPathGenerator(context, location.pathname);
|
|
49
|
+
}),
|
|
50
|
+
filter(Boolean)
|
|
51
|
+
)
|
|
52
|
+
.subscribe((path) => history.push(path));
|
|
53
|
+
```
|
|
54
|
+
|
|
3
55
|
## 10.6.1
|
|
4
56
|
|
|
5
57
|
### Patch Changes
|
|
@@ -4,6 +4,19 @@ import { extractContextIdFromPath } from '@equinor/fusion-framework-module-conte
|
|
|
4
4
|
import { useObservableSubscription } from '@equinor/fusion-observable/react';
|
|
5
5
|
import { EMPTY } from 'rxjs';
|
|
6
6
|
import { useFrameworkModule } from '@equinor/fusion-framework-react';
|
|
7
|
+
const generatePathname = (currentPathname, item, context, pathContextId) => {
|
|
8
|
+
var _a, _b, _c, _d;
|
|
9
|
+
if (pathContextId) {
|
|
10
|
+
// context id exists in the url, replace it with the new context id
|
|
11
|
+
const pathname = (_b = (_a = context === null || context === void 0 ? void 0 : context.generatePathFromContext) === null || _a === void 0 ? void 0 : _a.call(context, item, currentPathname)) !== null && _b !== void 0 ? _b : currentPathname.replace(pathContextId, item.id);
|
|
12
|
+
console.debug(`🌍 Portal: context changed, navigating to app's context url:`, `found context id [${pathContextId}] in url, replacing with [${pathname}]`);
|
|
13
|
+
return pathname;
|
|
14
|
+
}
|
|
15
|
+
// could not find context id in the url, set the path to the new context id
|
|
16
|
+
const pathname = (_d = (_c = context === null || context === void 0 ? void 0 : context.generatePathFromContext) === null || _c === void 0 ? void 0 : _c.call(context, item, currentPathname)) !== null && _d !== void 0 ? _d : `/${item === null || item === void 0 ? void 0 : item.id}`;
|
|
17
|
+
console.debug(`🌍 Portal: context changed, navigating to app's context url:`, `could not find context id in url, navigating to path [${pathname}]`);
|
|
18
|
+
return pathname;
|
|
19
|
+
};
|
|
7
20
|
/**
|
|
8
21
|
* when current application changes, this hook will observe the application module instances.
|
|
9
22
|
* If the module has Context and Navigation, this hook will navigate when the context changes
|
|
@@ -22,6 +35,7 @@ export const useAppContextNavigation = () => {
|
|
|
22
35
|
(_a = context === null || context === void 0 ? void 0 : context.currentContext$) !== null && _a !== void 0 ? _a : EMPTY,
|
|
23
36
|
// when the context changes, navigate to the new context
|
|
24
37
|
useCallback((item) => {
|
|
38
|
+
var _a, _b;
|
|
25
39
|
// sanity check, if the item or navigation is undefined, early return
|
|
26
40
|
if (item === undefined || navigation === undefined) {
|
|
27
41
|
return;
|
|
@@ -46,20 +60,11 @@ export const useAppContextNavigation = () => {
|
|
|
46
60
|
}
|
|
47
61
|
return;
|
|
48
62
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
? // context id exists in the url, replace it with the new context id
|
|
55
|
-
currentPathname.replace(pathContextId, item.id)
|
|
56
|
-
: // context was cleared, set the path to the root
|
|
57
|
-
'/'
|
|
58
|
-
: // could not find context id in the url, set the path to the new context id
|
|
59
|
-
`/${item === null || item === void 0 ? void 0 : item.id}`;
|
|
60
|
-
console.debug('🌍 Portal:', "context changed, navigating to app's context url:", pathContextId
|
|
61
|
-
? `found context id [${pathContextId}] in url, ${item ? `replacing with [${item.id}]` : 'context was cleared, navigating to root'}`
|
|
62
|
-
: `could not find context id in url, navigating to context id [${item ? item.id : 'root'}]`);
|
|
63
|
+
if (item === undefined) {
|
|
64
|
+
// no-op
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const pathname = generatePathname(currentPathname, item, context, (_b = (_a = context === null || context === void 0 ? void 0 : context.extractContextIdFromPath) === null || _a === void 0 ? void 0 : _a.call(context, currentPathname)) !== null && _b !== void 0 ? _b : extractContextIdFromPath(currentPathname));
|
|
63
68
|
// if app has its own navigation, use it to navigate
|
|
64
69
|
if (appNavigation) {
|
|
65
70
|
// update the path of the app navigation, preserving search and hash
|
|
@@ -74,6 +79,7 @@ export const useAppContextNavigation = () => {
|
|
|
74
79
|
navigation,
|
|
75
80
|
// application navigation instance, may change when the application changes
|
|
76
81
|
appNavigation,
|
|
82
|
+
context,
|
|
77
83
|
]));
|
|
78
84
|
};
|
|
79
85
|
//# sourceMappingURL=useAppContextNavigation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAppContextNavigation.js","sourceRoot":"","sources":["../../../src/bin/dev-portal/useAppContextNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"useAppContextNavigation.js","sourceRoot":"","sources":["../../../src/bin/dev-portal/useAppContextNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAEpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAO3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD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