simplify asset access passthrough

This commit is contained in:
Nate Kelley 2025-09-24 11:51:43 -06:00
parent f6e910fb1f
commit f2a3546596
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 18 additions and 18 deletions

View File

@ -1,5 +1,5 @@
import type { ShareAssetType, ShareConfig } from '@buster/server-shared/share';
import { useRouter } from '@tanstack/react-router';
import { type ParsedLocation, useRouter } from '@tanstack/react-router';
import React, { useMemo, useState } from 'react';
import { useBusterNotifications } from '@/context/BusterNotifications';
import { useMemoizedFn } from '@/hooks/useMemoizedFn';
@ -25,7 +25,7 @@ export const ShareMenuContent: React.FC<{
const { buildLocation } = useRouter();
const embedlinkUrl: string = useMemo(() => {
let url = '';
let url: ParsedLocation | string = '';
if (!assetId) {
return '';
}
@ -35,39 +35,39 @@ export const ShareMenuContent: React.FC<{
params: {
metricId: assetId,
},
}).href;
});
} else if (assetType === 'dashboard_file') {
url = buildLocation({
to: '/embed/dashboard/$dashboardId',
params: {
dashboardId: assetId,
},
}).href;
});
} else if (assetType === 'collection') {
url = buildLocation({
to: '/auth/login',
}).href;
});
} else if (assetType === 'report_file') {
url = buildLocation({
to: '/embed/report/$reportId',
params: {
reportId: assetId,
},
}).href;
});
} else if (assetType === 'chat') {
url = buildLocation({
to: '/auth/login',
}).href;
});
} else {
const _exhaustiveCheck: never = assetType;
}
const urlWithDomain: string = window.location.origin + url;
const urlWithDomain: string = createFullURL(url);
return urlWithDomain;
}, [assetId, assetType, buildLocation]);
const linkUrl: string = useMemo(() => {
let url = '';
let url: ParsedLocation | string = '';
if (!assetId) {
return '';
}
@ -77,38 +77,38 @@ export const ShareMenuContent: React.FC<{
params: {
metricId: assetId,
},
}).href;
});
} else if (assetType === 'dashboard_file') {
url = buildLocation({
to: '/app/dashboards/$dashboardId',
params: {
dashboardId: assetId,
},
}).href;
});
} else if (assetType === 'collection') {
url = buildLocation({
to: '/app/collections/$collectionId',
params: {
collectionId: assetId,
},
}).href;
});
} else if (assetType === 'report_file') {
url = buildLocation({
to: '/app/reports/$reportId',
params: {
reportId: assetId,
},
}).href;
});
} else if (assetType === 'chat') {
url = buildLocation({
to: '/app/chats/$chatId',
params: {
chatId: assetId,
},
}).href;
});
}
const urlWithDomain: string = window.location.origin + url;
const urlWithDomain: string = createFullURL(url);
return urlWithDomain;
}, [assetId, buildLocation]);

View File

@ -36,14 +36,14 @@ export const AppAssetCheckLayout: React.FC<
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) {
} else if (isPublic && passwordRequired && !hasAccess) {
content = (
<AppPasswordAccess assetId={assetId} type={assetType}>
{children}
</AppPasswordAccess>
);
} else if (!hasAccess) {
content = <AppNoPageAccess assetId={assetId} type={assetType} />;
} else {
content = children;
}