mirror of https://github.com/buster-so/buster.git
Add some additional logs for report
This commit is contained in:
parent
44fd488df0
commit
0df89c0ba9
|
@ -1,8 +1,4 @@
|
||||||
import type {
|
import type { GetReportResponse, UpdateReportResponse } from '@buster/server-shared/reports';
|
||||||
GetReportResponse,
|
|
||||||
ReportResponse,
|
|
||||||
UpdateReportResponse,
|
|
||||||
} from '@buster/server-shared/reports';
|
|
||||||
import {
|
import {
|
||||||
type QueryClient,
|
type QueryClient,
|
||||||
type UseQueryOptions,
|
type UseQueryOptions,
|
||||||
|
@ -11,7 +7,6 @@ import {
|
||||||
useQueryClient,
|
useQueryClient,
|
||||||
} from '@tanstack/react-query';
|
} from '@tanstack/react-query';
|
||||||
import { create } from 'mutative';
|
import { create } from 'mutative';
|
||||||
import type { BusterMetric } from '@/api/asset_interfaces/metric';
|
|
||||||
import { collectionQueryKeys } from '@/api/query_keys/collection';
|
import { collectionQueryKeys } from '@/api/query_keys/collection';
|
||||||
import { reportsQueryKeys } from '@/api/query_keys/reports';
|
import { reportsQueryKeys } from '@/api/query_keys/reports';
|
||||||
import type { RustApiError } from '../../errors';
|
import type { RustApiError } from '../../errors';
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
import type { AssetType } from '@buster/server-shared/assets';
|
||||||
|
import type { ResponseMessageFileType } from '@buster/server-shared/chats';
|
||||||
|
import { Link } from '@tanstack/react-router';
|
||||||
|
import React from 'react';
|
||||||
|
import { BusterLogo } from '@/assets/svg/BusterLogo';
|
||||||
|
import { Button } from '@/components/ui/buttons';
|
||||||
|
import { Title } from '@/components/ui/typography';
|
||||||
|
import { useMount } from '@/hooks/useMount';
|
||||||
|
import { AppNoPageAccess } from './AppNoPageAccess';
|
||||||
|
|
||||||
|
export const AppAssetNotFound: React.FC<{
|
||||||
|
assetId: string;
|
||||||
|
type: AssetType | ResponseMessageFileType;
|
||||||
|
}> = React.memo(({ type, assetId }) => {
|
||||||
|
useMount(() => {
|
||||||
|
console.info('AppAssetNotFound for asset:', assetId, 'and type:', type);
|
||||||
|
});
|
||||||
|
return (
|
||||||
|
<div className="flex h-[85vh] w-full flex-col items-center justify-center space-y-6">
|
||||||
|
<BusterLogo className="h-16 w-16" />
|
||||||
|
|
||||||
|
<div className="max-w-[550px] text-center">
|
||||||
|
<Title as="h2" className="text-center">
|
||||||
|
{`It looks like this asset is does not exist...`}
|
||||||
|
</Title>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex space-x-2">
|
||||||
|
<Link to="/app/home">
|
||||||
|
<Button>Go home</Button>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
AppNoPageAccess.displayName = 'AppNoPageAccess';
|
|
@ -5,7 +5,7 @@ import type React from 'react';
|
||||||
import { FileIndeterminateLoader } from '@/components/features/loaders/FileIndeterminateLoader';
|
import { FileIndeterminateLoader } from '@/components/features/loaders/FileIndeterminateLoader';
|
||||||
import { AppNoPageAccess } from '@/controllers/AppNoPageAccess';
|
import { AppNoPageAccess } from '@/controllers/AppNoPageAccess';
|
||||||
import { AppPasswordAccess } from '@/controllers/AppPasswordAccess';
|
import { AppPasswordAccess } from '@/controllers/AppPasswordAccess';
|
||||||
import { useMount } from '@/hooks/useMount';
|
import { AppAssetNotFound } from '../../controllers/AppAssetNotFound';
|
||||||
import { getAssetIdAndVersionNumber } from './getAssetIdAndVersionNumberServer';
|
import { getAssetIdAndVersionNumber } from './getAssetIdAndVersionNumberServer';
|
||||||
import { useGetAssetPasswordConfig } from './useGetAssetPasswordConfig';
|
import { useGetAssetPasswordConfig } from './useGetAssetPasswordConfig';
|
||||||
import { useShowLoader } from './useShowLoader';
|
import { useShowLoader } from './useShowLoader';
|
||||||
|
@ -31,8 +31,11 @@ export const AppAssetCheckLayout: React.FC<
|
||||||
const showLoader = useShowLoader(assetId, assetType, versionNumber);
|
const showLoader = useShowLoader(assetId, assetType, versionNumber);
|
||||||
|
|
||||||
let content: React.ReactNode;
|
let content: React.ReactNode;
|
||||||
|
|
||||||
if (!isFetched) {
|
if (!isFetched) {
|
||||||
return null;
|
return null;
|
||||||
|
} else if (!assetId || !assetType) {
|
||||||
|
return <AppAssetNotFound assetId={assetId} type={assetType} />;
|
||||||
} else if (!hasAccess && !isPublic) {
|
} else if (!hasAccess && !isPublic) {
|
||||||
content = <AppNoPageAccess assetId={assetId} type={assetType} />;
|
content = <AppNoPageAccess assetId={assetId} type={assetType} />;
|
||||||
} else if (isPublic && passwordRequired) {
|
} else if (isPublic && passwordRequired) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { AssetType } from '@buster/server-shared/assets';
|
import type { AssetType } from '@buster/server-shared/assets';
|
||||||
import type { ResponseMessageFileType } from '@buster/server-shared/chats';
|
import type { ResponseMessageFileType } from '@buster/server-shared/chats';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { type QueryKey, useQuery } from '@tanstack/react-query';
|
||||||
import { useCallback, useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
import type { RustApiError } from '@/api/errors';
|
import type { RustApiError } from '@/api/errors';
|
||||||
import { chatQueryKeys } from '@/api/query_keys/chat';
|
import { chatQueryKeys } from '@/api/query_keys/chat';
|
||||||
|
@ -17,19 +17,17 @@ interface AssetAccess {
|
||||||
isFetched: boolean;
|
isFetched: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getAssetAccess = (error: RustApiError | null, isFetched: boolean): AssetAccess => {
|
const getAssetAccess = (
|
||||||
if (!error) {
|
error: RustApiError | null,
|
||||||
return {
|
isFetched: boolean,
|
||||||
hasAccess: true,
|
selectedQuery: QueryKey
|
||||||
passwordRequired: false,
|
): AssetAccess => {
|
||||||
isPublic: false,
|
if (error) {
|
||||||
isDeleted: false,
|
console.error('Error in getAssetAccess', error, isFetched, selectedQuery);
|
||||||
isFetched,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 418 is password required
|
// 418 is password required
|
||||||
if (error.status === 418) {
|
if (error?.status === 418) {
|
||||||
return {
|
return {
|
||||||
hasAccess: false,
|
hasAccess: false,
|
||||||
passwordRequired: true,
|
passwordRequired: true,
|
||||||
|
@ -40,7 +38,7 @@ const getAssetAccess = (error: RustApiError | null, isFetched: boolean): AssetAc
|
||||||
}
|
}
|
||||||
|
|
||||||
// 410 is deleted
|
// 410 is deleted
|
||||||
if (error.status === 410) {
|
if (error?.status === 410) {
|
||||||
return {
|
return {
|
||||||
hasAccess: false,
|
hasAccess: false,
|
||||||
passwordRequired: false,
|
passwordRequired: false,
|
||||||
|
@ -51,7 +49,7 @@ const getAssetAccess = (error: RustApiError | null, isFetched: boolean): AssetAc
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hasAccess: false,
|
hasAccess: true,
|
||||||
passwordRequired: false,
|
passwordRequired: false,
|
||||||
isPublic: false,
|
isPublic: false,
|
||||||
isDeleted: false,
|
isDeleted: false,
|
||||||
|
@ -92,8 +90,8 @@ export const useGetAssetPasswordConfig = (
|
||||||
queryKey: selectedQuery.queryKey,
|
queryKey: selectedQuery.queryKey,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
select: useCallback((v: unknown) => !!v, []),
|
select: useCallback((v: unknown) => !!v, []),
|
||||||
notifyOnChangeProps: ['error', 'isFetched'],
|
notifyOnChangeProps: ['error', 'isFetched', 'data'],
|
||||||
});
|
});
|
||||||
|
|
||||||
return getAssetAccess(error, isFetched);
|
return getAssetAccess(error, isFetched, selectedQuery.queryKey);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue