Repository navigation
fix: ui permission - #7734
fix: ui permission#7734
Conversation
| APPLICATION_CLEAR_POLICY: p(Group.APPLICATION, Group.APPLICATION, Operate.CLEAR_POLICY, 42), | ||
| APPLICATION_RESOURCE_AUTHORIZATION: p(Group.APPLICATION, Group.APPLICATION, Operate.AUTH, 10), | ||
| APPLICATION_RELATE_RESOURCE_VIEW: p(Group.APPLICATION, Group.APPLICATION, Operate.RELATE_VIEW, 11), | ||
| APPLICATION_TRIGGER_READ: p(Group.APPLICATION, Group.APPLICATION, Operate.TRIGGER_READ, 12), |
There was a problem hiding this comment.
Here's my review of the diff:
Irregularities / Potential Issues
-
Magic number
42for the permission code. Other entries use sequential codes (7, 8, 9, 10, 11, 12). The jump to42is suspicious—likely conflicts with, or leaves gaps from, other permissions. Verify:- That
42isn't already assigned elsewhere in this file or sibling constant files. - Whether an existing constant/enum (e.g.,
Operate.CLEAR_POLICY) already defines the numeric value, so you can reference it instead of hardcoding. - That the intended behavior is "gap allowed" rather than a typo (e.g., should be
9.5-style or13).
- That
-
Operate.CLEAR_POLICYmay not exist yet. If this is the first usage, ensure it's added to theOperateenum and that any backend/permission-mapping tables are updated in the same change—otherwise runtime lookups will fail. -
Ordering inconsistency. The new entry is inserted between
BATCH_MOVE(9) andRESOURCE_AUTHORIZATION(10), but its code is42. This breaks the visual/numeric ordering convention of the block and makes future diffs harder to scan. Consider placing it at the end of theAPPLICATION_*group or beside other high-numbered codes. -
Naming/scope mismatch (minor). The key is
APPLICATION_CLEAR_POLICYbut both groups areGroup.APPLICATION. Confirm this permission is genuinely application-scoped and not resource-level; if it belongs elsewhere, the group args should reflect that. -
Backward compatibility. Adding a permission to a shared constants export can affect serialization (e.g., if consumers enumerate
PermissionConstantsand persist indices). Confirm no consumer relies on positional/contiguous numbering.
Optimization Suggestions
- Define the code via a named constant (e.g.,
Operate.CLEAR_POLICY = 42or aCODEmap) rather than an inline literal, to keep a single source of truth. - Add a brief comment noting why
42is used (if intentional) or renumber. - If permission codes must remain unique across modules, add/extend a unit test asserting uniqueness of all values in
PermissionConstants. - Ensure corresponding authorization tests cover the new permission.
Summary: Functionally likely fine, but verify the 42 code doesn't collide, confirm Operate.CLEAR_POLICY is defined, and consider ordering/naming consistency plus a uniqueness test.
fix: ui permission