Skip to content

Commit 98ee3de

Browse files
authored
Feat: Move the dataset permission drop-down box to a separate file for better permission control #3221 (#9850)
### What problem does this PR solve? Feat: Move the dataset permission drop-down box to a separate file for better permission control #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
1 parent d4b0cd8 commit 98ee3de

File tree

3 files changed

+32
-23
lines changed

3 files changed

+32
-23
lines changed

web/src/pages/dataset/setting/form-schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const formSchema = z.object({
99
}),
1010
// avatar: z.instanceof(File),
1111
avatar: z.any().nullish(),
12-
permission: z.string(),
12+
permission: z.string().optional(),
1313
parser_id: z.string(),
1414
embd_id: z.string(),
1515
parser_config: z

web/src/pages/dataset/setting/general-form.tsx

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { AvatarUpload } from '@/components/avatar-upload';
22
import { FormContainer } from '@/components/form-container';
3-
import { SelectWithSearch } from '@/components/originui/select-with-search';
4-
import { RAGFlowFormItem } from '@/components/ragflow-form';
53
import { Button } from '@/components/ui/button';
64
import {
75
FormControl,
@@ -11,23 +9,15 @@ import {
119
FormMessage,
1210
} from '@/components/ui/form';
1311
import { Input } from '@/components/ui/input';
14-
import { PermissionRole } from '@/constants/permission';
15-
import { useMemo } from 'react';
1612
import { useFormContext } from 'react-hook-form';
1713
import { useTranslation } from 'react-i18next';
14+
import { PermissionFormField } from './permission-form-field';
1815
import { GeneralSavingButton } from './saving-button';
1916

2017
export function GeneralForm() {
2118
const form = useFormContext();
2219
const { t } = useTranslation();
2320

24-
const teamOptions = useMemo(() => {
25-
return Object.values(PermissionRole).map((x) => ({
26-
label: t('knowledgeConfiguration.' + x),
27-
value: x,
28-
}));
29-
}, [t]);
30-
3121
return (
3222
<>
3323
<FormContainer className="space-y-10 p-10">
@@ -98,17 +88,7 @@ export function GeneralForm() {
9888
);
9989
}}
10090
/>
101-
<RAGFlowFormItem
102-
name="permission"
103-
label={t('knowledgeConfiguration.permissions')}
104-
tooltip={t('knowledgeConfiguration.permissionsTip')}
105-
horizontal
106-
>
107-
<SelectWithSearch
108-
options={teamOptions}
109-
triggerClassName="w-3/4"
110-
></SelectWithSearch>
111-
</RAGFlowFormItem>
91+
<PermissionFormField></PermissionFormField>
11292
</FormContainer>
11393
<div className="text-right pt-4 flex justify-end gap-3">
11494
<Button
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { SelectWithSearch } from '@/components/originui/select-with-search';
2+
import { RAGFlowFormItem } from '@/components/ragflow-form';
3+
import { PermissionRole } from '@/constants/permission';
4+
import { useMemo } from 'react';
5+
import { useTranslation } from 'react-i18next';
6+
7+
export function PermissionFormField() {
8+
const { t } = useTranslation();
9+
const teamOptions = useMemo(() => {
10+
return Object.values(PermissionRole).map((x) => ({
11+
label: t('knowledgeConfiguration.' + x),
12+
value: x,
13+
}));
14+
}, [t]);
15+
16+
return (
17+
<RAGFlowFormItem
18+
name="permission"
19+
label={t('knowledgeConfiguration.permissions')}
20+
tooltip={t('knowledgeConfiguration.permissionsTip')}
21+
horizontal
22+
>
23+
<SelectWithSearch
24+
options={teamOptions}
25+
triggerClassName="w-3/4"
26+
></SelectWithSearch>
27+
</RAGFlowFormItem>
28+
);
29+
}

0 commit comments

Comments
 (0)