-
Notifications
You must be signed in to change notification settings - Fork 0
feat(console): VNC redesign, form layout polish, and UI fixes #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
90f4efc
feat(vnc): redesign VNC tab with fullscreen and connection controls
f2c104e
style(ui): polish command palette, dialog, header and order page
81cc8a4
fix(console): improve RJSF form layout and array field UX
122b377
fix(console): resolve TypeScript build errors
7e46cef
fix(console): address PR review feedback on VNC race conditions and nits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
94 changes: 75 additions & 19 deletions
94
apps/console/src/components/CustomObjectFieldTemplate.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,66 +1,122 @@ | ||
| import type { | ||
| ObjectFieldTemplateProps, | ||
| ObjectFieldTemplatePropertyType, | ||
| RJSFSchema, | ||
| StrictRJSFSchema, | ||
| FormContextType, | ||
| } from "@rjsf/utils" | ||
|
|
||
| function isSimpleField(schema: any): boolean { | ||
| if (!schema) return true | ||
| const type = schema.type | ||
| if (type === "object") return false | ||
| if (type === "array") { | ||
| const itemType = schema.items?.type | ||
| return itemType === "integer" || itemType === "string" || itemType === "number" | ||
| } | ||
| if (schema.anyOf || schema.oneOf || schema.allOf) { | ||
| if (schema["x-kubernetes-int-or-string"]) return true | ||
| return false | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| function groupByComplexity( | ||
| properties: ObjectFieldTemplatePropertyType[], | ||
| parentSchema: any, | ||
| ) { | ||
| type Group = { simple: boolean; items: ObjectFieldTemplatePropertyType[] } | ||
| const groups: Group[] = [] | ||
| let current: Group | null = null | ||
|
|
||
| for (const prop of properties) { | ||
| const fieldSchema = parentSchema?.properties?.[prop.name] | ||
| const simple = isSimpleField(fieldSchema) | ||
| if (!current || current.simple !== simple) { | ||
| current = { simple, items: [] } | ||
| groups.push(current) | ||
| } | ||
| current.items.push(prop) | ||
| } | ||
| return groups | ||
| } | ||
|
|
||
| export function CustomObjectFieldTemplate< | ||
| T = any, | ||
| S extends StrictRJSFSchema = RJSFSchema, | ||
| F extends FormContextType = any, | ||
| >(props: ObjectFieldTemplateProps<T, S, F>) { | ||
| const { formData } = props | ||
|
|
||
| // Check if this is an addon object (has 'enabled' field and other config fields) | ||
| // Addon pattern: has 'enabled' + other config fields → conditional expand | ||
| const hasEnabledField = props.properties.some((p) => p.name === "enabled") | ||
| const hasOtherFields = props.properties.some((p) => p.name !== "enabled") | ||
| const isAddon = hasEnabledField && hasOtherFields | ||
|
|
||
| // If this is an addon, use conditional rendering based on 'enabled' state | ||
| if (isAddon) { | ||
| const isEnabled = (formData as any)?.enabled === true | ||
| const enabledProp = props.properties.find((p) => p.name === "enabled") | ||
| const otherProps = props.properties.filter((p) => p.name !== "enabled") | ||
| const groups = groupByComplexity(otherProps, props.schema) | ||
|
|
||
| return ( | ||
| <fieldset id={props.idSchema.$id} className="border border-slate-200 rounded-lg p-4 mb-3"> | ||
| <fieldset id={props.idSchema.$id} className="border border-slate-200 rounded-lg p-3 mb-3"> | ||
| {props.title && ( | ||
| <legend className="text-sm font-medium text-slate-900 px-2">{props.title}</legend> | ||
| <legend className="text-xs font-semibold text-slate-700 px-1">{props.title}</legend> | ||
| )} | ||
| {props.description && <p className="field-description text-xs text-slate-500 mb-3">{props.description}</p>} | ||
|
|
||
| {/* Always show the 'enabled' checkbox */} | ||
| {enabledProp && ( | ||
| <div className="mb-3"> | ||
| {enabledProp.content} | ||
| </div> | ||
| {props.description && ( | ||
| <p className="field-description text-xs text-slate-400 mb-2">{props.description}</p> | ||
| )} | ||
|
|
||
| {/* Show other fields only if enabled */} | ||
| {enabledProp && <div className="mb-2">{enabledProp.content}</div>} | ||
|
|
||
| {isEnabled && otherProps.length > 0 && ( | ||
| <div className="space-y-3 pl-6 border-l-2 border-blue-200"> | ||
| {otherProps.map((prop) => ( | ||
| <div key={prop.name}>{prop.content}</div> | ||
| ))} | ||
| <div className="pl-4 border-l-2 border-blue-200 space-y-0.5"> | ||
| {groups.map((group, i) => | ||
| group.simple ? ( | ||
| <div key={i} className="grid-fields grid grid-cols-2 gap-x-3 xl:grid-cols-3"> | ||
| {group.items.map((prop) => ( | ||
| <div key={prop.name} className={group.items.length === 1 ? "col-span-full" : ""}>{prop.content}</div> | ||
| ))} | ||
| </div> | ||
| ) : ( | ||
| group.items.map((prop) => ( | ||
| <div key={prop.name}>{prop.content}</div> | ||
| )) | ||
| ) | ||
| )} | ||
| </div> | ||
| )} | ||
|
|
||
| {!isEnabled && otherProps.length > 0 && ( | ||
| <p className="text-xs text-slate-400 italic mt-2"> | ||
| <p className="text-xs text-slate-400 italic mt-1.5"> | ||
| Enable this addon to configure additional settings | ||
| </p> | ||
| )} | ||
| </fieldset> | ||
| ) | ||
| } | ||
|
|
||
| // Otherwise, use default rendering | ||
| // Default: smart 2-column grid for simple fields, full width for complex | ||
| const groups = groupByComplexity(props.properties, props.schema) | ||
|
|
||
| return ( | ||
| <fieldset id={props.idSchema.$id}> | ||
| {props.title && <legend>{props.title}</legend>} | ||
| {props.description && <p className="field-description">{props.description}</p>} | ||
| {props.properties.map((prop) => prop.content)} | ||
| {groups.map((group, i) => | ||
| group.simple ? ( | ||
| <div key={i} className="grid-fields grid grid-cols-2 gap-x-3 xl:grid-cols-3"> | ||
| {group.items.map((prop) => ( | ||
| <div key={prop.name} className={group.items.length === 1 ? "col-span-full" : ""}>{prop.content}</div> | ||
| ))} | ||
| </div> | ||
| ) : ( | ||
| group.items.map((prop) => ( | ||
| <div key={prop.name}>{prop.content}</div> | ||
| )) | ||
| ) | ||
| )} | ||
| </fieldset> | ||
| ) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
group-hover:opacity-100overridesdisabled:opacity-30due to higher CSS specificityThe compound selector for
group-hover:opacity-100(.group:hover .child, specificity 0,3,0) beatsdisabled:opacity-30(.element:disabled, specificity 0,2,0). In Tailwind v4 utilities are not wrapped in:where(), so when the button isdisabled(e.g., due to anmaxItemsconstraint while the form is otherwise interactive) and the user hovers the parent row, the button becomes fully visible (opacity 1) but non-functional — a confusing affordance.🐛 Proposed fix — suppress group-hover reveal when disabled/readonly
By conditionally omitting the
groupclass on the row when the action is unavailable, thegroup-hover:variant never fires, keeping the button invisible regardless of hover state.🤖 Prompt for AI Agents