Skip to content
This repository was archived by the owner on Jun 26, 2026. It is now read-only.

Commit d658de3

Browse files
authored
Merge pull request #1 from cozystack/feat/ui-overhaul
feat(ui): major UI/UX overhaul for forms and resource management
2 parents 2b197ef + 37fd2d2 commit d658de3

64 files changed

Lines changed: 4747 additions & 179 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/build.yaml‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Build and Push Container Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
packages: write
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Docker Buildx
25+
uses: docker/setup-buildx-action@v3
26+
27+
- name: Log in to Container Registry
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ${{ env.REGISTRY }}
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Extract metadata
35+
id: meta
36+
uses: docker/metadata-action@v5
37+
with:
38+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
39+
tags: |
40+
type=ref,event=branch
41+
type=ref,event=pr
42+
type=semver,pattern={{version}}
43+
type=semver,pattern={{major}}.{{minor}}
44+
type=sha,prefix={{branch}}-
45+
type=raw,value=latest,enable={{is_default_branch}}
46+
47+
- name: Build and push
48+
uses: docker/build-push-action@v6
49+
with:
50+
context: .
51+
file: ./Containerfile
52+
platforms: linux/amd64,linux/arm64
53+
push: true
54+
tags: ${{ steps.meta.outputs.tags }}
55+
labels: ${{ steps.meta.outputs.labels }}
56+
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
57+
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max

‎Containerfile‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ ARG NODE_VERSION=22-alpine
33
# Stage 1: Install dependencies and build
44
FROM node:${NODE_VERSION} AS builder
55

6+
ARG APP_VERSION
7+
ENV VITE_APP_VERSION=${APP_VERSION}
8+
69
RUN corepack enable && corepack prepare pnpm@latest --activate
710

811
WORKDIR /src
@@ -67,6 +70,20 @@ server {
6770
proxy_pass https://kubernetes.default.svc:443;
6871
}
6972

