import { Flex, chakra, Box } from '@chakra-ui/react'; import React from 'react'; import { alt } from 'toolkit/utils/htmlEntities'; import useThemeColors from 'ui/shared/monaco/utils/useThemeColors'; import CodeEditorFileIcon from './CodeEditorFileIcon'; import CodeEditorMainFileIndicator from './CodeEditorMainFileIndicator'; import getFilePathParts from './utils/getFilePathParts'; interface Props { isActive?: boolean; isMainFile?: boolean; path: string; onClick: (path: string) => void; onClose: (path: string) => void; isCloseDisabled: boolean; tabsPathChunks: Array>; } const CodeEditorTab = ({ isActive, isMainFile, path, onClick, onClose, isCloseDisabled, tabsPathChunks }: Props) => { const [ fileName, folderName ] = getFilePathParts(path, tabsPathChunks); const themeColors = useThemeColors(); const handleClick = React.useCallback(() => { onClick(path); }, [ onClick, path ]); const handleClose = React.useCallback((event: React.MouseEvent) => { event.stopPropagation(); !isCloseDisabled && onClose(path); }, [ isCloseDisabled, onClose, path ]); return ( { fileName } { folderName && { folderName[0] === '.' ? '' : '...' }{ folderName } } { isMainFile && } ); }; export default React.memo(CodeEditorTab);