Skip to content

Commit 611183a

Browse files
committed
feat: improve access scope names field UX
- Move name preview tags above textarea for better visibility - Change preview tag color from gray to blue - Reduce names textarea height from 6 to 4 rows - Remove wildcard-only validation to allow * with other names
1 parent 7a91915 commit 611183a

File tree

2 files changed

+20
-47
lines changed

2 files changed

+20
-47
lines changed

src/components/AccessScopes/Forms/AccessScopeCriteriaForm.tsx

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,15 @@ export default function AccessScopeCriteriaForm({
8383
className="rounded border border-gray-300 bg-gray-50 p-3"
8484
>
8585
<div className="mb-2 flex items-center justify-end gap-2">
86-
{/* Display per-scope validation error (except wildcard errors, which are shown inline) */}
86+
{/* Display per-scope validation error */}
8787
{(() => {
8888
const error =
8989
showError &&
9090
Array.isArray(scopesError) &&
9191
scopesError[index];
9292
return (
9393
error &&
94-
typeof error === "string" &&
95-
!error.includes("Wildcard") && (
94+
typeof error === "string" && (
9695
<p className="text-sm text-red-500">{error}</p>
9796
)
9897
);
@@ -130,47 +129,36 @@ export default function AccessScopeCriteriaForm({
130129
<div
131130
className={disabled ? "pointer-events-none opacity-60" : ""}
132131
>
133-
<FormikTextArea
134-
name={`scopes.${index}.names`}
135-
label="Names"
136-
placeholder="Enter resource names, one per line, or * for all"
137-
hint="Enter one resource name per line for exact matches. Use * alone to match all resources."
138-
rows={6}
139-
/>
132+
<label className="form-label">Names</label>
140133
{scope.names &&
141134
scope.names.trim().length > 0 &&
142135
(() => {
143136
const names = scope.names
144137
.split("\n")
145138
.map((n: string) => n.trim())
146139
.filter(Boolean);
147-
const hasWildcard = names.includes("*");
148-
const hasWildcardError = hasWildcard && names.length > 1;
149140

150141
return (
151-
<>
152-
<div
153-
className={`mt-2 rounded border p-2 ${hasWildcardError ? "border-red-300 bg-red-50" : "border-gray-200 bg-gray-50"}`}
154-
>
155-
<div className="flex flex-wrap gap-1">
156-
{names.map((name: string, nameIndex: number) => (
157-
<Badge
158-
key={nameIndex}
159-
text={name}
160-
color="gray"
161-
size="sm"
162-
/>
163-
))}
164-
</div>
142+
<div className="mb-2 rounded border border-gray-200 bg-gray-50 p-2">
143+
<div className="flex flex-wrap gap-1">
144+
{names.map((name: string, nameIndex: number) => (
145+
<Badge
146+
key={nameIndex}
147+
text={name}
148+
color="blue"
149+
size="sm"
150+
/>
151+
))}
165152
</div>
166-
{hasWildcardError && (
167-
<p className="mt-1 text-sm text-red-600">
168-
Wildcard '*' must be the only name when used
169-
</p>
170-
)}
171-
</>
153+
</div>
172154
);
173155
})()}
156+
<FormikTextArea
157+
name={`scopes.${index}.names`}
158+
placeholder="Enter resource names, one per line, or * for all"
159+
hint="Enter one resource name per line for exact matches. Use * alone to match all resources."
160+
rows={4}
161+
/>
174162
</div>
175163
</div>
176164
</div>

src/components/AccessScopes/Forms/AccessScopeForm.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,6 @@ export default function AccessScopeForm({
164164
errors.scopes[index] =
165165
"Each scope must have at least one of: tags, agents, or names";
166166
}
167-
168-
// Validate wildcard usage in names
169-
if (scope.names && scope.names.trim().length > 0) {
170-
const names = scope.names
171-
.split("\n")
172-
.map((n: string) => n.trim())
173-
.filter(Boolean);
174-
175-
const hasWildcard = names.includes("*");
176-
if (hasWildcard && names.length > 1) {
177-
if (!errors.scopes) errors.scopes = [];
178-
errors.scopes[index] =
179-
"Wildcard '*' must be the only name when used";
180-
}
181-
}
182167
});
183168
}
184169

0 commit comments

Comments
 (0)