mirror of https://github.com/buster-so/buster.git
save to dropdown bug fixes
This commit is contained in:
parent
fd6bf7fa33
commit
017ec722e4
|
@ -15,13 +15,7 @@ export const SaveToCollectionsDropdown: React.FC<{
|
|||
onSaveToCollection: (collectionId: string[]) => Promise<void>;
|
||||
onRemoveFromCollection: (collectionId: string) => Promise<void>;
|
||||
}> = React.memo(({ children, onRemoveFromCollection, onSaveToCollection, selectedCollections }) => {
|
||||
const [showDropdown, setShowDropdown] = React.useState(false);
|
||||
|
||||
const onOpenChange = useMemoizedFn((open: boolean) => {
|
||||
setShowDropdown(open);
|
||||
});
|
||||
|
||||
const { modal, selectType, footerContent, menuHeader, items } =
|
||||
const { ModalComponent, selectType, footerContent, menuHeader, items } =
|
||||
useSaveToCollectionsDropdownContent({
|
||||
selectedCollections,
|
||||
onSaveToCollection,
|
||||
|
@ -35,14 +29,13 @@ export const SaveToCollectionsDropdown: React.FC<{
|
|||
align="end"
|
||||
selectType={selectType}
|
||||
menuHeader={menuHeader}
|
||||
onOpenChange={onOpenChange}
|
||||
footerContent={footerContent}
|
||||
emptyStateText="No collections found"
|
||||
items={items}>
|
||||
{children}
|
||||
</Dropdown>
|
||||
|
||||
{modal}
|
||||
{ModalComponent}
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
@ -61,7 +54,7 @@ export const useSaveToCollectionsDropdownContent = ({
|
|||
DropdownProps,
|
||||
'items' | 'footerContent' | 'menuHeader' | 'selectType' | 'emptyStateText'
|
||||
> & {
|
||||
modal: React.ReactNode;
|
||||
ModalComponent: React.ReactNode;
|
||||
} => {
|
||||
const { data: collectionsList, isPending: isCreatingCollection } = useGetCollectionsList({});
|
||||
const onChangePage = useAppLayoutContextSelector((s) => s.onChangePage);
|
||||
|
@ -135,7 +128,7 @@ export const useSaveToCollectionsDropdownContent = ({
|
|||
footerContent,
|
||||
selectType: 'multiple',
|
||||
emptyStateText: 'No collections found',
|
||||
modal: (
|
||||
ModalComponent: (
|
||||
<NewCollectionModal
|
||||
open={openCollectionModal}
|
||||
onClose={onCloseCollectionModal}
|
||||
|
|
|
@ -34,21 +34,24 @@ export const SaveToDashboardDropdown: React.FC<{
|
|||
onOpenChangeProp?.(open);
|
||||
});
|
||||
|
||||
const dropdownProps = useSaveToDashboardDropdownContent({
|
||||
const { ModalComponent, ...dropdownProps } = useSaveToDashboardDropdownContent({
|
||||
selectedDashboards,
|
||||
onSaveToDashboard,
|
||||
onRemoveFromDashboard
|
||||
});
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
side={side}
|
||||
align={align}
|
||||
open={showDropdown}
|
||||
onOpenChange={onOpenChange}
|
||||
{...dropdownProps}>
|
||||
{children}
|
||||
</Dropdown>
|
||||
<>
|
||||
<Dropdown
|
||||
side={side}
|
||||
align={align}
|
||||
open={showDropdown}
|
||||
onOpenChange={onOpenChange}
|
||||
{...dropdownProps}>
|
||||
{children}
|
||||
</Dropdown>
|
||||
{ModalComponent}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
@ -63,7 +66,9 @@ export const useSaveToDashboardDropdownContent = ({
|
|||
}): Pick<
|
||||
DropdownProps,
|
||||
'items' | 'footerContent' | 'menuHeader' | 'selectType' | 'emptyStateText'
|
||||
> => {
|
||||
> & {
|
||||
ModalComponent: React.ReactNode;
|
||||
} => {
|
||||
const { data: dashboardsList } = useGetDashboardsList({});
|
||||
const onChangePage = useAppLayoutContextSelector((x) => x.onChangePage);
|
||||
const [openNewDashboardModal, setOpenNewDashboardModal] = useState(false);
|
||||
|
@ -130,7 +135,7 @@ export const useSaveToDashboardDropdownContent = ({
|
|||
menuHeader,
|
||||
selectType: 'multiple',
|
||||
emptyStateText: 'No dashboards found',
|
||||
modal: (
|
||||
ModalComponent: (
|
||||
<NewDashboardModal
|
||||
open={openNewDashboardModal}
|
||||
onClose={onCloseNewDashboardModal}
|
||||
|
|
|
@ -15,6 +15,7 @@ export const NewDashboardModal: React.FC<{
|
|||
useChangePage?: boolean;
|
||||
onDashboardCreated?: (dashboardId: string) => void;
|
||||
}> = React.memo(({ onClose, open, useChangePage = true, onDashboardCreated }) => {
|
||||
console.log('NewDashboardModal', open);
|
||||
const [title, setTitle] = React.useState('');
|
||||
const inputRef = React.useRef<HTMLInputElement>(null);
|
||||
const { mutateAsync: createNewDashboard, isPending: isCreatingDashboard } = useCreateDashboard();
|
||||
|
|
|
@ -103,12 +103,7 @@ export const DropdownBase = <T,>({
|
|||
showEmptyState = true
|
||||
}: DropdownProps<T>) => {
|
||||
return (
|
||||
<DropdownMenu
|
||||
open={open}
|
||||
defaultOpen={open}
|
||||
onOpenChange={onOpenChange}
|
||||
dir={dir}
|
||||
modal={modal}>
|
||||
<DropdownMenu open={open} defaultOpen={open} onOpenChange={onOpenChange} dir={dir}>
|
||||
<DropdownMenuTrigger asChild disabled={disabled}>
|
||||
<span className="dropdown-trigger">{children}</span>
|
||||
</DropdownMenuTrigger>
|
||||
|
|
|
@ -9,6 +9,7 @@ import { DashboardListContent } from './DashboardListContent';
|
|||
|
||||
export const DashboardListController: React.FC = () => {
|
||||
const [openNewDashboardModal, setOpenNewDashboardModal] = useState(false);
|
||||
console.log('DashboardListController', openNewDashboardModal);
|
||||
const [dashboardListFilters, setDashboardListFilters] = useState<{
|
||||
shared_with_me?: boolean;
|
||||
only_my_dashboards?: boolean;
|
||||
|
|
Loading…
Reference in New Issue