(props: EntryProps)
| 68 | } |
| 69 | |
| 70 | export const ScopeTray = (props: EntryProps) => { |
| 71 | const { rootNode, startDrag } = props |
| 72 | const [rootScopeWrapped, setRootScope] = useState({ s: rootNode.getScope() }) |
| 73 | |
| 74 | const rootScope = rootScopeWrapped.s |
| 75 | |
| 76 | useEffect(() => { |
| 77 | const observer: ScopeObserver = { |
| 78 | handleScopeMutation: (mutation) => { |
| 79 | setRootScope({ s: rootNode.scope }) |
| 80 | }, |
| 81 | } |
| 82 | globalMutationDispatcher.registerScopeObserver(observer) |
| 83 | return () => { |
| 84 | globalMutationDispatcher.deregisterScopeObserver(observer) |
| 85 | } |
| 86 | }, [rootNode]) |
| 87 | |
| 88 | return ( |
| 89 | <Accordion defaultIndex={[0]} allowToggle fontSize={'14px'}> |
| 90 | <AccordionItem border={'none'}> |
| 91 | {({ isExpanded }) => ( |
| 92 | <> |
| 93 | <AccordionButton border={'none'} px={0} py={1} mb={1} fontSize={'14px'} _hover={{ bg: 'gray.700' }}> |
| 94 | {isExpanded ? ( |
| 95 | <ChevronDownIcon textColor={'gray.400'} mr={0.5} /> |
| 96 | ) : ( |
| 97 | <ChevronRightIcon textColor={'gray.400'} mr={0.5} /> |
| 98 | )}{' '} |
| 99 | <Text>Variables</Text> |
| 100 | </AccordionButton> |
| 101 | <AccordionPanel pt={0} pr={0} pb={1} pl={2} mb={1} ml={2} className={'tray-expanded-category'}> |
| 102 | {rootScope.hasEntries() ? ( |
| 103 | <Box borderY={'solid 1px'} borderColor={'gray.700'} py={2} mb={2}> |
| 104 | <Text textColor={'gray.400'} lineHeight={1.1} py={1} px={1}> |
| 105 | Global |
| 106 | </Text> |
| 107 | <ScopeTree scope={rootScope} startDrag={startDrag} /> |
| 108 | </Box> |
| 109 | ) : null} |
| 110 | <Category category={AssignmentCategory} startDrag={startDrag} /> |
| 111 | </AccordionPanel> |
| 112 | </> |
| 113 | )} |
| 114 | </AccordionItem> |
| 115 | </Accordion> |
| 116 | ) |
| 117 | } |
| 118 | |
| 119 | interface ScopeTreeProps { |
| 120 | scope: PythonScope |
nothing calls this directly
no test coverage detected