mirror of https://github.com/buster-so/buster.git
share menu updates for report
This commit is contained in:
parent
fda555211a
commit
153756b3db
|
@ -169,41 +169,9 @@ const dashboardItems: IDropdownItem<ShareRole>[] = [
|
|||
},
|
||||
];
|
||||
|
||||
const collectionItems: IDropdownItem<ShareRole>[] = [
|
||||
{
|
||||
value: 'full_access',
|
||||
label: 'Full access',
|
||||
secondaryLabel: 'Can edit and share with others.',
|
||||
},
|
||||
{
|
||||
value: 'can_edit',
|
||||
label: 'Can edit',
|
||||
secondaryLabel: 'Can edit but not share with others.',
|
||||
},
|
||||
{
|
||||
value: 'can_view',
|
||||
label: 'Can view',
|
||||
secondaryLabel: 'Can view assets but not edit.',
|
||||
},
|
||||
];
|
||||
const collectionItems: IDropdownItem<ShareRole>[] = metricItems;
|
||||
|
||||
const reportItems: IDropdownItem<ShareRole>[] = [
|
||||
{
|
||||
value: 'full_access',
|
||||
label: 'Full access',
|
||||
secondaryLabel: 'Can edit and share with others.',
|
||||
},
|
||||
{
|
||||
value: 'can_edit',
|
||||
label: 'Can edit',
|
||||
secondaryLabel: 'Can edit but not share with others.',
|
||||
},
|
||||
{
|
||||
value: 'can_view',
|
||||
label: 'Can view',
|
||||
secondaryLabel: 'Can view asset but not edit.',
|
||||
},
|
||||
];
|
||||
const reportItems: IDropdownItem<ShareRole>[] = metricItems;
|
||||
|
||||
const workspaceItems: IDropdownItem<WorkspaceShareRole>[] = [
|
||||
{
|
||||
|
|
|
@ -25,27 +25,46 @@ export const ShareMenuContent: React.FC<{
|
|||
|
||||
const onCopyLink = useMemoizedFn(() => {
|
||||
let url = '';
|
||||
if (assetType === 'metric' && assetId) {
|
||||
if (!assetId) {
|
||||
return;
|
||||
}
|
||||
if (assetType === 'metric') {
|
||||
url = buildLocation({
|
||||
to: '/app/metrics/$metricId/chart',
|
||||
params: {
|
||||
metricId: assetId,
|
||||
},
|
||||
}).href;
|
||||
} else if (assetType === 'dashboard' && assetId) {
|
||||
} else if (assetType === 'dashboard') {
|
||||
url = buildLocation({
|
||||
to: '/app/dashboards/$dashboardId',
|
||||
params: {
|
||||
dashboardId: assetId,
|
||||
},
|
||||
}).href;
|
||||
} else if (assetType === 'collection' && assetId) {
|
||||
} else if (assetType === 'collection') {
|
||||
url = buildLocation({
|
||||
to: '/app/collections/$collectionId',
|
||||
params: {
|
||||
collectionId: assetId,
|
||||
},
|
||||
}).href;
|
||||
} else if (assetType === 'report') {
|
||||
url = buildLocation({
|
||||
to: '/app/reports/$reportId',
|
||||
params: {
|
||||
reportId: assetId,
|
||||
},
|
||||
}).href;
|
||||
} else if (assetType === 'chat') {
|
||||
url = buildLocation({
|
||||
to: '/app/chats/$chatId',
|
||||
params: {
|
||||
chatId: assetId,
|
||||
},
|
||||
}).href;
|
||||
} else {
|
||||
const _exhaustiveCheck: never = assetType;
|
||||
}
|
||||
const urlWithDomain = window.location.origin + url;
|
||||
navigator.clipboard.writeText(urlWithDomain);
|
||||
|
|
|
@ -6,6 +6,7 @@ import type {
|
|||
} from '@buster/server-shared/share';
|
||||
import pluralize from 'pluralize';
|
||||
import React from 'react';
|
||||
import { useUnshareChat, useUpdateChatShare } from '@/api/buster_rest/chats';
|
||||
import { useUnshareCollection, useUpdateCollectionShare } from '@/api/buster_rest/collections';
|
||||
import { useUnshareDashboard, useUpdateDashboardShare } from '@/api/buster_rest/dashboards';
|
||||
import { useUnshareMetric, useUpdateMetricShare } from '@/api/buster_rest/metrics';
|
||||
|
@ -74,10 +75,12 @@ const ShareMenuContentShare: React.FC<ShareMenuContentBodyProps> = React.memo(
|
|||
const { mutateAsync: onUpdateDashboardShare } = useUpdateDashboardShare();
|
||||
const { mutateAsync: onUpdateCollectionShare } = useUpdateCollectionShare();
|
||||
const { mutateAsync: onUpdateReportShare } = useUpdateReportShare();
|
||||
const { mutateAsync: onUpdateChatShare } = useUpdateChatShare();
|
||||
const { mutateAsync: onUnshareMetric } = useUnshareMetric();
|
||||
const { mutateAsync: onUnshareDashboard } = useUnshareDashboard();
|
||||
const { mutateAsync: onUnshareCollection } = useUnshareCollection();
|
||||
const { mutateAsync: onUnshareReport } = useUnshareReport();
|
||||
const { mutateAsync: onUnshareChat } = useUnshareChat();
|
||||
|
||||
const hasIndividualPermissions = !!individual_permissions?.length;
|
||||
const workspaceMemberCount = shareAssetConfig.workspace_member_count || 0;
|
||||
|
@ -93,11 +96,10 @@ const ShareMenuContentShare: React.FC<ShareMenuContentBodyProps> = React.memo(
|
|||
} else if (assetType === 'report') {
|
||||
return await onUpdateReportShare(payload);
|
||||
} else if (assetType === 'chat') {
|
||||
// TODO: Implement chat sharing when available
|
||||
return;
|
||||
return await onUpdateChatShare(payload);
|
||||
} else {
|
||||
const _exhaustiveCheck: never = assetType;
|
||||
}
|
||||
|
||||
const _exhaustiveCheck: never = assetType;
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -129,7 +131,9 @@ const ShareMenuContentShare: React.FC<ShareMenuContentBodyProps> = React.memo(
|
|||
} else if (assetType === 'report') {
|
||||
await onUnshareReport(payload);
|
||||
} else if (assetType === 'chat') {
|
||||
// TODO: Implement chat unsharing when available
|
||||
await onUnshareChat(payload);
|
||||
} else {
|
||||
const _exhaustiveCheck: never = assetType;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import type { ShareAssetType, ShareConfig, ShareRole } from '@buster/server-shared/share';
|
||||
import React, { useMemo } from 'react';
|
||||
import { useShareChat } from '@/api/buster_rest/chats';
|
||||
import { useShareCollection } from '@/api/buster_rest/collections';
|
||||
import { useShareDashboard } from '@/api/buster_rest/dashboards';
|
||||
import { useShareMetric } from '@/api/buster_rest/metrics';
|
||||
import { useShareReport } from '@/api/buster_rest/reports';
|
||||
import { Button } from '@/components/ui/buttons';
|
||||
import { InputSearchDropdown } from '@/components/ui/inputs/InputSearchDropdown';
|
||||
import { useBusterNotifications } from '@/context/BusterNotifications';
|
||||
|
@ -29,6 +31,8 @@ export const ShareMenuInvite: React.FC<ShareMenuInviteProps> = React.memo(
|
|||
const { mutateAsync: onShareDashboard, isPending: isInvitingDashboard } = useShareDashboard();
|
||||
const { mutateAsync: onShareCollection, isPending: isInvitingCollection } =
|
||||
useShareCollection();
|
||||
const { mutateAsync: onShareChat, isPending: isInvitingChat } = useShareChat();
|
||||
const { mutateAsync: onShareReport, isPending: isInvitingReport } = useShareReport();
|
||||
|
||||
const [inputValue, setInputValue] = React.useState<string>('');
|
||||
|
||||
|
@ -44,7 +48,8 @@ export const ShareMenuInvite: React.FC<ShareMenuInviteProps> = React.memo(
|
|||
});
|
||||
|
||||
const disableSubmit = !inputHasText(inputValue) || !isValidEmail(inputValue);
|
||||
const isInviting = isInvitingMetric || isInvitingDashboard || isInvitingCollection;
|
||||
const isInviting =
|
||||
isInvitingMetric || isInvitingDashboard || isInvitingCollection || isInvitingChat;
|
||||
|
||||
const options: SelectItem<string>[] = useMemo(() => {
|
||||
return (
|
||||
|
@ -103,6 +108,12 @@ export const ShareMenuInvite: React.FC<ShareMenuInviteProps> = React.memo(
|
|||
await onShareDashboard(payload);
|
||||
} else if (assetType === 'collection') {
|
||||
await onShareCollection(payload);
|
||||
} else if (assetType === 'chat') {
|
||||
await onShareChat(payload);
|
||||
} else if (assetType === 'report') {
|
||||
await onShareReport(payload);
|
||||
} else {
|
||||
const _exhaustiveCheck: never = assetType;
|
||||
}
|
||||
|
||||
setInputValue('');
|
||||
|
|
Loading…
Reference in New Issue