File tree Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -4,9 +4,10 @@ import { useRoute } from 'vue-router';
4
4
5
5
import LoadingModule from ' ./modules/LoadingModule.vue' ;
6
6
import ExternalSystem from ' ./ExternalSystem.vue' ;
7
- import { tryImportWithRetries } from ' .. /utils/moduleFederation' ;
7
+ import { tryImportWithRetries } from ' @ /utils/moduleFederation' ;
8
8
import { useSharedStore } from ' @/store/Shared' ;
9
- import { useFeatureFlagsStore } from ' ../store/featureFlags' ;
9
+ import { useFeatureFlagsStore } from ' @/store/featureFlags' ;
10
+ import { useModuleUpdateRoute } from ' @/composables/useModuleUpdateRoute' ;
10
11
11
12
const insightsApp = ref (null );
12
13
const useIframe = ref (false );
@@ -25,6 +26,8 @@ const route = useRoute();
25
26
const sharedStore = useSharedStore ();
26
27
const featureFlagsStore = useFeatureFlagsStore ();
27
28
29
+ useModuleUpdateRoute (' insights' );
30
+
28
31
async function mount ({ force = false } = {}) {
29
32
if (! force && ! props .modelValue ) {
30
33
return ;
@@ -47,7 +50,6 @@ async function mount({ force = false } = {}) {
47
50
48
51
insightsApp .value = await mountInsightsApp ({
49
52
containerId: ' insights-app' ,
50
- routerBase: ` /projects/${ sharedStore .current .project .uuid } /insights` ,
51
53
});
52
54
}
53
55
Original file line number Diff line number Diff line change
1
+ import { onMounted , onUnmounted } from 'vue' ;
2
+ import { useRouter } from 'vue-router' ;
3
+
4
+ /**
5
+ * Composable to handle updateRoute window events
6
+ * @param {string } routeName - The name of the route to navigate to
7
+ * @returns {void }
8
+ */
9
+ export function useModuleUpdateRoute ( routeName ) {
10
+ const router = useRouter ( ) ;
11
+
12
+ const handleUpdateRoute = ( event ) => {
13
+ const path = event . detail . path
14
+ . split ( '/' )
15
+ . slice ( 1 )
16
+ . filter ( ( item ) => item ) ;
17
+
18
+ if ( path . length ) {
19
+ router . replace ( {
20
+ name : routeName ,
21
+ params : {
22
+ internal : path ,
23
+ } ,
24
+ query : event . detail ?. query ,
25
+ } ) ;
26
+ }
27
+ } ;
28
+
29
+ onMounted ( ( ) => {
30
+ window . addEventListener ( 'updateRoute' , handleUpdateRoute ) ;
31
+ } ) ;
32
+
33
+ onUnmounted ( ( ) => {
34
+ window . removeEventListener ( 'updateRoute' , handleUpdateRoute ) ;
35
+ } ) ;
36
+ }
You can’t perform that action at this time.
0 commit comments