mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 18:48:55 +00:00
4.8.6 merge (#1943)
* Dataset collection forbid (#1885) * perf: tool call support same id * feat: collection forbid * feat: collection forbid * Inheritance Permission for apps (#1897) * feat: app schema define chore: references of authapp * feat: authApp method inheritance * feat: create and update api * feat: update * feat: inheritance Permission controller for app. * feat: abstract version of inheritPermission * feat: ancestorId for apps * chore: update app * fix: inheritPermission abstract version * feat: update folder defaultPermission * feat: app update api * chore: inheritance frontend * chore: app list api * feat: update defaultPermission in app deatil * feat: backend api finished * feat: app inheritance permission fe * fix: app update defaultpermission causes collaborator miss * fix: ts error * chore: adjust the codes * chore: i18n chore: i18n * chore: fe adjust and i18n * chore: adjust the code * feat: resume api; chore: rewrite update api and inheritPermission methods * chore: something * chore: fe code adjusting * feat: frontend adjusting * chore: fe code adjusting * chore: adjusting the code * perf: fe loading * format * Inheritance fix (#1908) * fix: SlideCard * fix: authapp did not return parent app for inheritance app * fix: fe adjusting * feat: fe adjusing * perf: inherit per ux * doc * fix: ts errors (#1916) * perf: inherit permission * fix: permission inherit * Workflow type (#1938) * perf: workflow type tmp workflow perf: workflow type feat: custom field config * perf: dynamic input * perf: node classify * perf: node classify * perf: node classify * perf: node classify * fix: workflow custom input * feat: text editor and customFeedback move to basic nodes * feat: community system plugin * fix: ts * feat: exprEval plugin * perf: workflow type * perf: plugin important * fix: default templates * perf: markdown hr css * lock * perf: fetch url * perf: new plugin version * fix: chat histories update * fix: collection paths invalid * perf: app card ui --------- Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com>
This commit is contained in:
@@ -8,7 +8,7 @@ const Avatar = ({ w = '30px', src, ...props }: ImageProps) => {
|
||||
<Image
|
||||
fallbackSrc={LOGO_ICON}
|
||||
fallbackStrategy={'onError'}
|
||||
borderRadius={'md'}
|
||||
// borderRadius={'md'}
|
||||
objectFit={'contain'}
|
||||
alt=""
|
||||
w={w}
|
||||
|
@@ -15,7 +15,7 @@ const ChatAvatar = ({ src, type }: { src?: string; type: 'Human' | 'AI' }) => {
|
||||
boxShadow={'0 0 5px rgba(0,0,0,0.1)'}
|
||||
bg={type === 'Human' ? 'white' : 'primary.50'}
|
||||
>
|
||||
<Avatar src={src} w={'100%'} h={'100%'} />
|
||||
<Avatar src={src} w={'100%'} h={'100%'} borderRadius={'sm'} />
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
@@ -158,7 +158,7 @@ ${JSON.stringify(questionGuides)}`;
|
||||
bg: 'auto'
|
||||
}}
|
||||
>
|
||||
<Avatar src={tool.toolAvatar} borderRadius={'md'} w={'1rem'} mr={2} />
|
||||
<Avatar src={tool.toolAvatar} w={'1rem'} mr={2} />
|
||||
<Box mr={1} fontSize={'sm'}>
|
||||
{tool.toolName}
|
||||
</Box>
|
||||
|
@@ -3,6 +3,7 @@ import { ChatItemType } from '@fastgpt/global/core/chat/type';
|
||||
import { useCallback } from 'react';
|
||||
import { htmlTemplate } from '@/web/core/chat/constants';
|
||||
import { fileDownload } from '@/web/common/file/utils';
|
||||
import { ChatItemValueTypeEnum } from '@fastgpt/global/core/chat/constants';
|
||||
|
||||
export const useChatBox = () => {
|
||||
const onExportChat = useCallback(
|
||||
@@ -40,8 +41,30 @@ export const useChatBox = () => {
|
||||
|
||||
const map: Record<ExportChatType, () => void> = {
|
||||
md: () => {
|
||||
console.log(history);
|
||||
fileDownload({
|
||||
text: history.map((item) => item.value).join('\n\n'),
|
||||
text: history
|
||||
.map((item) => {
|
||||
let result = `Role: ${item.obj}\n`;
|
||||
const content = item.value.map((item) => {
|
||||
if (item.type === ChatItemValueTypeEnum.text) {
|
||||
return item.text?.content;
|
||||
} else if (item.type === ChatItemValueTypeEnum.file) {
|
||||
return `
|
||||

|
||||
`;
|
||||
} else if (item.type === ChatItemValueTypeEnum.tool) {
|
||||
return `
|
||||
\`\`\`Toll
|
||||
${JSON.stringify(item.tools, null, 2)}
|
||||
\`\`\`
|
||||
`;
|
||||
}
|
||||
});
|
||||
|
||||
return result + content;
|
||||
})
|
||||
.join('\n\n-------\n\n'),
|
||||
type: 'text/markdown',
|
||||
filename: 'chat.md'
|
||||
});
|
||||
|
@@ -10,7 +10,7 @@ const CommunityModal = ({ onClose }: { onClose: () => void }) => {
|
||||
const { feConfigs } = useSystemStore();
|
||||
|
||||
return (
|
||||
<MyModal isOpen={true} onClose={onClose} iconSrc="modal/concat" title={t('home.Community')}>
|
||||
<MyModal isOpen={true} onClose={onClose} iconSrc="modal/concat" title={t('system.Concat us')}>
|
||||
<ModalBody textAlign={'center'}>
|
||||
<Markdown source={feConfigs?.concatMd || ''} />
|
||||
</ModalBody>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import { Skeleton } from '@chakra-ui/react';
|
||||
import MyPhotoView from '@fastgpt/web/components/common/Image/PhotoView';
|
||||
import { useBoolean } from 'ahooks';
|
||||
@@ -6,11 +6,13 @@ import { useBoolean } from 'ahooks';
|
||||
const MdImage = ({ src }: { src?: string }) => {
|
||||
const [isLoaded, { setTrue }] = useBoolean(false);
|
||||
|
||||
const [renderSrc, setRenderSrc] = useState(src);
|
||||
|
||||
return (
|
||||
<Skeleton isLoaded={isLoaded}>
|
||||
<MyPhotoView
|
||||
borderRadius={'md'}
|
||||
src={src}
|
||||
src={renderSrc}
|
||||
alt={''}
|
||||
fallbackSrc={'/imgs/errImg.png'}
|
||||
fallbackStrategy={'onError'}
|
||||
@@ -21,10 +23,12 @@ const MdImage = ({ src }: { src?: string }) => {
|
||||
minH={'120px'}
|
||||
maxH={'500px'}
|
||||
my={1}
|
||||
mx={'auto'}
|
||||
onLoad={() => {
|
||||
setTrue();
|
||||
}}
|
||||
onError={() => {
|
||||
setRenderSrc('/imgs/errImg.png');
|
||||
setTrue();
|
||||
}}
|
||||
/>
|
||||
|
@@ -341,6 +341,7 @@
|
||||
}
|
||||
.markdown hr {
|
||||
margin: 10px 0;
|
||||
border-color: var(--chakra-colors-gray-300);
|
||||
}
|
||||
.markdown {
|
||||
tab-size: 4;
|
||||
|
@@ -39,7 +39,7 @@ const FolderPath = (props: {
|
||||
{concatPaths.map((item, i) => (
|
||||
<Flex key={item.parentId || i} alignItems={'center'}>
|
||||
<Box
|
||||
fontSize={['sm', fontSize || 'sm']}
|
||||
fontSize={['xs', fontSize || 'sm']}
|
||||
py={0.5}
|
||||
px={1.5}
|
||||
borderRadius={'md'}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import { Box, Button, Flex, HStack } from '@chakra-ui/react';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import React from 'react';
|
||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import { FolderIcon } from '@fastgpt/global/common/file/image/constants';
|
||||
@@ -13,6 +14,8 @@ import CollaboratorContextProvider, {
|
||||
} from '../../support/permission/MemberManager/context';
|
||||
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import { useI18n } from '@/web/context/I18n';
|
||||
import ResumeInherit from '@/components/support/permission/ResumeInheritText';
|
||||
|
||||
const FolderSlideCard = ({
|
||||
refreshDeps,
|
||||
@@ -24,7 +27,11 @@ const FolderSlideCard = ({
|
||||
onDelete,
|
||||
|
||||
defaultPer,
|
||||
managePer
|
||||
managePer,
|
||||
isInheritPermission,
|
||||
resumeInheritPermission,
|
||||
hasParent,
|
||||
refetchResource
|
||||
}: {
|
||||
refreshDeps?: any[];
|
||||
name: string;
|
||||
@@ -40,9 +47,16 @@ const FolderSlideCard = ({
|
||||
onChange: (v: PermissionValueType) => Promise<any>;
|
||||
};
|
||||
managePer: MemberManagerInputPropsType;
|
||||
|
||||
isInheritPermission?: boolean;
|
||||
resumeInheritPermission?: () => Promise<void>;
|
||||
hasParent?: boolean;
|
||||
refetchResource?: () => Promise<any>;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const { feConfigs } = useSystemStore();
|
||||
const { commonT } = useI18n();
|
||||
const { toast } = useToast();
|
||||
|
||||
const { ConfirmModal, openConfirm } = useConfirm({
|
||||
type: 'delete',
|
||||
@@ -118,6 +132,12 @@ const FolderSlideCard = ({
|
||||
<Box>
|
||||
<FormLabel>{t('support.permission.Permission')}</FormLabel>
|
||||
|
||||
{!isInheritPermission && (
|
||||
<Box mt={2}>
|
||||
<ResumeInherit onResume={() => resumeInheritPermission?.().then(refetchResource)} />
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{managePer.permission.hasManagePer && (
|
||||
<Box mt={5}>
|
||||
<Box fontSize={'sm'} color={'myGray.500'}>
|
||||
@@ -127,12 +147,20 @@ const FolderSlideCard = ({
|
||||
mt="1"
|
||||
per={defaultPer.value}
|
||||
defaultPer={defaultPer.defaultValue}
|
||||
onChange={defaultPer.onChange}
|
||||
isInheritPermission={isInheritPermission}
|
||||
onChange={(v) => defaultPer.onChange(v)}
|
||||
hasParent={hasParent}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
<Box mt={6}>
|
||||
<CollaboratorContextProvider {...managePer} refreshDeps={refreshDeps}>
|
||||
<CollaboratorContextProvider
|
||||
{...managePer}
|
||||
refreshDeps={refreshDeps}
|
||||
refetchResource={refetchResource}
|
||||
isInheritPermission={isInheritPermission}
|
||||
hasParent={hasParent}
|
||||
>
|
||||
{({ MemberListCard, onOpenManageModal, onOpenAddMember }) => {
|
||||
return (
|
||||
<>
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import React, { useState, DragEvent, useCallback } from 'react';
|
||||
import type { BoxProps } from '@chakra-ui/react';
|
||||
import { useBoolean } from 'ahooks';
|
||||
|
||||
export const useFolderDrag = ({
|
||||
onDrop,
|
||||
@@ -10,11 +11,13 @@ export const useFolderDrag = ({
|
||||
}) => {
|
||||
const [dragId, setDragId] = useState<string>();
|
||||
const [targetId, setTargetId] = useState<string>();
|
||||
const [isDropping, { setTrue, setFalse }] = useBoolean();
|
||||
|
||||
const getBoxProps = useCallback(
|
||||
({ dataId, isFolder }: { dataId: string; isFolder: boolean }) => {
|
||||
return {
|
||||
draggable: true,
|
||||
userSelect: 'none' as any,
|
||||
'data-drag-id': isFolder ? dataId : undefined,
|
||||
onDragStart: (e: DragEvent<HTMLDivElement>) => {
|
||||
setDragId(dataId);
|
||||
@@ -29,15 +32,19 @@ export const useFolderDrag = ({
|
||||
e.preventDefault();
|
||||
setTargetId(undefined);
|
||||
},
|
||||
onDrop: (e: DragEvent<HTMLDivElement>) => {
|
||||
onDrop: async (e: DragEvent<HTMLDivElement>) => {
|
||||
e.preventDefault();
|
||||
setTrue();
|
||||
|
||||
if (targetId && dragId && targetId !== dragId) {
|
||||
onDrop(dragId, targetId);
|
||||
}
|
||||
try {
|
||||
if (targetId && dragId && targetId !== dragId) {
|
||||
await onDrop(dragId, targetId);
|
||||
}
|
||||
} catch (error) {}
|
||||
|
||||
setTargetId(undefined);
|
||||
setDragId(undefined);
|
||||
setFalse();
|
||||
},
|
||||
...(activeStyles &&
|
||||
targetId === dataId && {
|
||||
@@ -45,10 +52,11 @@ export const useFolderDrag = ({
|
||||
})
|
||||
};
|
||||
},
|
||||
[activeStyles, dragId, onDrop, targetId]
|
||||
[activeStyles, dragId, onDrop, setFalse, setTrue, targetId]
|
||||
);
|
||||
|
||||
return {
|
||||
getBoxProps
|
||||
getBoxProps,
|
||||
isDropping
|
||||
};
|
||||
};
|
||||
|
@@ -7,6 +7,9 @@ import { Box, Button, Flex, HStack, ModalBody } from '@chakra-ui/react';
|
||||
import Avatar from '@/components/Avatar';
|
||||
import DefaultPermissionList from '../DefaultPerList';
|
||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||
import { useConfirm } from '@fastgpt/web/hooks/useConfirm';
|
||||
import { useI18n } from '@/web/context/I18n';
|
||||
import ResumeInherit from '../ResumeInheritText';
|
||||
|
||||
export type ConfigPerModalProps = {
|
||||
avatar?: string;
|
||||
@@ -18,6 +21,10 @@ export type ConfigPerModalProps = {
|
||||
onChange: (v: PermissionValueType) => Promise<any>;
|
||||
};
|
||||
managePer: MemberManagerInputPropsType;
|
||||
isInheritPermission?: boolean;
|
||||
resumeInheritPermission?: () => void;
|
||||
hasParent?: boolean;
|
||||
refetchResource?: () => void;
|
||||
};
|
||||
|
||||
const ConfigPerModal = ({
|
||||
@@ -25,71 +32,90 @@ const ConfigPerModal = ({
|
||||
name,
|
||||
defaultPer,
|
||||
managePer,
|
||||
onClose
|
||||
isInheritPermission,
|
||||
resumeInheritPermission,
|
||||
hasParent,
|
||||
onClose,
|
||||
refetchResource
|
||||
}: ConfigPerModalProps & {
|
||||
onClose: () => void;
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<MyModal
|
||||
isOpen
|
||||
iconSrc="/imgs/modal/key.svg"
|
||||
onClose={onClose}
|
||||
title={t('permission.Permission config')}
|
||||
>
|
||||
<ModalBody>
|
||||
<HStack>
|
||||
<Avatar src={avatar} w={'1.75rem'} />
|
||||
<Box>{name}</Box>
|
||||
</HStack>
|
||||
<Box mt={6}>
|
||||
<Box fontSize={'sm'}>{t('permission.Default permission')}</Box>
|
||||
<DefaultPermissionList
|
||||
mt="1"
|
||||
per={defaultPer.value}
|
||||
defaultPer={defaultPer.defaultValue}
|
||||
onChange={defaultPer.onChange}
|
||||
/>
|
||||
</Box>
|
||||
<Box mt={4}>
|
||||
<CollaboratorContextProvider {...managePer}>
|
||||
{({ MemberListCard, onOpenManageModal, onOpenAddMember }) => {
|
||||
return (
|
||||
<>
|
||||
<Flex
|
||||
alignItems="center"
|
||||
flexDirection="row"
|
||||
justifyContent="space-between"
|
||||
w="full"
|
||||
>
|
||||
<Box fontSize={'sm'}>{t('permission.Collaborator')}</Box>
|
||||
<Flex flexDirection="row" gap="2">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="whitePrimary"
|
||||
leftIcon={<MyIcon w="4" name="common/settingLight" />}
|
||||
onClick={onOpenManageModal}
|
||||
>
|
||||
{t('permission.Manage')}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="whitePrimary"
|
||||
leftIcon={<MyIcon w="4" name="support/permission/collaborator" />}
|
||||
onClick={onOpenAddMember}
|
||||
>
|
||||
{t('common.Add')}
|
||||
</Button>
|
||||
<>
|
||||
<MyModal
|
||||
isOpen
|
||||
iconSrc="/imgs/modal/key.svg"
|
||||
onClose={onClose}
|
||||
title={t('permission.Permission config')}
|
||||
>
|
||||
<ModalBody>
|
||||
<HStack>
|
||||
<Avatar src={avatar} w={'1.75rem'} />
|
||||
<Box>{name}</Box>
|
||||
</HStack>
|
||||
{!isInheritPermission && (
|
||||
<Box mt={3}>
|
||||
<ResumeInherit onResume={resumeInheritPermission} />
|
||||
</Box>
|
||||
)}
|
||||
<Box mt={5}>
|
||||
<Box fontSize={'sm'}>{t('permission.Default permission')}</Box>
|
||||
<DefaultPermissionList
|
||||
mt="1"
|
||||
per={defaultPer.value}
|
||||
defaultPer={defaultPer.defaultValue}
|
||||
isInheritPermission={isInheritPermission}
|
||||
onChange={(v) => defaultPer.onChange(v)}
|
||||
hasParent={hasParent}
|
||||
/>
|
||||
</Box>
|
||||
<Box mt={4}>
|
||||
<CollaboratorContextProvider
|
||||
{...managePer}
|
||||
refetchResource={refetchResource}
|
||||
isInheritPermission={isInheritPermission}
|
||||
hasParent={hasParent}
|
||||
>
|
||||
{({ MemberListCard, onOpenManageModal, onOpenAddMember }) => {
|
||||
return (
|
||||
<>
|
||||
<Flex
|
||||
alignItems="center"
|
||||
flexDirection="row"
|
||||
justifyContent="space-between"
|
||||
w="full"
|
||||
>
|
||||
<Box fontSize={'sm'}>{t('permission.Collaborator')}</Box>
|
||||
<Flex flexDirection="row" gap="2">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="whitePrimary"
|
||||
leftIcon={<MyIcon w="4" name="common/settingLight" />}
|
||||
onClick={onOpenManageModal}
|
||||
>
|
||||
{t('permission.Manage')}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="whitePrimary"
|
||||
leftIcon={<MyIcon w="4" name="support/permission/collaborator" />}
|
||||
onClick={onOpenAddMember}
|
||||
>
|
||||
{t('common.Add')}
|
||||
</Button>
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Flex>
|
||||
<MemberListCard mt={2} p={1.5} bg="myGray.100" borderRadius="md" />
|
||||
</>
|
||||
);
|
||||
}}
|
||||
</CollaboratorContextProvider>
|
||||
</Box>
|
||||
</ModalBody>
|
||||
</MyModal>
|
||||
<MemberListCard mt={2} p={1.5} bg="myGray.100" borderRadius="md" />
|
||||
</>
|
||||
);
|
||||
}}
|
||||
</CollaboratorContextProvider>
|
||||
</Box>
|
||||
</ModalBody>
|
||||
</MyModal>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
@@ -1,10 +1,11 @@
|
||||
import { Box, BoxProps } from '@chakra-ui/react';
|
||||
import MySelect from '@fastgpt/web/components/common/MySelect';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import React from 'react';
|
||||
import type { PermissionValueType } from '@fastgpt/global/support/permission/type';
|
||||
import { ReadPermissionVal, WritePermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
import { useConfirm } from '@fastgpt/web/hooks/useConfirm';
|
||||
import { useI18n } from '@/web/context/I18n';
|
||||
|
||||
export enum defaultPermissionEnum {
|
||||
private = 'private',
|
||||
@@ -18,6 +19,8 @@ type Props = Omit<BoxProps, 'onChange'> & {
|
||||
readPer?: PermissionValueType;
|
||||
writePer?: PermissionValueType;
|
||||
onChange: (v: PermissionValueType) => Promise<any> | any;
|
||||
isInheritPermission?: boolean;
|
||||
hasParent?: boolean;
|
||||
};
|
||||
|
||||
const DefaultPermissionList = ({
|
||||
@@ -26,28 +29,45 @@ const DefaultPermissionList = ({
|
||||
readPer = ReadPermissionVal,
|
||||
writePer = WritePermissionVal,
|
||||
onChange,
|
||||
isInheritPermission = false,
|
||||
hasParent,
|
||||
...styles
|
||||
}: Props) => {
|
||||
const { t } = useTranslation();
|
||||
const { ConfirmModal, openConfirm } = useConfirm({});
|
||||
const { commonT } = useI18n();
|
||||
|
||||
const defaultPermissionSelectList = [
|
||||
{ label: '仅协作者访问', value: defaultPer },
|
||||
{ label: '团队可访问', value: readPer },
|
||||
{ label: '团队可编辑', value: writePer }
|
||||
];
|
||||
|
||||
const { runAsync: onRequestChange, loading } = useRequest2(async (v: PermissionValueType) =>
|
||||
const { runAsync: onRequestChange, loading } = useRequest2((v: PermissionValueType) =>
|
||||
onChange(v)
|
||||
);
|
||||
|
||||
return (
|
||||
<Box {...styles}>
|
||||
<MySelect
|
||||
isLoading={loading}
|
||||
list={defaultPermissionSelectList}
|
||||
value={per}
|
||||
onchange={onRequestChange}
|
||||
/>
|
||||
</Box>
|
||||
<>
|
||||
<Box {...styles}>
|
||||
<MySelect
|
||||
isLoading={loading}
|
||||
list={defaultPermissionSelectList}
|
||||
value={per}
|
||||
onchange={(per) => {
|
||||
if (isInheritPermission && hasParent) {
|
||||
openConfirm(
|
||||
() => onRequestChange(per),
|
||||
undefined,
|
||||
commonT('permission.Remove InheritPermission Confirm')
|
||||
)();
|
||||
} else {
|
||||
return onRequestChange(per);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
<ConfirmModal />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { BoxProps, useDisclosure } from '@chakra-ui/react';
|
||||
import { useDisclosure } from '@chakra-ui/react';
|
||||
import {
|
||||
CollaboratorItemType,
|
||||
UpdateClbPermissionProps
|
||||
@@ -13,6 +13,8 @@ import dynamic from 'next/dynamic';
|
||||
import MemberListCard, { MemberListCardProps } from './MemberListCard';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||
import { useConfirm } from '@fastgpt/web/hooks/useConfirm';
|
||||
import { useI18n } from '@/web/context/I18n';
|
||||
const AddMemberModal = dynamic(() => import('./AddMemberModal'));
|
||||
const ManageModal = dynamic(() => import('./ManageModal'));
|
||||
|
||||
@@ -66,12 +68,28 @@ const CollaboratorContextProvider = ({
|
||||
permissionList,
|
||||
onUpdateCollaborators,
|
||||
onDelOneCollaborator,
|
||||
children,
|
||||
refetchResource,
|
||||
refreshDeps = [],
|
||||
children
|
||||
isInheritPermission,
|
||||
hasParent
|
||||
}: MemberManagerInputPropsType & {
|
||||
children: (props: ChildrenProps) => ReactNode;
|
||||
refetchResource?: () => void;
|
||||
isInheritPermission?: boolean;
|
||||
hasParent?: boolean;
|
||||
}) => {
|
||||
const onUpdateCollaboratorsThen = async (props: UpdateClbPermissionProps) => {
|
||||
await onUpdateCollaborators(props);
|
||||
refetchCollaboratorList();
|
||||
};
|
||||
const onDelOneCollaboratorThen = async (tmbId: string) => {
|
||||
await onDelOneCollaborator(tmbId);
|
||||
refetchCollaboratorList();
|
||||
};
|
||||
|
||||
const { feConfigs } = useSystemStore();
|
||||
const { commonT } = useI18n();
|
||||
|
||||
const {
|
||||
data: collaboratorList = [],
|
||||
@@ -86,19 +104,10 @@ const CollaboratorContextProvider = ({
|
||||
},
|
||||
{
|
||||
manual: false,
|
||||
refreshDeps
|
||||
refreshDeps: refreshDeps
|
||||
}
|
||||
);
|
||||
|
||||
const onUpdateCollaboratorsThen = async (props: UpdateClbPermissionProps) => {
|
||||
await onUpdateCollaborators(props);
|
||||
refetchCollaboratorList();
|
||||
};
|
||||
const onDelOneCollaboratorThen = async (tmbId: string) => {
|
||||
await onDelOneCollaborator(tmbId);
|
||||
refetchCollaboratorList();
|
||||
};
|
||||
|
||||
const getPerLabelList = useCallback(
|
||||
(per: PermissionValueType) => {
|
||||
const Per = new Permission({ per });
|
||||
@@ -125,6 +134,7 @@ const CollaboratorContextProvider = ({
|
||||
[permissionList]
|
||||
);
|
||||
|
||||
const { ConfirmModal, openConfirm } = useConfirm({});
|
||||
const {
|
||||
isOpen: isOpenAddMember,
|
||||
onOpen: onOpenAddMember,
|
||||
@@ -147,11 +157,57 @@ const CollaboratorContextProvider = ({
|
||||
onDelOneCollaborator: onDelOneCollaboratorThen,
|
||||
getPerLabelList
|
||||
};
|
||||
|
||||
const onOpenAddMemberModal = () => {
|
||||
if (isInheritPermission && hasParent) {
|
||||
openConfirm(
|
||||
() => {
|
||||
onOpenAddMember();
|
||||
},
|
||||
undefined,
|
||||
commonT('permission.Remove InheritPermission Confirm')
|
||||
)();
|
||||
} else {
|
||||
onOpenAddMember();
|
||||
}
|
||||
};
|
||||
const onOpenManageModalModal = () => {
|
||||
if (isInheritPermission && hasParent) {
|
||||
openConfirm(
|
||||
() => {
|
||||
onOpenManageModal();
|
||||
},
|
||||
undefined,
|
||||
commonT('permission.Remove InheritPermission Confirm')
|
||||
)();
|
||||
} else {
|
||||
onOpenManageModal();
|
||||
}
|
||||
};
|
||||
return (
|
||||
<CollaboratorContext.Provider value={contextValue}>
|
||||
{children({ onOpenAddMember, onOpenManageModal, MemberListCard })}
|
||||
{isOpenAddMember && <AddMemberModal onClose={onCloseAddMember} />}
|
||||
{isOpenManageModal && <ManageModal onClose={onCloseManageModal} />}
|
||||
{children({
|
||||
onOpenAddMember: onOpenAddMemberModal,
|
||||
onOpenManageModal: onOpenManageModalModal,
|
||||
MemberListCard
|
||||
})}
|
||||
{isOpenAddMember && (
|
||||
<AddMemberModal
|
||||
onClose={() => {
|
||||
onCloseAddMember();
|
||||
refetchResource?.();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{isOpenManageModal && (
|
||||
<ManageModal
|
||||
onClose={() => {
|
||||
onCloseManageModal();
|
||||
refetchResource?.();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<ConfirmModal />
|
||||
</CollaboratorContext.Provider>
|
||||
);
|
||||
};
|
||||
|
@@ -0,0 +1,47 @@
|
||||
import { useI18n } from '@/web/context/I18n';
|
||||
import { Box, BoxProps } from '@chakra-ui/react';
|
||||
import { useConfirm } from '@fastgpt/web/hooks/useConfirm';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import React from 'react';
|
||||
|
||||
const ResumeInherit = ({
|
||||
onResume,
|
||||
...props
|
||||
}: BoxProps & {
|
||||
onResume?: () => Promise<any> | any;
|
||||
}) => {
|
||||
const { commonT } = useI18n();
|
||||
const { toast } = useToast();
|
||||
const { ConfirmModal: CommonConfirmModal, openConfirm: openCommonConfirm } = useConfirm({});
|
||||
|
||||
return onResume ? (
|
||||
<Box display={'inline'} fontSize={'sm'} {...props}>
|
||||
{commonT('permission.No InheritPermission')}
|
||||
<Box
|
||||
display={'inline'}
|
||||
textDecoration={'underline'}
|
||||
cursor={'pointer'}
|
||||
_hover={{ color: 'primary.600' }}
|
||||
onClick={() => {
|
||||
openCommonConfirm(
|
||||
() =>
|
||||
onResume()?.then(() => {
|
||||
toast({
|
||||
title: commonT('permission.Resume InheritPermission Success'),
|
||||
status: 'success'
|
||||
});
|
||||
}),
|
||||
undefined,
|
||||
commonT('permission.Resume InheritPermission Confirm')
|
||||
)();
|
||||
}}
|
||||
>
|
||||
{commonT('Click to resume')}
|
||||
</Box>
|
||||
|
||||
<CommonConfirmModal />
|
||||
</Box>
|
||||
) : null;
|
||||
};
|
||||
|
||||
export default ResumeInherit;
|
Reference in New Issue
Block a user