mirror of https://github.com/buster-so/buster.git
create listing updates
This commit is contained in:
parent
d98c5f6e37
commit
f01c6d7dc5
|
@ -26,6 +26,7 @@ import {
|
|||
unshareCollection,
|
||||
updateCollectionShare
|
||||
} from './requests';
|
||||
import type { ShareAssetType } from '@buster/server-shared/share';
|
||||
|
||||
export const useGetCollectionsList = (
|
||||
filters: Omit<Parameters<typeof collectionsGetList>[0], 'page_token' | 'page_size'>,
|
||||
|
@ -309,7 +310,7 @@ export const useAddAndRemoveAssetsFromCollection = () => {
|
|||
async (variables: {
|
||||
collectionId: string;
|
||||
assets: {
|
||||
type: 'metric' | 'dashboard';
|
||||
type: Exclude<ShareAssetType, 'collection' | 'chat'>;
|
||||
id: string;
|
||||
}[];
|
||||
}) => {
|
||||
|
@ -330,7 +331,7 @@ export const useAddAndRemoveAssetsFromCollection = () => {
|
|||
currentCollection.assets
|
||||
?.filter((a) => !variables.assets.some((b) => b.id === a.id))
|
||||
.map((a) => ({
|
||||
type: a.asset_type as 'metric' | 'dashboard',
|
||||
type: a.asset_type as Exclude<ShareAssetType, 'collection' | 'chat'>,
|
||||
id: a.id
|
||||
})) || [];
|
||||
const addedAssets = variables.assets.filter(
|
||||
|
|
|
@ -107,7 +107,7 @@ export const addAssetToCollection = async ({
|
|||
}: {
|
||||
id: string;
|
||||
assets: {
|
||||
type: 'metric' | 'dashboard' | 'chat';
|
||||
type: Exclude<ShareAssetType, 'collection' | 'chat'>;
|
||||
id: string;
|
||||
}[];
|
||||
}) => {
|
||||
|
|
|
@ -15,6 +15,7 @@ import { formatDate } from '@/lib';
|
|||
import { ASSET_ICONS } from '../config/assetIcons';
|
||||
import type { BusterSearchResult } from '@/api/asset_interfaces/search';
|
||||
import type { BusterListRowItem } from '@/components/ui/list/BusterList';
|
||||
import type { ShareAssetType } from '@buster/server-shared/share';
|
||||
|
||||
export const AddToCollectionModal: React.FC<{
|
||||
open: boolean;
|
||||
|
@ -77,15 +78,19 @@ export const AddToCollectionModal: React.FC<{
|
|||
}, [searchResults]);
|
||||
|
||||
const handleAddAndRemoveMetrics = useMemoizedFn(async () => {
|
||||
const keyedAssets = rows.reduce<Record<string, { type: 'metric' | 'dashboard'; id: string }>>(
|
||||
(acc, asset) => {
|
||||
acc[asset.id] = { type: asset.data?.type as 'metric' | 'dashboard', id: asset.id };
|
||||
return acc;
|
||||
},
|
||||
{}
|
||||
);
|
||||
const keyedAssets = rows.reduce<
|
||||
Record<string, { type: Exclude<ShareAssetType, 'collection' | 'chat'>; id: string }>
|
||||
>((acc, asset) => {
|
||||
if (asset.data?.type && asset.data?.type !== 'collection' && asset.data?.type !== 'chat') {
|
||||
acc[asset.id] = { type: asset.data?.type, id: asset.id };
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const assets = selectedAssets.map<{ type: 'metric' | 'dashboard'; id: string }>((asset) => ({
|
||||
const assets = selectedAssets.map<{
|
||||
type: Exclude<ShareAssetType, 'collection' | 'chat'>;
|
||||
id: string;
|
||||
}>((asset) => ({
|
||||
id: asset,
|
||||
type: keyedAssets[asset].type
|
||||
}));
|
||||
|
|
|
@ -60,17 +60,7 @@ describe('useGetChatParams', () => {
|
|||
expect(result.current.chatId).toBe('chat-123');
|
||||
expect(result.current.messageId).toBe('msg-456');
|
||||
});
|
||||
it('handles metric version number from path parameter', () => {
|
||||
mockUseParams.mockReturnValue({
|
||||
metricId: 'metric-123',
|
||||
versionNumber: '42'
|
||||
});
|
||||
|
||||
const { result } = renderHook(() => useGetChatParams());
|
||||
|
||||
expect(result.current.metricId).toBe('metric-123');
|
||||
expect(result.current.metricVersionNumber).toBe(42);
|
||||
});
|
||||
it('handles metric version number from query parameter', () => {
|
||||
mockUseParams.mockReturnValue({
|
||||
metricId: 'metric-123'
|
||||
|
@ -83,17 +73,7 @@ describe('useGetChatParams', () => {
|
|||
|
||||
expect(result.current.metricVersionNumber).toBe(43);
|
||||
});
|
||||
it('handles dashboard version number from path parameter', () => {
|
||||
mockUseParams.mockReturnValue({
|
||||
dashboardId: 'dashboard-123',
|
||||
versionNumber: '44'
|
||||
});
|
||||
|
||||
const { result } = renderHook(() => useGetChatParams());
|
||||
|
||||
expect(result.current.dashboardId).toBe('dashboard-123');
|
||||
expect(result.current.dashboardVersionNumber).toBe(44);
|
||||
});
|
||||
it('handles dashboard version number from query parameter', () => {
|
||||
mockUseParams.mockReturnValue({
|
||||
dashboardId: 'dashboard-123'
|
||||
|
|
Loading…
Reference in New Issue