({
collection,
currentRequestId,
currentCollectionId,
currentScriptId,
selectCollection,
selectRequest,
selectScript,
index,
renameRequest,
deleteRequest,
duplicateRequest,
duplicateCollection,
dispatchCollections,
renderCollection,
moveCollection,
isCollectionDescendant,
deleteScript,
duplicateScript,
takeScriptOwnership,
}: CollectionProps)
| 69 | }; |
| 70 | |
| 71 | function CollectionView({ |
| 72 | collection, |
| 73 | currentRequestId, |
| 74 | currentCollectionId, |
| 75 | currentScriptId, |
| 76 | selectCollection, |
| 77 | selectRequest, |
| 78 | selectScript, |
| 79 | index, |
| 80 | renameRequest, |
| 81 | deleteRequest, |
| 82 | duplicateRequest, |
| 83 | duplicateCollection, |
| 84 | dispatchCollections, |
| 85 | renderCollection, |
| 86 | moveCollection, |
| 87 | isCollectionDescendant, |
| 88 | deleteScript, |
| 89 | duplicateScript, |
| 90 | takeScriptOwnership, |
| 91 | }: CollectionProps) { |
| 92 | const { colorMode } = useColorMode(); |
| 93 | const iconVariants = collection.open ? ['open'] : []; |
| 94 | |
| 95 | const toast = useToast(); |
| 96 | |
| 97 | const moveRequest = useCallback( |
| 98 | async (id: number, newRank: number, newCollectionId: number) => { |
| 99 | try { |
| 100 | dispatchCollections({ |
| 101 | type: CollectionsActionType.MOVE_REQUEST, |
| 102 | id, |
| 103 | newRank, |
| 104 | newCollectionId, |
| 105 | }); |
| 106 | const response = await api.moveRequest(id, newRank, newCollectionId); |
| 107 | if (response.status !== 200) throw new Error(); |
| 108 | successToast('Request was moved.', toast); |
| 109 | } catch (e) { |
| 110 | console.error(e); |
| 111 | errorToast('Could not move request.', toast); |
| 112 | } |
| 113 | }, |
| 114 | [dispatchCollections, toast], |
| 115 | ); |
| 116 | |
| 117 | const moveScript = useCallback( |
| 118 | async (id: number, newRank: number, newCollectionId: number) => { |
| 119 | try { |
| 120 | dispatchCollections({ |
| 121 | type: CollectionsActionType.MOVE_SCRIPT, |
| 122 | id, |
| 123 | newRank, |
| 124 | newCollectionId, |
| 125 | }); |
| 126 | const response = await api.moveScript(id, newRank, newCollectionId); |
| 127 | if (response.status !== 200) throw new Error(); |
| 128 | successToast('Script was moved.', toast); |
nothing calls this directly
no test coverage detected