|
5 | 5 | from graphene import Boolean, InputObjectType, List, Mutation, NonNull, String |
6 | 6 |
|
7 | 7 | from infrahub.core.account import ObjectPermission |
8 | | -from infrahub.core.constants import PermissionAction, PermissionDecision |
| 8 | +from infrahub.core.constants import GlobalPermissions, PermissionAction, PermissionDecision |
9 | 9 | from infrahub.core.manager import NodeManager |
10 | 10 | from infrahub.core.registry import registry |
11 | 11 | from infrahub.database import retry_db_transaction |
|
15 | 15 | from infrahub.graphql.context import apply_external_context |
16 | 16 | from infrahub.graphql.types.context import ContextInput |
17 | 17 | from infrahub.log import get_log_data |
| 18 | +from infrahub.permissions import define_global_permission_from_branch |
18 | 19 | from infrahub.worker import WORKER_IDENTITY |
19 | 20 |
|
20 | 21 | if TYPE_CHECKING: |
@@ -61,15 +62,21 @@ async def mutate( |
61 | 62 | input_value=f"{node_schema.kind}.human_friendly_id requires {len(node_schema.human_friendly_id)} parts data has {len(updated_hfid)}" |
62 | 63 | ) |
63 | 64 |
|
64 | | - graphql_context.active_permissions.raise_for_permission( |
65 | | - permission=ObjectPermission( |
66 | | - namespace=node_schema.namespace, |
67 | | - name=node_schema.name, |
68 | | - action=PermissionAction.UPDATE.value, |
69 | | - decision=PermissionDecision.ALLOW_DEFAULT.value |
70 | | - if graphql_context.branch.name == registry.default_branch |
71 | | - else PermissionDecision.ALLOW_OTHER.value, |
72 | | - ) |
| 65 | + graphql_context.active_permissions.raise_for_permissions( |
| 66 | + permissions=[ |
| 67 | + define_global_permission_from_branch( |
| 68 | + permission=GlobalPermissions.UPDATE_OBJECT_HFID_DISPLAY_LABEL, |
| 69 | + branch_name=graphql_context.branch.name, |
| 70 | + ), |
| 71 | + ObjectPermission( |
| 72 | + namespace=node_schema.namespace, |
| 73 | + name=node_schema.name, |
| 74 | + action=PermissionAction.UPDATE.value, |
| 75 | + decision=PermissionDecision.ALLOW_DEFAULT.value |
| 76 | + if graphql_context.branch.name == registry.default_branch |
| 77 | + else PermissionDecision.ALLOW_OTHER.value, |
| 78 | + ), |
| 79 | + ] |
73 | 80 | ) |
74 | 81 | await apply_external_context(graphql_context=graphql_context, context_input=context) |
75 | 82 |
|
|
0 commit comments