Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor(web): migrate dataset settings name input (#41611)

yyh18ac946e2b9f
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index b49151c8f84..486baa63b5d 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -392,9 +392,6 @@
"jsx-a11y/no-static-element-interactions": {
"count": 1
},
- "no-restricted-imports": {
- "count": 1
- },
"typescript/no-explicit-any": {
"count": 1
}
@@ -5374,4 +5371,4 @@
"count": 2
}
}
-}
+}
\ No newline at end of file
diff --git a/web/app/components/app/configuration/dataset-config/settings-modal/__tests__/index.spec.tsx b/web/app/components/app/configuration/dataset-config/settings-modal/__tests__/index.spec.tsx
index 6b3363366eb..acd85b398ce 100644
--- a/web/app/components/app/configuration/dataset-config/settings-modal/__tests__/index.spec.tsx
+++ b/web/app/components/app/configuration/dataset-config/settings-modal/__tests__/index.spec.tsx
@@ -284,7 +284,7 @@ describe('SettingsModal', () => {
await renderSettingsModal(dataset)
// Assert
- expect(screen.getByPlaceholderText('datasetSettings.form.namePlaceholder')).toHaveValue(
+ expect(screen.getByRole('textbox', { name: 'datasetSettings.form.name' })).toHaveValue(
'Test Dataset',
)
expect(screen.getByPlaceholderText('datasetSettings.form.descPlaceholder')).toHaveValue(
@@ -333,7 +333,7 @@ describe('SettingsModal', () => {
const user = userEvent.setup()
await renderSettingsModal(createDataset())
- const nameInput = screen.getByPlaceholderText('datasetSettings.form.namePlaceholder')
+ const nameInput = screen.getByRole('textbox', { name: 'datasetSettings.form.name' })
// Act
await user.clear(nameInput)
@@ -417,7 +417,7 @@ describe('SettingsModal', () => {
const user = userEvent.setup()
await renderSettingsModal(createDataset())
- const nameInput = screen.getByPlaceholderText('datasetSettings.form.namePlaceholder')
+ const nameInput = screen.getByRole('textbox', { name: 'datasetSettings.form.name' })
// Act
await user.clear(nameInput)
@@ -483,7 +483,7 @@ describe('SettingsModal', () => {
// Act
await renderSettingsModal(dataset)
- const nameInput = screen.getByPlaceholderText('datasetSettings.form.namePlaceholder')
+ const nameInput = screen.getByRole('textbox', { name: 'datasetSettings.form.name' })
await user.clear(nameInput)
await user.type(nameInput, 'Updated Internal Dataset')
await user.click(screen.getByRole('button', { name: 'common.operation.save' }))
diff --git a/web/app/components/app/configuration/dataset-config/settings-modal/index.tsx b/web/app/components/app/configuration/dataset-config/settings-modal/index.tsx
index be646be30fd..a36903a222a 100644
--- a/web/app/components/app/configuration/dataset-config/settings-modal/index.tsx
+++ b/web/app/components/app/configuration/dataset-config/settings-modal/index.tsx
@@ -5,14 +5,14 @@ import type { DataSet } from '@/models/datasets'
import type { RetrievalConfig } from '@/types/app'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
+import { Input } from '@langgenius/dify-ui/input'
import { Textarea } from '@langgenius/dify-ui/textarea'
import { RiCloseLine } from '@remixicon/react'
import { isEqual } from 'es-toolkit/predicate'
import { useQueryState } from 'nuqs'
-import { useEffect, useMemo, useRef, useState } from 'react'
+import { useEffect, useId, useMemo, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { toast } from '@/app/components/app/configuration/toast'
-import Input from '@/app/components/base/input'
import { isReRankModelSelected } from '@/app/components/datasets/common/check-rerank-model'
import { IndexingType } from '@/app/components/datasets/create/step-two'
import IndexMethod from '@/app/components/datasets/settings/index-method'
@@ -58,6 +58,7 @@ const SettingsModal: FC<SettingsModalProps> = ({
const translateRetrieval: RetrievalTranslate = (selector, options) => t(selector, options)
const docLink = useDocLink()
const ref = useRef(null)
+ const nameInputId = useId()
const isExternal = currentDataset.provider === 'external'
const [, setSettingsDestination] = useQueryState(settingsQueryParamName, settingsQueryParser)
const [loading, setLoading] = useState(false)
@@ -232,13 +233,14 @@ const SettingsModal: FC<SettingsModalProps> = ({
<div className="overflow-y-auto border-b border-divider-regular p-6 pt-5 pb-17">
<div className={cn(rowClass, 'items-center')}>
<div className={labelClass}>
- <div className="system-sm-semibold text-text-secondary">
+ <label htmlFor={nameInputId} className="system-sm-semibold text-text-secondary">
{t(($) => $['form.name'], { ns: 'datasetSettings' })}
- </div>
+ </label>
</div>
<Input
+ id={nameInputId}
value={localeCurrentDataset.name}
- onChange={(e) => handleValueChange('name', e.target.value)}
+ onValueChange={(value) => handleValueChange('name', value)}
className="block h-9"
placeholder={t(($) => $['form.namePlaceholder'], { ns: 'datasetSettings' }) || ''}
/>