diff --git a/web/src/api/buster_rest/collections/requests.ts b/web/src/api/buster_rest/collections/requests.ts index 962615da1..6614c6d98 100644 --- a/web/src/api/buster_rest/collections/requests.ts +++ b/web/src/api/buster_rest/collections/requests.ts @@ -15,15 +15,19 @@ export const collectionsGetList = async (params: GetCollectionListParams) => { }; export const collectionsGetCollection = async (params: GetCollectionParams) => { - return await mainApi.get('/collections', { params }).then((res) => res.data); + return await mainApi + .get(`/collections/${params.id}`, { params }) + .then((res) => res.data); }; export const collectionsCreateCollection = async (params: CreateCollectionParams) => { - return await mainApi.post('/collections', { params }).then((res) => res.data); + return await mainApi.post('/collections', params).then((res) => res.data); }; export const collectionsUpdateCollection = async (params: UpdateCollectionParams) => { - return await mainApi.put('/collections', { params }).then((res) => res.data); + return await mainApi + .put(`/collections/${params.id}`, params) + .then((res) => res.data); }; export const collectionsDeleteCollection = async (params: DeleteCollectionParams) => { diff --git a/web/src/components/features/dropdowns/SaveToCollectionsDropdown.tsx b/web/src/components/features/dropdowns/SaveToCollectionsDropdown.tsx index 455f99a34..e4ec61017 100644 --- a/web/src/components/features/dropdowns/SaveToCollectionsDropdown.tsx +++ b/web/src/components/features/dropdowns/SaveToCollectionsDropdown.tsx @@ -16,7 +16,7 @@ export const SaveToCollectionsDropdown: React.FC<{ onSaveToCollection: (collectionId: string[]) => Promise; onRemoveFromCollection: (collectionId: string) => Promise; }> = React.memo(({ children, onRemoveFromCollection, onSaveToCollection, selectedCollections }) => { - const { data: collectionsList } = useGetCollectionsList({}); + const { data: collectionsList, isPending: isCreatingCollection } = useGetCollectionsList({}); const onChangePage = useAppLayoutContextSelector((s) => s.onChangePage); const [openCollectionModal, setOpenCollectionModal] = React.useState(false); const [showDropdown, setShowDropdown] = React.useState(false); @@ -34,14 +34,7 @@ export const SaveToCollectionsDropdown: React.FC<{ }) }; }); - - return [ - ...collectionsItems, - { - value: 'new', - label: 'New collection' - } - ]; + return collectionsItems; }, [collectionsList, selectedCollections]); const onClickItem = useMemoizedFn((collection: BusterCollectionListItem) => { @@ -69,34 +62,38 @@ export const SaveToCollectionsDropdown: React.FC<{ const onOpenChange = useMemoizedFn((open: boolean) => { setShowDropdown(open); - console.log('open', open); }); - const onClick = useMemoizedFn(() => { + const onOpenNewCollectionModal = useMemoizedFn(() => { setOpenCollectionModal(true); setShowDropdown(false); }); const memoizedButton = useMemo(() => { return ( - ); - }, [onClick]); + }, [onOpenNewCollectionModal]); return ( <> 0 ? 'Save to a collection' : undefined} onOpenChange={onOpenChange} footerContent={memoizedButton} + emptyStateText="No collections found" items={items}> -
- {children} -
+ {children}
0 ? 'Save to a dashboard' : undefined} open={showDropdown} onOpenChange={onOpenChange} footerContent={memoizedButton} diff --git a/web/src/components/ui/dropdown/Dropdown.tsx b/web/src/components/ui/dropdown/Dropdown.tsx index 4b86202bb..435fcece4 100644 --- a/web/src/components/ui/dropdown/Dropdown.tsx +++ b/web/src/components/ui/dropdown/Dropdown.tsx @@ -159,7 +159,9 @@ export const DropdownBase = ({ onOpenChange={onOpenChange} dir={dir} modal={modal}> - {children} + + {children} +