fix oxlint warnings (#26634)

This commit is contained in:
Asuka Minato
2025-10-09 10:23:34 +09:00
committed by GitHub
parent c4d8bf0ce9
commit a8746bff30
76 changed files with 261 additions and 144 deletions

View File

@@ -16,7 +16,7 @@ jest.mock('cmdk', () => ({
Item: ({ children, onSelect, value, className }: any) => ( Item: ({ children, onSelect, value, className }: any) => (
<div <div
className={className} className={className}
onClick={() => onSelect && onSelect()} onClick={() => onSelect?.()}
data-value={value} data-value={value}
data-testid={`command-item-${value}`} data-testid={`command-item-${value}`}
> >

View File

@@ -4,6 +4,7 @@ import React, { useCallback, useRef, useState } from 'react'
import type { PopupProps } from './config-popup' import type { PopupProps } from './config-popup'
import ConfigPopup from './config-popup' import ConfigPopup from './config-popup'
import cn from '@/utils/classnames'
import { import {
PortalToFollowElem, PortalToFollowElem,
PortalToFollowElemContent, PortalToFollowElemContent,
@@ -45,7 +46,7 @@ const ConfigBtn: FC<Props> = ({
offset={12} offset={12}
> >
<PortalToFollowElemTrigger onClick={handleTrigger}> <PortalToFollowElemTrigger onClick={handleTrigger}>
<div className="select-none"> <div className={cn('select-none', className)}>
{children} {children}
</div> </div>
</PortalToFollowElemTrigger> </PortalToFollowElemTrigger>

View File

@@ -28,7 +28,8 @@ const CSVUploader: FC<Props> = ({
const handleDragEnter = (e: DragEvent) => { const handleDragEnter = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
e.target !== dragRef.current && setDragging(true) if (e.target !== dragRef.current)
setDragging(true)
} }
const handleDragOver = (e: DragEvent) => { const handleDragOver = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
@@ -37,7 +38,8 @@ const CSVUploader: FC<Props> = ({
const handleDragLeave = (e: DragEvent) => { const handleDragLeave = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
e.target === dragRef.current && setDragging(false) if (e.target === dragRef.current)
setDragging(false)
} }
const handleDrop = (e: DragEvent) => { const handleDrop = (e: DragEvent) => {
e.preventDefault() e.preventDefault()

View File

@@ -348,7 +348,8 @@ const AppPublisher = ({
<SuggestedAction <SuggestedAction
className='flex-1' className='flex-1'
onClick={() => { onClick={() => {
publishedAt && handleOpenInExplore() if (publishedAt)
handleOpenInExplore()
}} }}
disabled={!publishedAt || (systemFeatures.webapp_auth.enabled && !userCanAccessApp?.result)} disabled={!publishedAt || (systemFeatures.webapp_auth.enabled && !userCanAccessApp?.result)}
icon={<RiPlanetLine className='h-4 w-4' />} icon={<RiPlanetLine className='h-4 w-4' />}

View File

@@ -40,7 +40,8 @@ const VersionInfoModal: FC<VersionInfoModalProps> = ({
return return
} }
else { else {
titleError && setTitleError(false) if (titleError)
setTitleError(false)
} }
if (releaseNotes.length > RELEASE_NOTES_MAX_LENGTH) { if (releaseNotes.length > RELEASE_NOTES_MAX_LENGTH) {
@@ -52,7 +53,8 @@ const VersionInfoModal: FC<VersionInfoModalProps> = ({
return return
} }
else { else {
releaseNotesError && setReleaseNotesError(false) if (releaseNotesError)
setReleaseNotesError(false)
} }
onPublish({ title, releaseNotes, id: versionInfo?.id }) onPublish({ title, releaseNotes, id: versionInfo?.id })

View File

@@ -0,0 +1,29 @@
import type { SVGProps } from 'react'
const CitationIcon = (props: SVGProps<SVGSVGElement>) => (
<svg
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
{...props}
>
<path
d="M7 6h10M7 12h6M7 18h10"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M5 6c0-1.105.895-2 2-2h10c1.105 0 2 .895 2 2v12c0 1.105-.895 2-2 2H9l-4 3v-3H7"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
fill="none"
/>
</svg>
)
export default CitationIcon

View File

@@ -79,7 +79,7 @@ const ConfigModal: FC<IConfigModalProps> = ({
try { try {
return JSON.stringify(JSON.parse(tempPayload.json_schema).properties, null, 2) return JSON.stringify(JSON.parse(tempPayload.json_schema).properties, null, 2)
} }
catch (_e) { catch {
return '' return ''
} }
}, [tempPayload.json_schema]) }, [tempPayload.json_schema])
@@ -123,7 +123,7 @@ const ConfigModal: FC<IConfigModalProps> = ({
} }
handlePayloadChange('json_schema')(JSON.stringify(res, null, 2)) handlePayloadChange('json_schema')(JSON.stringify(res, null, 2))
} }
catch (_e) { catch {
return null return null
} }
}, [handlePayloadChange]) }, [handlePayloadChange])

View File

@@ -480,7 +480,7 @@ const Configuration: FC = () => {
Toast.notify({ type: 'warning', message: `${t('common.modelProvider.parametersInvalidRemoved')}: ${Object.entries(removedDetails).map(([k, reason]) => `${k} (${reason})`).join(', ')}` }) Toast.notify({ type: 'warning', message: `${t('common.modelProvider.parametersInvalidRemoved')}: ${Object.entries(removedDetails).map(([k, reason]) => `${k} (${reason})`).join(', ')}` })
setCompletionParams(filtered) setCompletionParams(filtered)
} }
catch (e) { catch {
Toast.notify({ type: 'error', message: t('common.error') }) Toast.notify({ type: 'error', message: t('common.error') })
setCompletionParams({}) setCompletionParams({})
} }

View File

@@ -192,7 +192,7 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({
<Button <Button
variant="primary" variant="primary"
disabled={canNotRun} disabled={canNotRun}
onClick={() => onSend && onSend()} onClick={() => onSend?.()}
className="w-[96px]"> className="w-[96px]">
<RiPlayLargeFill className="mr-0.5 h-4 w-4 shrink-0" aria-hidden="true" /> <RiPlayLargeFill className="mr-0.5 h-4 w-4 shrink-0" aria-hidden="true" />
{t('appDebug.inputs.run')} {t('appDebug.inputs.run')}
@@ -203,7 +203,7 @@ const PromptValuePanel: FC<IPromptValuePanelProps> = ({
<Button <Button
variant="primary" variant="primary"
disabled={canNotRun} disabled={canNotRun}
onClick={() => onSend && onSend()} onClick={() => onSend?.()}
className="w-[96px]"> className="w-[96px]">
<RiPlayLargeFill className="mr-0.5 h-4 w-4 shrink-0" aria-hidden="true" /> <RiPlayLargeFill className="mr-0.5 h-4 w-4 shrink-0" aria-hidden="true" />
{t('appDebug.inputs.run')} {t('appDebug.inputs.run')}

View File

@@ -38,7 +38,8 @@ const Uploader: FC<Props> = ({
const handleDragEnter = (e: DragEvent) => { const handleDragEnter = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
e.target !== dragRef.current && setDragging(true) if (e.target !== dragRef.current)
setDragging(true)
} }
const handleDragOver = (e: DragEvent) => { const handleDragOver = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
@@ -47,7 +48,8 @@ const Uploader: FC<Props> = ({
const handleDragLeave = (e: DragEvent) => { const handleDragLeave = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
e.target === dragRef.current && setDragging(false) if (e.target === dragRef.current)
setDragging(false)
} }
const handleDrop = (e: DragEvent) => { const handleDrop = (e: DragEvent) => {
e.preventDefault() e.preventDefault()

View File

@@ -107,7 +107,8 @@ const Chart: React.FC<IChartProps> = ({
const { t } = useTranslation() const { t } = useTranslation()
const statistics = chartData.data const statistics = chartData.data
const statisticsLen = statistics.length const statisticsLen = statistics.length
const extraDataForMarkLine = new Array(statisticsLen >= 2 ? statisticsLen - 2 : statisticsLen).fill('1') const markLineLength = statisticsLen >= 2 ? statisticsLen - 2 : statisticsLen
const extraDataForMarkLine = Array.from({ length: markLineLength }, () => '1')
extraDataForMarkLine.push('') extraDataForMarkLine.push('')
extraDataForMarkLine.unshift('') extraDataForMarkLine.unshift('')

View File

@@ -127,7 +127,7 @@ export default class AudioPlayer {
} }
catch { catch {
this.isLoadData = false this.isLoadData = false
this.callback && this.callback('error') this.callback?.('error')
} }
} }
@@ -137,15 +137,14 @@ export default class AudioPlayer {
if (this.audioContext.state === 'suspended') { if (this.audioContext.state === 'suspended') {
this.audioContext.resume().then((_) => { this.audioContext.resume().then((_) => {
this.audio.play() this.audio.play()
this.callback && this.callback('play') this.callback?.('play')
}) })
} }
else if (this.audio.ended) { else if (this.audio.ended) {
this.audio.play() this.audio.play()
this.callback && this.callback('play') this.callback?.('play')
} }
if (this.callback) this.callback?.('play')
this.callback('play')
} }
else { else {
this.isLoadData = true this.isLoadData = true
@@ -189,24 +188,24 @@ export default class AudioPlayer {
if (this.audio.paused) { if (this.audio.paused) {
this.audioContext.resume().then((_) => { this.audioContext.resume().then((_) => {
this.audio.play() this.audio.play()
this.callback && this.callback('play') this.callback?.('play')
}) })
} }
else if (this.audio.ended) { else if (this.audio.ended) {
this.audio.play() this.audio.play()
this.callback && this.callback('play') this.callback?.('play')
} }
else if (this.audio.played) { /* empty */ } else if (this.audio.played) { /* empty */ }
else { else {
this.audio.play() this.audio.play()
this.callback && this.callback('play') this.callback?.('play')
} }
} }
} }
public pauseAudio() { public pauseAudio() {
this.callback && this.callback('paused') this.callback?.('paused')
this.audio.pause() this.audio.pause()
this.audioContext.suspend() this.audioContext.suspend()
} }

View File

@@ -128,7 +128,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
const localState = localStorage.getItem('webappSidebarCollapse') const localState = localStorage.getItem('webappSidebarCollapse')
return localState === 'collapsed' return localState === 'collapsed'
} }
catch (e) { catch {
// localStorage may be disabled in private browsing mode or by security settings // localStorage may be disabled in private browsing mode or by security settings
// fallback to default value // fallback to default value
return false return false
@@ -142,7 +142,7 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => {
try { try {
localStorage.setItem('webappSidebarCollapse', state ? 'collapsed' : 'expanded') localStorage.setItem('webappSidebarCollapse', state ? 'collapsed' : 'expanded')
} }
catch (e) { catch {
// localStorage may be disabled, continue without persisting state // localStorage may be disabled, continue without persisting state
} }
} }

View File

@@ -101,10 +101,14 @@ const Answer: FC<AnswerProps> = ({
}, []) }, [])
const handleSwitchSibling = useCallback((direction: 'prev' | 'next') => { const handleSwitchSibling = useCallback((direction: 'prev' | 'next') => {
if (direction === 'prev') if (direction === 'prev') {
item.prevSibling && switchSibling?.(item.prevSibling) if (item.prevSibling)
else switchSibling?.(item.prevSibling)
item.nextSibling && switchSibling?.(item.nextSibling) }
else {
if (item.nextSibling)
switchSibling?.(item.nextSibling)
}
}, [switchSibling, item.prevSibling, item.nextSibling]) }, [switchSibling, item.prevSibling, item.nextSibling])
return ( return (

View File

@@ -73,10 +73,14 @@ const Question: FC<QuestionProps> = ({
}, [content]) }, [content])
const handleSwitchSibling = useCallback((direction: 'prev' | 'next') => { const handleSwitchSibling = useCallback((direction: 'prev' | 'next') => {
if (direction === 'prev') if (direction === 'prev') {
item.prevSibling && switchSibling?.(item.prevSibling) if (item.prevSibling)
else switchSibling?.(item.prevSibling)
item.nextSibling && switchSibling?.(item.nextSibling) }
else {
if (item.nextSibling)
switchSibling?.(item.nextSibling)
}
}, [switchSibling, item.prevSibling, item.nextSibling]) }, [switchSibling, item.prevSibling, item.nextSibling])
const getContentWidth = () => { const getContentWidth = () => {

View File

@@ -124,7 +124,7 @@ export const parseDateWithFormat = (dateString: string, format?: string): Dayjs
} }
// Format date output with localization support // Format date output with localization support
export const formatDateForOutput = (date: Dayjs, includeTime: boolean = false, locale: string = 'en-US'): string => { export const formatDateForOutput = (date: Dayjs, includeTime: boolean = false, _locale: string = 'en-US'): string => {
if (!date || !date.isValid()) return '' if (!date || !date.isValid()) return ''
if (includeTime) { if (includeTime) {

View File

@@ -47,7 +47,10 @@ export default function Drawer({
<Dialog <Dialog
unmount={unmount} unmount={unmount}
open={isOpen} open={isOpen}
onClose={() => !clickOutsideNotOpen && onClose()} onClose={() => {
if (!clickOutsideNotOpen)
onClose()
}}
className={cn('fixed inset-0 z-[30] overflow-y-auto', dialogClassName)} className={cn('fixed inset-0 z-[30] overflow-y-auto', dialogClassName)}
> >
<div className={cn('flex h-screen w-screen justify-end', positionCenter && '!justify-center')}> <div className={cn('flex h-screen w-screen justify-end', positionCenter && '!justify-center')}>
@@ -55,7 +58,8 @@ export default function Drawer({
<DialogBackdrop <DialogBackdrop
className={cn('fixed inset-0 z-[40]', mask && 'bg-black/30', dialogBackdropClassName)} className={cn('fixed inset-0 z-[40]', mask && 'bg-black/30', dialogBackdropClassName)}
onClick={() => { onClick={() => {
!clickOutsideNotOpen && onClose() if (!clickOutsideNotOpen)
onClose()
}} }}
/> />
<div className={cn('relative z-[50] flex w-full max-w-sm flex-col justify-between overflow-hidden bg-components-panel-bg p-6 text-left align-middle shadow-xl', panelClassName)}> <div className={cn('relative z-[50] flex w-full max-w-sm flex-col justify-between overflow-hidden bg-components-panel-bg p-6 text-left align-middle shadow-xl', panelClassName)}>
@@ -80,11 +84,11 @@ export default function Drawer({
<Button <Button
className='mr-2' className='mr-2'
onClick={() => { onClick={() => {
onCancel && onCancel() onCancel?.()
}}>{t('common.operation.cancel')}</Button> }}>{t('common.operation.cancel')}</Button>
<Button <Button
onClick={() => { onClick={() => {
onOk && onOk() onOk?.()
}}>{t('common.operation.save')}</Button> }}>{t('common.operation.save')}</Button>
</div>)} </div>)}
</div> </div>

View File

@@ -45,7 +45,7 @@ const EmojiPicker: FC<IEmojiPickerProps> = ({
<Divider className='mb-0 mt-3' /> <Divider className='mb-0 mt-3' />
<div className='flex w-full items-center justify-center gap-2 p-3'> <div className='flex w-full items-center justify-center gap-2 p-3'>
<Button className='w-full' onClick={() => { <Button className='w-full' onClick={() => {
onClose && onClose() onClose?.()
}}> }}>
{t('app.iconPicker.cancel')} {t('app.iconPicker.cancel')}
</Button> </Button>
@@ -54,7 +54,7 @@ const EmojiPicker: FC<IEmojiPickerProps> = ({
variant="primary" variant="primary"
className='w-full' className='w-full'
onClick={() => { onClick={() => {
onSelect && onSelect(selectedEmoji, selectedBackground!) onSelect?.(selectedEmoji, selectedBackground!)
}}> }}>
{t('app.iconPicker.ok')} {t('app.iconPicker.ok')}
</Button> </Button>

View File

@@ -33,7 +33,10 @@ const SelectField = ({
<PureSelect <PureSelect
value={field.state.value} value={field.state.value}
options={options} options={options}
onChange={value => field.handleChange(value)} onChange={(value) => {
field.handleChange(value)
onChange?.(value)
}}
{...selectProps} {...selectProps}
/> />
</div> </div>

View File

@@ -62,7 +62,7 @@ const ImageList: FC<ImageListProps> = ({
{item.progress === -1 && ( {item.progress === -1 && (
<RefreshCcw01 <RefreshCcw01
className="h-5 w-5 text-white" className="h-5 w-5 text-white"
onClick={() => onReUpload && onReUpload(item._id)} onClick={() => onReUpload?.(item._id)}
/> />
)} )}
</div> </div>
@@ -122,7 +122,7 @@ const ImageList: FC<ImageListProps> = ({
'rounded-2xl shadow-lg hover:bg-state-base-hover', 'rounded-2xl shadow-lg hover:bg-state-base-hover',
item.progress === -1 ? 'flex' : 'hidden group-hover:flex', item.progress === -1 ? 'flex' : 'hidden group-hover:flex',
)} )}
onClick={() => onRemove && onRemove(item._id)} onClick={() => onRemove?.(item._id)}
> >
<RiCloseLine className="h-3 w-3 text-text-tertiary" /> <RiCloseLine className="h-3 w-3 text-text-tertiary" />
</button> </button>

View File

@@ -20,7 +20,7 @@ const isBase64 = (str: string): boolean => {
try { try {
return btoa(atob(str)) === str return btoa(atob(str)) === str
} }
catch (err) { catch {
return false return false
} }
} }

View File

@@ -127,7 +127,7 @@ const CodeBlock: any = memo(({ inline, className, children = '', ...props }: any
// Store event handlers in useMemo to avoid recreating them // Store event handlers in useMemo to avoid recreating them
const echartsEvents = useMemo(() => ({ const echartsEvents = useMemo(() => ({
finished: (params: EChartsEventParams) => { finished: (_params: EChartsEventParams) => {
// Limit finished event frequency to avoid infinite loops // Limit finished event frequency to avoid infinite loops
finishedEventCountRef.current++ finishedEventCountRef.current++
if (finishedEventCountRef.current > 3) { if (finishedEventCountRef.current > 3) {

View File

@@ -60,7 +60,7 @@ export function svgToBase64(svgGraph: string): Promise<string> {
reader.readAsDataURL(blob) reader.readAsDataURL(blob)
}) })
} }
catch (error) { catch {
return Promise.resolve('') return Promise.resolve('')
} }
} }

View File

@@ -10,9 +10,7 @@ const usePagination = ({
edgePageCount, edgePageCount,
middlePagesSiblingCount, middlePagesSiblingCount,
}: IPaginationProps): IUsePagination => { }: IPaginationProps): IUsePagination => {
const pages = new Array(totalPages) const pages = React.useMemo(() => Array.from({ length: totalPages }, (_, i) => i + 1), [totalPages])
.fill(0)
.map((_, i) => i + 1)
const hasPreviousPage = currentPage > 1 const hasPreviousPage = currentPage > 1
const hasNextPage = currentPage < totalPages const hasNextPage = currentPage < totalPages

View File

@@ -37,13 +37,16 @@ export default function CustomPopover({
const timeOutRef = useRef<number | null>(null) const timeOutRef = useRef<number | null>(null)
const onMouseEnter = (isOpen: boolean) => { const onMouseEnter = (isOpen: boolean) => {
timeOutRef.current && window.clearTimeout(timeOutRef.current) if (timeOutRef.current != null)
!isOpen && buttonRef.current?.click() window.clearTimeout(timeOutRef.current)
if (!isOpen)
buttonRef.current?.click()
} }
const onMouseLeave = (isOpen: boolean) => { const onMouseLeave = (isOpen: boolean) => {
timeOutRef.current = window.setTimeout(() => { timeOutRef.current = window.setTimeout(() => {
isOpen && buttonRef.current?.click() if (isOpen)
buttonRef.current?.click()
}, timeoutDuration) }, timeoutDuration)
} }

View File

@@ -43,7 +43,7 @@ export default function LocaleSigninSelect({
className={'group flex w-full items-center rounded-lg px-3 py-2 text-sm text-text-secondary data-[active]:bg-state-base-hover'} className={'group flex w-full items-center rounded-lg px-3 py-2 text-sm text-text-secondary data-[active]:bg-state-base-hover'}
onClick={(evt) => { onClick={(evt) => {
evt.preventDefault() evt.preventDefault()
onChange && onChange(item.value) onChange?.(item.value)
}} }}
> >
{item.name} {item.name}

View File

@@ -43,7 +43,7 @@ export default function Select({
className={'group flex w-full items-center rounded-lg px-3 py-2 text-sm text-text-secondary data-[active]:bg-state-base-hover'} className={'group flex w-full items-center rounded-lg px-3 py-2 text-sm text-text-secondary data-[active]:bg-state-base-hover'}
onClick={(evt) => { onClick={(evt) => {
evt.preventDefault() evt.preventDefault()
onChange && onChange(item.value) onChange?.(item.value)
}} }}
> >
{item.name} {item.name}

View File

@@ -97,10 +97,13 @@ const Panel = (props: PanelProps) => {
const removeTagIDs = value.filter(v => !selectedTagIDs.includes(v)) const removeTagIDs = value.filter(v => !selectedTagIDs.includes(v))
const selectedTags = tagList.filter(tag => selectedTagIDs.includes(tag.id)) const selectedTags = tagList.filter(tag => selectedTagIDs.includes(tag.id))
onCacheUpdate(selectedTags) onCacheUpdate(selectedTags)
Promise.all([ const operations: Promise<unknown>[] = []
...(addTagIDs.length ? [bind(addTagIDs)] : []), if (addTagIDs.length)
...[removeTagIDs.length ? removeTagIDs.map(tagID => unbind(tagID)) : []], operations.push(bind(addTagIDs))
]).finally(() => { if (removeTagIDs.length)
operations.push(...removeTagIDs.map(tagID => unbind(tagID)))
Promise.all(operations).finally(() => {
if (onChange) if (onChange)
onChange() onChange()
}) })

View File

@@ -81,7 +81,8 @@ const VoiceInput = ({
setStartRecord(false) setStartRecord(false)
setStartConvert(true) setStartConvert(true)
recorder.current.stop() recorder.current.stop()
drawRecordId.current && cancelAnimationFrame(drawRecordId.current) if (drawRecordId.current)
cancelAnimationFrame(drawRecordId.current)
drawRecordId.current = null drawRecordId.current = null
const canvas = canvasRef.current! const canvas = canvasRef.current!
const ctx = ctxRef.current! const ctx = ctxRef.current!

View File

@@ -34,7 +34,8 @@ const Uploader: FC<Props> = ({
const handleDragEnter = (e: DragEvent) => { const handleDragEnter = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
e.target !== dragRef.current && setDragging(true) if (e.target !== dragRef.current)
setDragging(true)
} }
const handleDragOver = (e: DragEvent) => { const handleDragOver = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
@@ -43,7 +44,8 @@ const Uploader: FC<Props> = ({
const handleDragLeave = (e: DragEvent) => { const handleDragLeave = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
e.target === dragRef.current && setDragging(false) if (e.target === dragRef.current)
setDragging(false)
} }
const handleDrop = (e: DragEvent) => { const handleDrop = (e: DragEvent) => {
e.preventDefault() e.preventDefault()

View File

@@ -185,7 +185,8 @@ const FileUploader = ({
const handleDragEnter = (e: DragEvent) => { const handleDragEnter = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
e.target !== dragRef.current && setDragging(true) if (e.target !== dragRef.current)
setDragging(true)
} }
const handleDragOver = (e: DragEvent) => { const handleDragOver = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
@@ -194,7 +195,8 @@ const FileUploader = ({
const handleDragLeave = (e: DragEvent) => { const handleDragLeave = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
e.target === dragRef.current && setDragging(false) if (e.target === dragRef.current)
setDragging(false)
} }
type FileWithPath = { type FileWithPath = {
relativePath?: string relativePath?: string

View File

@@ -568,9 +568,9 @@ const StepTwo = ({
params, params,
{ {
onSuccess(data) { onSuccess(data) {
updateIndexingTypeCache && updateIndexingTypeCache(indexType as string) updateIndexingTypeCache?.(indexType as string)
updateResultCache && updateResultCache(data) updateResultCache?.(data)
updateRetrievalMethodCache && updateRetrievalMethodCache(retrievalConfig.search_method as string) updateRetrievalMethodCache?.(retrievalConfig.search_method as string)
}, },
}, },
) )
@@ -578,17 +578,18 @@ const StepTwo = ({
else { else {
await createDocumentMutation.mutateAsync(params, { await createDocumentMutation.mutateAsync(params, {
onSuccess(data) { onSuccess(data) {
updateIndexingTypeCache && updateIndexingTypeCache(indexType as string) updateIndexingTypeCache?.(indexType as string)
updateResultCache && updateResultCache(data) updateResultCache?.(data)
updateRetrievalMethodCache && updateRetrievalMethodCache(retrievalConfig.search_method as string) updateRetrievalMethodCache?.(retrievalConfig.search_method as string)
}, },
}) })
} }
if (mutateDatasetRes) if (mutateDatasetRes)
mutateDatasetRes() mutateDatasetRes()
invalidDatasetList() invalidDatasetList()
onStepChange && onStepChange(+1) onStepChange?.(+1)
isSetting && onSave && onSave() if (isSetting)
onSave?.()
} }
useEffect(() => { useEffect(() => {
@@ -1026,7 +1027,7 @@ const StepTwo = ({
{!isSetting {!isSetting
? ( ? (
<div className='mt-8 flex items-center py-2'> <div className='mt-8 flex items-center py-2'>
<Button onClick={() => onStepChange && onStepChange(-1)}> <Button onClick={() => onStepChange?.(-1)}>
<RiArrowLeftLine className='mr-1 h-4 w-4' /> <RiArrowLeftLine className='mr-1 h-4 w-4' />
{t('datasetCreation.stepTwo.previousStep')} {t('datasetCreation.stepTwo.previousStep')}
</Button> </Button>

View File

@@ -200,7 +200,8 @@ const LocalFile = ({
const handleDragEnter = (e: DragEvent) => { const handleDragEnter = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
e.target !== dragRef.current && setDragging(true) if (e.target !== dragRef.current)
setDragging(true)
} }
const handleDragOver = (e: DragEvent) => { const handleDragOver = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
@@ -209,7 +210,8 @@ const LocalFile = ({
const handleDragLeave = (e: DragEvent) => { const handleDragLeave = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
e.target === dragRef.current && setDragging(false) if (e.target === dragRef.current)
setDragging(false)
} }
const handleDrop = useCallback((e: DragEvent) => { const handleDrop = useCallback((e: DragEvent) => {

View File

@@ -45,10 +45,13 @@ const CrawledResult = ({
const handleItemCheckChange = useCallback((item: CrawlResultItem) => { const handleItemCheckChange = useCallback((item: CrawlResultItem) => {
return (checked: boolean) => { return (checked: boolean) => {
if (checked) if (checked) {
isMultipleChoice ? onSelectedChange([...checkedList, item]) : onSelectedChange([item]) if (isMultipleChoice)
else onSelectedChange([...checkedList, item])
onSelectedChange(checkedList.filter(checkedItem => checkedItem.source_url !== item.source_url)) else
onSelectedChange([item])
}
else { onSelectedChange(checkedList.filter(checkedItem => checkedItem.source_url !== item.source_url)) }
} }
}, [checkedList, onSelectedChange, isMultipleChoice]) }, [checkedList, onSelectedChange, isMultipleChoice])

View File

@@ -326,7 +326,10 @@ const CreateFormPipeline = () => {
}, []) }, [])
const handleSubmit = useCallback((data: Record<string, any>) => { const handleSubmit = useCallback((data: Record<string, any>) => {
isPreview.current ? handlePreviewChunks(data) : handleProcess(data) if (isPreview.current)
handlePreviewChunks(data)
else
handleProcess(data)
}, [handlePreviewChunks, handleProcess]) }, [handlePreviewChunks, handleProcess])
const handlePreviewFileChange = useCallback((file: DocumentItem) => { const handlePreviewFileChange = useCallback((file: DocumentItem) => {

View File

@@ -99,7 +99,8 @@ const CSVUploader: FC<Props> = ({
const handleDragEnter = (e: DragEvent) => { const handleDragEnter = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
e.target !== dragRef.current && setDragging(true) if (e.target !== dragRef.current)
setDragging(true)
} }
const handleDragOver = (e: DragEvent) => { const handleDragOver = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
@@ -108,7 +109,8 @@ const CSVUploader: FC<Props> = ({
const handleDragLeave = (e: DragEvent) => { const handleDragLeave = (e: DragEvent) => {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
e.target === dragRef.current && setDragging(false) if (e.target === dragRef.current)
setDragging(false)
} }
const handleDrop = (e: DragEvent) => { const handleDrop = (e: DragEvent) => {
e.preventDefault() e.preventDefault()

View File

@@ -284,7 +284,8 @@ const Completed: FC<ICompletedProps> = ({
onSuccess: () => { onSuccess: () => {
notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') })
resetList() resetList()
!segId && setSelectedSegmentIds([]) if (!segId)
setSelectedSegmentIds([])
}, },
onError: () => { onError: () => {
notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') })
@@ -438,7 +439,8 @@ const Completed: FC<ICompletedProps> = ({
} }
else { else {
resetList() resetList()
currentPage !== totalPages && setCurrentPage(totalPages) if (currentPage !== totalPages)
setCurrentPage(totalPages)
} }
}, [segmentListData, limit, currentPage, resetList]) }, [segmentListData, limit, currentPage, resetList])
@@ -491,7 +493,8 @@ const Completed: FC<ICompletedProps> = ({
} }
else { else {
resetChildList() resetChildList()
currentPage !== totalPages && setCurrentPage(totalPages) if (currentPage !== totalPages)
setCurrentPage(totalPages)
} }
}, [childChunkListData, limit, currentPage, resetChildList]) }, [childChunkListData, limit, currentPage, resetChildList])

View File

@@ -66,7 +66,7 @@ export const FieldInfo: FC<IFieldInfoProps> = ({
? displayedValue ? displayedValue
: inputType === 'select' : inputType === 'select'
? <SimpleSelect ? <SimpleSelect
onSelect={({ value }) => onUpdate && onUpdate(value as string)} onSelect={({ value }) => onUpdate?.(value as string)}
items={selectOptions} items={selectOptions}
defaultValue={value} defaultValue={value}
className={s.select} className={s.select}
@@ -75,7 +75,7 @@ export const FieldInfo: FC<IFieldInfoProps> = ({
/> />
: inputType === 'textarea' : inputType === 'textarea'
? <AutoHeightTextarea ? <AutoHeightTextarea
onChange={e => onUpdate && onUpdate(e.target.value)} onChange={e => onUpdate?.(e.target.value)}
value={value} value={value}
className={s.textArea} className={s.textArea}
placeholder={`${t('datasetDocuments.metadata.placeholder.add')}${label}`} placeholder={`${t('datasetDocuments.metadata.placeholder.add')}${label}`}

View File

@@ -148,7 +148,10 @@ const PipelineSettings = ({
}, []) }, [])
const handleSubmit = useCallback((data: Record<string, any>) => { const handleSubmit = useCallback((data: Record<string, any>) => {
isPreview.current ? handlePreviewChunks(data) : handleProcess(data) if (isPreview.current)
handlePreviewChunks(data)
else
handleProcess(data)
}, [handlePreviewChunks, handleProcess]) }, [handlePreviewChunks, handleProcess])
if (isFetchingLastRunData) { if (isFetchingLastRunData) {

View File

@@ -80,7 +80,8 @@ const TextAreaWithButton = ({
onUpdateList?.() onUpdateList?.()
} }
setLoading(false) setLoading(false)
_onSubmit && _onSubmit() if (_onSubmit)
_onSubmit()
} }
const externalRetrievalTestingOnSubmit = async () => { const externalRetrievalTestingOnSubmit = async () => {

View File

@@ -157,12 +157,12 @@ const DatasetCard = ({
data-disable-nprogress={true} data-disable-nprogress={true}
onClick={(e) => { onClick={(e) => {
e.preventDefault() e.preventDefault()
isExternalProvider if (isExternalProvider)
? push(`/datasets/${dataset.id}/hitTesting`) push(`/datasets/${dataset.id}/hitTesting`)
// eslint-disable-next-line sonarjs/no-nested-conditional else if (isPipelineUnpublished)
: isPipelineUnpublished push(`/datasets/${dataset.id}/pipeline`)
? push(`/datasets/${dataset.id}/pipeline`) else
: push(`/datasets/${dataset.id}/documents`) push(`/datasets/${dataset.id}/documents`)
}} }}
> >
{!dataset.embedding_available && ( {!dataset.embedding_available && (

View File

@@ -0,0 +1,3 @@
const DatasetsLoading = () => null
export default DatasetsLoading

View File

@@ -0,0 +1,3 @@
const DatasetPreview = () => null
export default DatasetPreview

View File

@@ -39,7 +39,7 @@ const Collapse = ({
<div className='mx-1 mb-1 rounded-lg border-t border-divider-subtle bg-components-panel-on-panel-item-bg py-1'> <div className='mx-1 mb-1 rounded-lg border-t border-divider-subtle bg-components-panel-on-panel-item-bg py-1'>
{ {
items.map(item => ( items.map(item => (
<div key={item.key} onClick={() => onSelect && onSelect(item)}> <div key={item.key} onClick={() => onSelect?.(item)}>
{renderItem(item)} {renderItem(item)}
</div> </div>
)) ))

View File

@@ -49,7 +49,7 @@ const ModelLoadBalancingConfigs = ({
provider, provider,
model, model,
configurationMethod, configurationMethod,
currentCustomConfigurationModelFixedFields, currentCustomConfigurationModelFixedFields: _currentCustomConfigurationModelFixedFields,
withSwitch = false, withSwitch = false,
className, className,
modelCredential, modelCredential,

View File

@@ -33,7 +33,7 @@ type Props = {
} }
const AppPicker: FC<Props> = ({ const AppPicker: FC<Props> = ({
scope, scope: _scope,
disabled, disabled,
trigger, trigger,
placement = 'right-start', placement = 'right-start',
@@ -90,7 +90,7 @@ const AppPicker: FC<Props> = ({
} }
// Set up MutationObserver to watch DOM changes // Set up MutationObserver to watch DOM changes
mutationObserver = new MutationObserver((mutations) => { mutationObserver = new MutationObserver((_mutations) => {
if (observerTarget.current) { if (observerTarget.current) {
setupIntersectionObserver() setupIntersectionObserver()
mutationObserver?.disconnect() mutationObserver?.disconnect()

View File

@@ -148,7 +148,7 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
}) })
} }
} }
catch (e) { catch {
Toast.notify({ type: 'error', message: t('common.error') }) Toast.notify({ type: 'error', message: t('common.error') })
} }
} }

View File

@@ -51,7 +51,7 @@ export const useFieldList = ({
const handleListSortChange = useCallback((list: SortableItem[]) => { const handleListSortChange = useCallback((list: SortableItem[]) => {
const newInputFields = list.map((item) => { const newInputFields = list.map((item) => {
const { id, chosen, selected, ...filed } = item const { id: _id, chosen: _chosen, selected: _selected, ...filed } = item
return filed return filed
}) })
handleInputFieldsChange(newInputFields) handleInputFieldsChange(newInputFields)

View File

@@ -15,7 +15,8 @@ const Header = () => {
isPreparingDataSource, isPreparingDataSource,
setIsPreparingDataSource, setIsPreparingDataSource,
} = workflowStore.getState() } = workflowStore.getState()
isPreparingDataSource && setIsPreparingDataSource?.(false) if (isPreparingDataSource)
setIsPreparingDataSource?.(false)
handleCancelDebugAndPreviewPanel() handleCancelDebugAndPreviewPanel()
}, [workflowStore]) }, [workflowStore])

View File

@@ -104,7 +104,7 @@ export const useNodesSyncDraft = () => {
const res = await syncWorkflowDraft(postParams) const res = await syncWorkflowDraft(postParams)
setSyncWorkflowDraftHash(res.hash) setSyncWorkflowDraftHash(res.hash)
setDraftUpdatedAt(res.updated_at) setDraftUpdatedAt(res.updated_at)
callback?.onSuccess && callback.onSuccess() callback?.onSuccess?.()
} }
catch (error: any) { catch (error: any) {
if (error && error.json && !error.bodyUsed) { if (error && error.json && !error.bodyUsed) {
@@ -113,10 +113,10 @@ export const useNodesSyncDraft = () => {
handleRefreshWorkflowDraft() handleRefreshWorkflowDraft()
}) })
} }
callback?.onError && callback.onError() callback?.onError?.()
} }
finally { finally {
callback?.onSettled && callback.onSettled() callback?.onSettled?.()
} }
} }
}, [getPostParams, getNodesReadOnly, workflowStore, handleRefreshWorkflowDraft]) }, [getPostParams, getNodesReadOnly, workflowStore, handleRefreshWorkflowDraft])

View File

@@ -363,7 +363,8 @@ const TextGeneration: FC<IMainProps> = ({
(async () => { (async () => {
if (!appData || !appParams) if (!appData || !appParams)
return return
!isWorkflow && fetchSavedMessage() if (!isWorkflow)
fetchSavedMessage()
const { app_id: appId, site: siteInfo, custom_config } = appData const { app_id: appId, site: siteInfo, custom_config } = appData
setAppId(appId) setAppId(appId)
setSiteInfo(siteInfo as SiteInfo) setSiteInfo(siteInfo as SiteInfo)

View File

@@ -62,8 +62,10 @@ const SwrInitializer = ({
return return
} }
if (searchParams.has('access_token') || searchParams.has('refresh_token')) { if (searchParams.has('access_token') || searchParams.has('refresh_token')) {
consoleToken && localStorage.setItem('console_token', consoleToken) if (consoleToken)
refreshToken && localStorage.setItem('refresh_token', refreshToken) localStorage.setItem('console_token', consoleToken)
if (refreshToken)
localStorage.setItem('refresh_token', refreshToken)
const redirectUrl = resolvePostLoginRedirect(searchParams) const redirectUrl = resolvePostLoginRedirect(searchParams)
if (redirectUrl) if (redirectUrl)
location.replace(redirectUrl) location.replace(redirectUrl)

View File

@@ -124,7 +124,7 @@ export const useNodesSyncDraft = () => {
const res = await syncWorkflowDraft(postParams) const res = await syncWorkflowDraft(postParams)
setSyncWorkflowDraftHash(res.hash) setSyncWorkflowDraftHash(res.hash)
setDraftUpdatedAt(res.updated_at) setDraftUpdatedAt(res.updated_at)
callback?.onSuccess && callback.onSuccess() callback?.onSuccess?.()
} }
catch (error: any) { catch (error: any) {
if (error && error.json && !error.bodyUsed) { if (error && error.json && !error.bodyUsed) {
@@ -133,10 +133,10 @@ export const useNodesSyncDraft = () => {
handleRefreshWorkflowDraft() handleRefreshWorkflowDraft()
}) })
} }
callback?.onError && callback.onError() callback?.onError?.()
} }
finally { finally {
callback?.onSettled && callback.onSettled() callback?.onSettled?.()
} }
} }
}, [workflowStore, getPostParams, getNodesReadOnly, handleRefreshWorkflowDraft]) }, [workflowStore, getPostParams, getNodesReadOnly, handleRefreshWorkflowDraft])

View File

@@ -73,7 +73,7 @@ const Tool: FC<Props> = ({
if (isHovering && !isAllSelected) { if (isHovering && !isAllSelected) {
return ( return (
<span className='system-xs-regular text-components-button-secondary-accent-text' <span className='system-xs-regular text-components-button-secondary-accent-text'
onClick={(e) => { onClick={() => {
onSelectMultiple?.(BlockEnum.Tool, actions.filter(action => !getIsDisabled(action)).map((tool) => { onSelectMultiple?.(BlockEnum.Tool, actions.filter(action => !getIsDisabled(action)).map((tool) => {
const params: Record<string, string> = {} const params: Record<string, string> = {}
if (tool.parameters) { if (tool.parameters) {

View File

@@ -107,7 +107,8 @@ export const useShortcuts = (): void => {
const { showDebugAndPreviewPanel } = workflowStore.getState() const { showDebugAndPreviewPanel } = workflowStore.getState()
if (shouldHandleShortcut(e) && !showDebugAndPreviewPanel) { if (shouldHandleShortcut(e) && !showDebugAndPreviewPanel) {
e.preventDefault() e.preventDefault()
workflowHistoryShortcutsEnabled && handleHistoryBack() if (workflowHistoryShortcutsEnabled)
handleHistoryBack()
} }
}, { exactMatch: true, useCapture: true }) }, { exactMatch: true, useCapture: true })
@@ -116,7 +117,8 @@ export const useShortcuts = (): void => {
(e) => { (e) => {
if (shouldHandleShortcut(e)) { if (shouldHandleShortcut(e)) {
e.preventDefault() e.preventDefault()
workflowHistoryShortcutsEnabled && handleHistoryForward() if (workflowHistoryShortcutsEnabled)
handleHistoryForward()
} }
}, },
{ exactMatch: true, useCapture: true }, { exactMatch: true, useCapture: true },

View File

@@ -354,7 +354,7 @@ export const useWorkflow = () => {
return startNodes return startNodes
}, [nodesMap, getRootNodesById]) }, [nodesMap, getRootNodesById])
const isValidConnection = useCallback(({ source, sourceHandle, target }: Connection) => { const isValidConnection = useCallback(({ source, sourceHandle: _sourceHandle, target }: Connection) => {
const { const {
edges, edges,
getNodes, getNodes,

View File

@@ -407,7 +407,10 @@ const VarReferencePicker: FC<Props> = ({
<WrapElem onClick={() => { <WrapElem onClick={() => {
if (readonly) if (readonly)
return return
!isConstant ? setOpen(!open) : setControlFocus(Date.now()) if (!isConstant)
setOpen(!open)
else
setControlFocus(Date.now())
}} className='group/picker-trigger-wrap relative !flex'> }} className='group/picker-trigger-wrap relative !flex'>
<> <>
{isAddBtnTrigger {isAddBtnTrigger
@@ -457,7 +460,10 @@ const VarReferencePicker: FC<Props> = ({
onClick={() => { onClick={() => {
if (readonly) if (readonly)
return return
!isConstant ? setOpen(!open) : setControlFocus(Date.now()) if (!isConstant)
setOpen(!open)
else
setControlFocus(Date.now())
}} }}
className='h-full grow' className='h-full grow'
> >

View File

@@ -137,7 +137,7 @@ const Item: FC<ItemProps> = ({
const isHovering = isItemHovering || isChildrenHovering const isHovering = isItemHovering || isChildrenHovering
const open = (isObj || isStructureOutput) && isHovering const open = (isObj || isStructureOutput) && isHovering
useEffect(() => { useEffect(() => {
onHovering && onHovering(isHovering) onHovering?.(isHovering)
}, [isHovering]) }, [isHovering])
const handleChosen = (e: React.MouseEvent) => { const handleChosen = (e: React.MouseEvent) => {
e.stopPropagation() e.stopPropagation()

View File

@@ -25,12 +25,12 @@ type Props = {
} & Partial<ResultPanelProps> } & Partial<ResultPanelProps>
const LastRun: FC<Props> = ({ const LastRun: FC<Props> = ({
appId, appId: _appId,
nodeId, nodeId,
canSingleRun, canSingleRun,
isRunAfterSingleRun, isRunAfterSingleRun,
updateNodeRunningStatus, updateNodeRunningStatus,
nodeInfo, nodeInfo: _nodeInfo,
runningStatus: oneStepRunRunningStatus, runningStatus: oneStepRunRunningStatus,
onSingleRunClicked, onSingleRunClicked,
singleRunResult, singleRunResult,

View File

@@ -88,7 +88,8 @@ const OptionCard = memo(({
)} )}
onClick={(e) => { onClick={(e) => {
e.stopPropagation() e.stopPropagation()
!readonly && enableSelect && id && onClick?.(id) if (!readonly && enableSelect && id)
onClick?.(id)
}} }}
> >
<div className={cn( <div className={cn(

View File

@@ -139,8 +139,10 @@ const JsonSchemaConfig: FC<JsonSchemaConfigProps> = ({
const handleResetDefaults = useCallback(() => { const handleResetDefaults = useCallback(() => {
if (currentTab === SchemaView.VisualEditor) { if (currentTab === SchemaView.VisualEditor) {
setHoveringProperty(null) setHoveringProperty(null)
advancedEditing && setAdvancedEditing(false) if (advancedEditing)
isAddingNewField && setIsAddingNewField(false) setAdvancedEditing(false)
if (isAddingNewField)
setIsAddingNewField(false)
} }
setJsonSchema(DEFAULT_SCHEMA) setJsonSchema(DEFAULT_SCHEMA)
setJson(JSON.stringify(DEFAULT_SCHEMA, null, 2)) setJson(JSON.stringify(DEFAULT_SCHEMA, null, 2))

View File

@@ -87,8 +87,10 @@ const EditCard: FC<EditCardProps> = ({
}) })
useSubscribe('fieldChangeSuccess', () => { useSubscribe('fieldChangeSuccess', () => {
isAddingNewField && setIsAddingNewField(false) if (isAddingNewField)
advancedEditing && setAdvancedEditing(false) setIsAddingNewField(false)
if (advancedEditing)
setAdvancedEditing(false)
}) })
const emitPropertyNameChange = useCallback(() => { const emitPropertyNameChange = useCallback(() => {

View File

@@ -45,8 +45,10 @@ export const useSchemaNodeOperations = (props: VisualEditorProps) => {
onChange(backupSchema) onChange(backupSchema)
setBackupSchema(null) setBackupSchema(null)
} }
isAddingNewField && setIsAddingNewField(false) if (isAddingNewField)
advancedEditing && setAdvancedEditing(false) setIsAddingNewField(false)
if (advancedEditing)
setAdvancedEditing(false)
setHoveringProperty(null) setHoveringProperty(null)
}) })
@@ -221,7 +223,8 @@ export const useSchemaNodeOperations = (props: VisualEditorProps) => {
}) })
useSubscribe('addField', (params) => { useSubscribe('addField', (params) => {
advancedEditing && setAdvancedEditing(false) if (advancedEditing)
setAdvancedEditing(false)
setBackupSchema(jsonSchema) setBackupSchema(jsonSchema)
const { path } = params as AddEventParams const { path } = params as AddEventParams
setIsAddingNewField(true) setIsAddingNewField(true)

View File

@@ -22,7 +22,7 @@ type ConditionValueProps = {
} }
const ConditionValue = ({ const ConditionValue = ({
variableSelector, variableSelector,
labelName, labelName: _labelName,
operator, operator,
value, value,
}: ConditionValueProps) => { }: ConditionValueProps) => {

View File

@@ -35,7 +35,8 @@ const VariableModalTrigger = ({
open={open} open={open}
onOpenChange={() => { onOpenChange={() => {
setOpen(v => !v) setOpen(v => !v)
open && onClose() if (open)
onClose()
}} }}
placement='left-start' placement='left-start'
offset={{ offset={{
@@ -45,7 +46,8 @@ const VariableModalTrigger = ({
> >
<PortalToFollowElemTrigger onClick={() => { <PortalToFollowElemTrigger onClick={() => {
setOpen(v => !v) setOpen(v => !v)
open && onClose() if (open)
onClose()
}}> }}>
<Button variant='primary'> <Button variant='primary'>
<RiAddLine className='mr-1 h-4 w-4' /> <RiAddLine className='mr-1 h-4 w-4' />

View File

@@ -33,7 +33,8 @@ const VariableTrigger = ({
open={open} open={open}
onOpenChange={() => { onOpenChange={() => {
setOpen(v => !v) setOpen(v => !v)
open && onClose() if (open)
onClose()
}} }}
placement='left-start' placement='left-start'
offset={{ offset={{
@@ -43,7 +44,8 @@ const VariableTrigger = ({
> >
<PortalToFollowElemTrigger onClick={() => { <PortalToFollowElemTrigger onClick={() => {
setOpen(v => !v) setOpen(v => !v)
open && onClose() if (open)
onClose()
}}> }}>
<Button variant='primary'> <Button variant='primary'>
<RiAddLine className='mr-1 h-4 w-4' /> <RiAddLine className='mr-1 h-4 w-4' />

View File

@@ -81,9 +81,12 @@ const RunPanel: FC<RunProps> = ({
const switchTab = async (tab: string) => { const switchTab = async (tab: string) => {
setCurrentTab(tab) setCurrentTab(tab)
if (tab === 'RESULT') if (tab === 'RESULT') {
runDetailUrl && await getResult() if (runDetailUrl)
tracingListUrl && await getTracingList() await getResult()
}
if (tracingListUrl)
await getTracingList()
} }
useEffect(() => { useEffect(() => {

View File

@@ -15,7 +15,7 @@ import { useNodeLoopInteractions } from './hooks'
const Node: FC<NodeProps<LoopNodeType>> = ({ const Node: FC<NodeProps<LoopNodeType>> = ({
id, id,
data, data: _data,
}) => { }) => {
const { zoom } = useViewport() const { zoom } = useViewport()
const nodesInitialized = useNodesInitialized() const nodesInitialized = useNodesInitialized()

View File

@@ -19,7 +19,7 @@ type MailAndPasswordAuthProps = {
allowRegistration: boolean allowRegistration: boolean
} }
export default function MailAndPasswordAuth({ isInvite, isEmailSetup, allowRegistration }: MailAndPasswordAuthProps) { export default function MailAndPasswordAuth({ isInvite, isEmailSetup, allowRegistration: _allowRegistration }: MailAndPasswordAuthProps) {
const { t } = useTranslation() const { t } = useTranslation()
const { locale } = useContext(I18NContext) const { locale } = useContext(I18NContext)
const router = useRouter() const router = useRouter()

View File

@@ -14,7 +14,8 @@ export type Locale = typeof i18n['locales'][number]
export const setLocaleOnClient = async (locale: Locale, reloadPage = true) => { export const setLocaleOnClient = async (locale: Locale, reloadPage = true) => {
Cookies.set(LOCALE_COOKIE_NAME, locale, { expires: 365 }) Cookies.set(LOCALE_COOKIE_NAME, locale, { expires: 365 })
await changeLanguage(locale) await changeLanguage(locale)
reloadPage && location.reload() if (reloadPage)
location.reload()
} }
export const getLocaleOnClient = (): Locale => { export const getLocaleOnClient = (): Locale => {

View File

@@ -182,7 +182,7 @@ const handleStream = (
let hasError = false let hasError = false
reader?.read().then((result: any) => { reader?.read().then((result: any) => {
if (result.done) { if (result.done) {
onCompleted && onCompleted() onCompleted?.()
return return
} }
buffer += decoder.decode(result.value, { stream: true }) buffer += decoder.decode(result.value, { stream: true })

View File

@@ -0,0 +1 @@
export {}

View File

@@ -290,8 +290,10 @@ export const fetchAccessToken = async ({ appCode, userId, webAppAccessToken }: {
const headers = new Headers() const headers = new Headers()
headers.append('X-App-Code', appCode) headers.append('X-App-Code', appCode)
const params = new URLSearchParams() const params = new URLSearchParams()
webAppAccessToken && params.append('web_app_access_token', webAppAccessToken) if (webAppAccessToken)
userId && params.append('user_id', userId) params.append('web_app_access_token', webAppAccessToken)
if (userId)
params.append('user_id', userId)
const url = `/passport?${params.toString()}` const url = `/passport?${params.toString()}`
return get(url, { headers }) as Promise<{ access_token: string }> return get(url, { headers }) as Promise<{ access_token: string }>
} }

View File

@@ -29,7 +29,7 @@ export const getNewVar = (key: string, type: string) => {
} }
export const getNewVarInWorkflow = (key: string, type = InputVarType.textInput): InputVar => { export const getNewVarInWorkflow = (key: string, type = InputVarType.textInput): InputVar => {
const { max_length, ...rest } = VAR_ITEM_TEMPLATE_IN_WORKFLOW const { max_length: _maxLength, ...rest } = VAR_ITEM_TEMPLATE_IN_WORKFLOW
if (type !== InputVarType.textInput) { if (type !== InputVarType.textInput) {
return { return {
...rest, ...rest,
@@ -49,7 +49,7 @@ export const getNewVarInWorkflow = (key: string, type = InputVarType.textInput):
} }
} }
export const checkKey = (key: string, canBeEmpty?: boolean, keys?: string[]) => { export const checkKey = (key: string, canBeEmpty?: boolean, _keys?: string[]) => {
if (key.length === 0 && !canBeEmpty) if (key.length === 0 && !canBeEmpty)
return 'canNoBeEmpty' return 'canNoBeEmpty'