({
collection,
currentCollectionId,
selectCollection,
selectRequest,
selectScript,
index,
duplicateCollection,
dispatchCollections,
moveCollection,
moveRequest,
moveScript,
isCollectionDescendant,
}: MoveableHeaderProps)
| 100 | } |
| 101 | |
| 102 | function MoveableHeader({ |
| 103 | collection, |
| 104 | currentCollectionId, |
| 105 | selectCollection, |
| 106 | selectRequest, |
| 107 | selectScript, |
| 108 | index, |
| 109 | duplicateCollection, |
| 110 | dispatchCollections, |
| 111 | moveCollection, |
| 112 | moveRequest, |
| 113 | moveScript, |
| 114 | isCollectionDescendant, |
| 115 | }: MoveableHeaderProps) { |
| 116 | const { user } = useContext(UserContext); |
| 117 | const [state, setState] = useState<MoveableHeaderState>({ |
| 118 | name: collection.name, |
| 119 | newRequestName: '', |
| 120 | currentModal: '', |
| 121 | importData: '', |
| 122 | newCollectionName: '', |
| 123 | groups: user?.data?.groups ?? [], |
| 124 | uploadFile: undefined, |
| 125 | basePath: '', |
| 126 | selectedImport: 'openapi', |
| 127 | newScriptName: '', |
| 128 | }); |
| 129 | const id = collection.id; |
| 130 | const ref = useRef<HTMLDivElement>(null); |
| 131 | const initialRef = useRef(null); |
| 132 | const [isTopHovered, setIsTopHovered] = useState(false); |
| 133 | const [isMiddleHovered, setIsMiddleHovered] = useState(false); |
| 134 | const [isBottomHovered, setIsBottomHovered] = useState(false); |
| 135 | const { colorMode } = useColorMode(); |
| 136 | const { onCopy } = useClipboard(`${window.location.origin}/#/${collection.id}`); |
| 137 | const toast = useToast(); |
| 138 | const { isOpen, onOpen, onClose } = useDisclosure(); |
| 139 | const headerVariants = useMemo(() => { |
| 140 | return currentCollectionId === collection.id ? ['selected'] : []; |
| 141 | }, [currentCollectionId, collection.id]); |
| 142 | const iconVariants = useMemo(() => { |
| 143 | return collection.open ? ['open'] : []; |
| 144 | }, [collection.open]); |
| 145 | const [{ handlerId }, drop] = useDrop< |
| 146 | DragItem, |
| 147 | void, |
| 148 | { |
| 149 | handlerId: Identifier | null; |
| 150 | } |
| 151 | >({ |
| 152 | accept: DragTypes.COLLECTION, |
| 153 | hover(item, monitor) { |
| 154 | if (!ref.current || !monitor.isOver()) { |
| 155 | return; |
| 156 | } |
| 157 | |
| 158 | if (isCollectionDescendant(item.id, id)) { |
| 159 | return; |
nothing calls this directly
no test coverage detected