-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(next/web): collaborator privileges
- Loading branch information
Showing
3 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
next/web/src/App/Admin/Settings/Collaborators/Privileges.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,54 @@ | ||
import { Checkbox, Spin } from 'antd'; | ||
|
||
import { | ||
CollaboratorPrivileges, | ||
useCollaboratorPrivileges, | ||
useSetCollaboratorPrivileges, | ||
} from '@/api/collaborator'; | ||
|
||
interface PrivilegeItem { | ||
key?: keyof CollaboratorPrivileges; | ||
title: string; | ||
} | ||
|
||
export function Privileges() { | ||
const { data: privileges } = useCollaboratorPrivileges(); | ||
const { mutate, isLoading: isMutating } = useSetCollaboratorPrivileges(); | ||
|
||
const privilegeItems: PrivilegeItem[] = [ | ||
{ | ||
title: '查看分配给其的工单', | ||
}, | ||
{ | ||
title: '创建内部回复', | ||
}, | ||
{ | ||
key: 'createPublicReply', | ||
title: '创建公开回复', | ||
}, | ||
]; | ||
|
||
if (!privileges) { | ||
return <Spin />; | ||
} | ||
|
||
return ( | ||
<ul> | ||
{privilegeItems.map(({ key, title }, index) => { | ||
const enabled = !!privileges['createPublicReply']; | ||
return ( | ||
<li key={key || index} className="space-x-1"> | ||
<span className={key && (enabled ? undefined : 'line-through')}>{title}</span> | ||
{key && ( | ||
<Checkbox | ||
checked={enabled} | ||
disabled={isMutating} | ||
onChange={(e) => mutate({ ...privileges, [key]: e.target.checked })} | ||
/> | ||
)} | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
); | ||
} |
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