|
|
|
@ -11,8 +11,6 @@ import type { ToolDefaultValue } from '../types'
|
|
|
|
import { ViewType } from '../view-type-select'
|
|
|
|
import { ViewType } from '../view-type-select'
|
|
|
|
import ActonItem from './action-item'
|
|
|
|
import ActonItem from './action-item'
|
|
|
|
import BlockIcon from '../../block-icon'
|
|
|
|
import BlockIcon from '../../block-icon'
|
|
|
|
|
|
|
|
|
|
|
|
import { useBoolean } from 'ahooks'
|
|
|
|
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
type Props = {
|
|
|
|
@ -20,6 +18,8 @@ type Props = {
|
|
|
|
payload: ToolWithProvider
|
|
|
|
payload: ToolWithProvider
|
|
|
|
viewType: ViewType
|
|
|
|
viewType: ViewType
|
|
|
|
isShowLetterIndex: boolean
|
|
|
|
isShowLetterIndex: boolean
|
|
|
|
|
|
|
|
isFold: boolean
|
|
|
|
|
|
|
|
onFoldChange: (fold: boolean) => void
|
|
|
|
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
|
|
|
|
onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -28,6 +28,8 @@ const Tool: FC<Props> = ({
|
|
|
|
payload,
|
|
|
|
payload,
|
|
|
|
viewType,
|
|
|
|
viewType,
|
|
|
|
isShowLetterIndex,
|
|
|
|
isShowLetterIndex,
|
|
|
|
|
|
|
|
isFold,
|
|
|
|
|
|
|
|
onFoldChange,
|
|
|
|
onSelect,
|
|
|
|
onSelect,
|
|
|
|
}) => {
|
|
|
|
}) => {
|
|
|
|
const { t } = useTranslation()
|
|
|
|
const { t } = useTranslation()
|
|
|
|
@ -35,10 +37,8 @@ const Tool: FC<Props> = ({
|
|
|
|
const isFlatView = viewType === ViewType.flat
|
|
|
|
const isFlatView = viewType === ViewType.flat
|
|
|
|
const actions = payload.tools
|
|
|
|
const actions = payload.tools
|
|
|
|
const hasAction = true // Now always support actions
|
|
|
|
const hasAction = true // Now always support actions
|
|
|
|
const [isFold, {
|
|
|
|
|
|
|
|
toggle: toggleFold,
|
|
|
|
const FoldIcon = isFold ? RiArrowRightSLine : RiArrowDownSLine
|
|
|
|
}] = useBoolean(false)
|
|
|
|
|
|
|
|
const FoldIcon = isFold ? RiArrowDownSLine : RiArrowRightSLine
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const groupName = useMemo(() => {
|
|
|
|
const groupName = useMemo(() => {
|
|
|
|
if (payload.type === CollectionType.builtIn)
|
|
|
|
if (payload.type === CollectionType.builtIn)
|
|
|
|
@ -63,7 +63,7 @@ const Tool: FC<Props> = ({
|
|
|
|
className='flex items-center justify-between pl-3 pr-1 w-full rounded-lg hover:bg-gray-50 cursor-pointer select-none'
|
|
|
|
className='flex items-center justify-between pl-3 pr-1 w-full rounded-lg hover:bg-gray-50 cursor-pointer select-none'
|
|
|
|
onClick={() => {
|
|
|
|
onClick={() => {
|
|
|
|
if (hasAction)
|
|
|
|
if (hasAction)
|
|
|
|
toggleFold()
|
|
|
|
onFoldChange(!isFold)
|
|
|
|
|
|
|
|
|
|
|
|
// Now always support actions
|
|
|
|
// Now always support actions
|
|
|
|
// if (payload.parameters) {
|
|
|
|
// if (payload.parameters) {
|
|
|
|
@ -101,7 +101,7 @@ const Tool: FC<Props> = ({
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{hasAction && isFold && (
|
|
|
|
{hasAction && !isFold && (
|
|
|
|
actions.map(action => (
|
|
|
|
actions.map(action => (
|
|
|
|
<ActonItem
|
|
|
|
<ActonItem
|
|
|
|
key={action.name}
|
|
|
|
key={action.name}
|
|
|
|
|