2021-03-18 05:52:36 -04:00
|
|
|
import classnames from 'classnames'
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import Icon from '../../../../shared/components/icon'
|
|
|
|
import { useFileTreeActionable } from '../../contexts/file-tree-actionable'
|
2023-08-22 09:33:19 -04:00
|
|
|
import * as eventTracking from '../../../../infrastructure/event-tracking'
|
2024-09-25 09:46:02 -04:00
|
|
|
import OLButton from '@/features/ui/components/ol/ol-button'
|
|
|
|
import BootstrapVersionSwitcher from '@/features/ui/components/bootstrap-5/bootstrap-version-switcher'
|
|
|
|
import MaterialIcon from '@/shared/components/material-icon'
|
2021-03-18 05:52:36 -04:00
|
|
|
|
|
|
|
export default function FileTreeModalCreateFileMode({ mode, icon, label }) {
|
|
|
|
const { newFileCreateMode, startCreatingFile } = useFileTreeActionable()
|
|
|
|
|
|
|
|
const handleClick = () => {
|
|
|
|
startCreatingFile(mode)
|
2023-08-22 09:33:19 -04:00
|
|
|
eventTracking.sendMB('file-modal-click', { method: mode })
|
2021-03-18 05:52:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<li className={classnames({ active: newFileCreateMode === mode })}>
|
2024-09-25 09:46:02 -04:00
|
|
|
<OLButton
|
|
|
|
variant="link"
|
2021-03-18 05:52:36 -04:00
|
|
|
onClick={handleClick}
|
|
|
|
className="modal-new-file-mode"
|
|
|
|
>
|
2024-09-25 09:46:02 -04:00
|
|
|
<BootstrapVersionSwitcher
|
|
|
|
bs3={<Icon type={icon} fw />}
|
|
|
|
bs5={<MaterialIcon type={icon} />}
|
|
|
|
/>
|
2021-03-18 05:52:36 -04:00
|
|
|
|
|
|
|
{label}
|
2024-09-25 09:46:02 -04:00
|
|
|
</OLButton>
|
2021-03-18 05:52:36 -04:00
|
|
|
</li>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
FileTreeModalCreateFileMode.propTypes = {
|
|
|
|
mode: PropTypes.string.isRequired,
|
|
|
|
icon: PropTypes.string.isRequired,
|
2021-04-27 03:52:58 -04:00
|
|
|
label: PropTypes.string.isRequired,
|
2021-03-18 05:52:36 -04:00
|
|
|
}
|