73+
# /k8s prefix for VNC WebSocket compatibility
74+
location /k8s/ {
75+
proxy_http_version 1.1;
76+
proxy_buffering off;
77+
proxy_set_header Upgrade $http_upgrade;
78+
proxy_set_header Connection $connection_upgrade;
79+
proxy_set_header X-Forwarded-Proto $scheme;
80+
proxy_set_header Host kubernetes.default.svc;
81+
proxy_read_timeout 86400s;
82+
proxy_send_timeout 86400s;
83+
rewrite /k8s/(.*) /$1 break;
84+
proxy_pass https://kubernetes.default.svc:443;
85+
}
86+
7087
# SPA fallback: serve index.html for all frontend routes.
7188
location / {
7289
try_files $uri $uri/ /index.html;

‎README.md‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ Cozystack Marketplace and Console UI — a pure SPA that talks directly to the
44
Kubernetes API. No BFF, no controller-generated configuration: all UI entities
55
are discovered dynamically from `ApplicationDefinitions` in the cluster.
66

7-
Inspired by [`cozyportal-ui`](https://github.com/aenix-io/cozyportal-ui), but
8-
scoped to Cozystack resources only (`apps.cozystack.io/v1alpha1`).
9-
107
## Structure
118

129
- `apps/console` — React + Vite SPA

‎apps/console/package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
"preview": "vite preview"
1212
},
1313
"dependencies": {
14+
"@base-ui/react": "^1.4.1",
1415
"@cozystack/k8s-client": "workspace:*",
1516
"@cozystack/types": "workspace:*",
1617
"@cozystack/ui": "workspace:*",
1718
"@monaco-editor/react": "^4.7.0",
19+
"@novnc/novnc": "^1.6.0",
1820
"@rjsf/core": "^5.24.8",
1921
"@rjsf/utils": "^5.24.8",
2022
"@rjsf/validator-ajv8": "^5.24.8",

‎apps/console/public/favicon.svg‎

Lines changed: 4 additions & 1 deletion
Loading

‎apps/console/src/App.tsx‎

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,32 @@ import {
88
useConsoleSidebarSections,
99
useMarketplaceSidebarSections,
1010
} from "./routes/sidebar-sections.tsx"
11+
import { CommandPaletteProvider, useCommandPalette } from "./components/command-palette/command-palette-provider.tsx"
12+
import { CommandPalette } from "./components/command-palette/command-palette.tsx"
13+
import type { AppConfig } from "./lib/config.ts"
1114

12-
function Shell() {
15+
interface ShellProps {
16+
config: AppConfig
17+
}
18+
19+
function Shell({ config }: ShellProps) {
1320
const { pathname } = useLocation()
1421
const inMarketplace = pathname.startsWith("/marketplace")
1522
const marketplaceSections = useMarketplaceSidebarSections()
1623
const consoleSections = useConsoleSidebarSections()
1724
const sections = inMarketplace ? marketplaceSections : consoleSections
25+
const { toggle } = useCommandPalette()
26+
1827
return (
19-
<AppShell sections={sections} subtitle={<Breadcrumb />}>
28+
<AppShell
29+
sections={sections}
30+
subtitle={<Breadcrumb />}
31+
onSearchClick={toggle}
32+
version={import.meta.env.VITE_APP_VERSION}
33+
logoSvg={config.logoSvg}
34+
logoText={config.logoText}
35+
>
36+
<CommandPalette />
2037
<Routes>
2138
<Route path="/" element={<Navigate to="/marketplace" replace />} />
2239
<Route path="/marketplace/*" element={<MarketplacePage />} />
@@ -26,10 +43,16 @@ function Shell() {
2643
)
2744
}
2845

29-
export default function App() {
46+
export interface AppProps {
47+
config?: AppConfig
48+
}
49+
50+
export default function App({ config = {} }: AppProps) {
3051
return (
3152
<TenantProvider>
32-
<Shell />
53+
<CommandPaletteProvider>
54+
<Shell config={config} />
55+
</CommandPaletteProvider>
3356
</TenantProvider>
3457
)
3558
}
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import { useState } from "react"
2+
import Form from "@rjsf/core"
3+
import validator from "@rjsf/validator-ajv8"
4+
import type { RJSFSchema } from "@rjsf/utils"
5+
import { customTemplates, customWidgets } from "./rjsf-templates.tsx"
6+
7+
interface AdditionalPropertiesEditorProps {
8+
value: Record<string, unknown>
9+
onChange: (value: Record<string, unknown>) => void
10+
readonly?: boolean
11+
title?: string
12+
description?: string
13+
required?: boolean
14+
itemSchema: RJSFSchema
15+
}
16+
17+
export function AdditionalPropertiesEditor({
18+
value,
19+
onChange,
20+
readonly,
21+
title,
22+
description,
23+
required,
24+
itemSchema,
25+
}: AdditionalPropertiesEditorProps) {
26+
const [newKey, setNewKey] = useState("")
27+
28+
const keys = Object.keys(value || {})
29+
30+
const handleAddKey = () => {
31+
if (!newKey.trim()) return
32+
if (value && newKey in value) {
33+
alert(`Key "${newKey}" already exists`)
34+
return
35+
}
36+
37+
// Initialize with default value from schema
38+
const defaultValue = itemSchema.type === "object" ? {} : itemSchema.default ?? ""
39+
onChange({ ...value, [newKey]: defaultValue })
40+
setNewKey("")
41+
}
42+
43+
const handleRemoveKey = (key: string) => {
44+
const newValue = { ...value }
45+
delete newValue[key]
46+
onChange(newValue)
47+
}
48+
49+
const handleValueChange = (key: string, newVal: unknown) => {
50+
onChange({ ...value, [key]: newVal })
51+
}
52+
53+
return (
54+
<div className="field">
55+
{title && (
56+
<label className="control-label mb-2 block text-sm font-medium text-slate-700">
57+
{title}
58+
{required && <span className="required ml-1 text-red-500">*</span>}
59+
</label>
60+
)}
61+
{description && <p className="field-description mb-3 text-xs text-slate-500">{description}</p>}
62+
63+
<div className="space-y-3">
64+
{keys.map((key) => (
65+
<div key={key} className="rounded-lg border border-slate-200 bg-slate-50 p-4">
66+
<div className="mb-2 flex items-center justify-between">
67+
<div className="font-mono text-sm font-semibold text-slate-900">{key}</div>
68+
{!readonly && (
69+
<button
70+
type="button"
71+
onClick={() => handleRemoveKey(key)}
72+
className="rounded-md border border-red-300 bg-white px-2 py-1 text-xs font-medium text-red-600 hover:bg-red-50"
73+
>
74+
× Remove
75+
</button>
76+
)}
77+
</div>
78+
<div className="rounded-md bg-white p-3">
79+
<Form
80+
schema={itemSchema}
81+
formData={value[key]}
82+
validator={validator}
83+
templates={customTemplates}
84+
widgets={customWidgets}
85+
onChange={(e) => handleValueChange(key, e.formData)}
86+
disabled={readonly}
87+
liveValidate={false}
88+
showErrorList={false}
89+
uiSchema={{
90+
"ui:submitButtonOptions": { norender: true },
91+
}}
92+
>
93+
{/* No submit button */}
94+
</Form>
95+
</div>
96+
</div>
97+
))}
98+
99+
{keys.length === 0 && readonly && (
100+
<div className="text-sm text-slate-500 italic">No entries</div>
101+
)}
102+
103+
{!readonly && (
104+
<div className="flex gap-2">
105+
<input
106+
type="text"
107+
value={newKey}
108+
onChange={(e) => setNewKey(e.target.value)}
109+
onKeyDown={(e) => {
110+
if (e.key === "Enter") {
111+
e.preventDefault()
112+
handleAddKey()
113+
}
114+
}}
115+
placeholder="Enter key name..."
116+
className="flex-1 rounded-lg border border-slate-300 bg-white px-3 py-2 text-sm text-slate-900 placeholder:text-slate-400 outline-none focus:border-blue-400 focus:ring-1 focus:ring-blue-400"
117+
/>
118+
<button
119+
type="button"
120+
onClick={handleAddKey}
121+
disabled={!newKey.trim()}
122+
className="rounded-md border border-slate-300 bg-white px-3 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed"
123+
>
124+
+ Add
125+
</button>
126+
</div>
127+
)}
128+
</div>
129+
</div>
130+
)
131+
}

0 commit comments

Comments
 (0)