forked from infiniflow/ragflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Bind data to TenantTable infiniflow#2846 (infiniflow#2883)
### What problem does this PR solve? feat: Bind data to TenantTable infiniflow#2846 feat: Add TenantTable ### Type of change - [x] New Feature (non-breaking change which adds functionality)
- Loading branch information
Showing
15 changed files
with
548 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
web/src/pages/user-setting/setting-team/add-user-modal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { IModalProps } from '@/interfaces/common'; | ||
import { Form, Input, Modal } from 'antd'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
const AddingUserModal = ({ | ||
visible, | ||
hideModal, | ||
loading, | ||
onOk, | ||
}: IModalProps<string>) => { | ||
const [form] = Form.useForm(); | ||
const { t } = useTranslation(); | ||
|
||
type FieldType = { | ||
email?: string; | ||
}; | ||
|
||
const handleOk = async () => { | ||
const ret = await form.validateFields(); | ||
|
||
return onOk?.(ret.email); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
title={t('setting.add')} | ||
open={visible} | ||
onOk={handleOk} | ||
onCancel={hideModal} | ||
okButtonProps={{ loading }} | ||
confirmLoading={loading} | ||
> | ||
<Form | ||
name="basic" | ||
labelCol={{ span: 6 }} | ||
wrapperCol={{ span: 18 }} | ||
autoComplete="off" | ||
form={form} | ||
> | ||
<Form.Item<FieldType> | ||
label={t('setting.email')} | ||
name="email" | ||
rules={[{ required: true, message: t('namePlaceholder') }]} | ||
> | ||
<Input /> | ||
</Form.Item> | ||
</Form> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default AddingUserModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { useSetModalState, useShowDeleteConfirm } from '@/hooks/common-hooks'; | ||
import { | ||
useAddTenantUser, | ||
useAgreeTenant, | ||
useDeleteTenantUser, | ||
useFetchUserInfo, | ||
} from '@/hooks/user-setting-hooks'; | ||
import { useCallback } from 'react'; | ||
|
||
export const useAddUser = () => { | ||
const { addTenantUser } = useAddTenantUser(); | ||
const { | ||
visible: addingTenantModalVisible, | ||
hideModal: hideAddingTenantModal, | ||
showModal: showAddingTenantModal, | ||
} = useSetModalState(); | ||
|
||
const handleAddUserOk = useCallback( | ||
async (email: string) => { | ||
const retcode = await addTenantUser(email); | ||
if (retcode === 0) { | ||
hideAddingTenantModal(); | ||
} | ||
}, | ||
[addTenantUser, hideAddingTenantModal], | ||
); | ||
|
||
return { | ||
addingTenantModalVisible, | ||
hideAddingTenantModal, | ||
showAddingTenantModal, | ||
handleAddUserOk, | ||
}; | ||
}; | ||
|
||
export const useHandleDeleteUser = () => { | ||
const { deleteTenantUser, loading } = useDeleteTenantUser(); | ||
const showDeleteConfirm = useShowDeleteConfirm(); | ||
|
||
const handleDeleteTenantUser = (userId: string) => () => { | ||
showDeleteConfirm({ | ||
onOk: async () => { | ||
const retcode = await deleteTenantUser({ userId }); | ||
if (retcode === 0) { | ||
} | ||
return; | ||
}, | ||
}); | ||
}; | ||
|
||
return { handleDeleteTenantUser, loading }; | ||
}; | ||
|
||
export const useHandleAgreeTenant = () => { | ||
const { agreeTenant } = useAgreeTenant(); | ||
const { deleteTenantUser } = useDeleteTenantUser(); | ||
const { data: user } = useFetchUserInfo(); | ||
|
||
const handleAgree = (tenantId: string, isAgree: boolean) => () => { | ||
if (isAgree) { | ||
agreeTenant(tenantId); | ||
} else { | ||
deleteTenantUser({ tenantId, userId: user.id }); | ||
} | ||
}; | ||
|
||
return { handleAgree }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
.teamWrapper { | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 20px; | ||
.teamCard { | ||
// width: 100%; | ||
} | ||
|
Oops, something went wrong.