From ec40762ececd481d99b7be736d80e4c3a79b8537 Mon Sep 17 00:00:00 2001 From: ianmuchyri Date: Mon, 22 Jun 2026 11:46:08 +0300 Subject: [PATCH] Replace object type dropdown with free-text input in permission block form --- .../permission-block-create-form.tsx | 53 +++++-------------- 1 file changed, 12 insertions(+), 41 deletions(-) diff --git a/app/components/permission-blocks/permission-block-create-form.tsx b/app/components/permission-blocks/permission-block-create-form.tsx index 8fb0c34..1387cac 100644 --- a/app/components/permission-blocks/permission-block-create-form.tsx +++ b/app/components/permission-blocks/permission-block-create-form.tsx @@ -23,7 +23,6 @@ import { GLOBAL_TENANT } from "@/lib/tenant/context"; import { cn } from "@/lib/utils"; const TENANT_NONE = "__platform__"; -const NO_OBJECT_TYPE = "__none__"; const STEPS = ["Boundary", "Scope", "Actions", "Conditions", "Review"] as const; const TENANTS_QUERY = ` @@ -65,21 +64,6 @@ const CREATE_PERMISSION_BLOCK_MUTATION = ` } `; -const ENTITY_TYPES = [ - { value: "entity:human", label: "Human user" }, - { value: "entity:device", label: "Device/client" }, - { value: "entity:service", label: "Service" }, - { value: "entity:workload", label: "Workload" }, - { value: "entity:application", label: "Application" }, -] as const; - -const RESOURCE_TYPES = [ - { value: "resource:channel", label: "Channel" }, - { value: "resource:rule", label: "Rule" }, - { value: "resource:report", label: "Report" }, - { value: "resource:alarm", label: "Alarm" }, -] as const; - const OBJECT_KINDS = [ { value: "entity", label: "Entity" }, { value: "resource", label: "Resource" }, @@ -433,31 +417,24 @@ export function PermissionBlockCreateForm({ {needsObjectType(draft.scopeMode, draft.objectKind) ? ( - setDraft((prev) => ({ ...prev, - objectType: objectType === NO_OBJECT_TYPE ? "" : objectType, + objectType: event.target.value, actionIds: [], })) } - > - - - - - No subtype - {objectTypeOptions(draft.objectKind).map((type) => ( - - {type.label} ({type.value}) - - ))} - - + placeholder={ + draft.objectKind === "entity" + ? "e.g. entity:human" + : "e.g. resource:invoice" + } + />

- For entity/resource scopes this is stored as a namespaced value, - for example `resource:channel`. + Stored as a namespaced value, e.g. `resource:invoice` or + `entity:human`.

) : null} @@ -760,12 +737,6 @@ function objectKindOptions(scopeMode: ScopeMode) { return OBJECT_KINDS; } -function objectTypeOptions(objectKind: string) { - if (objectKind === "entity") return ENTITY_TYPES; - if (objectKind === "resource") return RESOURCE_TYPES; - return []; -} - function actionFilterForScope(draft: Draft) { switch (draft.scopeMode) { case "object_kind":