mirror of https://github.com/buster-so/buster.git
Remove false positive in report
This commit is contained in:
parent
3b819cdf7e
commit
5b01949baa
|
@ -16,6 +16,7 @@ export const useIsAssetFileChanged = () => {
|
||||||
dashboardId: assetId,
|
dashboardId: assetId,
|
||||||
enabled: assetType === 'dashboard_file',
|
enabled: assetType === 'dashboard_file',
|
||||||
});
|
});
|
||||||
|
console.log('reportParams', assetId, assetType);
|
||||||
const reportParams = useIsReportFileChanged({
|
const reportParams = useIsReportFileChanged({
|
||||||
reportId: assetId,
|
reportId: assetId,
|
||||||
enabled: assetType === 'report_file',
|
enabled: assetType === 'report_file',
|
||||||
|
|
|
@ -6,53 +6,66 @@ import {
|
||||||
} from '@tanstack/react-router';
|
} from '@tanstack/react-router';
|
||||||
|
|
||||||
export const useSelectedAssetType = (): NonNullable<StaticDataRouteOption['assetType']> => {
|
export const useSelectedAssetType = (): NonNullable<StaticDataRouteOption['assetType']> => {
|
||||||
const lastMatch = useMatches({
|
const { dashboardId, metricId, reportId, chatId, collectionId, messageId } = useParams({
|
||||||
select: (matches) => matches.reverse().find((match) => match.staticData?.assetType),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (typeof lastMatch === 'number') {
|
|
||||||
return 'chat';
|
|
||||||
}
|
|
||||||
const data = lastMatch?.staticData?.assetType as StaticDataRouteOption['assetType'];
|
|
||||||
const { messageId } = useParams({
|
|
||||||
strict: false,
|
strict: false,
|
||||||
});
|
});
|
||||||
if (messageId || !data) {
|
|
||||||
|
if (metricId) {
|
||||||
|
return 'metric_file';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (messageId) {
|
||||||
return 'reasoning';
|
return 'reasoning';
|
||||||
}
|
}
|
||||||
return data;
|
|
||||||
|
if (dashboardId) {
|
||||||
|
return 'dashboard_file';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reportId) {
|
||||||
|
return 'report_file';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chatId) {
|
||||||
|
return 'chat';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collectionId) {
|
||||||
|
return 'collection';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'metric_file';
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useSelectedAssetId = () => {
|
export const useSelectedAssetId = () => {
|
||||||
const assetType = useSelectedAssetType();
|
const { dashboardId, metricId, reportId, chatId, collectionId, messageId } = useParams({
|
||||||
const params = useParams({ strict: false });
|
strict: false,
|
||||||
|
});
|
||||||
|
|
||||||
if (assetType === 'dashboard_file') {
|
if (metricId) {
|
||||||
return params?.dashboardId;
|
return metricId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assetType === 'report_file') {
|
if (dashboardId) {
|
||||||
return params?.reportId;
|
return dashboardId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assetType === 'collection') {
|
if (reportId) {
|
||||||
return params?.collectionId;
|
return reportId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assetType === 'metric_file') {
|
if (chatId) {
|
||||||
return params?.metricId;
|
return chatId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assetType === 'chat') {
|
if (collectionId) {
|
||||||
return params?.chatId;
|
return collectionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assetType === 'reasoning') {
|
if (messageId) {
|
||||||
return params?.messageId;
|
return messageId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const _exhaustiveCheck: never = assetType;
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue