mirror of https://github.com/langgenius/dify.git
feat: edit beacon
This commit is contained in:
parent
b9f223d9d4
commit
49dd77e219
|
|
@ -32,7 +32,7 @@ import { useTabSearchParams } from '@/hooks/use-tab-searchparams'
|
|||
import { useStore as useTagStore } from '@/app/components/base/tag-management/store'
|
||||
import { useAppContext } from '@/context/app-context'
|
||||
import { useExternalApiPanel } from '@/context/external-api-panel-context'
|
||||
import { DataType } from '@/app/components/datasets/metadata/types'
|
||||
import { DataType, UpdateType } from '@/app/components/datasets/metadata/types'
|
||||
|
||||
const Container = () => {
|
||||
const { t } = useTranslation()
|
||||
|
|
@ -119,9 +119,13 @@ const Container = () => {
|
|||
id: '1', name: 'name1', type: DataType.string, value: 'aaa',
|
||||
},
|
||||
{
|
||||
id: '2', name: 'name2', type: DataType.number, value: 'ccc', isMultipleValue: true,
|
||||
}, {
|
||||
id: '3', name: 'name3', type: DataType.time, value: '', isMultipleValue: false,
|
||||
id: '2', name: 'name2', type: DataType.number, value: 'ccc', isMultipleValue: true, isUpdated: true,
|
||||
},
|
||||
{
|
||||
id: '2.1', name: 'num v', type: DataType.number, value: 10,
|
||||
},
|
||||
{
|
||||
id: '3', name: 'name3', type: DataType.time, value: '', isUpdated: true, updateType: UpdateType.delete,
|
||||
},
|
||||
]}
|
||||
onHide={() => { }}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,13 @@ export type InputNumberProps = {
|
|||
max?: number
|
||||
min?: number
|
||||
defaultValue?: number
|
||||
wrapClassName?: string
|
||||
controlWrapClassName?: string
|
||||
controlClassName?: string
|
||||
} & Omit<InputProps, 'value' | 'onChange' | 'size' | 'min' | 'max' | 'defaultValue'>
|
||||
|
||||
export const InputNumber: FC<InputNumberProps> = (props) => {
|
||||
const { unit, className, onChange, amount = 1, value, size = 'md', max, min, defaultValue, ...rest } = props
|
||||
const { unit, className, onChange, amount = 1, value, size = 'md', max, min, defaultValue, wrapClassName, controlWrapClassName, controlClassName, ...rest } = props
|
||||
|
||||
const isValidValue = (v: number) => {
|
||||
if (max && v > max)
|
||||
|
|
@ -46,7 +49,7 @@ export const InputNumber: FC<InputNumberProps> = (props) => {
|
|||
onChange(newValue)
|
||||
}
|
||||
|
||||
return <div className='flex'>
|
||||
return <div className={classNames('flex', wrapClassName)}>
|
||||
<Input {...rest}
|
||||
// disable default controller
|
||||
type='text'
|
||||
|
|
@ -68,16 +71,18 @@ export const InputNumber: FC<InputNumberProps> = (props) => {
|
|||
}}
|
||||
unit={unit}
|
||||
/>
|
||||
<div className='flex flex-col bg-components-input-bg-normal rounded-r-md border-l border-divider-subtle text-text-tertiary focus:shadow-xs'>
|
||||
<div className={classNames('flex flex-col bg-components-input-bg-normal rounded-r-md border-l border-divider-subtle text-text-tertiary focus:shadow-xs', controlWrapClassName)}>
|
||||
<button onClick={inc} className={classNames(
|
||||
size === 'sm' ? 'pt-1' : 'pt-1.5',
|
||||
'px-1.5 hover:bg-components-input-bg-hover',
|
||||
controlClassName,
|
||||
)}>
|
||||
<RiArrowUpSLine className='size-3' />
|
||||
</button>
|
||||
<button onClick={dec} className={classNames(
|
||||
size === 'sm' ? 'pb-1' : 'pb-1.5',
|
||||
'px-1.5 hover:bg-components-input-bg-hover',
|
||||
controlClassName,
|
||||
)}>
|
||||
<RiArrowDownSLine className='size-3' />
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import { RiDeleteBinLine } from '@remixicon/react'
|
|||
import cn from '@/utils/classnames'
|
||||
import InputHasSetMultipleValue from './input-has-set-multiple-value'
|
||||
import InputCombined from './input-combined'
|
||||
import EditedBeacon from './edited-beacon'
|
||||
|
||||
type Props = {
|
||||
payload: MetadataItemWithEdit
|
||||
|
|
@ -37,9 +38,11 @@ const EditMetadatabatchItem: FC<Props> = ({
|
|||
onChange,
|
||||
onRemove,
|
||||
}) => {
|
||||
const isUpdated = payload.isUpdated
|
||||
const isDeleted = payload.updateType === UpdateType.delete
|
||||
return (
|
||||
<div className='flex h-6 items-center space-x-0.5'>
|
||||
{isUpdated ? <EditedBeacon onReset={() => { }} /> : <div className='shrink-0 size-4' />}
|
||||
<Label text={payload.name} isDeleted={isDeleted} />
|
||||
{payload.isMultipleValue
|
||||
? <InputHasSetMultipleValue onClear={() => onChange({ ...payload, isMultipleValue: false })} />
|
||||
|
|
@ -53,7 +56,7 @@ const EditMetadatabatchItem: FC<Props> = ({
|
|||
className={
|
||||
cn(
|
||||
'p-1 rounded-md text-text-tertiary hover:bg-state-destructive-hover hover:text-text-destructive cursor-pointer',
|
||||
isDeleted && 'cursor-default bg-state-destructive-hover text-text-quaternary ')
|
||||
isDeleted && 'cursor-default bg-state-destructive-hover text-text-destructive')
|
||||
}
|
||||
onClick={() => onRemove(payload.id)}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ import type { FC } from 'react'
|
|||
import React from 'react'
|
||||
import { DataType } from '../types'
|
||||
import Input from '@/app/components/base/input'
|
||||
import { InputNumber } from '@/app/components/base/input-number'
|
||||
import cn from '@/utils/classnames'
|
||||
|
||||
type Props = {
|
||||
type: DataType
|
||||
|
|
@ -15,12 +17,28 @@ const InputCombined: FC<Props> = ({
|
|||
value,
|
||||
onChange,
|
||||
}) => {
|
||||
const className = 'grow p-0.5 h-6 text-xs'
|
||||
if (type === DataType.time)
|
||||
return <div className='grow text-xs'>Datepicker placeholder</div>
|
||||
|
||||
if (type === DataType.number) {
|
||||
return (
|
||||
<div className='grow'>
|
||||
<InputNumber
|
||||
wrapClassName='items-center'
|
||||
className={cn(className, 'rounded-l-md')}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
size='sm'
|
||||
controlWrapClassName='h-6 overflow-hidden'
|
||||
controlClassName='pt-0 pb-0'
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<Input
|
||||
className='p-0.5 h-6 rounded-md text-xs'
|
||||
className={cn(className, 'rounded-md')}
|
||||
value={value}
|
||||
onChange={e => onChange(e.target.value)}
|
||||
>
|
||||
|
|
|
|||
Loading…
Reference in New Issue