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