import { useAddDashboardToCollection, useDeleteDashboards, useGetDashboard, useRemoveDashboardFromCollection } from '@/api/buster_rest/dashboards'; import { DropdownContent, DropdownItem, DropdownItems } from '@/components/ui/dropdown'; import { Trash, Dots, Pencil, History, Star, ShareRight, Plus, Filter } from '@/components/ui/icons'; import { Star as StarFilled } from '@/components/ui/icons/NucleoIconFilled'; import { useBusterNotifications } from '@/context/BusterNotifications'; import { useChatLayoutContextSelector } from '@/layouts/ChatLayout/ChatLayoutContext'; import { useMemo } from 'react'; import { Dropdown } from '@/components/ui/dropdown'; import { Button } from '@/components/ui/buttons'; import React from 'react'; import { timeFromNow } from '@/lib/date'; import { ASSET_ICONS } from '@/components/features/config/assetIcons'; import { useMemoizedFn } from '@/hooks'; import { useSaveToCollectionsDropdownContent } from '@/components/features/dropdowns/SaveToCollectionsDropdown'; import { ShareAssetType } from '@/api/asset_interfaces/share'; import { useFavoriteStar } from '@/components/features/list/FavoriteStar'; import { timeout } from '@/lib'; import { ShareMenuContent } from '@/components/features/ShareMenu/ShareMenuContent'; import { DASHBOARD_TITLE_INPUT_ID } from '@/controllers/DashboardController/DashboardViewDashboardController/DashboardEditTitle'; import { canEdit, canFilter, getIsEffectiveOwner } from '@/lib/share'; import { getShareAssetConfig } from '@/components/features/ShareMenu/helpers'; import { useDashboardContentStore } from '@/context/Dashboards'; export const DashboardThreeDotMenu = React.memo(({ dashboardId }: { dashboardId: string }) => { const versionHistoryItems = useVersionHistorySelectMenu({ dashboardId }); const collectionSelectMenu = useCollectionSelectMenu({ dashboardId }); const favoriteDashboard = useFavoriteDashboardSelectMenu({ dashboardId }); const deleteDashboardMenu = useDeleteDashboardSelectMenu({ dashboardId }); const renameDashboardMenu = useRenameDashboardSelectMenu({ dashboardId }); const shareMenu = useShareMenuSelectMenu({ dashboardId }); const addContentToDashboardMenu = useAddContentToDashboardSelectMenu(); const filterDashboardMenu = useFilterDashboardSelectMenu(); const { data: permission } = useGetDashboard({ id: dashboardId }, (x) => x.permission); const isOwner = getIsEffectiveOwner(permission); const isFilter = canFilter(permission); const isEditor = canEdit(permission); const items: DropdownItems = useMemo( () => [ isFilter && filterDashboardMenu, isEditor && addContentToDashboardMenu, { type: 'divider' }, isOwner && shareMenu, collectionSelectMenu, favoriteDashboard, versionHistoryItems, { type: 'divider' }, isEditor && renameDashboardMenu, isOwner && deleteDashboardMenu ], [ filterDashboardMenu, addContentToDashboardMenu, shareMenu, collectionSelectMenu, favoriteDashboard, versionHistoryItems, renameDashboardMenu, deleteDashboardMenu ] ); return (