Skip to content

Commit c9b6757

Browse files
committed
[Obs AI Assistant] Simplify routing
1 parent 15ea681 commit c9b6757

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

x-pack/plugins/observability_ai_assistant/public/hooks/use_observability_ai_assistant_router.ts

+4-27
Original file line numberDiff line numberDiff line change
@@ -47,39 +47,16 @@ export function useObservabilityAIAssistantRouter(): StatefulObservabilityAIAssi
4747
...observabilityAIAssistantRouter,
4848
push: (...args) => {
4949
const next = link(...args);
50-
5150
history.push(next);
5251
},
53-
navigateToConversationsApp: (path, ...args) => {
54-
const [_, route, routeParam] = path.split('/');
55-
56-
const sanitized = routeParam.replace('{', '').replace('}', '');
57-
58-
const pathKey = args[0]?.path;
59-
60-
if (typeof pathKey !== 'object') {
61-
return;
62-
}
63-
64-
if (Object.keys(pathKey).length === 0) {
65-
navigateToApp('observabilityAIAssistant', {
66-
path: route,
67-
});
68-
return;
69-
}
70-
71-
if (Object.keys(pathKey).length === 1) {
72-
navigateToApp('observabilityAIAssistant', {
73-
// @ts-expect-error
74-
path: `${route}/${pathKey[sanitized]}`,
75-
});
76-
return;
77-
}
78-
},
7952
replace: (path, ...args) => {
8053
const next = link(path, ...args);
8154
history.replace(next);
8255
},
56+
navigateToConversationsApp: (path, ...args) => {
57+
const next = link(path, ...args);
58+
navigateToApp('observabilityAIAssistant', { path: next, replace: false });
59+
},
8360
link: (path, ...args) => {
8461
return http.basePath.prepend('/app/observabilityAIAssistant' + link(path, ...args));
8562
},

0 commit comments

Comments
 (0)