2025-03-06 12:47:49 +08:00
|
|
|
import type { SelectedFile } from '../../interfaces';
|
|
|
|
import type { ChatURLParsed } from './parsePathnameSegments';
|
|
|
|
|
2025-03-15 01:50:53 +08:00
|
|
|
export const initializeSelectedFile = (params: ChatURLParsed): SelectedFile | null => {
|
2025-03-06 12:47:49 +08:00
|
|
|
const { metricId, collectionId, datasetId, dashboardId, chatId, messageId } = params;
|
|
|
|
|
|
|
|
if (metricId) {
|
|
|
|
return {
|
|
|
|
id: metricId,
|
|
|
|
type: 'metric'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dashboardId) {
|
|
|
|
return {
|
|
|
|
id: dashboardId,
|
|
|
|
type: 'dashboard'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (messageId) {
|
|
|
|
return {
|
|
|
|
id: messageId,
|
|
|
|
type: 'reasoning'
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2025-03-15 01:50:53 +08:00
|
|
|
return null;
|
2025-03-06 12:47:49 +08:00
|
|
|
};
|