mirror of https://github.com/buster-so/buster.git
Merge pull request #1019 from buster-so/nate/hot-fix-report
Add some additional logs for report
This commit is contained in:
commit
317c3a86ad
|
@ -1,8 +1,4 @@
|
|||
import type {
|
||||
GetReportResponse,
|
||||
ReportResponse,
|
||||
UpdateReportResponse,
|
||||
} from '@buster/server-shared/reports';
|
||||
import type { GetReportResponse, UpdateReportResponse } from '@buster/server-shared/reports';
|
||||
import {
|
||||
type QueryClient,
|
||||
type UseQueryOptions,
|
||||
|
@ -11,7 +7,6 @@ import {
|
|||
useQueryClient,
|
||||
} from '@tanstack/react-query';
|
||||
import { create } from 'mutative';
|
||||
import type { BusterMetric } from '@/api/asset_interfaces/metric';
|
||||
import { collectionQueryKeys } from '@/api/query_keys/collection';
|
||||
import { reportsQueryKeys } from '@/api/query_keys/reports';
|
||||
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 { AppNoPageAccess } from '@/controllers/AppNoPageAccess';
|
||||
import { AppPasswordAccess } from '@/controllers/AppPasswordAccess';
|
||||
import { useMount } from '@/hooks/useMount';
|
||||
import { AppAssetNotFound } from '../../controllers/AppAssetNotFound';
|
||||
import { getAssetIdAndVersionNumber } from './getAssetIdAndVersionNumberServer';
|
||||
import { useGetAssetPasswordConfig } from './useGetAssetPasswordConfig';
|
||||
import { useShowLoader } from './useShowLoader';
|
||||
|
@ -31,8 +31,11 @@ export const AppAssetCheckLayout: React.FC<
|
|||
const showLoader = useShowLoader(assetId, assetType, versionNumber);
|
||||
|
||||
let content: React.ReactNode;
|
||||
|
||||
if (!isFetched) {
|
||||
return null;
|
||||
} else if (!assetId || !assetType) {
|
||||
return <AppAssetNotFound assetId={assetId} type={assetType} />;
|
||||
} else if (!hasAccess && !isPublic) {
|
||||
content = <AppNoPageAccess assetId={assetId} type={assetType} />;
|
||||
} else if (isPublic && passwordRequired) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { AssetType } from '@buster/server-shared/assets';
|
||||
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 type { RustApiError } from '@/api/errors';
|
||||
import { chatQueryKeys } from '@/api/query_keys/chat';
|
||||
|
@ -17,19 +17,17 @@ interface AssetAccess {
|
|||
isFetched: boolean;
|
||||
}
|
||||
|
||||
const getAssetAccess = (error: RustApiError | null, isFetched: boolean): AssetAccess => {
|
||||
if (!error) {
|
||||
return {
|
||||
hasAccess: true,
|
||||
passwordRequired: false,
|
||||
isPublic: false,
|
||||
isDeleted: false,
|
||||
isFetched,
|
||||
};
|
||||
const getAssetAccess = (
|
||||
error: RustApiError | null,
|
||||
isFetched: boolean,
|
||||
selectedQuery: QueryKey
|
||||
): AssetAccess => {
|
||||
if (error) {
|
||||
console.error('Error in getAssetAccess', error, isFetched, selectedQuery);
|
||||
}
|
||||
|
||||
// 418 is password required
|
||||
if (error.status === 418) {
|
||||
if (error?.status === 418) {
|
||||
return {
|
||||
hasAccess: false,
|
||||
passwordRequired: true,
|
||||
|
@ -40,7 +38,7 @@ const getAssetAccess = (error: RustApiError | null, isFetched: boolean): AssetAc
|
|||
}
|
||||
|
||||
// 410 is deleted
|
||||
if (error.status === 410) {
|
||||
if (error?.status === 410) {
|
||||
return {
|
||||
hasAccess: false,
|
||||
passwordRequired: false,
|
||||
|
@ -51,7 +49,7 @@ const getAssetAccess = (error: RustApiError | null, isFetched: boolean): AssetAc
|
|||
}
|
||||
|
||||
return {
|
||||
hasAccess: false,
|
||||
hasAccess: true,
|
||||
passwordRequired: false,
|
||||
isPublic: false,
|
||||
isDeleted: false,
|
||||
|
@ -92,8 +90,8 @@ export const useGetAssetPasswordConfig = (
|
|||
queryKey: selectedQuery.queryKey,
|
||||
enabled: true,
|
||||
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