Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
d96bcfa4
Unverified
Commit
d96bcfa4
authored
May 24, 2023
by
zxhlyh
Committed by
GitHub
May 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: dataset setting (#183)
parent
380b4b3d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
10 deletions
+34
-10
page.tsx
...asets/(datasetDetailLayout)/[datasetId]/settings/page.tsx
+8
-2
index.tsx
web/app/components/datasets/settings/form/index.tsx
+26
-8
No files found.
web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/settings/page.tsx
View file @
d96bcfa4
...
...
@@ -3,7 +3,13 @@ import { getLocaleOnServer } from '@/i18n/server'
import
{
useTranslation
}
from
'@/i18n/i18next-serverside-config'
import
Form
from
'@/app/components/datasets/settings/form'
const
Settings
=
async
()
=>
{
type
Props
=
{
params
:
{
datasetId
:
string
}
}
const
Settings
=
async
({
params
:
{
datasetId
},
}:
Props
)
=>
{
const
locale
=
getLocaleOnServer
()
const
{
t
}
=
await
useTranslation
(
locale
,
'dataset-settings'
)
...
...
@@ -14,7 +20,7 @@ const Settings = async () => {
<
div
className=
'text-sm text-gray-500'
>
{
t
(
'desc'
)
}
</
div
>
</
div
>
<
div
>
<
Form
/>
<
Form
datasetId=
{
datasetId
}
/>
</
div
>
</
div
>
)
...
...
web/app/components/datasets/settings/form/index.tsx
View file @
d96bcfa4
'use client'
import
{
useState
}
from
'react'
import
{
Dispatch
,
SetStateAction
,
useEffect
,
useState
}
from
'react'
import
useSWR
from
'swr'
import
{
useContext
}
from
'use-context-selector'
import
{
BookOpenIcon
}
from
'@heroicons/react/24/outline'
import
{
useTranslation
}
from
'react-i18next'
...
...
@@ -7,8 +8,8 @@ import { ToastContext } from '@/app/components/base/toast'
import
PermissionsRadio
from
'../permissions-radio'
import
IndexMethodRadio
from
'../index-method-radio'
import
Button
from
'@/app/components/base/button'
import
{
u
seDatasetsContext
}
from
'@/context/datasets-context
'
import
{
updateDatasetSetting
}
from
'@/service
/datasets'
import
{
u
pdateDatasetSetting
,
fetchDataDetail
}
from
'@/service/datasets
'
import
{
DataSet
}
from
'@/models
/datasets'
const
rowClass
=
`
flex justify-between py-4
...
...
@@ -20,13 +21,25 @@ const inputClass = `
w-[480px] px-3 bg-gray-100 text-sm text-gray-800 rounded-lg outline-none appearance-none
`
const
Form
=
()
=>
{
const
useInitialValue
=
<
T
,
>
(depend: T, dispatch: Dispatch
<
SetStateAction
<
T
>
>
) =
>
{
useEffect
(()
=>
{
dispatch
(
depend
)
},
[
depend
])
}
type Props =
{
datasetId
:
string
}
const Form = (
{
datasetId
}
: Props) =
>
{
const
{
t
}
=
useTranslation
()
const
{
notify
}
=
useContext
(
ToastContext
)
const
{
currentDataset
,
mutateDatasets
}
=
useDatasetsContext
(
)
const
{
data
:
currentDataset
,
mutate
:
mutateDatasets
}
=
useSWR
(
datasetId
,
fetchDataDetail
)
const
[
loading
,
setLoading
]
=
useState
(
false
)
const
[
name
,
setName
]
=
useState
(
currentDataset
?.
name
)
const
[
description
,
setDescription
]
=
useState
(
currentDataset
?.
description
)
const
[
name
,
setName
]
=
useState
(
currentDataset
?.
name
??
''
)
const
[
description
,
setDescription
]
=
useState
(
currentDataset
?.
description
??
''
)
const
[
permission
,
setPermission
]
=
useState
(
currentDataset
?.
permission
)
const
[
indexMethod
,
setIndexMethod
]
=
useState
(
currentDataset
?.
indexing_technique
)
...
...
@@ -48,7 +61,7 @@ const Form = () => {
}
})
notify
({
type
:
'success'
,
message
:
t
(
'common.actionMsg.modifiedSuccessfully'
)
})
mutateDatasets
()
await
mutateDatasets
()
}
catch
(
e
)
{
notify
({
type
:
'error'
,
message
:
t
(
'common.actionMsg.modificationFailed'
)
})
}
finally
{
...
...
@@ -56,6 +69,11 @@ const Form = () => {
}
}
useInitialValue
<
string
>
(
currentDataset
?.
name
??
''
,
setName
)
useInitialValue
<
string
>
(
currentDataset
?.
description
??
''
,
setDescription
)
useInitialValue
<
DataSet
[
'permission'
]
|
undefined
>
(
currentDataset
?.
permission
,
setPermission
)
useInitialValue
<
DataSet
[
'indexing_technique'
]
|
undefined
>
(
currentDataset
?.
indexing_technique
,
setIndexMethod
)
return
(
<
div
className=
'w-[800px] px-16 py-6'
>
<
div
className=
{
rowClass
}
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment