Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: MemberModal UI #3553

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/web/components/common/Icon/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ export const iconPaths = {
'modal/selectSource': () => import('./icons/modal/selectSource.svg'),
'modal/setting': () => import('./icons/modal/setting.svg'),
'modal/teamPlans': () => import('./icons/modal/teamPlans.svg'),
'modal/key': () => import('./icons/modal/key.svg'),
'model/BAAI': () => import('./icons/model/BAAI.svg'),
'model/alicloud': () => import('./icons/model/alicloud.svg'),
'model/baichuan': () => import('./icons/model/baichuan.svg'),
Expand Down
9 changes: 9 additions & 0 deletions packages/web/components/common/Icon/icons/modal/key.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion packages/web/i18n/en/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"password.to_login": "Go to Login",
"password.verification_code": "Verification Code",
"permission.Manage": "Admin",
"permission.Add": "Add Permissions",
"permission.Manage tip": "Team admin with full permissions",
"permission.Read": "Read Only",
"permission.Read desc": "Members can only read related resources, cannot create new resources",
Expand All @@ -57,6 +58,7 @@
"permission_des.manage": "Can create resources, invite, and delete members",
"permission_des.read": "Members can only read related resources and cannot create new resources.",
"permission_des.write": "In addition to readable resources, you can also create new resources",
"permission_add_tip": "After adding, you can check the permissions for them.",
"permissions": "Permissions",
"personal_information": "Me",
"personalization": "Personalization",
Expand All @@ -81,6 +83,7 @@
"team.Update Team": "Update team information",
"team.add_collaborator": "Add Collaborator",
"team.add_writer": "Add writable members",
"team.add_permission": "Add permissions",
"team.avatar_and_name": "avatar",
"team.belong_to_group": "Member group",
"team.group.avatar": "Group avatar",
Expand All @@ -102,7 +105,7 @@
"team.group.role.admin": "administrator",
"team.group.role.member": "member",
"team.group.role.owner": "owner",
"team.group.search_placeholder": "Search member/group name",
"team.group.search_placeholder": "Search member/group/org name",
"team.group.set_as_admin": "Set as administrator",
"team.group.toast.can_not_delete_owner": "Owner cannot be deleted, please transfer first",
"team.group.transfer_owner": "transfer owner",
Expand Down
5 changes: 4 additions & 1 deletion packages/web/i18n/zh-CN/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"permission.Manage tip": "团队管理员,拥有全部权限",
"permission.Read": "仅读",
"permission.Read desc": "成员仅可阅读相关资源,无法新建资源",
"permission.Add": "添加权限",
"permission.Write": "可写",
"permission.Write tip": "除了可读资源外,还可以新建新的资源",
"permission.only_collaborators": "仅协作者访问",
Expand All @@ -57,6 +58,7 @@
"permission_des.manage": "可创建资源、邀请、删除成员",
"permission_des.read": "成员仅可阅读相关资源,无法新建资源",
"permission_des.write": "除了可读资源外,还可以新建新的资源",
"permission_add_tip": "添加后,您可为其勾选权限。",
"permissions": "权限",
"personal_information": "个人信息",
"personalization": "个性化",
Expand All @@ -81,6 +83,7 @@
"team.Update Team": "更新团队信息",
"team.add_collaborator": "添加协作者",
"team.add_writer": "添加可写成员",
"team.add_permission": "添加权限",
"team.avatar_and_name": "头像 & 名称",
"team.belong_to_group": "所属群组",
"team.group.avatar": "群头像",
Expand All @@ -102,7 +105,7 @@
"team.group.role.admin": "管理员",
"team.group.role.member": "成员",
"team.group.role.owner": "所有者",
"team.group.search_placeholder": "搜索成员/群组名称",
"team.group.search_placeholder": "搜索成员/部门/群组名称",
"team.group.set_as_admin": "设为管理员",
"team.group.toast.can_not_delete_owner": "不能删除所有者, 请先转让",
"team.group.transfer_owner": "转让所有者",
Expand Down
5 changes: 4 additions & 1 deletion packages/web/i18n/zh-Hant/user.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"permission.Manage tip": "團隊管理員,擁有完整權限",
"permission.Read": "唯讀",
"permission.Read desc": "成員僅能閱讀相關資源,無法建立新資源",
"permission.Add": "新增權限",
"permission.Write": "可寫入",
"permission.Write tip": "除了可讀取資源外,還可以建立新的資源",
"permission.only_collaborators": "僅協作者可存取",
Expand All @@ -57,6 +58,7 @@
"permission_des.manage": "可建立資源、邀請及刪除成員",
"permission_des.read": "成員僅能閱讀相關資源,無法建立新資源",
"permission_des.write": "除了可讀取資源外,還可以建立新的資源",
"permission_add_tip": "添加後,您可為其勾選權限。",
"permissions": "權限",
"personal_information": "個人資料",
"personalization": "個人化",
Expand All @@ -81,6 +83,7 @@
"team.Update Team": "更新團隊資訊",
"team.add_collaborator": "新增協作者",
"team.add_writer": "新增可寫入成員",
"team.add_permission": "新增權限",
"team.avatar_and_name": "頭像與名稱",
"team.belong_to_group": "所屬成員群組",
"team.group.avatar": "群組頭像",
Expand All @@ -102,7 +105,7 @@
"team.group.role.admin": "管理員",
"team.group.role.member": "成員",
"team.group.role.owner": "擁有者",
"team.group.search_placeholder": "搜尋成員/群組名稱",
"team.group.search_placeholder": "搜尋成員/部門/群組名稱",
"team.group.set_as_admin": "設為管理員",
"team.group.toast.can_not_delete_owner": "無法刪除擁有者,請先轉移擁有權",
"team.group.transfer_owner": "轉移擁有者",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ const HoverBoxStyle = {
cursor: 'pointer'
};

function MemberModal({ onClose }: { onClose: () => void }) {
function MemberModal({
onClose,
addPermissionOnly: addOnly = false
}: {
onClose: () => void;
addPermissionOnly?: boolean;
}) {
const { t } = useTranslation();
const { userInfo, loadAndGetTeamMembers, loadAndGetGroups, myGroups, loadAndGetOrgs } =
useUserStore();
Expand Down Expand Up @@ -195,8 +201,8 @@ function MemberModal({ onClose }: { onClose: () => void }) {
<MyModal
isOpen
onClose={onClose}
iconSrc="modal/AddClb"
title={t('user:team.add_collaborator')}
iconSrc={addOnly ? 'modal/key' : 'modal/AddClb'}
title={addOnly ? t('user:team.add_permission') : t('user:team.add_collaborator')}
minW="800px"
h={'100%'}
maxH={'90vh'}
Expand All @@ -219,7 +225,7 @@ function MemberModal({ onClose }: { onClose: () => void }) {
p="4"
>
<SearchInput
placeholder={t('user:search_user')}
placeholder={t('user:team.group.search_placeholder')}
bgColor="myGray.50"
onChange={(e) => setSearchText(e.target.value)}
/>
Expand Down Expand Up @@ -289,15 +295,17 @@ function MemberModal({ onClose }: { onClose: () => void }) {

<Flex flexDirection={'column'} gap={1} userSelect={'none'}>
{filterMembers.map((member) => {
const collaborator = collaboratorList?.find((v) => v.tmbId === member.tmbId);
const disabled = addOnly && collaborator !== undefined;
const onChange = () => {
if (disabled) return;
setSelectedMembers((state) => {
if (state.includes(member.tmbId)) {
return state.filter((v) => v !== member.tmbId);
}
return [...state, member.tmbId];
});
};
const collaborator = collaboratorList?.find((v) => v.tmbId === member.tmbId);
return (
<HStack
justifyContent="space-between"
Expand All @@ -310,27 +318,32 @@ function MemberModal({ onClose }: { onClose: () => void }) {
onClick={onChange}
>
<Checkbox
isChecked={selectedMemberIdList.includes(member.tmbId)}
isDisabled={disabled}
isChecked={disabled || selectedMemberIdList.includes(member.tmbId)}
pointerEvents="none"
/>
<MyAvatar src={member.avatar} w="1.5rem" borderRadius={'50%'} />
<Box w="full" ml="2">
{member.memberName}
</Box>
<PermissionTags permission={collaborator?.permission.value} />
<PermissionTags
permission={addOnly ? undefined : collaborator?.permission.value}
/>
</HStack>
);
})}
{filterOrgs.map((org) => {
const collaborator = collaboratorList?.find((v) => v.orgId === org._id);
const disabled = addOnly && collaborator !== undefined;
const onChange = () => {
if (disabled) return;
setSelectedOrgIdList((state) => {
if (state.includes(org._id)) {
return state.filter((v) => v !== org._id);
}
return [...state, org._id];
});
};
const collaborator = collaboratorList?.find((v) => v.orgId === org._id);
return (
<HStack
justifyContent="space-between"
Expand All @@ -343,7 +356,8 @@ function MemberModal({ onClose }: { onClose: () => void }) {
onClick={onChange}
>
<Checkbox
isChecked={selectedOrgIdList.includes(org._id)}
isDisabled={disabled}
isChecked={disabled || selectedOrgIdList.includes(org._id)}
pointerEvents="none"
/>
<MyAvatar src={org.avatar} w="1.5rem" borderRadius={'50%'} />
Expand All @@ -357,7 +371,9 @@ function MemberModal({ onClose }: { onClose: () => void }) {
</>
)}
</HStack>
<PermissionTags permission={collaborator?.permission.value} />
<PermissionTags
permission={addOnly ? undefined : collaborator?.permission.value}
/>
{org.count && (
<MyIcon
name="core/chat/chevronRight"
Expand All @@ -367,7 +383,8 @@ function MemberModal({ onClose }: { onClose: () => void }) {
_hover={{
bgColor: 'myGray.200'
}}
onClick={() => {
onClick={(e) => {
e.stopPropagation();
setParentPath(getOrgChildrenPath(org));
}}
/>
Expand All @@ -376,15 +393,17 @@ function MemberModal({ onClose }: { onClose: () => void }) {
);
})}
{filterGroups.map((group) => {
const collaborator = collaboratorList?.find((v) => v.groupId === group._id);
const disabled = addOnly && collaborator !== undefined;
const onChange = () => {
if (disabled) return;
setSelectedGroupIdList((state) => {
if (state.includes(group._id)) {
return state.filter((v) => v !== group._id);
}
return [...state, group._id];
});
};
const collaborator = collaboratorList?.find((v) => v.groupId === group._id);
return (
<HStack
justifyContent="space-between"
Expand All @@ -397,14 +416,17 @@ function MemberModal({ onClose }: { onClose: () => void }) {
onClick={onChange}
>
<Checkbox
isChecked={selectedGroupIdList.includes(group._id)}
isDisabled={disabled}
isChecked={disabled || selectedGroupIdList.includes(group._id)}
pointerEvents="none"
/>
<MyAvatar src={group.avatar} w="1.5rem" borderRadius={'50%'} />
<Box ml="2" w="full">
{group.name === DefaultGroupName ? userInfo?.team.teamName : group.name}
</Box>
<PermissionTags permission={collaborator?.permission.value} />
<PermissionTags
permission={addOnly ? undefined : collaborator?.permission.value}
/>
</HStack>
);
})}
Expand Down Expand Up @@ -450,7 +472,7 @@ function MemberModal({ onClose }: { onClose: () => void }) {
</Grid>
</ModalBody>
<ModalFooter>
{!!permissionList && (
{!addOnly && !!permissionList && (
<PermissionSelect
value={selectedPermission}
Button={
Expand All @@ -470,6 +492,12 @@ function MemberModal({ onClose }: { onClose: () => void }) {
onChange={(v) => setSelectedPermission(v)}
/>
)}
{addOnly && (
<HStack bg={'blue.50'} color={'blue.600'} padding={'6px 12px'} rounded={'5px'}>
<MyIcon name="common/info" w="1rem" h="1rem" />
<Text fontSize="12px">{t('user:permission_add_tip')}</Text>
</HStack>
)}
<Button isLoading={isUpdating} ml="4" h={'32px'} onClick={onConfirm}>
{t('common:common.Confirm')}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ const CollaboratorContextProvider = ({
refetchResource,
refreshDeps = [],
isInheritPermission,
hasParent
hasParent,
addPermissionOnly
}: MemberManagerInputPropsType & {
children: (props: ChildrenProps) => ReactNode;
refetchResource?: () => void;
isInheritPermission?: boolean;
hasParent?: boolean;
addPermissionOnly?: boolean;
}) => {
const onUpdateCollaboratorsThen = async (props: UpdateClbPermissionProps) => {
await onUpdateCollaborators(props);
Expand Down Expand Up @@ -209,6 +211,7 @@ const CollaboratorContextProvider = ({
onCloseAddMember();
refetchResource?.();
}}
addPermissionOnly={addPermissionOnly}
/>
)}
{isOpenManageModal && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ function PermissionManage({
}) {
const { t } = useTranslation();
const { userInfo } = useUserStore();
const [searchKey, setSearchKey] = useState('');

const collaboratorList = useContextSelector(
CollaboratorContext,
Expand Down Expand Up @@ -144,7 +143,7 @@ function PermissionManage({
leftIcon={<MyIcon name="common/add2" w={'14px'} />}
onClick={onOpenAddMember}
>
{t('common:common.Add')}
{t('user:permission.Add')}
</Button>
)}
</Flex>
Expand Down Expand Up @@ -418,6 +417,7 @@ export const Render = ({ Tabs }: { Tabs: React.ReactNode }) => {
onUpdateCollaborators={updateMemberPermission}
onDelOneCollaborator={deleteMemberPermission}
refreshDeps={[userInfo?.team.teamId]}
addPermissionOnly={true}
>
{({ onOpenAddMember }) => <PermissionManage Tabs={Tabs} onOpenAddMember={onOpenAddMember} />}
</CollaboratorContextProvider>
Expand Down
Loading