擷取、創建、更新和刪除具有細粒度權限的自訂用戶角色。
自訂角色
Blue中的自訂角色允許您定義精確的權限集,以滿足團隊的需求。除了標準的訪問級別(擁有者、管理員、成員等)之外,自訂角色還提供對用戶在項目中可以查看和執行的操作的細粒度控制。
基本範例 - 列出自訂角色
擷取項目的所有自訂角色:
query GetProjectRoles {
projectUserRoles(filter: { projectId: "web-redesign" }) {
id
name
description
allowInviteOthers
canDeleteRecords
}
}
進階範例 - 創建自訂角色
創建具有特定權限的承包商角色:
mutation CreateContractorRole {
createProjectUserRole(
input: {
projectId: "web-redesign"
name: "External Contractor"
description: "Limited access for external contractors"
allowInviteOthers: false
allowMarkRecordsAsDone: true
canDeleteRecords: false
showOnlyAssignedTodos: true
isActivityEnabled: true
isFormsEnabled: false
isWikiEnabled: true
isChatEnabled: false
isDocsEnabled: true
isFilesEnabled: true
isRecordsEnabled: true
isPeopleEnabled: false
}
) {
id
name
}
}
可用操作
查詢: projectUserRoles
擷取項目的所有自訂角色。
輸入參數
參數 | 類型 | 必需 | 描述 |
---|---|---|---|
filter.projectId |
String | 否 | 項目ID或別名(如果未提供,則返回所有可訪問項目的角色) |
變更: createProjectUserRole
創建具有特定權限的新自訂角色。
輸入參數
參數 | 類型 | 必需 | 描述 |
---|---|---|---|
projectId |
String! | ✅ 是 | 項目ID或別名 |
name |
String! | ✅ 是 | 角色名稱 |
description |
String | 否 | 角色描述 |
Permission Flags | |||
allowInviteOthers |
Boolean | 否 | 可以邀請新用戶(默認:假) |
allowMarkRecordsAsDone |
Boolean | 否 | 可以完成任務(默認:假) |
canDeleteRecords |
Boolean | 否 | 可以刪除記錄(默認:真) |
Feature Access | |||
isActivityEnabled |
Boolean | 否 | 訪問活動部分(默認:真) |
isChatEnabled |
Boolean | 否 | 訪問聊天(默認:真) |
isDocsEnabled |
Boolean | 否 | 訪問文檔(默認:真) |
isFilesEnabled |
Boolean | 否 | 訪問文件(默認:真) |
isFormsEnabled |
Boolean | 否 | 訪問表單(默認:真) |
isWikiEnabled |
Boolean | 否 | 訪問維基(默認:真) |
isRecordsEnabled |
Boolean | 否 | 訪問記錄(默認:真) |
isPeopleEnabled |
Boolean | 否 | 訪問人員部分(默認:真) |
Visibility Settings | |||
showOnlyAssignedTodos |
Boolean | 否 | 只查看分配的任務(默認:假) |
showOnlyMentionedComments |
Boolean | 否 | 只查看提及的評論(默認:假) |
變更: updateProjectUserRole
更新現有的自訂角色。
輸入參數
與 createProjectUserRole
相同,另外:
參數 | 類型 | 必需 | 描述 |
---|---|---|---|
roleId |
String! | ✅ 是 | 要更新的角色ID |
變更: deleteProjectUserRole
刪除自訂角色。
輸入參數
參數 | 類型 | 必需 | 描述 |
---|---|---|---|
roleId |
String! | ✅ 是 | 要刪除的角色ID |
projectId |
String! | ✅ 是 | 項目ID或別名 |
回應字段
ProjectUserRole 對象
字段 | 類型 | 描述 |
---|---|---|
id |
String! | 唯一角色標識符 |
name |
String! | 角色名稱 |
description |
String | 角色描述 |
createdAt |
DateTime! | 創建時間戳 |
updatedAt |
DateTime! | 最後更新時間戳 |
Permissions | ||
allowInviteOthers |
Boolean! | 可以邀請用戶 |
allowMarkRecordsAsDone |
Boolean! | 可以完成任務 |
canDeleteRecords |
Boolean! | 可以刪除記錄 |
Feature Flags | ||
isActivityEnabled |
Boolean! | 活動部分訪問 |
isChatEnabled |
Boolean! | 聊天訪問 |
isDocsEnabled |
Boolean! | 文檔訪問 |
isFilesEnabled |
Boolean! | 文件訪問 |
isFormsEnabled |
Boolean! | 表單訪問 |
isWikiEnabled |
Boolean! | 維基訪問 |
isRecordsEnabled |
Boolean! | 記錄訪問 |
isPeopleEnabled |
Boolean! | 人員部分訪問 |
Visibility | ||
showOnlyAssignedTodos |
Boolean! | 任務可見性過濾器 |
showOnlyMentionedComments |
Boolean! | 評論可見性過濾器 |
所需權限
操作 | 所需權限 |
---|---|
projectUserRoles |
Any project member |
createProjectUserRole |
Project OWNER or ADMIN |
updateProjectUserRole |
Project OWNER or ADMIN |
deleteProjectUserRole |
Project OWNER or ADMIN |
錯誤回應
權限不足
{
"errors": [{
"message": "You don't have permission to manage custom roles",
"extensions": {
"code": "UNAUTHORIZED"
}
}]
}
找不到角色
{
"errors": [{
"message": "Custom role not found",
"extensions": {
"code": "PROJECT_USER_ROLE_NOT_FOUND"
}
}]
}
角色限制已達
{
"errors": [{
"message": "Project user role limit reached.",
"extensions": {
"code": "PROJECT_USER_ROLE_LIMIT"
}
}]
}
重要說明
- 默認權限:創建角色時,未指定的布林權限默認為假,除了
canDeleteRecords
默認為真 - 角色分配:通過設置
accessLevel: MEMBER
並在inviteUser
變更中提供roleId
來分配自訂角色 - 層級:自訂角色在層級目的上被視為成員級別
- 角色限制:每個項目最多可以有20個自訂角色
- 功能訪問:功能標誌控制對應用程序整個部分的訪問
使用案例
承包商角色
{
name: "Contractor",
allowInviteOthers: false,
canDeleteRecords: false,
showOnlyAssignedTodos: true,
isActivityEnabled: true,
isChatEnabled: false,
isPeopleEnabled: false
}
部門負責人
{
name: "Department Lead",
allowInviteOthers: true,
allowMarkRecordsAsDone: true,
canDeleteRecords: true,
isActivityEnabled: true,
isWikiEnabled: true,
isPeopleEnabled: true
}
只讀觀察者
{
name: "Observer",
allowMarkRecordsAsDone: false,
canDeleteRecords: false,
allowInviteOthers: false,
showOnlyMentionedComments: true,
isFormsEnabled: false
}