Compare commits
32
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4ad18a8a3 | ||
|
|
2a69826e66 | ||
|
|
92412cb300 | ||
|
|
35e9b796f7 | ||
|
|
3446f261be | ||
|
|
5a1aa447d5 | ||
|
|
2697a591aa | ||
|
|
23840e8fbf | ||
|
|
ba6ab7554d | ||
|
|
a7129b417e | ||
|
|
a83752c34e | ||
|
|
bba99993cb | ||
|
|
1136046fc2 | ||
|
|
44eace2bcb | ||
|
|
dc5cfd1c54 | ||
|
|
fae25c11a6 | ||
|
|
b55b8d2d86 | ||
|
|
dbb58e6e94 | ||
|
|
3d89eb3118 | ||
|
|
e70051f912 | ||
|
|
0073b41333 | ||
|
|
d4a2646786 | ||
|
|
48896d1958 | ||
|
|
417af36227 | ||
|
|
55ae666f01 | ||
|
|
ff39d3f452 | ||
|
|
c17d2f4bf3 | ||
|
|
12babb9b88 | ||
|
|
c7bc7a8dcb | ||
|
|
a0da31f0da | ||
|
|
e3d7b7ec4c | ||
|
|
be74080492 |
No files matched your search
@@ -47,6 +47,13 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check the Kubernetes manifests
|
||||
# Proves each manifest rule still fires, then checks the prod overlay (openspec spec cluster-deployment).
|
||||
# Cluster-fact placeholders are allowed here; deploy/check.sh --release refuses them before a real apply.
|
||||
run: |
|
||||
sh deploy/check.sh --self-test
|
||||
sh deploy/check.sh
|
||||
|
||||
- name: Build and test the services
|
||||
run: |
|
||||
mvn -T 1C -B -Dmaven.repo.local=/root/.m2/repository-co-lite verify \
|
||||
|
||||
@@ -20,3 +20,6 @@ solvway-admin-portal/.impeccable/
|
||||
|
||||
# Build output
|
||||
target/
|
||||
|
||||
# Filled-in Kubernetes secrets (templates: deploy/k8s/secrets.example)
|
||||
deploy/k8s/secrets/
|
||||
@@ -0,0 +1,35 @@
|
||||
# expect: replicas must be 1
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: admin-portal}}
|
||||
template:
|
||||
metadata: {labels: {app: admin-portal}}
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-portal
|
||||
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: service-counter}
|
||||
spec:
|
||||
replicas: 2
|
||||
strategy: {type: Recreate}
|
||||
selector: {matchLabels: {app: service-counter}}
|
||||
template:
|
||||
metadata: {labels: {app: service-counter}}
|
||||
spec:
|
||||
containers:
|
||||
- name: service-counter
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
@@ -0,0 +1,18 @@
|
||||
# expect: strategy must be Recreate
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: service-counter}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: service-counter}}
|
||||
template:
|
||||
metadata: {labels: {app: service-counter}}
|
||||
spec:
|
||||
containers:
|
||||
- name: service-counter
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
@@ -0,0 +1,18 @@
|
||||
# expect: not 'latest'
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: admin-portal}}
|
||||
template:
|
||||
metadata: {labels: {app: admin-portal}}
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-portal
|
||||
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:latest
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
@@ -0,0 +1,90 @@
|
||||
# expect: env JWT_SECRET holds a literal value
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: admin-portal}}
|
||||
template:
|
||||
metadata: {labels: {app: admin-portal}}
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-portal
|
||||
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: mobile-api}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: mobile-api}}
|
||||
template:
|
||||
metadata: {labels: {app: mobile-api}}
|
||||
spec:
|
||||
containers:
|
||||
- name: mobile-api
|
||||
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: service-counter}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: Recreate}
|
||||
selector: {matchLabels: {app: service-counter}}
|
||||
template:
|
||||
metadata: {labels: {app: service-counter}}
|
||||
spec:
|
||||
containers:
|
||||
- name: service-counter
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`)
|
||||
kind: Rule
|
||||
services: [{name: admin-portal, port: 3000}]
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: whatsapp-webhook}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
|
||||
kind: Rule
|
||||
services: [{name: mobile-api, port: 80}]
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: service-log}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: service-log}}
|
||||
template:
|
||||
metadata: {labels: {app: service-log}}
|
||||
spec:
|
||||
containers:
|
||||
- name: service-log
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-log:abc1234
|
||||
env:
|
||||
- {name: JWT_SECRET, value: x}
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
@@ -0,0 +1,89 @@
|
||||
# expect: different tags
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: admin-portal}}
|
||||
template:
|
||||
metadata: {labels: {app: admin-portal}}
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-portal
|
||||
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: mobile-api}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: mobile-api}}
|
||||
template:
|
||||
metadata: {labels: {app: mobile-api}}
|
||||
spec:
|
||||
containers:
|
||||
- name: mobile-api
|
||||
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: service-counter}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: Recreate}
|
||||
selector: {matchLabels: {app: service-counter}}
|
||||
template:
|
||||
metadata: {labels: {app: service-counter}}
|
||||
spec:
|
||||
containers:
|
||||
- name: service-counter
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`)
|
||||
kind: Rule
|
||||
services: [{name: admin-portal, port: 3000}]
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: whatsapp-webhook}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
|
||||
kind: Rule
|
||||
services: [{name: mobile-api, port: 80}]
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: service-log}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: service-log}}
|
||||
template:
|
||||
metadata: {labels: {app: service-log}}
|
||||
spec:
|
||||
containers:
|
||||
- name: service-log
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-log:def5678
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
@@ -0,0 +1,77 @@
|
||||
# expect: Service type NodePort
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: admin-portal}}
|
||||
template:
|
||||
metadata: {labels: {app: admin-portal}}
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-portal
|
||||
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: mobile-api}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: mobile-api}}
|
||||
template:
|
||||
metadata: {labels: {app: mobile-api}}
|
||||
spec:
|
||||
containers:
|
||||
- name: mobile-api
|
||||
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: service-counter}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: Recreate}
|
||||
selector: {matchLabels: {app: service-counter}}
|
||||
template:
|
||||
metadata: {labels: {app: service-counter}}
|
||||
spec:
|
||||
containers:
|
||||
- name: service-counter
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`)
|
||||
kind: Rule
|
||||
services: [{name: admin-portal, port: 3000}]
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: whatsapp-webhook}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
|
||||
kind: Rule
|
||||
services: [{name: mobile-api, port: 80}]
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata: {name: api-gateway}
|
||||
spec: {type: NodePort, ports: [{port: 80}]}
|
||||
@@ -0,0 +1,18 @@
|
||||
# expect: not 'no tag'
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: admin-portal}}
|
||||
template:
|
||||
metadata: {labels: {app: admin-portal}}
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-portal
|
||||
image: gitea.containerverse.dev/solvway/co-lite-admin-portal
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
@@ -0,0 +1,78 @@
|
||||
# expect: still a placeholder: <mysql host>
|
||||
# flags: --release
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: admin-portal}}
|
||||
template:
|
||||
metadata: {labels: {app: admin-portal}}
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-portal
|
||||
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: mobile-api}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: mobile-api}}
|
||||
template:
|
||||
metadata: {labels: {app: mobile-api}}
|
||||
spec:
|
||||
containers:
|
||||
- name: mobile-api
|
||||
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: service-counter}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: Recreate}
|
||||
selector: {matchLabels: {app: service-counter}}
|
||||
template:
|
||||
metadata: {labels: {app: service-counter}}
|
||||
spec:
|
||||
containers:
|
||||
- name: service-counter
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`)
|
||||
kind: Rule
|
||||
services: [{name: admin-portal, port: 3000}]
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: whatsapp-webhook}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
|
||||
kind: Rule
|
||||
services: [{name: mobile-api, port: 80}]
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata: {name: co-lite-settings}
|
||||
data: {MYSQLHOST: <mysql host>}
|
||||
@@ -0,0 +1,82 @@
|
||||
# expect: reaches 'api-gateway'
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: admin-portal}}
|
||||
template:
|
||||
metadata: {labels: {app: admin-portal}}
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-portal
|
||||
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: mobile-api}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: mobile-api}}
|
||||
template:
|
||||
metadata: {labels: {app: mobile-api}}
|
||||
spec:
|
||||
containers:
|
||||
- name: mobile-api
|
||||
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: service-counter}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: Recreate}
|
||||
selector: {matchLabels: {app: service-counter}}
|
||||
template:
|
||||
metadata: {labels: {app: service-counter}}
|
||||
spec:
|
||||
containers:
|
||||
- name: service-counter
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`)
|
||||
kind: Rule
|
||||
services: [{name: admin-portal, port: 3000}]
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: whatsapp-webhook}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
|
||||
kind: Rule
|
||||
services: [{name: mobile-api, port: 80}]
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: gw}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`)
|
||||
kind: Rule
|
||||
services: [{name: api-gateway, port: 80}]
|
||||
@@ -0,0 +1,82 @@
|
||||
# expect: reaches 'mobile-api'
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: admin-portal}}
|
||||
template:
|
||||
metadata: {labels: {app: admin-portal}}
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-portal
|
||||
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: mobile-api}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: mobile-api}}
|
||||
template:
|
||||
metadata: {labels: {app: mobile-api}}
|
||||
spec:
|
||||
containers:
|
||||
- name: mobile-api
|
||||
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: service-counter}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: Recreate}
|
||||
selector: {matchLabels: {app: service-counter}}
|
||||
template:
|
||||
metadata: {labels: {app: service-counter}}
|
||||
spec:
|
||||
containers:
|
||||
- name: service-counter
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`)
|
||||
kind: Rule
|
||||
services: [{name: admin-portal, port: 3000}]
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: whatsapp-webhook}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
|
||||
kind: Rule
|
||||
services: [{name: mobile-api, port: 80}]
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: api}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`) && PathPrefix(`/api/public/whatsapp/webhook`)
|
||||
kind: Rule
|
||||
services: [{name: mobile-api, port: 80}]
|
||||
@@ -0,0 +1,77 @@
|
||||
# expect: Secret with data
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: admin-portal}}
|
||||
template:
|
||||
metadata: {labels: {app: admin-portal}}
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-portal
|
||||
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: mobile-api}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: mobile-api}}
|
||||
template:
|
||||
metadata: {labels: {app: mobile-api}}
|
||||
spec:
|
||||
containers:
|
||||
- name: mobile-api
|
||||
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: service-counter}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: Recreate}
|
||||
selector: {matchLabels: {app: service-counter}}
|
||||
template:
|
||||
metadata: {labels: {app: service-counter}}
|
||||
spec:
|
||||
containers:
|
||||
- name: service-counter
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`)
|
||||
kind: Rule
|
||||
services: [{name: admin-portal, port: 3000}]
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: whatsapp-webhook}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
|
||||
kind: Rule
|
||||
services: [{name: mobile-api, port: 80}]
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata: {name: co-lite-shared}
|
||||
data: {JWT_TOKEN: eA==}
|
||||
@@ -0,0 +1,72 @@
|
||||
# expect: pass
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: admin-portal}}
|
||||
template:
|
||||
metadata: {labels: {app: admin-portal}}
|
||||
spec:
|
||||
containers:
|
||||
- name: admin-portal
|
||||
image: gitea.containerverse.dev/solvway/co-lite-admin-portal:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: mobile-api}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: RollingUpdate}
|
||||
selector: {matchLabels: {app: mobile-api}}
|
||||
template:
|
||||
metadata: {labels: {app: mobile-api}}
|
||||
spec:
|
||||
containers:
|
||||
- name: mobile-api
|
||||
image: gitea.containerverse.dev/solvway/co-lite-mobile-api:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata: {name: service-counter}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: Recreate}
|
||||
selector: {matchLabels: {app: service-counter}}
|
||||
template:
|
||||
metadata: {labels: {app: service-counter}}
|
||||
spec:
|
||||
containers:
|
||||
- name: service-counter
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-counter:abc1234
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: admin-portal}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`)
|
||||
kind: Rule
|
||||
services: [{name: admin-portal, port: 3000}]
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata: {name: whatsapp-webhook}
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.example`) && Path(`/api/public/whatsapp/webhook`)
|
||||
kind: Rule
|
||||
services: [{name: mobile-api, port: 80}]
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/bin/sh
|
||||
# Checks the production manifests (openspec spec cluster-deployment): renders deploy/k8s/overlays/prod, validates it
|
||||
# against the Kubernetes schemas, then applies check_rules.py (public routes, pinned images, no secret data,
|
||||
# one service-counter, all ten services present). Needs only Docker. The deploy folder goes to the container through stdin, so this also works
|
||||
# against a remote Docker daemon (CI's DOCKER_HOST).
|
||||
# deploy/check.sh check the prod overlay
|
||||
# deploy/check.sh --self-test prove every rule fires on its fixture in deploy/check-fixtures
|
||||
# deploy/check.sh --release also refuse any <…> placeholder; run it before every real apply
|
||||
# deploy/check.sh --render print the rendered prod manifests
|
||||
set -eu
|
||||
IMAGE=alpine/k8s:1.33.4@sha256:b0523f0a244ddc4c8e055aa335c040d3d78b3ead5528f4544395f7f9f69c7b68
|
||||
# Traefik's IngressRoute schema comes from the CRDs catalog; Kubernetes' own from kubeconform's default location.
|
||||
CRDS='https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json'
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
in_container() {
|
||||
tar -cf - deploy | docker run --rm -i "$IMAGE" sh -c "set -e; mkdir -p /w && tar -xf - -C /w && cd /w && $1"
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
--render)
|
||||
in_container 'kubectl kustomize deploy/k8s/overlays/prod'
|
||||
;;
|
||||
--self-test)
|
||||
in_container '
|
||||
fail=0
|
||||
for f in deploy/check-fixtures/*.yaml; do
|
||||
expect=$(sed -n "1s/^# expect: //p" "$f")
|
||||
flags=$(sed -n "2s/^# flags: //p" "$f")
|
||||
if out=$(python3 -I deploy/check_rules.py $flags < "$f"); then got=pass; else got=$out; fi
|
||||
case "$got" in
|
||||
*"$expect"*) echo "ok $f" ;;
|
||||
*) echo "FAIL $f: expected \"$expect\", got: $got"; fail=1 ;;
|
||||
esac
|
||||
done
|
||||
exit $fail'
|
||||
;;
|
||||
""|--release)
|
||||
in_container "
|
||||
kubectl kustomize deploy/k8s/overlays/prod > /tmp/prod.yaml
|
||||
kubeconform -strict -summary -schema-location default -schema-location '$CRDS' /tmp/prod.yaml
|
||||
python3 -I deploy/check_rules.py --full ${1:-} < /tmp/prod.yaml && echo 'prod manifests: rules passed'"
|
||||
;;
|
||||
*)
|
||||
echo "usage: $0 [--release|--self-test|--render]" >&2; exit 2
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,127 @@
|
||||
"""Production manifest rules (openspec spec cluster-deployment). Reads rendered multi-document YAML on stdin,
|
||||
prints one line per violation and exits 1 if there is any. Runs inside the pinned alpine/k8s image (deploy/check.sh)."""
|
||||
import re
|
||||
import sys
|
||||
|
||||
import yaml
|
||||
|
||||
WEBHOOK = "/api/public/whatsapp/webhook"
|
||||
PUBLIC = {"admin-portal"}
|
||||
SECRETISH = re.compile(r"(SECRET|TOKEN|PASSWORD|PWD|KEY|KEYS)$")
|
||||
WORKLOADS = {"Deployment", "StatefulSet", "DaemonSet", "Job", "CronJob"}
|
||||
# The ten images of docs/deployment.md section 1; their Service names are fixed in the gateway's and mobile-api's config.
|
||||
SYSTEM = {"admin-portal", "mobile-api", "api-gateway", "service-auth", "service-system", "service-counter",
|
||||
"service-member", "service-log", "service-email", "service-whatsapp"}
|
||||
|
||||
|
||||
def name(doc):
|
||||
return f"{doc.get('kind')}/{(doc.get('metadata') or {}).get('name')}"
|
||||
|
||||
|
||||
def pod_spec(doc):
|
||||
spec = doc.get("spec") or {}
|
||||
if doc.get("kind") == "CronJob":
|
||||
spec = ((spec.get("jobTemplate") or {}).get("spec") or {})
|
||||
return ((spec.get("template") or {}).get("spec") or {})
|
||||
|
||||
|
||||
def check_route(doc, out):
|
||||
for route in (doc.get("spec") or {}).get("routes") or []:
|
||||
match = route.get("match", "")
|
||||
for svc in route.get("services") or []:
|
||||
target = svc.get("name")
|
||||
if target in PUBLIC:
|
||||
continue
|
||||
exact = f"Path(`{WEBHOOK}`)" in match and "PathPrefix" not in match and "||" not in match
|
||||
if target == "mobile-api" and exact:
|
||||
continue
|
||||
out.append(f"{name(doc)}: route '{match}' reaches '{target}'; only admin-portal and mobile-api's exact {WEBHOOK} may be public")
|
||||
|
||||
|
||||
def check_images(doc, out):
|
||||
spec = pod_spec(doc)
|
||||
for c in (spec.get("containers") or []) + (spec.get("initContainers") or []):
|
||||
image = c.get("image", "")
|
||||
if "@sha256:" in image:
|
||||
continue
|
||||
last = image.rsplit("/", 1)[-1]
|
||||
tag = last.split(":", 1)[1] if ":" in last else ""
|
||||
if tag in ("", "latest"):
|
||||
out.append(f"{name(doc)}: image '{image}' must be pinned to a commit SHA, not '{tag or 'no tag'}'")
|
||||
elif "co-lite-" in last and not re.fullmatch(r"[0-9a-f]{7,40}", tag):
|
||||
out.append(f"{name(doc)}: image '{image}' tag must be a commit SHA")
|
||||
|
||||
|
||||
def check_env(doc, out):
|
||||
spec = pod_spec(doc)
|
||||
for c in (spec.get("containers") or []) + (spec.get("initContainers") or []):
|
||||
for env in c.get("env") or []:
|
||||
if SECRETISH.search(env.get("name", "")) and "value" in env:
|
||||
out.append(f"{name(doc)}: env {env['name']} holds a literal value; take it from a Secret")
|
||||
|
||||
|
||||
def complete(docs):
|
||||
out = []
|
||||
for kind in ("Deployment", "Service"):
|
||||
have = {(d.get("metadata") or {}).get("name") for d in docs if d.get("kind") == kind}
|
||||
out += [f"{kind}/{n}: missing from the manifests" for n in sorted(SYSTEM - have)]
|
||||
return out
|
||||
|
||||
|
||||
def placeholders(docs):
|
||||
"""Before a real apply every <…> cluster fact must be filled in (deploy/check.sh --release)."""
|
||||
out = []
|
||||
|
||||
def walk(doc, value, path):
|
||||
if isinstance(value, dict):
|
||||
for k, v in value.items():
|
||||
walk(doc, v, f"{path}.{k}")
|
||||
elif isinstance(value, list):
|
||||
for i, v in enumerate(value):
|
||||
walk(doc, v, f"{path}[{i}]")
|
||||
elif isinstance(value, str) and re.search(r"<[^<>]+>", value):
|
||||
out.append(f"{name(doc)}: {path.lstrip('.')} is still a placeholder: {value}")
|
||||
|
||||
for doc in docs:
|
||||
walk(doc, doc, "")
|
||||
return out
|
||||
|
||||
|
||||
def rules(docs):
|
||||
out = []
|
||||
shas = {}
|
||||
for doc in docs:
|
||||
kind = doc.get("kind")
|
||||
if kind == "Secret" and (doc.get("data") or doc.get("stringData")):
|
||||
out.append(f"{name(doc)}: Secret with data in the manifests; create it with deploy/create-secrets.sh")
|
||||
if kind in ("Ingress", "IngressRouteTCP", "IngressRouteUDP"):
|
||||
out.append(f"{name(doc)}: {kind} is not allowed; public routes are Traefik IngressRoutes")
|
||||
if kind == "Service" and (doc.get("spec") or {}).get("type", "ClusterIP") != "ClusterIP":
|
||||
out.append(f"{name(doc)}: Service type {doc['spec']['type']} exposes it outside the cluster")
|
||||
if kind == "IngressRoute":
|
||||
check_route(doc, out)
|
||||
if kind in WORKLOADS:
|
||||
check_images(doc, out)
|
||||
check_env(doc, out)
|
||||
for c in pod_spec(doc).get("containers") or []:
|
||||
last = c.get("image", "").rsplit("/", 1)[-1]
|
||||
if last.startswith("co-lite-") and ":" in last:
|
||||
shas.setdefault(last.split(":", 1)[1].split("@")[0], []).append(name(doc))
|
||||
if kind == "Deployment" and doc["metadata"]["name"] == "service-counter":
|
||||
spec = doc.get("spec") or {}
|
||||
if spec.get("replicas", 1) != 1:
|
||||
out.append(f"{name(doc)}: replicas must be 1 (the daily follow-up summary would be sent once per replica)")
|
||||
if (spec.get("strategy") or {}).get("type") != "Recreate":
|
||||
out.append(f"{name(doc)}: strategy must be Recreate so a rollout never runs two copies")
|
||||
if len(shas) > 1:
|
||||
out.append(f"images: co-lite images use different tags {sorted(shas)}; one release is one commit SHA")
|
||||
return out
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
docs = [d for d in yaml.safe_load_all(sys.stdin) if d]
|
||||
found = rules(docs) + (complete(docs) if "--full" in sys.argv else []) \
|
||||
+ (placeholders(docs) if "--release" in sys.argv else [])
|
||||
for line in found:
|
||||
print(line)
|
||||
sys.exit(1 if found else 0)
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
#!/bin/sh
|
||||
# Creates or updates Co-Lite's Kubernetes Secrets from the filled-in copy of deploy/k8s/secrets.example
|
||||
# (openspec spec cluster-deployment: secrets never enter the repository). Never prints a value.
|
||||
# deploy/create-secrets.sh [--dry-run] [folder] folder defaults to deploy/k8s/secrets
|
||||
# --dry-run checks the folder and lists the Secrets and key names without kubectl.
|
||||
# NAMESPACE (default co-lite) picks the namespace.
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
dry=
|
||||
[ "${1:-}" = "--dry-run" ] && { dry=1; shift; }
|
||||
src=${1:-deploy/k8s/secrets}
|
||||
tpl=deploy/k8s/secrets.example
|
||||
ns=${NAMESPACE:-co-lite}
|
||||
optional="co-lite-whatsapp.env"
|
||||
fail() { echo "create-secrets: $*" >&2; exit 1; }
|
||||
[ -d "$src" ] || fail "no folder $src; copy $tpl there and fill it in"
|
||||
|
||||
keys() { sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p' "$1"; }
|
||||
value_of() { sed -n "s/^$2=//p" "$1" | head -n 1; }
|
||||
|
||||
# Check everything before creating anything, so a half-filled folder changes nothing.
|
||||
for t in "$tpl"/*.env "$tpl"/*/; do
|
||||
base=$(basename "$t")
|
||||
f="$src/$base"
|
||||
if [ ! -e "$f" ]; then
|
||||
case " $optional " in *" $base "*) continue ;; esac
|
||||
fail "missing $f"
|
||||
fi
|
||||
if [ -d "$t" ]; then
|
||||
for k in "$t"*; do
|
||||
kf="$f/$(basename "$k")"
|
||||
[ -s "$kf" ] || fail "missing or empty $kf"
|
||||
! grep -q '<[^<>]*>' "$kf" || fail "$kf still holds a <…> placeholder"
|
||||
done
|
||||
else
|
||||
for k in $(keys "$t"); do
|
||||
v=$(value_of "$f" "$k")
|
||||
[ -n "$v" ] || fail "$f: $k is missing or empty"
|
||||
case "$v" in *"<"*">"*) fail "$f: $k is still a placeholder" ;; esac
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
apply() { # name, then kubectl create arguments
|
||||
name=$1; shift
|
||||
kubectl create secret "$@" "$name" -n "$ns" --dry-run=client -o yaml | kubectl apply -f - >/dev/null
|
||||
echo "applied Secret $name"
|
||||
}
|
||||
|
||||
if [ -z "$dry" ]; then
|
||||
# The first run comes before the first apply, which is what would otherwise create the namespace.
|
||||
kubectl create namespace "$ns" --dry-run=client -o yaml | kubectl apply -f - >/dev/null
|
||||
fi
|
||||
for f in "$src"/*.env "$src"/*/; do
|
||||
[ -e "$f" ] || continue
|
||||
name=$(basename "$f" .env); name=${name%/}
|
||||
[ -e "$tpl/$(basename "$f")" ] || fail "$f has no template in $tpl"
|
||||
if [ "$name" = co-lite-registry ]; then
|
||||
echo "Secret $name (image pull secret for gitea.containerverse.dev)"
|
||||
[ -n "$dry" ] && continue
|
||||
tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT
|
||||
auth=$(printf '%s:%s' "$(value_of "$f" REGISTRY_USER)" "$(value_of "$f" REGISTRY_PASSWORD)" | base64 | tr -d '\n')
|
||||
(umask 077; printf '{"auths":{"gitea.containerverse.dev":{"auth":"%s"}}}' "$auth" > "$tmp/config.json")
|
||||
apply "$name" generic --type=kubernetes.io/dockerconfigjson --from-file=.dockerconfigjson="$tmp/config.json"
|
||||
elif [ -d "$f" ]; then
|
||||
echo "Secret $name: $(ls "$f" | tr '\n' ' ')"
|
||||
[ -n "$dry" ] && continue
|
||||
apply "$name" generic --from-file="$f"
|
||||
else
|
||||
echo "Secret $name: $(keys "$f" | tr '\n' ' ')"
|
||||
[ -n "$dry" ] && continue
|
||||
apply "$name" generic --from-env-file="$f"
|
||||
fi
|
||||
done
|
||||
@@ -0,0 +1,41 @@
|
||||
# The only Service routed to as a whole (overlays/prod/routes.yaml). No health endpoint: GET /login answers 200 without a session.
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: admin-portal
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels: {app: admin-portal}
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: admin-portal}
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- {name: co-lite-registry}
|
||||
containers:
|
||||
- name: admin-portal
|
||||
image: gitea.containerverse.dev/solvway/co-lite-admin-portal
|
||||
ports:
|
||||
- {name: http, containerPort: 3000}
|
||||
envFrom:
|
||||
- {configMapRef: {name: co-lite-portal}}
|
||||
- {secretRef: {name: co-lite-admin-portal}}
|
||||
livenessProbe:
|
||||
tcpSocket: {port: http}
|
||||
periodSeconds: 20
|
||||
readinessProbe:
|
||||
httpGet: {path: /login, port: http}
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 256Mi}
|
||||
limits: {memory: 512Mi}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: admin-portal
|
||||
spec:
|
||||
selector: {app: admin-portal}
|
||||
ports:
|
||||
- {name: http, port: 3000, targetPort: http}
|
||||
@@ -0,0 +1,51 @@
|
||||
# Routes to http://service-* on port 80; needs only JWT_TOKEN and the mounted appkeys.json (docs/deployment.md 6, 7).
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: api-gateway
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels: {app: api-gateway}
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: api-gateway}
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- {name: co-lite-registry}
|
||||
containers:
|
||||
- name: api-gateway
|
||||
image: gitea.containerverse.dev/solvway/co-lite-api-gateway
|
||||
ports:
|
||||
- {name: http, containerPort: 80}
|
||||
env:
|
||||
- name: JWT_TOKEN
|
||||
valueFrom: {secretKeyRef: {name: co-lite-shared, key: JWT_TOKEN}}
|
||||
- name: JAVA_OPTS
|
||||
valueFrom: {configMapKeyRef: {name: co-lite-settings, key: JAVA_OPTS}}
|
||||
startupProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 10
|
||||
failureThreshold: 30
|
||||
livenessProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 20
|
||||
readinessProbe:
|
||||
httpGet: {path: /actuator/health/readiness, port: http}
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 512Mi}
|
||||
limits: {memory: 1Gi}
|
||||
volumeMounts:
|
||||
- {name: appkeys, mountPath: /deployments/appkeys, readOnly: true}
|
||||
volumes:
|
||||
- {name: appkeys, secret: {secretName: co-lite-gateway-appkeys}}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: api-gateway
|
||||
spec:
|
||||
selector: {app: api-gateway}
|
||||
ports:
|
||||
- {name: http, port: 80, targetPort: http}
|
||||
@@ -0,0 +1,18 @@
|
||||
# Co-Lite on Kubernetes: one Deployment and one Service per image (docs/deployment.md section 1).
|
||||
# Settings and Secrets are referenced by name only; the prod overlay generates the settings and
|
||||
# deploy/create-secrets.sh creates the Secrets. Images carry no tag here: the overlay pins one commit SHA.
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
labels:
|
||||
- pairs: {app.kubernetes.io/part-of: co-lite}
|
||||
resources:
|
||||
- admin-portal.yaml
|
||||
- api-gateway.yaml
|
||||
- mobile-api.yaml
|
||||
- service-auth.yaml
|
||||
- service-counter.yaml
|
||||
- service-email.yaml
|
||||
- service-log.yaml
|
||||
- service-member.yaml
|
||||
- service-system.yaml
|
||||
- service-whatsapp.yaml
|
||||
@@ -0,0 +1,53 @@
|
||||
# Internal; only its WhatsApp webhook path is public (overlays/prod/routes.yaml).
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: mobile-api
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels: {app: mobile-api}
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: mobile-api}
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- {name: co-lite-registry}
|
||||
containers:
|
||||
- name: mobile-api
|
||||
image: gitea.containerverse.dev/solvway/co-lite-mobile-api
|
||||
ports:
|
||||
- {name: http, containerPort: 80}
|
||||
envFrom:
|
||||
- {configMapRef: {name: co-lite-settings}}
|
||||
- {secretRef: {name: co-lite-shared}}
|
||||
- {configMapRef: {name: co-lite-gcp}}
|
||||
- {secretRef: {name: co-lite-mobile-api}}
|
||||
- {configMapRef: {name: co-lite-whatsapp}}
|
||||
- {secretRef: {name: co-lite-whatsapp, optional: true}}
|
||||
startupProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 10
|
||||
failureThreshold: 30
|
||||
livenessProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 20
|
||||
readinessProbe:
|
||||
httpGet: {path: /actuator/health/readiness, port: http}
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 512Mi}
|
||||
limits: {memory: 1Gi}
|
||||
volumeMounts:
|
||||
- {name: gcp-key, mountPath: /var/secrets/gcp, readOnly: true}
|
||||
volumes:
|
||||
- {name: gcp-key, secret: {secretName: co-lite-gcp-key}}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: mobile-api
|
||||
spec:
|
||||
selector: {app: mobile-api}
|
||||
ports:
|
||||
- {name: http, port: 80, targetPort: http}
|
||||
@@ -0,0 +1,50 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: service-auth
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels: {app: service-auth}
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: service-auth}
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- {name: co-lite-registry}
|
||||
containers:
|
||||
- name: service-auth
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-auth
|
||||
ports:
|
||||
- {name: http, containerPort: 80}
|
||||
envFrom:
|
||||
- {configMapRef: {name: co-lite-settings}}
|
||||
- {secretRef: {name: co-lite-shared}}
|
||||
- {configMapRef: {name: co-lite-gcp}}
|
||||
- {secretRef: {name: co-lite-service-auth}}
|
||||
startupProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 10
|
||||
failureThreshold: 30
|
||||
livenessProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 20
|
||||
readinessProbe:
|
||||
httpGet: {path: /actuator/health/readiness, port: http}
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 512Mi}
|
||||
limits: {memory: 1Gi}
|
||||
volumeMounts:
|
||||
- {name: gcp-key, mountPath: /var/secrets/gcp, readOnly: true}
|
||||
volumes:
|
||||
- {name: gcp-key, secret: {secretName: co-lite-gcp-key}}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: service-auth
|
||||
spec:
|
||||
selector: {app: service-auth}
|
||||
ports:
|
||||
- {name: http, port: 80, targetPort: http}
|
||||
@@ -0,0 +1,51 @@
|
||||
# Exactly one replica, replaced not rolled: it sends the daily follow-up summary (deploy/check_rules.py).
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: service-counter
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy: {type: Recreate}
|
||||
selector:
|
||||
matchLabels: {app: service-counter}
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: service-counter}
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- {name: co-lite-registry}
|
||||
containers:
|
||||
- name: service-counter
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-counter
|
||||
ports:
|
||||
- {name: http, containerPort: 80}
|
||||
envFrom:
|
||||
- {configMapRef: {name: co-lite-settings}}
|
||||
- {secretRef: {name: co-lite-shared}}
|
||||
- {configMapRef: {name: co-lite-gcp}}
|
||||
startupProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 10
|
||||
failureThreshold: 30
|
||||
livenessProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 20
|
||||
readinessProbe:
|
||||
httpGet: {path: /actuator/health/readiness, port: http}
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 768Mi}
|
||||
limits: {memory: 1Gi}
|
||||
volumeMounts:
|
||||
- {name: gcp-key, mountPath: /var/secrets/gcp, readOnly: true}
|
||||
volumes:
|
||||
- {name: gcp-key, secret: {secretName: co-lite-gcp-key}}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: service-counter
|
||||
spec:
|
||||
selector: {app: service-counter}
|
||||
ports:
|
||||
- {name: http, port: 80, targetPort: http}
|
||||
@@ -0,0 +1,49 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: service-email
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels: {app: service-email}
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: service-email}
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- {name: co-lite-registry}
|
||||
containers:
|
||||
- name: service-email
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-email
|
||||
ports:
|
||||
- {name: http, containerPort: 80}
|
||||
envFrom:
|
||||
- {configMapRef: {name: co-lite-settings}}
|
||||
- {secretRef: {name: co-lite-shared}}
|
||||
- {configMapRef: {name: co-lite-gcp}}
|
||||
startupProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 10
|
||||
failureThreshold: 30
|
||||
livenessProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 20
|
||||
readinessProbe:
|
||||
httpGet: {path: /actuator/health/readiness, port: http}
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 512Mi}
|
||||
limits: {memory: 1Gi}
|
||||
volumeMounts:
|
||||
- {name: gcp-key, mountPath: /var/secrets/gcp, readOnly: true}
|
||||
volumes:
|
||||
- {name: gcp-key, secret: {secretName: co-lite-gcp-key}}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: service-email
|
||||
spec:
|
||||
selector: {app: service-email}
|
||||
ports:
|
||||
- {name: http, port: 80, targetPort: http}
|
||||
@@ -0,0 +1,49 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: service-log
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels: {app: service-log}
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: service-log}
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- {name: co-lite-registry}
|
||||
containers:
|
||||
- name: service-log
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-log
|
||||
ports:
|
||||
- {name: http, containerPort: 80}
|
||||
envFrom:
|
||||
- {configMapRef: {name: co-lite-settings}}
|
||||
- {secretRef: {name: co-lite-shared}}
|
||||
- {configMapRef: {name: co-lite-gcp}}
|
||||
startupProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 10
|
||||
failureThreshold: 30
|
||||
livenessProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 20
|
||||
readinessProbe:
|
||||
httpGet: {path: /actuator/health/readiness, port: http}
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 512Mi}
|
||||
limits: {memory: 1Gi}
|
||||
volumeMounts:
|
||||
- {name: gcp-key, mountPath: /var/secrets/gcp, readOnly: true}
|
||||
volumes:
|
||||
- {name: gcp-key, secret: {secretName: co-lite-gcp-key}}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: service-log
|
||||
spec:
|
||||
selector: {app: service-log}
|
||||
ports:
|
||||
- {name: http, port: 80, targetPort: http}
|
||||
@@ -0,0 +1,49 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: service-member
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels: {app: service-member}
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: service-member}
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- {name: co-lite-registry}
|
||||
containers:
|
||||
- name: service-member
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-member
|
||||
ports:
|
||||
- {name: http, containerPort: 80}
|
||||
envFrom:
|
||||
- {configMapRef: {name: co-lite-settings}}
|
||||
- {secretRef: {name: co-lite-shared}}
|
||||
- {configMapRef: {name: co-lite-gcp}}
|
||||
startupProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 10
|
||||
failureThreshold: 30
|
||||
livenessProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 20
|
||||
readinessProbe:
|
||||
httpGet: {path: /actuator/health/readiness, port: http}
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 512Mi}
|
||||
limits: {memory: 1Gi}
|
||||
volumeMounts:
|
||||
- {name: gcp-key, mountPath: /var/secrets/gcp, readOnly: true}
|
||||
volumes:
|
||||
- {name: gcp-key, secret: {secretName: co-lite-gcp-key}}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: service-member
|
||||
spec:
|
||||
selector: {app: service-member}
|
||||
ports:
|
||||
- {name: http, port: 80, targetPort: http}
|
||||
@@ -0,0 +1,49 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: service-system
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels: {app: service-system}
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: service-system}
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- {name: co-lite-registry}
|
||||
containers:
|
||||
- name: service-system
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-system
|
||||
ports:
|
||||
- {name: http, containerPort: 80}
|
||||
envFrom:
|
||||
- {configMapRef: {name: co-lite-settings}}
|
||||
- {secretRef: {name: co-lite-shared}}
|
||||
- {configMapRef: {name: co-lite-gcp}}
|
||||
startupProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 10
|
||||
failureThreshold: 30
|
||||
livenessProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 20
|
||||
readinessProbe:
|
||||
httpGet: {path: /actuator/health/readiness, port: http}
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 512Mi}
|
||||
limits: {memory: 1Gi}
|
||||
volumeMounts:
|
||||
- {name: gcp-key, mountPath: /var/secrets/gcp, readOnly: true}
|
||||
volumes:
|
||||
- {name: gcp-key, secret: {secretName: co-lite-gcp-key}}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: service-system
|
||||
spec:
|
||||
selector: {app: service-system}
|
||||
ports:
|
||||
- {name: http, port: 80, targetPort: http}
|
||||
@@ -0,0 +1,47 @@
|
||||
# No Pub/Sub, Redis or key.json; reads the WhatsApp settings at startup.
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: service-whatsapp
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels: {app: service-whatsapp}
|
||||
template:
|
||||
metadata:
|
||||
labels: {app: service-whatsapp}
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- {name: co-lite-registry}
|
||||
containers:
|
||||
- name: service-whatsapp
|
||||
image: gitea.containerverse.dev/solvway/co-lite-service-whatsapp
|
||||
ports:
|
||||
- {name: http, containerPort: 80}
|
||||
envFrom:
|
||||
- {configMapRef: {name: co-lite-settings}}
|
||||
- {secretRef: {name: co-lite-shared}}
|
||||
- {configMapRef: {name: co-lite-whatsapp}}
|
||||
- {secretRef: {name: co-lite-whatsapp, optional: true}}
|
||||
startupProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 10
|
||||
failureThreshold: 30
|
||||
livenessProbe:
|
||||
httpGet: {path: /actuator/health/liveness, port: http}
|
||||
periodSeconds: 20
|
||||
readinessProbe:
|
||||
httpGet: {path: /actuator/health/readiness, port: http}
|
||||
periodSeconds: 10
|
||||
resources:
|
||||
requests: {cpu: 100m, memory: 512Mi}
|
||||
limits: {memory: 1Gi}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: service-whatsapp
|
||||
spec:
|
||||
selector: {app: service-whatsapp}
|
||||
ports:
|
||||
- {name: http, port: 80, targetPort: http}
|
||||
@@ -0,0 +1,3 @@
|
||||
# Pub/Sub (docs/deployment.md section 5). The key itself is the co-lite-gcp-key Secret, mounted at /var/secrets/gcp.
|
||||
GCP_PROJECT=<google cloud project id>
|
||||
GCP_CREDENTIAL_FILE=file:/var/secrets/gcp/key.json
|
||||
@@ -0,0 +1,43 @@
|
||||
# Production: the team's cluster. Apply with `kubectl apply -k deploy/k8s/overlays/prod` after
|
||||
# deploy/create-secrets.sh and deploy/check.sh --release (docs/deployment.md section 2).
|
||||
# Every <…> value is a cluster fact still to be filled in; deploy/check.sh --release refuses them.
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: co-lite
|
||||
resources:
|
||||
- namespace.yaml
|
||||
- ../../base
|
||||
- routes.yaml
|
||||
# Plain settings (docs/deployment.md section 6). Secrets are not here: deploy/create-secrets.sh makes them.
|
||||
# A changed value gets a new ConfigMap name, so the pods that read it restart on the next apply.
|
||||
configMapGenerator:
|
||||
- name: co-lite-settings
|
||||
envs: [settings.env]
|
||||
- name: co-lite-gcp
|
||||
envs: [gcp.env]
|
||||
- name: co-lite-whatsapp
|
||||
envs: [whatsapp.env]
|
||||
- name: co-lite-portal
|
||||
envs: [portal.env]
|
||||
# One release is one commit SHA on main; change it with deploy/set-release.sh <sha>, roll back the same way.
|
||||
images:
|
||||
- name: gitea.containerverse.dev/solvway/co-lite-admin-portal
|
||||
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
|
||||
- name: gitea.containerverse.dev/solvway/co-lite-api-gateway
|
||||
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
|
||||
- name: gitea.containerverse.dev/solvway/co-lite-mobile-api
|
||||
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
|
||||
- name: gitea.containerverse.dev/solvway/co-lite-service-auth
|
||||
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
|
||||
- name: gitea.containerverse.dev/solvway/co-lite-service-counter
|
||||
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
|
||||
- name: gitea.containerverse.dev/solvway/co-lite-service-email
|
||||
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
|
||||
- name: gitea.containerverse.dev/solvway/co-lite-service-log
|
||||
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
|
||||
- name: gitea.containerverse.dev/solvway/co-lite-service-member
|
||||
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
|
||||
- name: gitea.containerverse.dev/solvway/co-lite-service-system
|
||||
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
|
||||
- name: gitea.containerverse.dev/solvway/co-lite-service-whatsapp
|
||||
newTag: "a0da31f0da71bb8b4276774c6a79dcdd672cac2b"
|
||||
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: co-lite
|
||||
@@ -0,0 +1 @@
|
||||
MOBILE_API_BASE_URL=http://mobile-api
|
||||
@@ -0,0 +1,31 @@
|
||||
# The only public entry points (openspec spec cluster-deployment; deploy/check_rules.py enforces them):
|
||||
# the admin portal, and exactly mobile-api's WhatsApp webhook path. Never route api-gateway or a service-*.
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
name: admin-portal
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.containerverse.dev`)
|
||||
kind: Rule
|
||||
services:
|
||||
- name: admin-portal
|
||||
port: 3000
|
||||
tls:
|
||||
certResolver: <traefik cert resolver>
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
name: whatsapp-webhook
|
||||
spec:
|
||||
entryPoints: [websecure]
|
||||
routes:
|
||||
- match: Host(`co-lite.containerverse.dev`) && Path(`/api/public/whatsapp/webhook`)
|
||||
kind: Rule
|
||||
services:
|
||||
- name: mobile-api
|
||||
port: 80
|
||||
tls:
|
||||
certResolver: <traefik cert resolver>
|
||||
@@ -0,0 +1,9 @@
|
||||
# Read by every Java service except api-gateway (which takes only JAVA_OPTS from here).
|
||||
MYSQLHOST=<mysql host from the DBA>
|
||||
MYSQLPORT=3306
|
||||
REDISHOST=<host of the existing Redis>
|
||||
APIGATEWAYURL=http://api-gateway
|
||||
ADMIN_PORTAL_BASE_URL=https://co-lite.containerverse.dev
|
||||
JAVA_OPTS=-Xmx384m
|
||||
# mobile-api does not switch its liveness and readiness endpoints on by itself.
|
||||
MANAGEMENT_HEALTH_PROBES_ENABLED=true
|
||||
@@ -0,0 +1,7 @@
|
||||
# WhatsApp stays off until WHATSAPP_COMPANIES is set (docs/deployment.md sections 6 and 11).
|
||||
# To switch it on, uncomment and fill in; the tokens and app secrets go in the co-lite-whatsapp Secret.
|
||||
# WHATSAPP_COMPANIES=INS,CV
|
||||
# WHATSAPP_INS_PHONE_NUMBER_ID=
|
||||
# WHATSAPP_INS_WABA_ID=
|
||||
# WHATSAPP_CV_PHONE_NUMBER_ID=
|
||||
# WHATSAPP_CV_WABA_ID=
|
||||
@@ -0,0 +1,11 @@
|
||||
# Secret templates
|
||||
|
||||
Placeholders only. Copy this folder to `deploy/k8s/secrets/` (git ignores it), fill in every `<…>`, then run
|
||||
`deploy/create-secrets.sh`. Never commit the filled-in copy.
|
||||
|
||||
- `<name>.env` becomes the Secret `<name>`, one key per line.
|
||||
- `<name>/` becomes the Secret `<name>`, one key per file (the file name is the key).
|
||||
- `co-lite-registry.env` becomes the image pull secret for `gitea.containerverse.dev`.
|
||||
- `co-lite-whatsapp.env` is optional: leave it out of `secrets/` while WhatsApp is off.
|
||||
|
||||
Make each random value separately, for example with `openssl rand -base64 48`. What each value is: `docs/deployment.md` sections 6 and 7.
|
||||
@@ -0,0 +1,2 @@
|
||||
MOBILE_API_KEY=<the portal key from AUTH_API_KEYS, without :APP>
|
||||
SESSION_SECRET=<random, at least 32 characters>
|
||||
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"key": "<the APIKEY value given to mobile-api>",
|
||||
"name": "Co-Lite mobile-api",
|
||||
"desc": "mobile-api calls to the gateway",
|
||||
"type": "BO",
|
||||
"allowList": ["/"],
|
||||
"ipList": ["<pod CIDR of the cluster>"]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
<the Pub/Sub service-account JSON key file, docs/deployment.md section 5>
|
||||
@@ -0,0 +1,4 @@
|
||||
# APIKEY: the key in appkeys.json. AUTH_API_KEYS: <key>:APP entries, comma-separated; one is the portal's MOBILE_API_KEY.
|
||||
APIKEY=<random, the same as the key in co-lite-gateway-appkeys/appkeys.json>
|
||||
AUTH_API_KEYS=<portal key>:APP
|
||||
JWT_SECRET=<the same value as JWT_TOKEN>
|
||||
@@ -0,0 +1,3 @@
|
||||
# A read-only package token for gitea.containerverse.dev, so the cluster can pull the images.
|
||||
REGISTRY_USER=<gitea user>
|
||||
REGISTRY_PASSWORD=<read-only package token>
|
||||
@@ -0,0 +1,2 @@
|
||||
AES_SECRET_KEY=<random, exactly 32 characters>
|
||||
USER_AUTH_API_SECRET=<random, at least 32 characters>
|
||||
@@ -0,0 +1,4 @@
|
||||
# Every Java service. JWT_TOKEN: HS512 key, at least 32 characters; mobile-api's JWT_SECRET must be the same value.
|
||||
JWT_TOKEN=<random, at least 32 characters>
|
||||
MYSQLUSER=<database user from the DBA>
|
||||
MYSQLPWD=<its password>
|
||||
@@ -0,0 +1,6 @@
|
||||
# Optional while WhatsApp is off. One ACCESS_TOKEN and APP_SECRET per company code in WHATSAPP_COMPANIES.
|
||||
WHATSAPP_VERIFY_TOKEN=<random, at least 32 characters>
|
||||
WHATSAPP_INS_ACCESS_TOKEN=<permanent system user token>
|
||||
WHATSAPP_INS_APP_SECRET=<meta app secret>
|
||||
WHATSAPP_CV_ACCESS_TOKEN=<permanent system user token>
|
||||
WHATSAPP_CV_APP_SECRET=<meta app secret>
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
# Pins every Co-Lite image in the prod overlay to one commit SHA of main (openspec spec cluster-deployment).
|
||||
# Roll back by running it with the previous SHA and applying again.
|
||||
# deploy/set-release.sh <40-character commit sha>
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
sha=${1:-}
|
||||
printf '%s' "$sha" | grep -Eq '^[0-9a-f]{40}$' || { echo "usage: $0 <40-character commit sha of main>" >&2; exit 2; }
|
||||
k=deploy/k8s/overlays/prod/kustomization.yaml
|
||||
sed -i -E "s/^( newTag: )\"[0-9a-f]+\"$/\1\"$sha\"/" "$k"
|
||||
n=$(grep -c "^ newTag: \"$sha\"$" "$k")
|
||||
[ "$n" -eq 10 ] || { echo "set-release: expected 10 images at $sha, found $n" >&2; exit 1; }
|
||||
echo "prod overlay now pins all 10 images to $sha"
|
||||
+79
-78
@@ -1,6 +1,6 @@
|
||||
# Co-Lite Deployment Handover
|
||||
|
||||
This is for whoever deploys Co-Lite to the Kubernetes cluster. CI builds and publishes the images. The deployer writes the manifests and rolls them out. The database package goes to the DBA.
|
||||
This is for whoever deploys Co-Lite to the Kubernetes cluster. CI builds and publishes the images. The manifests are in `deploy/k8s/` (Kustomize: a `base` and a `prod` overlay); the deployer fills in the cluster facts and Secrets and applies them. The database package goes to the DBA.
|
||||
|
||||
Spec: `openspec/specs/release-packaging/spec.md`. Local stack for comparison: `local/README.md`.
|
||||
|
||||
@@ -26,7 +26,7 @@ The Service names matter:
|
||||
- mobile-api and the portal find the gateway and mobile-api through `APIGATEWAYURL` and `MOBILE_API_BASE_URL`.
|
||||
|
||||
**Health probes:**
|
||||
- **Java services:** liveness `GET /actuator/health/liveness`, readiness `GET /actuator/health/readiness`. Spring Boot turns these on by itself on Kubernetes. `GET /actuator/health` also works everywhere.
|
||||
- **Java services:** liveness `GET /actuator/health/liveness`, readiness `GET /actuator/health/readiness`. mobile-api does not switch these on by itself (measured: 404 without the setting), so the prod settings set `MANAGEMENT_HEALTH_PROBES_ENABLED=true` for every Java pod. Use the liveness path for the startup probe too: `GET /actuator/health` is 503 on service-email while no mail server is set.
|
||||
- **Admin portal:** it has no health endpoint. Use a TCP probe on port 3000, or `GET /login`, which returns 200 without a session.
|
||||
|
||||
**The Java images run as root and listen on port 80** (the base image sets no user). A cluster that enforces `runAsNonRoot` or the restricted Pod Security level must allow them.
|
||||
@@ -35,17 +35,60 @@ The Service names matter:
|
||||
|
||||
## 2. Order of setup
|
||||
|
||||
Everything below runs from the repository root, on `main`, with `kubectl` pointed at the cluster. The checks need only Docker.
|
||||
|
||||
1. The DBA prepares MySQL (section 3).
|
||||
2. Create the Pub/Sub topics and the service-account key (section 5).
|
||||
3. Create the Secrets and mounted files (sections 6 and 7).
|
||||
4. Deploy, in this order:
|
||||
3. **Fill in the cluster facts.** Replace every `<…>` in `deploy/k8s/overlays/prod/`:
|
||||
- `settings.env`: `MYSQLHOST` (from the DBA) and `REDISHOST` (the existing Redis);
|
||||
- `gcp.env`: `GCP_PROJECT`;
|
||||
- `routes.yaml`: the Traefik cert resolver, in both routes.
|
||||
|
||||
The namespace is `co-lite` (`kustomization.yaml` and `namespace.yaml`). Commit these files: they hold no secrets.
|
||||
4. **Create the Secrets.** Copy `deploy/k8s/secrets.example/` to `deploy/k8s/secrets/`. Git ignores that folder, so never commit it. Fill in every `<…>` (sections 6 and 7 say what each value is). Then:
|
||||
```sh
|
||||
deploy/create-secrets.sh --dry-run # checks every key is filled in; prints names, never values
|
||||
deploy/create-secrets.sh # creates or updates the Secrets in the co-lite namespace
|
||||
```
|
||||
The script creates the `co-lite` namespace if it is missing. Leave `co-lite-whatsapp.env` out until WhatsApp is connected (step 9).
|
||||
5. **Pick the release.** Choose a commit on `main` whose CI run pushed the images, and pin it:
|
||||
```sh
|
||||
deploy/set-release.sh <40-character commit sha>
|
||||
deploy/check.sh --release # refuses any <…> left, a public route to an internal service, latest, or a second service-counter
|
||||
```
|
||||
6. **Apply:**
|
||||
```sh
|
||||
kubectl apply -k deploy/k8s/overlays/prod
|
||||
kubectl -n co-lite rollout status deploy --timeout=10m
|
||||
```
|
||||
All ten Deployments start together; each Java pod gets up to 5 minutes to start. Starting them together has not been tried on the cluster yet. If a pod keeps restarting, apply in the old order instead and wait for each step to be ready:
|
||||
1. `service-system`, `service-auth`, `service-counter`, `service-member`, `service-log`, `service-email`, `service-whatsapp`;
|
||||
2. `api-gateway`;
|
||||
3. `mobile-api`;
|
||||
4. `admin-portal`.
|
||||
5. Add the Traefik routes (section 8).
|
||||
6. Connect WhatsApp in Meta (section 11). This can wait: until it is done, the inbox says "WhatsApp is not configured".
|
||||
7. Sign in as the first admin at `https://co-lite.containerverse.dev` and set the real password. Then create the staff users under Users. The admin types each user's first password and passes it on in person. Each user must choose their own password at first sign-in. No email is needed.
|
||||
|
||||
Use `kubectl -n co-lite rollout restart deploy/<name>` once the services it calls are ready.
|
||||
7. Commit the overlay with the new SHA, so `main` records what runs.
|
||||
8. Check the Custom HTML frame header (section 8).
|
||||
9. Connect WhatsApp in Meta (section 11) whenever you are ready. Until then the inbox says "WhatsApp is not configured". To switch it on: fill in `whatsapp.env` in the overlay and `co-lite-whatsapp.env` in `secrets/`, then run `create-secrets.sh` and apply again.
|
||||
10. Sign in as the first admin at `https://co-lite.containerverse.dev` and set the real password. Then create the staff users under Users. The admin types each user's first password and passes it on in person. Each user must choose their own password at first sign-in. No email is needed.
|
||||
|
||||
**Rollback.** Run `deploy/set-release.sh <the previous sha>`, then `deploy/check.sh --release`, then apply again and wait for the rollout. The SHA history of `deploy/k8s/overlays/prod/kustomization.yaml` on `main` lists the releases. Database changes only go forward: roll back only to a SHA that works with the schema now in place. Each change's SQL in section 3 says whether older code still runs on it.
|
||||
|
||||
**Changing a setting.** Edit the `.env` file in the overlay and apply again. The settings ConfigMaps get a new name for each new content, so the pods that read them restart by themselves. **Changing a secret:** edit `deploy/k8s/secrets/`, run `create-secrets.sh`, then `kubectl -n co-lite rollout restart deploy/<name>` for the pods that read it. mobile-api needs no restart for the WhatsApp secrets (section 6).
|
||||
|
||||
**Left unset on purpose.** These settings keep their built-in defaults:
|
||||
- the email provider keys (section 10);
|
||||
- `SMSS360_EMAIL` and `CUSTOMER_PORTAL_BASE_URL`, which still point at Tastefully (section 10);
|
||||
- `JUMIO_TOKEN` and `JUMIO_SECRET`;
|
||||
- `XXL_JOB_TOKEN`.
|
||||
|
||||
**Cluster facts still to confirm before the first apply:**
|
||||
- the Traefik cert resolver name;
|
||||
- the Redis host and the MySQL host;
|
||||
- the Pub/Sub project;
|
||||
- whether the pull secret can be `co-lite-registry`, or the cluster already has one;
|
||||
- whether the separate public-pages hostname (section 8) is wanted at go-live (it would be a third route in `routes.yaml`).
|
||||
|
||||
## 3. Database (for the DBA)
|
||||
|
||||
@@ -309,6 +352,8 @@ Generate each random value separately, for example with `openssl rand -base64 48
|
||||
|
||||
## 8. Traefik
|
||||
|
||||
The routes below are in `deploy/k8s/overlays/prod/routes.yaml`; `deploy/check.sh` fails if a route reaches anything else.
|
||||
|
||||
Route `co-lite.containerverse.dev` to the `admin-portal` Service on port 3000, with TLS. Only the admin portal is public: the browser talks to the portal, and the portal talks to `mobile-api` inside the cluster. Do not expose `mobile-api`, `api-gateway` or the services.
|
||||
|
||||
**WhatsApp webhook.** Meta must reach exactly one mobile-api path from the internet. Add a second route on the same host, for the path `/api/public/whatsapp/webhook` only (Traefik rule `Host(\`co-lite.containerverse.dev\`) && Path(\`/api/public/whatsapp/webhook\`)`), to the `mobile-api` Service on port 80. Expose no other mobile-api path. Every call on it is checked: a GET needs the verify token, and a POST needs Meta's signature under one of the configured app secrets (mobile-api checks it, and `service-whatsapp` checks it again).
|
||||
@@ -323,76 +368,20 @@ QR registration pages (`/r/<code>`) are served by the admin portal on the same h
|
||||
|
||||
## 9. Secret templates
|
||||
|
||||
There is no template yet for `service-email` (its keys wait for the email provider) or `service-system` (its Jumio keys stay unset). Kubernetes Secrets hold base64 values. Encode each one with `printf '%s' 'value' | base64 -w0`. These are templates: replace every `<…>` and never commit the filled-in files.
|
||||
The templates are in `deploy/k8s/secrets.example/`, one file per Secret, with placeholders only:
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: co-lite-shared
|
||||
type: Opaque
|
||||
data:
|
||||
JWT_TOKEN: <base64>
|
||||
MYSQLUSER: <base64>
|
||||
MYSQLPWD: <base64>
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: co-lite-service-auth
|
||||
type: Opaque
|
||||
data:
|
||||
AES_SECRET_KEY: <base64>
|
||||
USER_AUTH_API_SECRET: <base64>
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: co-lite-mobile-api
|
||||
type: Opaque
|
||||
data:
|
||||
APIKEY: <base64>
|
||||
AUTH_API_KEYS: <base64>
|
||||
JWT_SECRET: <base64, same value as JWT_TOKEN>
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: co-lite-admin-portal
|
||||
type: Opaque
|
||||
data:
|
||||
MOBILE_API_KEY: <base64>
|
||||
SESSION_SECRET: <base64>
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: co-lite-whatsapp
|
||||
type: Opaque
|
||||
data:
|
||||
# mounted into both mobile-api and service-whatsapp; one ACCESS_TOKEN and APP_SECRET pair per company code
|
||||
WHATSAPP_INS_ACCESS_TOKEN: <base64>
|
||||
WHATSAPP_INS_APP_SECRET: <base64>
|
||||
WHATSAPP_CV_ACCESS_TOKEN: <base64>
|
||||
WHATSAPP_CV_APP_SECRET: <base64>
|
||||
WHATSAPP_VERIFY_TOKEN: <base64>
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: co-lite-gateway-appkeys
|
||||
type: Opaque
|
||||
data:
|
||||
appkeys.json: <base64 of the whole appkeys.json file>
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: co-lite-gcp-key
|
||||
type: Opaque
|
||||
data:
|
||||
key.json: <base64 of the service-account JSON key>
|
||||
```
|
||||
| Template | Secret | Read by |
|
||||
|---|---|---|
|
||||
| `co-lite-shared.env` | `co-lite-shared`: `JWT_TOKEN`, `MYSQLUSER`, `MYSQLPWD` | every Java service (api-gateway only `JWT_TOKEN`) |
|
||||
| `co-lite-service-auth.env` | `co-lite-service-auth` | service-auth |
|
||||
| `co-lite-mobile-api.env` | `co-lite-mobile-api` | mobile-api |
|
||||
| `co-lite-admin-portal.env` | `co-lite-admin-portal` | admin-portal |
|
||||
| `co-lite-whatsapp.env` | `co-lite-whatsapp` (optional) | mobile-api and service-whatsapp |
|
||||
| `co-lite-registry.env` | `co-lite-registry`, the image pull secret | every pod |
|
||||
| `co-lite-gateway-appkeys/appkeys.json` | `co-lite-gateway-appkeys` | api-gateway (section 7) |
|
||||
| `co-lite-gcp-key/key.json` | `co-lite-gcp-key` | every Java service except api-gateway and service-whatsapp |
|
||||
|
||||
`deploy/create-secrets.sh` turns the filled-in copy into Secrets (section 2, step 4). It refuses to change anything while any key is missing, empty or still a placeholder. There is still no template for `service-email` (its keys wait for the email provider) or `service-system` (its Jumio keys stay unset).
|
||||
|
||||
## 10. Known gaps at go-live
|
||||
|
||||
@@ -409,7 +398,7 @@ data:
|
||||
- **Reference data from Tastefully.** It still holds some Tastefully business text (message templates with a phone number, bank account and form links; a public image bucket URL; Tastefully usernames in audit columns). Review it before go-live.
|
||||
- **Other Tastefully defaults.** The sender addresses in `service-email` and the `CUSTOMER_PORTAL_BASE_URL` fallback point at Tastefully. Override them as described in section 6.
|
||||
- **Leaked SMS key.** An SMS360 API key from Tastefully was in `service-email`'s config and is in git history. It has been removed from the config, but it must be rotated with SMS360 before go-live, by whoever owns that Tastefully account.
|
||||
- **Deploy by SHA, not `latest`.** CI pushes the images one by one, so if a push fails halfway, `latest` can differ between images.
|
||||
- **Deploy by SHA, not `latest`.** CI pushes the images one by one, so if a push fails halfway, `latest` can differ between images. `deploy/check.sh` refuses `latest`.
|
||||
- **Chinese labels.** Staff switch the back office to 简体中文 with the language switcher, including on the sign-in page. The Chinese is a first pass, not checked by a native speaker. Grant `BO_MESSAGES` to the reviewer's role: under **Translations**, the **Missing Chinese** filter lists labels with no Chinese or with English copied in, and a saved change shows on the next page load. The list also holds about 3,400 labels inherited from Tastefully that Co-Lite never shows; the **Co-Lite labels only** box, ticked by default, hides them, and unticking it lists every label. Export and Import move all labels through a JSON file for review offline; import matches labels by code and never adds or removes languages. Grant `BO_LOCALES` only to whoever decides which languages staff can pick: English cannot be switched off. Only the back office is translated; visitor pages and emails keep their own wording.
|
||||
- **Gateway paths for labels.** The gateway used to let every `/message/` path through without a user token. It now lets through only the label reads (`/message/catalogVersion`, `/message/getAllMessages/<area>`, `/message/getMessageJsonByAreaAndLocale/<area>/<locale>`, `/message/getMessageJsonForMobile/...`, the code lookups) and `GET /locale/findAllEnabled`. Saving, searching and the language writes need the user token mobile-api forwards. The gateway also gains a `/locale/**` route to services-system.
|
||||
- **WhatsApp roles.** Staff need `BO_WHATSAPP` to see the inbox and their own chats. A WhatsApp admin needs both `BO_WHATSAPP` and `BO_WHATSAPP_ADMIN`: the menu entry and the page need the first, and the second adds every chat of the company, owner changes and template sync. A chat's owner is set automatically to the salesperson of the newest lead with that mobile number; an admin can set an owner by hand, which sticks until "Automatic" is chosen again. A user who is disabled or loses `BO_WHATSAPP` loses their chats to Unassigned.
|
||||
@@ -422,7 +411,7 @@ data:
|
||||
- A send that Meta accepts without a message id is stored as failed. A send that never gets an answer stays "Sending"; nothing sweeps it.
|
||||
- Media is streamed with `;charset=UTF-8` added to its content type; browsers ignore it.
|
||||
- Meta's media download address is not checked to be a Meta host before the access token is sent with it.
|
||||
- **WhatsApp webhook and outages.** If `service-whatsapp` is down or answers with an error, the webhook answers 503 and Meta sends the event again, for up to 7 days; a message is never stored twice. The same happens right after `service-whatsapp` starts while `service-system` is unreachable. Keep `service-system` up before `service-whatsapp` (section 2).
|
||||
- **WhatsApp webhook and outages.** If `service-whatsapp` is down or answers with an error, the webhook answers 503 and Meta sends the event again, for up to 7 days; a message is never stored twice. The same happens right after `service-whatsapp` starts while `service-system` is unreachable. So on the first apply, check that `service-system` is ready before Meta starts sending (section 2, step 6).
|
||||
- **Client addresses for rate limits.** mobile-api takes a caller's address for its rate limits from the first entry of `X-Forwarded-For` when the header is present (`HttpReqRespUtils` in core-libs). On the webhook route, a caller can set that header itself and so pick its own limit bucket. The webhook still rejects anything Meta did not sign, so this only weakens the flood limit (6000 calls per 10 minutes per address). Check that Traefik replaces an `X-Forwarded-For` sent by an untrusted caller instead of passing it on (`forwardedHeaders.insecure` off, `trustedIPs` limited to real proxies).
|
||||
|
||||
- **Landing pages.**
|
||||
@@ -475,4 +464,16 @@ A form stops taking sign-ups when its event is disabled, its end date has passed
|
||||
|
||||
**Release add-page-visual-editor (SQL, in its OpenSpec change folder):** portal only. Deploy the portal, then run `sql/01-visual-editor-labels.sql`. Rollback: the previous portal image, then `sql/99-rollback.sql` (labels only). No data changes.
|
||||
|
||||
**Release add-hero-signup-form (SQL, in its OpenSpec change folder):** deploy services-counter, mobile-api and the portal (any order), then run `sql/01-hero-form-labels.sql` (labels only). A hero section can now carry the sign-up form for an event, beside its text. Rollback: the previous images. A hero saved with an event keeps it in its JSON. The old code ignores it and shows the hero without a form, so add a Sign-up form section to those pages if you roll back.
|
||||
|
||||
**Release add-hero-full-width (SQL, in its OpenSpec change folder):** deploy services-counter, then the portal, then run `sql/01-hero-full-width-labels.sql` (labels only). Deploy services-counter first, because the portal's editor saves the new hero fields. A hero can now run full width, carry bullet points, and give its form card a heading. Custom HTML frames now shrink to fit short content and no longer leave a gap next to a full-width hero. Rollback: the previous images. Saved heroes keep the new fields in their JSON; the old code ignores them and shows the boxed hero. The old services-counter refuses to save a hero that has points or a form heading, so remove them before saving such a page.
|
||||
|
||||
**Release add-html-image-upload (SQL, in its OpenSpec change folder):** deploy the portal, then run `sql/01-html-image-labels.sql` (labels only). A Custom HTML block's panel can now upload an image and show its link to copy. Rollback: the previous portal image.
|
||||
|
||||
**Release add-compact-landing-form (SQL, in its OpenSpec change folder):** deploy the portal, then run `sql/01-compact-form-labels.sql` (labels only). Landing-page sign-up forms drop job title, ask for one service in a dropdown, and fold the privacy notice behind one line. Coloured sections now join with no gap. QR, invitation and customer forms are unchanged. Before go-live, the PDPA owner should confirm the folded notice. Rollback: the previous portal image.
|
||||
|
||||
**Release add-landing-thanks-and-footer (SQL, in its OpenSpec change folder):** deploy services-counter and the portal together, then run `sql/01-thanks-footer-labels.sql` (labels only). Landing pages gain a Footer section (1 to 4 columns, a legal line, contact links) and a thank-you text on the Form block and on a hero with a form. Full-width heroes get a lighter shade. Deploy the counter first: an older counter refuses pages that use the new fields. Rollback: the previous images; pages saved with a Footer or thank-you text then fail to save until the release is back.
|
||||
|
||||
**Release add-landing-page-polish (SQL, in its OpenSpec change folder):** deploy services-counter first, then the portal, then run `sql/01-polish-labels.sql` (labels only). Landing pages gain a Top bar section (the company logo and an optional button, kept at the top of the window, first section only) and an optional small label above the headings of Feature cards, Steps, Image with text, FAQ and Call to action. Section headings on every landing page, CV included, now use the serif typeface. Rollback: the previous images; pages saved with a top bar or labels then fail to save until the release is back.
|
||||
|
||||
**New portal dependencies:** `@tiptap/react`, `@tiptap/pm`, `@tiptap/starter-kit` and `@tiptap/extension-text-align` (the editor, loaded only on the editor screens), and `sanitize-html` (cleans page text on the server before it reaches a visitor). The image build installs them from `package-lock.json`; nothing to do by hand.
|
||||
@@ -1117,6 +1117,12 @@ INSERT INTO message (code, content, area) SELECT 'RegCompany', JSON_OBJECT('en_U
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '公司') WHERE LOWER(code) = LOWER('RegCompany') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'RegJobTitle', JSON_OBJECT('en_US', 'Job title', 'zh_CN', '职位'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegJobTitle') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '职位') WHERE LOWER(code) = LOWER('RegJobTitle') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'RegServiceInterest', JSON_OBJECT('en_US', 'Service interested in (optional)', 'zh_CN', '感兴趣的服务(可选)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegServiceInterest') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '感兴趣的服务(可选)') WHERE LOWER(code) = LOWER('RegServiceInterest') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'RegChooseService', JSON_OBJECT('en_US', 'Choose a service', 'zh_CN', '选择服务'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegChooseService') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '选择服务') WHERE LOWER(code) = LOWER('RegChooseService') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'RegNoticeSummary', JSON_OBJECT('en_US', 'How we use your details (English / Bahasa Malaysia)', 'zh_CN', '我们如何使用您的资料(English / Bahasa Malaysia)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegNoticeSummary') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '我们如何使用您的资料(English / Bahasa Malaysia)') WHERE LOWER(code) = LOWER('RegNoticeSummary') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'RegInterests', JSON_OBJECT('en_US', 'Interests (optional)', 'zh_CN', '兴趣(可选)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegInterests') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '兴趣(可选)') WHERE LOWER(code) = LOWER('RegInterests') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'RegNoticeEn', JSON_OBJECT('en_US', 'English', 'zh_CN', '英文'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegNoticeEn') AND area = 'A');
|
||||
@@ -1713,6 +1719,40 @@ INSERT INTO message (code, content, area) SELECT 'PagesFormClosed', JSON_OBJECT(
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '报名已截止。') WHERE LOWER(code) = LOWER('PagesFormClosed') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesFormPreview', JSON_OBJECT('en_US', 'The sign-up form shows here on the published page.', 'zh_CN', '发布后的网页会在此显示报名表。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormPreview') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '发布后的网页会在此显示报名表。') WHERE LOWER(code) = LOWER('PagesFormPreview') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesHeroForm', JSON_OBJECT('en_US', 'Sign-up form', 'zh_CN', '报名表单'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesHeroForm') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '报名表单') WHERE LOWER(code) = LOWER('PagesHeroForm') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesNoForm', JSON_OBJECT('en_US', 'No form', 'zh_CN', '不显示表单'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesNoForm') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '不显示表单') WHERE LOWER(code) = LOWER('PagesNoForm') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesFullWidth', JSON_OBJECT('en_US', 'Full width', 'zh_CN', '全宽'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFullWidth') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '全宽') WHERE LOWER(code) = LOWER('PagesFullWidth') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesPointN', JSON_OBJECT('en_US', 'Point {number}', 'zh_CN', '要点 {number}'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesPointN') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '要点 {number}') WHERE LOWER(code) = LOWER('PagesPointN') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesAddPoint', JSON_OBJECT('en_US', 'Add point', 'zh_CN', '添加要点'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesAddPoint') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '添加要点') WHERE LOWER(code) = LOWER('PagesAddPoint') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesFormHeading', JSON_OBJECT('en_US', 'Form heading', 'zh_CN', '表单标题'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormHeading') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单标题') WHERE LOWER(code) = LOWER('PagesFormHeading') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesFormText', JSON_OBJECT('en_US', 'Form text', 'zh_CN', '表单说明'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单说明') WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesThanksText', JSON_OBJECT('en_US', 'Thank-you text', 'zh_CN', '感谢语'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesThanksText') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '感谢语') WHERE LOWER(code) = LOWER('PagesThanksText') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesBlockFooter', JSON_OBJECT('en_US', 'Footer', 'zh_CN', '页脚'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesBlockFooter') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '页脚') WHERE LOWER(code) = LOWER('PagesBlockFooter') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesColumnN', JSON_OBJECT('en_US', 'Column {number}', 'zh_CN', '第 {number} 栏'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesColumnN') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '第 {number} 栏') WHERE LOWER(code) = LOWER('PagesColumnN') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesAddColumn', JSON_OBJECT('en_US', 'Add column', 'zh_CN', '添加栏'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesAddColumn') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '添加栏') WHERE LOWER(code) = LOWER('PagesAddColumn') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesFooterLegal', JSON_OBJECT('en_US', 'Legal line', 'zh_CN', '版权声明'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFooterLegal') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '版权声明') WHERE LOWER(code) = LOWER('PagesFooterLegal') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesBlockTopBar', JSON_OBJECT('en_US', 'Top bar', 'zh_CN', '顶栏'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesBlockTopBar') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '顶栏') WHERE LOWER(code) = LOWER('PagesBlockTopBar') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesEyebrow', JSON_OBJECT('en_US', 'Label', 'zh_CN', '小标签'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesEyebrow') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '小标签') WHERE LOWER(code) = LOWER('PagesEyebrow') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesTopBarFirst', JSON_OBJECT('en_US', 'The top bar must be the first section.', 'zh_CN', '顶栏必须是第一个区块。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesTopBarFirst') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '顶栏必须是第一个区块。') WHERE LOWER(code) = LOWER('PagesTopBarFirst') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesUploadImage', JSON_OBJECT('en_US', 'Upload image', 'zh_CN', '上传图片'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '上传图片') WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesUploadImageHint', JSON_OBJECT('en_US', 'PNG, JPEG or WebP up to 2 MB. Paste the link into your HTML, for example in an img tag''s src.', 'zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。') WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesToolbar', JSON_OBJECT('en_US', 'Formatting', 'zh_CN', '格式'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesToolbar') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '格式') WHERE LOWER(code) = LOWER('PagesToolbar') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesTextStyle', JSON_OBJECT('en_US', 'Text style', 'zh_CN', '文字样式'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesTextStyle') AND area = 'A');
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-12-04
|
||||
@@ -0,0 +1,24 @@
|
||||
# Design
|
||||
|
||||
## Context
|
||||
|
||||
The company header and the page title are drawn by `LandingPage`, and "hide page header" (`hideHeader`) removes both. Page settings are database columns threaded through services-counter, mobile-api and the portal. Blocks are JSON validated by `CmsBlockValidator`, so a new block or block field needs no schema change.
|
||||
|
||||
## Approaches
|
||||
|
||||
1. **A Top bar block, used with "hide page header" (chosen).** It is JSON only: no migration, and no changes to the page records in three services. The INS page already uses "hide page header" with a Custom HTML top bar, so this is a native swap for the same layout.
|
||||
2. **New page settings** ("hide title", header button label and link, heading font). This is the natural model, but it means four new columns and changes to every page DTO, the draft record, the admin and public APIs, and the settings panel. That is about ten times the work for the same result.
|
||||
3. **Keep the top bar in Custom HTML.** This is what the original page does; the native page exists to avoid it.
|
||||
|
||||
## Decisions
|
||||
|
||||
- **The top bar is the first block only.** The server refuses it anywhere else (`PagesTopBarFirst`), because a sticky bar in the middle of a page would cover the content as the visitor scrolls past it. The bar is `sticky top-0` with a card background and a bottom border. It runs full width (it counts as bleed), so it joins a full-width hero below it with no gap.
|
||||
- **Top bar fields.** Only `buttonLabel` and `buttonUrl` (the pair rule, at most 40 characters, a safe link) plus the usual `anchor`. A heading, text, image, cards or look are refused (`PagesUnusedField`). The logo comes from the company's branding, as the default header's does.
|
||||
- **The label (`eyebrow`).** At most 40 characters, allowed on FEATURES, STEPS, IMAGE_TEXT, FAQ and CTA, and refused on other types. It renders as a `p` above the h2, not as part of the heading, so screen readers read the heading on its own. It can be edited in place on the canvas.
|
||||
- **Label colour.** On the DARK band it uses `text-primary`, the accent colour. On light backgrounds the accent can be too pale (INS gold on white is about 2:1), so it uses the accent mixed with the foreground colour, `color-mix(in srgb, var(--primary) 60%, var(--foreground))`. On the ACCENT band it uses the band's own text colour.
|
||||
- **Serif headings.** Section h2s get `font-serif`, Tailwind's system serif, as the full-width hero does. No web font is added. This changes every landing page, CV's included. It is a small change, and it matches the hero.
|
||||
|
||||
## Risks
|
||||
|
||||
- **CV pages change font.** CV's section headings become serif. If CV wants sans-serif, a later change can make the font a company setting.
|
||||
- **Sticky bar and same-page links.** A `#name` jump lands with the heading under the bar. `scroll-margin-top` on the named blocks keeps them clear when a top bar exists.
|
||||
@@ -0,0 +1,42 @@
|
||||
# Proposal
|
||||
|
||||
## Why
|
||||
|
||||
The native INS page (`/p/INS/hotel-technology-native`) now matches INS's standalone page in content, but it still looks different at the top and in its section headings:
|
||||
|
||||
- INS has a white top bar with the logo on the left and a "Get My Free Consultation" button on the right. The bar stays at the top while the visitor scrolls. Our page has two choices: show the company header and the page title, which INS does not have, or hide both, which also hides the logo.
|
||||
- INS puts a small gold uppercase label above each section heading ("Services", "How we work", "Why Infinity", "FAQ"). We have no such label.
|
||||
- INS's section headings are serif. Ours are sans-serif, except for the full-width hero.
|
||||
|
||||
## What Changes
|
||||
|
||||
- **Top bar block** (`TOPBAR`). It shows the company logo on the left (the company name when there is no logo) and an optional button on the right (`buttonLabel` and `buttonUrl`, with the same link rules as other buttons). It stays at the top of the window while the page scrolls. It may only be the first block. Together with "hide page header", it gives INS's layout: the logo and button stay, and the title and the default header go.
|
||||
- **Section labels** (`eyebrow`, at most 40 characters). Feature cards, Steps, Image with text, FAQ and Call to action may carry a short label. It shows above the heading in small uppercase letters in the accent colour, darkened on light backgrounds so it stays readable.
|
||||
- **Serif section headings.** Section headings (h2) on landing pages use the same serif as the full-width hero.
|
||||
- New editor labels in English and Chinese, with an SQL label file.
|
||||
|
||||
Not changing:
|
||||
- The page settings and the database. "Hide page header" already exists, and the new fields live in the block JSON.
|
||||
- Card and step layout, and the bullet style in rich text.
|
||||
- The default company header on pages without a top bar.
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
None.
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
- `landing-pages`: adds "Top Bar Block", "Section Labels" and "Serif Section Headings".
|
||||
|
||||
## Impact
|
||||
|
||||
- services-counter: `CmsBlock` gains `eyebrow`. `CmsBlockValidator` validates TOPBAR and `eyebrow`.
|
||||
- mobile-api: none. Public blocks pass through as maps.
|
||||
- Portal:
|
||||
- `cmsPages.ts`: the TOPBAR type, its label and empty block, and `eyebrow`;
|
||||
- `CmsBlocks.tsx`: renders the top bar, the labels and the serif headings;
|
||||
- `BlockFields.tsx`: the top bar's button and the label field;
|
||||
- labels in `defaultMessages.ts` and `zh_CN.seed.json`.
|
||||
- Data: no schema change. The new labels need a SQL label file in this change folder.
|
||||
@@ -0,0 +1,42 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Top Bar Block
|
||||
|
||||
A page's first block MAY be a top bar. The top bar SHALL show the company logo, or the company name when there is no logo, and an optional button, and SHALL stay at the top of the window while the page scrolls. The server SHALL refuse a top bar that is not the first block, or one that carries fields other than its button and link name.
|
||||
|
||||
#### Scenario: Logo and button without the page title
|
||||
|
||||
- **GIVEN** page `/p/INS/hotel-technology-native` with "hide page header" on, a top bar with the button "Get My Free Consultation" linking to `#consult`, and a full-width hero
|
||||
- **WHEN** a visitor opens the page and scrolls down
|
||||
- **THEN** the INS logo and the button stay at the top of the window
|
||||
- **AND** no page title heading shows, and the hero starts directly under the bar
|
||||
|
||||
#### Scenario: Top bar further down is refused
|
||||
|
||||
- **WHEN** staff save a page whose top bar is the second block
|
||||
- **THEN** the save is refused with the reason naming that block
|
||||
|
||||
### Requirement: Section Labels
|
||||
|
||||
Feature cards, Steps, Image with text, FAQ and Call to action blocks MAY carry a label of at most 40 characters. The page SHALL show the label above the block's heading, in small uppercase letters in the accent colour. The server SHALL refuse a longer label, or a label on any other block type.
|
||||
|
||||
#### Scenario: Label above a heading
|
||||
|
||||
- **GIVEN** a Feature cards block with the label "Services" and the heading "Everything your guests touch, handled by one team"
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** "Services" shows in small uppercase letters directly above the heading
|
||||
|
||||
#### Scenario: Type a label in the editor
|
||||
|
||||
- **GIVEN** staff editing a Steps block
|
||||
- **WHEN** they type "How we work" in its label field and save
|
||||
- **THEN** the page keeps the label
|
||||
|
||||
### Requirement: Serif Section Headings
|
||||
|
||||
Section headings on landing pages SHALL use the serif typeface that the full-width hero uses.
|
||||
|
||||
#### Scenario: Feature heading in serif
|
||||
|
||||
- **WHEN** a visitor opens a page with a Feature cards block
|
||||
- **THEN** its heading uses the serif typeface
|
||||
@@ -0,0 +1,9 @@
|
||||
-- The labels added by add-landing-page-polish, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
|
||||
SET NAMES utf8mb4;
|
||||
USE `service-system`;
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesBlockTopBar', JSON_OBJECT('en_US', 'Top bar', 'zh_CN', '顶栏'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesBlockTopBar') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '顶栏') WHERE LOWER(code) = LOWER('PagesBlockTopBar') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesEyebrow', JSON_OBJECT('en_US', 'Label', 'zh_CN', '小标签'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesEyebrow') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '小标签') WHERE LOWER(code) = LOWER('PagesEyebrow') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesTopBarFirst', JSON_OBJECT('en_US', 'The top bar must be the first section.', 'zh_CN', '顶栏必须是第一个区块。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesTopBarFirst') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '顶栏必须是第一个区块。') WHERE LOWER(code) = LOWER('PagesTopBarFirst') AND area = 'A';
|
||||
@@ -0,0 +1,55 @@
|
||||
# Tasks
|
||||
|
||||
## 1. Server
|
||||
|
||||
- [x] 1.1 services-counter `CmsBlock`: add `eyebrow`. `CmsBlockValidator`:
|
||||
- TOPBAR is allowed only at index 0 (`PagesTopBarFirst`); it takes the button pair and `anchor` only, and any other field is refused (`PagesUnusedField`);
|
||||
- `eyebrow` at most 40 characters on FEATURES, STEPS, IMAGE_TEXT, FAQ and CTA, and refused elsewhere (`PagesUnusedField`).
|
||||
|
||||
Verify: new validator tests fail first, then pass; `mvn -T 1C -pl solvway-services-counter verify`.
|
||||
|
||||
## 2. Portal
|
||||
|
||||
- [x] 2.1 `CmsBlocks.tsx`:
|
||||
- renders TOPBAR (logo or name, optional button, sticky, full width, joins a full-width hero);
|
||||
- renders the label above section headings, in the accent colour, darkened on light backgrounds;
|
||||
- renders section h2s in serif;
|
||||
- named blocks keep clear of a sticky bar when jumped to.
|
||||
|
||||
Verify: render tests fail first, then pass; vitest exit 0.
|
||||
- [x] 2.2 Editor:
|
||||
- `cmsPages.ts`: TOPBAR type, label and empty block; `eyebrow`;
|
||||
- `BlockFields.tsx`: the top bar's button fields, and the label field on the five types; the label is editable in place on the canvas;
|
||||
- labels in `defaultMessages.ts`, `zh_CN.seed.json` and `sql/01-polish-labels.sql`; regenerate `local/seed/04-zh-cn-messages.sql`.
|
||||
|
||||
Verify: editor tests fail first, then pass; tsc and lint clean.
|
||||
|
||||
## 3. Verification
|
||||
|
||||
- [x] 3.1 Rebuild services-counter. Use Playwright on port 3001 to edit `/p/INS/hotel-technology-native` through the editor:
|
||||
- turn on "hide page header";
|
||||
- add a top bar first, with "Get My Free Consultation" linking to `#consult`;
|
||||
- add the labels "Services", "How we work", "Why Infinity" and "FAQ";
|
||||
- publish.
|
||||
|
||||
Check the published page at 1280 px and 390 px against the INS page, including the bar staying put on scroll.
|
||||
- [x] 3.2 Run the full portal vitest (exit 0), tsc, lint, Maven verify for services-counter, and `openspec validate add-landing-page-polish --strict`.
|
||||
- [x] 3.3 Add a release note to `docs/deployment.md` (label SQL).
|
||||
|
||||
## Notes (2026-12-04)
|
||||
|
||||
- **Red first:**
|
||||
- the validator tests failed on the top bar and the labels;
|
||||
- the render tests failed on the top bar, the scroll margin, the labels and the serif headings;
|
||||
- the editor test failed on the label field and the top bar.
|
||||
- **Changed existing tests:** none. One of my own new render tests changed before going green: the sticky class sits on the top bar's row, not on the header. A sticky element only sticks inside its parent, and the header's parent is just as tall as the header.
|
||||
- **Live check** (port 3001, rebuilt counter), on `/p/INS/hotel-technology-native` through the editor:
|
||||
- "hide page header" was already on;
|
||||
- added a Top bar section, moved it first, and set "Get My Free Consultation" linking to `#consult`;
|
||||
- typed the labels "Services", "How we work", "Why Infinity" and "FAQ" on the canvas;
|
||||
- saved and published.
|
||||
- **Published result:**
|
||||
- at 1280 px the logo and button sit in a white bar above the full-width hero, with no title, and the bar stays at the top while scrolling;
|
||||
- the labels show in darkened gold uppercase above serif headings;
|
||||
- at 390 px the bar keeps the logo and button, and the hero stacks.
|
||||
- **Not reachable in the UI, covered by the validator tests:** a top bar that is not first is refused (the server rule; the editor's Move up and Move down allow it, and the refusal shows on the canvas).
|
||||
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-12-03
|
||||
@@ -0,0 +1,43 @@
|
||||
# Proposal
|
||||
|
||||
## Why
|
||||
|
||||
Event pages convert best when the sign-up form is visible as soon as the page opens. INS's standalone landing page (`~/Projects/ins-landing-page`) puts the form in a card beside the hero text. In Co-Lite the form is always its own section, so on a page built from Custom HTML it lands below the hero, and the hero tells visitors to "scroll down to the form". Custom HTML cannot hold the real form: it runs in a sealed frame that cannot send leads into Co-Lite.
|
||||
|
||||
## What Changes
|
||||
|
||||
- A HERO block gains an optional event (`eventUuid`). When it is set, the hero shows Co-Lite's sign-up form for that event in a card beside the heading, text and button on wide screens, and below them on phones.
|
||||
- The hero form behaves exactly like the FORM block:
|
||||
- the same fields, interests and privacy notice;
|
||||
- the same submit rules and limits;
|
||||
- the same lead source, UTM values and closing rules.
|
||||
- The server checks a hero's event like a FORM block's: it must be an event of the page's company.
|
||||
- In the editor, the Hero's settings gain the same event picker as the Sign-up form, with "No form" as the default. The canvas shows the form card in place.
|
||||
- Switching company in the editor clears a hero's event, as it already clears a FORM block's.
|
||||
|
||||
Not changing:
|
||||
- The FORM block stays as it is.
|
||||
- A page may have a hero form and a FORM block together, and each registers for its own event.
|
||||
- The form card has no heading of its own; the hero's heading and text introduce it.
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
None.
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
- `landing-pages`: hero blocks may carry the sign-up form, and the event-reference rule covers them.
|
||||
|
||||
## Impact
|
||||
|
||||
- **services-counter:** `CmsBlockValidator`, which now checks a HERO's optional `eventUuid`.
|
||||
- **mobile-api:** `PublicPageService`, which attaches form info to, and accepts submits for, any block with an event (FORM or a HERO that has one).
|
||||
- **admin-portal:**
|
||||
- the `HERO` rendering in `CmsBlocks.tsx`;
|
||||
- the Hero fields in `BlockFields.tsx`;
|
||||
- the company-switch reset in `usePageDraft.ts`;
|
||||
- two labels, in English and Chinese.
|
||||
- **No schema change:** blocks are JSON.
|
||||
- **No new dependency.**
|
||||
@@ -0,0 +1,48 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Hero With A Sign-Up Form
|
||||
|
||||
A HERO block MAY name an event. When it does, the hero SHALL show Co-Lite's sign-up form for that event in a card beside its heading, text and button on wide screens, and below them on narrow screens. The hero's form SHALL follow every rule of the FORM block (see "The Form Block Registers For An Event" and "The Form Block Closes With Its Event"). A HERO block without an event SHALL show no form.
|
||||
|
||||
#### Scenario: Sign up from the hero
|
||||
|
||||
- **GIVEN** page `/p/INS/hotel-technology` has a HERO block whose event is `INS website enquiries`
|
||||
- **WHEN** a new visitor submits the form in the hero from a URL with `utm_source=facebook`
|
||||
- **THEN** a new lead and an event lead with source Web page, no salesperson and UTM source `facebook` are created
|
||||
|
||||
#### Scenario: Hero form closes with its event
|
||||
|
||||
- **GIVEN** the HERO block's event ended yesterday
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the hero still shows its heading and text, and its form area says sign-up is closed
|
||||
|
||||
#### Scenario: Hero without an event
|
||||
|
||||
- **WHEN** a visitor opens a page whose HERO block names no event
|
||||
- **THEN** the hero shows no form
|
||||
- **AND** a submit addressed to that block is refused as not found
|
||||
|
||||
#### Scenario: Pick the hero's event in the editor
|
||||
|
||||
- **GIVEN** staff editing a page with a HERO block
|
||||
- **WHEN** they pick `INS website enquiries` under the hero's sign-up form setting
|
||||
- **THEN** the canvas shows the form card beside the hero text
|
||||
- **AND** choosing "No form" removes it
|
||||
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: Block References Stay Inside The Company
|
||||
|
||||
A block's image SHALL be an image of the page's company, and the event of a FORM block or of a HERO block that names one SHALL be an event of the page's company. Otherwise the save SHALL be refused on that field.
|
||||
|
||||
#### Scenario: Another company's event
|
||||
|
||||
- **GIVEN** event `CV Roadshow` belongs to CV
|
||||
- **WHEN** INS staff save a FORM block pointing at `CV Roadshow`
|
||||
- **THEN** the save is refused on that block's event field
|
||||
|
||||
#### Scenario: Another company's event in a hero
|
||||
|
||||
- **GIVEN** event `CV Roadshow` belongs to CV
|
||||
- **WHEN** INS staff save a HERO block whose event is `CV Roadshow`
|
||||
- **THEN** the save is refused on that block's event field
|
||||
@@ -0,0 +1,7 @@
|
||||
-- The labels added by add-hero-signup-form, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
|
||||
SET NAMES utf8mb4;
|
||||
USE `service-system`;
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesHeroForm', JSON_OBJECT('en_US', 'Sign-up form', 'zh_CN', '报名表单'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesHeroForm') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '报名表单') WHERE LOWER(code) = LOWER('PagesHeroForm') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesNoForm', JSON_OBJECT('en_US', 'No form', 'zh_CN', '不显示表单'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesNoForm') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '不显示表单') WHERE LOWER(code) = LOWER('PagesNoForm') AND area = 'A';
|
||||
@@ -0,0 +1,39 @@
|
||||
# Tasks
|
||||
|
||||
## 1. Server
|
||||
|
||||
- [x] 1.1 services-counter `CmsBlockValidator`: a HERO's optional `eventUuid` must be an event of the page's company, refused at `blocks[n].eventUuid` with `PagesBadEvent`. Verify: new validator tests (own event saves, other company's event refused, no event saves) fail first, then pass; `mvn -T 1C -pl solvway-services-counter verify`.
|
||||
- [x] 1.2 mobile-api `PublicPageService`: `page()` attaches `form`/`closed` to every block with an event that is FORM or HERO; `submit()` accepts a HERO with an event and refuses a HERO without one as not found. Verify: new service tests fail first, then pass; `mvn -T 1C -pl solvway-mobile-api verify`.
|
||||
|
||||
## 2. Portal
|
||||
|
||||
- [x] 2.1 `CmsBlocks.tsx` HERO: with `form` or `closed`, two columns from `md` (text left, form card right; stacked on phones), image and shade kept; the card is `LandingForm` with the hero's block index. Verify: render tests for with/without event, closed, and the edit canvas; vitest exit 0.
|
||||
- [x] 2.2 `BlockFields.tsx`: the Hero gets the event picker ("No form" default, same hint and unavailable-event option as FORM; `eventUuid` shown inline); `usePageDraft` clears a HERO's event on company switch like a FORM's; labels `PagesHeroForm` and `PagesNoForm` in `defaultMessages.ts`, `zh_CN.seed.json` and an SQL label file in this change folder. Verify: editor tests fail first, then pass; tsc and lint clean.
|
||||
|
||||
## 3. Verification
|
||||
|
||||
- [x] 3.1 Rebuild services-counter and mobile-api locally; Playwright on port 3001: give a page's hero an event, see the card beside the text at 1280 px and below it at 390 px, submit as a visitor on the published page and see the lead under Event leads with source Web page; pick another company's event is impossible in the picker, and an ended event shows "closed". Use a disposable test page and the existing "LP Enquiries" test event; delete the test page after.
|
||||
- [x] 3.2 Full portal vitest (exit 0), tsc, lint, both Maven modules, `openspec validate add-hero-signup-form --strict`.
|
||||
|
||||
## Notes (2026-12-03)
|
||||
|
||||
- **Red first:** each new test failed before its code existed. The validator test failed on the foreign event; the service tests found no form on the hero; the render tests, the editor picker test and the company-switch test failed too.
|
||||
- **Existing editor test:** one query was scoped to the FORM block's picker, because "Website enquiries" is now an option in two pickers. Its assertions are unchanged.
|
||||
- **Live check** (port 3001, rebuilt counter and mobile-api), on the throwaway page "Live check hero form":
|
||||
- the hero picker defaults to "No form";
|
||||
- the canvas shows the card beside the text;
|
||||
- published at 1280 px, the form sits beside the text, and at 390 px below it;
|
||||
- the visitor "Hero Check Visitor" registered from the hero and appears under INS website enquiries with "Web page: /p/INS/live-check-hero-form";
|
||||
- the page was deleted afterwards. The test lead stays in the local database.
|
||||
- **Fixes from the live check:**
|
||||
- the hero text is top-aligned, because a long form left it below the fold;
|
||||
- the top padding is larger, so the editor's image button clears the heading;
|
||||
- the shade is a gradient, because the design-token test refuses flat `bg-black/*`.
|
||||
- **Not checked live:**
|
||||
- the closed state, which the picker cannot reach because it offers no ended events (covered by the service and render tests);
|
||||
- the other-company refusal, which the picker cannot reach either (covered by the validator test).
|
||||
- **Results:** Maven verify passed for services-counter and mobile-api; vitest 1985 passed (exit 0); tsc clean; lint 0 errors.
|
||||
|
||||
## Workflow follow-up
|
||||
|
||||
- PR to `main` and merge; archive on its own branch with its own PR.
|
||||
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-12-03
|
||||
@@ -0,0 +1,124 @@
|
||||
# Design
|
||||
|
||||
## Context
|
||||
|
||||
- **Images:** CI publishes ten images to `gitea.containerverse.dev/solvway/`, each tagged with the commit SHA and with `latest`.
|
||||
- **What `docs/deployment.md` already fixes:**
|
||||
- the Service names and ports;
|
||||
- the probes;
|
||||
- every environment variable, and whether it is secret or plain;
|
||||
- the two mounted files (`appkeys.json` for the gateway, the Pub/Sub `key.json` for the other Java images);
|
||||
- the setup order;
|
||||
- the Traefik routes (portal on `co-lite.containerverse.dev`, plus the webhook path).
|
||||
- **Outside the cluster manifests:**
|
||||
- MySQL, prepared by the DBA;
|
||||
- Redis ("use the existing Redis");
|
||||
- Google Pub/Sub.
|
||||
- **Tools:** the repository has no Kubernetes files, and this machine has Docker but no kubectl.
|
||||
|
||||
## Goals / Non-Goals
|
||||
|
||||
**Goals:**
|
||||
- One `kubectl apply -k deploy/k8s/overlays/prod` deploys the whole system once the Secrets exist.
|
||||
- A check that fails on the mistakes that would hurt in production:
|
||||
- a public route to an internal service;
|
||||
- an image on `latest`;
|
||||
- secret data in git;
|
||||
- two service-counter replicas.
|
||||
|
||||
**Non-Goals:**
|
||||
- Helm charts, GitOps tooling (Argo CD or Flux), or automatic deploys from CI. A person applies each release.
|
||||
- Running MySQL, Redis or a Pub/Sub emulator in the cluster.
|
||||
- A local Kubernetes preview. The owner previews the system with the docker-compose stack.
|
||||
- Autoscaling, resource tuning beyond sensible requests, and NetworkPolicies. These can follow once the cluster's policy is known.
|
||||
|
||||
## Decisions
|
||||
|
||||
### 1. Kustomize, with a base and a `prod` overlay
|
||||
|
||||
- **Choice:** plain YAML under `deploy/k8s/base/`, plus `deploy/k8s/overlays/prod/` for the image SHA, the plain settings, the namespace and the routes.
|
||||
- **Why:**
|
||||
- Kustomize is built into kubectl, so the deployer installs nothing.
|
||||
- The YAML reads like the handover doc.
|
||||
- **Rejected:**
|
||||
- Helm: templating for one environment adds code, and Helm would need installing.
|
||||
- Raw YAML without overlays: the SHA would then be edited in ten files.
|
||||
|
||||
### 2. The image SHA is set in one place
|
||||
|
||||
- **How:** the overlay's `images:` list sets `newTag` for all ten images. A small `deploy/set-release.sh <sha>` rewrites those ten lines.
|
||||
- **Rollback:** run `set-release.sh <previous sha>` and apply again. Every release is a commit on `main`, so the SHA in git history is the record of what ran.
|
||||
|
||||
### 3. Secrets are created by a script from git-ignored files, not stored as manifests
|
||||
|
||||
- **Templates:** `deploy/k8s/secrets.example/` holds one `.env` template per Secret (from `docs/deployment.md` section 9), plus an `appkeys.json` template.
|
||||
- **Filling them in:** the deployer copies the folder to `deploy/k8s/secrets/`, which git ignores, and fills it in.
|
||||
- **Creating them:** `deploy/create-secrets.sh` runs `kubectl create secret generic --from-env-file / --from-file ... --dry-run=client -o yaml | kubectl apply -f -`. It never prints a value.
|
||||
- **Rejected:**
|
||||
- Sealed Secrets or SOPS: new tooling and keys to manage, for a two-developer team. They can come later.
|
||||
- A Kustomize `secretGenerator`: it would put the values into the rendered output, which the check must stay able to forbid.
|
||||
|
||||
### 4. Traefik IngressRoute for the public routes
|
||||
|
||||
- **What:** the `prod` overlay holds two IngressRoutes on `co-lite.containerverse.dev`:
|
||||
- `/` to `admin-portal:3000`;
|
||||
- `Path(/api/public/whatsapp/webhook)` to `mobile-api:80`.
|
||||
- **Why:** the handover doc already states the routes as Traefik rules, and the cluster runs Traefik.
|
||||
- **TLS:** a `tls:` block whose cert resolver (or cert-manager secret) name is a single field in the overlay (see Open Questions).
|
||||
- **Rejected:** a standard Ingress with Traefik annotations. Exact-path matching is less clear there, and nothing else in the cluster needs portability.
|
||||
|
||||
### 5. The check runs from one pinned container
|
||||
|
||||
- **What:** `deploy/check.sh` sends the `deploy/` folder through stdin into `alpine/k8s:1.33.4`, pinned by digest. That one image has kubectl and kustomize, kubeconform, and python3 with PyYAML.
|
||||
- **Why stdin:** it also works against CI's remote Docker daemon, where bind mounts would not reach the files.
|
||||
- **Steps:**
|
||||
1. Kustomize renders the overlay.
|
||||
2. kubeconform validates the result. The Traefik schemas come from the CRDs catalog.
|
||||
3. `check_rules.py` applies the rules.
|
||||
- **Modes:**
|
||||
- `--self-test` runs every rule against its fixture in `deploy/check-fixtures/`.
|
||||
- `--release` also refuses any `<…>` placeholder. CI runs the plain check, because the cluster facts are still placeholders in git; the deployer runs `--release` before applying.
|
||||
- **Rejected:** separate kubectl, kubeconform and Python images. That is three pulls and three pins for the same result.
|
||||
|
||||
### 6. Pod settings
|
||||
|
||||
- **Common to all pods:**
|
||||
- one replica each;
|
||||
- `TZ` left to the image;
|
||||
- `GCP_CREDENTIAL_FILE` and the `key.json` mount on every Java pod except `api-gateway` and `service-whatsapp`;
|
||||
- `imagePullSecrets` set to one named pull secret.
|
||||
- **service-counter:** `strategy: Recreate`, so a rollout never runs two copies at once and the daily summary is never sent twice.
|
||||
- **Probes:** the startup probe uses `/actuator/health/liveness` and allows up to 5 minutes. The overall `/actuator/health` is 503 on service-email while no mail server is configured.
|
||||
- mobile-api does not turn its probe groups on by itself, so the settings set `MANAGEMENT_HEALTH_PROBES_ENABLED=true` for every Java pod.
|
||||
- Both facts were measured on the local containers.
|
||||
- **WhatsApp Secret:** referenced with `optional: true`, so mobile-api and service-whatsapp start while WhatsApp is off.
|
||||
- **Image tags:** quoted in the overlay. A SHA made only of digits, or shaped like `1e45…`, would otherwise be read as a number.
|
||||
- **Requests:** modest (`100m` CPU and `512Mi` for the Java pods; `256Mi` for the portal), with no CPU limit. `JAVA_OPTS=-Xmx384m` keeps the heap inside the memory limit.
|
||||
- **Security context:** the Java images run as root (documented). The manifests do not set `runAsNonRoot`. If the cluster enforces it, that is a finding for the image, not a manifest workaround.
|
||||
|
||||
## Risks / Trade-offs
|
||||
|
||||
- **[A wrong cluster fact breaks the first apply]** (CRD version, pull-secret name, TLS method). Mitigation: those facts are single overlay fields, listed under Open Questions, and the first apply is done together with the owner.
|
||||
- **[Secrets created by hand drift from the templates]** Mitigation: `create-secrets.sh` refuses to run if any key in a template is missing from the filled file.
|
||||
- **[No automatic deploy means releases lag `main`]** This is accepted for go-live. Every release is a deliberate act with a recorded SHA.
|
||||
- **[The check uses an image pulled from Docker Hub]** Mitigation: it is pinned by version and digest.
|
||||
- **[kubeconform fetches the Traefik schema from GitHub]** Without network access the check fails rather than skipping. CI already needs the network to pull images.
|
||||
|
||||
## Migration Plan
|
||||
|
||||
1. The DBA prepares MySQL, and the Pub/Sub topics and key are created (handover sections 3 and 5).
|
||||
2. Fill in `deploy/k8s/secrets/` and run `deploy/create-secrets.sh`. Create the registry pull secret.
|
||||
3. Run `deploy/set-release.sh <sha>` and `deploy/check.sh`, then `kubectl apply -k deploy/k8s/overlays/prod`.
|
||||
4. Wait for every Deployment to roll out (`kubectl rollout status`), then sign in as the first admin.
|
||||
5. **Rollback:** run `set-release.sh <previous sha>`, apply again, and wait for the rollout. Database changes are forward-only. A release that ran new SQL rolls back only to a SHA that works with that schema; the SQL files say which ones are safe.
|
||||
|
||||
## Open Questions
|
||||
|
||||
These are single overlay fields. They are needed before the first real apply, not to build or check the manifests.
|
||||
|
||||
- **Namespace:** the default is `co-lite`.
|
||||
- **TLS:** the Traefik cert resolver name (for example `letsencrypt`), or a cert-manager ClusterIssuer.
|
||||
- **Pull secret:** its name for `gitea.containerverse.dev`, if the cluster already has one.
|
||||
- **Redis:** the address of "the existing Redis".
|
||||
- **Public-pages hostname:** the separate one for `/r`, `/i`, `/c` and `/p` (handover section 8), if it should exist at go-live.
|
||||
- **Access:** who has kubectl access to the cluster for the first apply.
|
||||
@@ -0,0 +1,46 @@
|
||||
# Proposal
|
||||
|
||||
## Why
|
||||
|
||||
Phase 1 ends with Co-Lite running on the team's Kubernetes cluster before go-live on 15 January 2027. CI already publishes the images, and `docs/deployment.md` describes the environment the images need. Nobody has written the Kubernetes manifests yet, so every deploy would be typed by hand from a long document. That invites mistakes in the things that matter most: which paths are public, where secrets come from, and which image version runs.
|
||||
|
||||
## What Changes
|
||||
|
||||
- Add a `deploy/k8s/` folder with Kustomize manifests for the whole system:
|
||||
- a Deployment and a Service for each of the ten images in `docs/deployment.md` section 1, with the names, ports, health probes and settings it lists;
|
||||
- a `prod` overlay that pins every image to one commit SHA, sets the plain settings, and routes the public host through Traefik with TLS.
|
||||
- Expose only two things to the internet: the admin portal, and mobile-api's WhatsApp webhook path. Nothing else gets a route.
|
||||
- Keep every secret out of git. The manifests only refer to Secrets and mounted files by name. Add a checked-in template and a script that creates them from local files the deployer fills in and never commits.
|
||||
- Add a check script, run locally and in CI, that renders the manifests and fails if:
|
||||
- a route reaches anything other than the portal or the webhook path;
|
||||
- an image uses `latest`;
|
||||
- a Secret value appears in the rendered output;
|
||||
- service-counter has more than one replica.
|
||||
- Update `docs/deployment.md` so the deploy steps use the manifests (`kubectl apply -k`) instead of describing them in prose. Add the rollback steps.
|
||||
|
||||
Out of scope:
|
||||
- MySQL and Redis: the DBA's MySQL and the existing Redis stay outside the cluster manifests.
|
||||
- The Pub/Sub project and key.
|
||||
- Choosing an email provider.
|
||||
- Connecting WhatsApp in Meta.
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
- `cluster-deployment`: how Co-Lite is described and rolled out on Kubernetes. It covers what is exposed publicly, how secrets are supplied, how image versions are pinned, and how a release is rolled back.
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
None. `release-packaging` (how images are built and published) does not change.
|
||||
|
||||
## Impact
|
||||
|
||||
- **New:** `deploy/k8s/` (base and `prod` overlay), `deploy/k8s/secrets.example/`, `deploy/check.sh`.
|
||||
- **Changed:** `docs/deployment.md` and `.gitea/workflows/ci.yml` (one manifest-check step).
|
||||
- **No application code changes.**
|
||||
- **No new dependencies in the repo.** The check runs `kubectl kustomize` and kubeconform from pinned container images, so the machine needs only Docker.
|
||||
- **The real cluster needs:**
|
||||
- Traefik, with its IngressRoute CRD;
|
||||
- a pull secret for `gitea.containerverse.dev`;
|
||||
- the DNS record for `co-lite.containerverse.dev`.
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
# Spec Delta
|
||||
|
||||
## Purpose
|
||||
|
||||
Describe how Co-Lite is rolled out to Kubernetes from manifests in the repository, so that public exposure, secrets, image versions and rollback are fixed in reviewed files rather than typed by hand.
|
||||
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: One manifest set deploys the whole system
|
||||
|
||||
The repository SHALL hold Kubernetes manifests that create a Deployment and a Service for each published image. The Service names and ports MUST be the ones the gateway, mobile-api and the portal already expect (`docs/deployment.md` section 1). Each Java service MUST have liveness and readiness probes on its actuator health endpoints. The admin portal MUST have a probe that needs no session.
|
||||
|
||||
#### Scenario: Apply brings every service up
|
||||
|
||||
- **GIVEN** a cluster where the Secrets, the mounted files, the database and the image pull secret already exist
|
||||
- **WHEN** the deployer applies the `prod` overlay
|
||||
- **THEN** a Deployment and a Service exist for all ten images under the expected names and ports
|
||||
- **AND** every pod becomes ready
|
||||
|
||||
#### Scenario: Unhealthy pod gets no traffic
|
||||
|
||||
- **GIVEN** a Java service whose readiness endpoint reports down
|
||||
- **WHEN** Kubernetes checks the pod
|
||||
- **THEN** the pod is not ready and its Service sends it no requests
|
||||
|
||||
### Requirement: Only the portal and the WhatsApp webhook are public
|
||||
|
||||
The manifests SHALL route the public host, over TLS, to the admin-portal Service. They SHALL route exactly the path `/api/public/whatsapp/webhook` to the mobile-api Service. No other Service may be reachable from outside the cluster. The repository's manifest check MUST fail when a route targets any other Service or path.
|
||||
|
||||
#### Scenario: Gateway is not reachable from the internet
|
||||
|
||||
- **WHEN** the rendered `prod` manifests are checked
|
||||
- **THEN** no route targets `api-gateway` or any `service-*`
|
||||
- **AND** the only route to `mobile-api` matches exactly `/api/public/whatsapp/webhook`
|
||||
|
||||
#### Scenario: A new route is caught
|
||||
|
||||
- **GIVEN** a manifest change that adds a route to `api-gateway`
|
||||
- **WHEN** the manifest check runs
|
||||
- **THEN** it fails and names the route
|
||||
|
||||
### Requirement: Secrets never enter the repository
|
||||
|
||||
The manifests SHALL refer to Secrets and mounted files only by name. The repository MUST NOT hold any real secret value. Secret templates hold placeholders only. The script that creates the Secrets MUST read the values from files that git ignores.
|
||||
|
||||
#### Scenario: Rendered manifests hold no secret data
|
||||
|
||||
- **WHEN** the `prod` overlay is rendered
|
||||
- **THEN** it contains no `Secret` object with data
|
||||
- **AND** the manifest check fails if one appears
|
||||
|
||||
#### Scenario: Filled-in secret files cannot be committed
|
||||
|
||||
- **GIVEN** a deployer who fills in the secret files under the secrets folder
|
||||
- **WHEN** they run `git status`
|
||||
- **THEN** those files are ignored
|
||||
|
||||
### Requirement: Releases are pinned by commit and can be rolled back
|
||||
|
||||
The `prod` overlay SHALL pin every image to one commit SHA, never `latest`. Rolling back MUST be done by setting the previous SHA and applying again. The deployment docs MUST describe both steps. Before a real apply, a release check MUST refuse any cluster fact still left as a placeholder.
|
||||
|
||||
#### Scenario: latest is refused
|
||||
|
||||
- **GIVEN** a `prod` overlay where an image tag is `latest` or missing
|
||||
- **WHEN** the manifest check runs
|
||||
- **THEN** it fails and names the image
|
||||
|
||||
#### Scenario: Unfilled cluster fact refused before apply
|
||||
|
||||
- **GIVEN** a `prod` overlay that still holds a `<…>` placeholder, such as the MySQL host
|
||||
- **WHEN** the deployer runs the release check
|
||||
- **THEN** it fails and names each placeholder
|
||||
|
||||
#### Scenario: Roll back to the previous release
|
||||
|
||||
- **GIVEN** a release at SHA B that misbehaves, with SHA A deployed before it
|
||||
- **WHEN** the deployer sets the overlay to SHA A and applies it
|
||||
- **THEN** every Deployment rolls back to the SHA A images
|
||||
|
||||
### Requirement: Single-run jobs stay single
|
||||
|
||||
service-counter SHALL run as exactly one replica. It sends the daily follow-up summary, and two replicas would send it twice. The manifest check MUST fail when service-counter has more than one replica.
|
||||
|
||||
#### Scenario: Counter scaled by mistake
|
||||
|
||||
- **GIVEN** a manifest change that sets service-counter to two replicas
|
||||
- **WHEN** the manifest check runs
|
||||
- **THEN** it fails
|
||||
@@ -0,0 +1,84 @@
|
||||
# Tasks
|
||||
|
||||
## 1. Manifest check first (red)
|
||||
|
||||
- [x] 1.1 Add `deploy/check.sh` and its rule script.
|
||||
- The script renders `deploy/k8s/overlays/prod` with pinned kubectl and kubeconform images, then applies the four rules:
|
||||
- public routes reach only the portal and the exact webhook path;
|
||||
- no image on `latest` or without a tag;
|
||||
- no Secret data in the output;
|
||||
- service-counter has exactly one replica.
|
||||
- Add rule fixtures under `deploy/check-fixtures/`: one passing set and one failing set per rule.
|
||||
- Verify: `deploy/check.sh --self-test` fails each bad fixture with a message naming the offending object, and passes the good one.
|
||||
- Running it against the still-missing overlay fails.
|
||||
- Done: 12 fixtures (one per rule, plus `bad-placeholder.yaml` for `--release`). The first red run passed on an empty render, so the container now stops on the first error, and `--full` requires all ten Deployments and Services.
|
||||
|
||||
## 2. Base manifests
|
||||
|
||||
- [x] 2.1 Add `deploy/k8s/base/`: a Deployment and a Service for each of the ten images, with the names, ports, probes, environment (secret refs and plain values) and mounts from `docs/deployment.md` sections 1, 6 and 7.
|
||||
- service-counter: one replica, `strategy: Recreate`.
|
||||
- Verify: `kubectl kustomize deploy/k8s/base`, run in the check container, renders the ten Deployments and ten Services. kubeconform passes.
|
||||
- Done: 20 resources, all valid. The probe paths were checked against the running local containers. Two fixes came out of that:
|
||||
- mobile-api answered 404 on liveness and readiness, so `MANAGEMENT_HEALTH_PROBES_ENABLED=true` is now in the settings;
|
||||
- service-email's overall health is 503 without a mail server, so the startup probe uses the liveness path.
|
||||
- [x] 2.2 Cross-check the base against `local/docker-compose.yml`: every variable a service reads locally is either set or deliberately left unset in the base.
|
||||
- Verify: a scripted diff of the variable names per service shows no unexplained gaps. Record the deliberate ones in `docs/deployment.md`.
|
||||
- Done: every `${…}` in each `application.yml` is supplied. Deliberately unset: the email keys, `SMSS360_EMAIL`, `CUSTOMER_PORTAL_BASE_URL`, Jumio, and `XXL_JOB_TOKEN` (listed in section 2).
|
||||
- The WhatsApp Secret reference is `optional: true`, so mobile-api starts while WhatsApp is off.
|
||||
|
||||
## 3. Prod overlay, release pinning and routes
|
||||
|
||||
- [x] 3.1 Add `deploy/k8s/overlays/prod/`. It sets:
|
||||
- the namespace;
|
||||
- the `images:` list with one SHA for all ten images;
|
||||
- the plain settings (`ADMIN_PORTAL_BASE_URL`, `REDISHOST`, `MYSQLHOST`, `GCP_PROJECT` and the rest);
|
||||
- the pull secret;
|
||||
- two Traefik IngressRoutes with TLS.
|
||||
|
||||
Verify: `deploy/check.sh` passes on the overlay (task 1 goes green).
|
||||
- [x] 3.2 Add `deploy/set-release.sh <sha>`, which rewrites the overlay's ten tags.
|
||||
- Verify: run it with a test SHA, then confirm that `check.sh` passes and `git diff` shows exactly ten tag lines changed. Running it with `latest` or a non-hex value is refused.
|
||||
- Done: ten lines change. Running it with `latest` or a short SHA is refused.
|
||||
- An all-digit SHA broke the render (YAML read it as a number), so the tags are now quoted. `2222…` and `1e45…` both render and pass.
|
||||
|
||||
## 4. Secrets
|
||||
|
||||
- [x] 4.1 Add `deploy/k8s/secrets.example/`: one `.env` template per Secret, plus an `appkeys.json` and a `key.json` placeholder, all with placeholders only.
|
||||
- Add `deploy/k8s/secrets/` to `.gitignore`.
|
||||
- Verify: a filled-in file under `deploy/k8s/secrets/` is listed by `git check-ignore`.
|
||||
- [x] 4.2 Add `deploy/create-secrets.sh`. It creates or updates each Secret through `kubectl create ... --dry-run=client -o yaml | kubectl apply -f -`. It refuses if a template key is missing or still holds a placeholder, and it never prints a value.
|
||||
- Verify: run it with `--dry-run` against a filled test folder; it prints only the Secret names and the key names.
|
||||
- Verify: a missing key is refused, and the refusal names the key.
|
||||
- Done: the dry run lists seven Secrets with their key names only. A missing `MYSQLPWD` is refused, and so is a placeholder `MYSQLPWD`.
|
||||
- The real path ran in the check container, with `kubectl apply` stubbed:
|
||||
- the `co-lite` namespace is created first, because the first run comes before any apply;
|
||||
- seven Secrets carry the right keys and decode to the filled values;
|
||||
- the registry Secret is a dockerconfigjson for `gitea.containerverse.dev`;
|
||||
- no value appears on stdout.
|
||||
- mobile-api's probes were proven on a throwaway container. Without `MANAGEMENT_HEALTH_PROBES_ENABLED` its liveness and readiness paths are missing; with it, all three return 200.
|
||||
|
||||
## 5. CI and docs
|
||||
|
||||
- [x] 5.1 Add a `deploy/check.sh` step to `.gitea/workflows/ci.yml`, before the image push.
|
||||
- Verify: the workflow file parses, and the step runs locally with the same command.
|
||||
- [x] 5.2 Rewrite the deploy steps in `docs/deployment.md` (sections 2 and 9) around the manifests:
|
||||
- create the Secrets, set the release, run the check, apply, wait for the rollout;
|
||||
- roll back;
|
||||
- list the open cluster facts from `design.md`.
|
||||
|
||||
Verify: following the doc's commands in order against the check container renders and passes.
|
||||
|
||||
## 6. Verification
|
||||
|
||||
- [x] 6.1 Run the full check: `deploy/check.sh` and its self-test, the repository's existing build and tests (unchanged), and `openspec validate add-k8s-deployment --strict`.
|
||||
- Done: the check and the self-test pass, and `openspec validate --strict` passes.
|
||||
- Maven and vitest were not re-run: no module source or build file changed. Only `deploy/`, `docs/`, `.gitignore` and the CI file changed.
|
||||
- [ ] 6.2 Run a server-side dry run against the real cluster: `kubectl apply -k deploy/k8s/overlays/prod --dry-run=server`, by the owner or with the owner's cluster access. Record the result here.
|
||||
- This needs the open cluster facts filled in and access to the cluster. If access is not available before archive, leave the task unticked with a note, as was done for the WhatsApp e2e.
|
||||
- Open (2026-12-03): there is no cluster access from this machine, and the cluster facts are not yet given. Owed by the owner with the first real apply.
|
||||
|
||||
## Workflow follow-up
|
||||
|
||||
- Branch from `origin/main`, then open a PR to `main` and merge it.
|
||||
- Archive the change on its own branch, with its own PR.
|
||||
- The first real apply happens with the owner, after the database package and Secrets are in place.
|
||||
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-12-04
|
||||
@@ -0,0 +1,44 @@
|
||||
# Proposal
|
||||
|
||||
## Why
|
||||
|
||||
The INS sign-up form on the standalone landing page is short: full name, email, phone, company, a single "service" dropdown and the button. Co-Lite's landing-page form is roughly three times as long. Most of that comes from three things: the full English and Malay privacy notice shown in the form, five interest checkboxes, and a job-title field that INS does not ask for. On the rebuilt Hotel technology page, the form card is taller than two screens.
|
||||
|
||||
The coloured sections at the end of the page have a second problem: they are separated by pale gaps. The dark call to action and the dark footer therefore read as two footers.
|
||||
|
||||
The owner chose the following on 2026-12-04: a collapsed privacy notice, one interest as a dropdown, and no job title on landing pages.
|
||||
|
||||
## What Changes
|
||||
|
||||
- **Landing-page forms are compact.** This covers the FORM block and a hero's form; QR, invitation and customer sign-up forms are unchanged.
|
||||
- The interests are a single optional dropdown ("Service interested in"), so a submission carries at most one interest.
|
||||
- There is no job-title field.
|
||||
- The privacy notice is folded behind one line, "How we use your details (English / Bahasa Malaysia)", just above the consent box. It opens to the full bilingual notice.
|
||||
- The consent box itself and its wording do not change.
|
||||
- **Coloured sections join.** A block with a non-default look (light grey, dark or company colour) counts as full width, like Custom HTML and the full-width hero. Two such blocks next to each other join with no gap.
|
||||
|
||||
Not changing:
|
||||
- The server: it already accepts a submission without a job title and with zero or one interest.
|
||||
- The QR, invitation and customer forms.
|
||||
- The notice text, which consent still covers.
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
None.
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
- `landing-pages`:
|
||||
- modifies "Full-Width Blocks Join Without Gaps";
|
||||
- adds "Compact Landing-Page Form".
|
||||
|
||||
## Impact
|
||||
|
||||
- Portal:
|
||||
- `RegistrationForm.tsx` gains a `compact` option;
|
||||
- `LandingForm.tsx` passes it;
|
||||
- `CmsBlocks.tsx` extends `bleeds()` to banded looks;
|
||||
- new labels.
|
||||
- The compliance owner should confirm that a folded notice next to the consent box meets PDPA. The owner was told this when they chose it.
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Compact Landing-Page Form
|
||||
|
||||
A landing page's sign-up form, in a FORM block or a hero, SHALL show name, mobile, email and company, the event's interests as one optional dropdown, the privacy notice folded behind a single line that opens it in full, and the consent box. It SHALL NOT show a job-title field. QR, invitation and customer sign-up forms SHALL keep their full layout.
|
||||
|
||||
#### Scenario: Short form on the page
|
||||
|
||||
- **GIVEN** a page whose hero has an event with five interests
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the form shows name, mobile, email, company, a "Service interested in" dropdown and the consent box, with no job title and no interest checkboxes
|
||||
- **AND** the privacy notice is folded behind "How we use your details"
|
||||
|
||||
#### Scenario: Pick one service
|
||||
|
||||
- **WHEN** the visitor chooses "Cloud IP PABX" in the dropdown and submits
|
||||
- **THEN** the submission carries that one interest
|
||||
|
||||
#### Scenario: Read the notice
|
||||
|
||||
- **WHEN** the visitor opens "How we use your details"
|
||||
- **THEN** the full English and Malay notice shows above the consent box
|
||||
|
||||
#### Scenario: QR form unchanged
|
||||
|
||||
- **WHEN** a visitor opens an event's QR sign-up form
|
||||
- **THEN** it shows job title, the interest checkboxes and the full notice as before
|
||||
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: Full-Width Blocks Join Without Gaps
|
||||
|
||||
A full-width HERO, a Custom HTML block, and a block with a non-default look SHALL join with no gap when two of them are next to each other. Other blocks SHALL keep their usual spacing.
|
||||
|
||||
#### Scenario: Top bar runs straight into the hero
|
||||
|
||||
- **GIVEN** a Custom HTML top bar followed by a full-width HERO
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the hero starts directly under the top bar, with no gap
|
||||
|
||||
#### Scenario: Dark call to action runs into a dark footer
|
||||
|
||||
- **GIVEN** a CTA block with the Dark look followed by a text block with the Dark look
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the two bands join with no gap between them
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
-- The labels added by add-compact-landing-form, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
|
||||
SET NAMES utf8mb4;
|
||||
USE `service-system`;
|
||||
INSERT INTO message (code, content, area) SELECT 'RegServiceInterest', JSON_OBJECT('en_US', 'Service interested in (optional)', 'zh_CN', '感兴趣的服务(可选)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegServiceInterest') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '感兴趣的服务(可选)') WHERE LOWER(code) = LOWER('RegServiceInterest') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'RegChooseService', JSON_OBJECT('en_US', 'Choose a service', 'zh_CN', '选择服务'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegChooseService') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '选择服务') WHERE LOWER(code) = LOWER('RegChooseService') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'RegNoticeSummary', JSON_OBJECT('en_US', 'How we use your details (English / Bahasa Malaysia)', 'zh_CN', '我们如何使用您的资料(English / Bahasa Malaysia)'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('RegNoticeSummary') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '我们如何使用您的资料(English / Bahasa Malaysia)') WHERE LOWER(code) = LOWER('RegNoticeSummary') AND area = 'A';
|
||||
@@ -0,0 +1,39 @@
|
||||
# Tasks
|
||||
|
||||
## 1. Portal
|
||||
|
||||
- [x] 1.1 `RegistrationForm` `compact` option, passed by `LandingForm`:
|
||||
- no job title;
|
||||
- interests in one optional `<select>` ("Service interested in", first option "Choose a service"), which sets `interestIds` to `[]` or `[id]`;
|
||||
- the notice inside a `<details>` with the summary "How we use your details (English / Bahasa Malaysia)", just above the consent box.
|
||||
|
||||
Verify: tests for the landing form (fields, one interest posted, the notice folded and openable) and for the QR form (unchanged) fail first, then pass.
|
||||
- [x] 1.2 `CmsBlocks.tsx` `bleeds()`: a block with a non-default look counts too. Verify: a render test (a dark CTA followed by a dark text block has no gap) fails first, then passes.
|
||||
- [x] 1.3 Add the labels (`RegServiceInterest`, `RegChooseService`, `RegNoticeSummary`) to `defaultMessages.ts`, `zh_CN.seed.json` and `sql/01-compact-form-labels.sql`, and regenerate the local seed.
|
||||
|
||||
## 2. Verification
|
||||
|
||||
- [x] 2.1 Use Playwright on port 3001 for `/p/INS/hotel-technology-native` at 1280 px and 390 px:
|
||||
- check the short form;
|
||||
- check that the notice opens;
|
||||
- check that the closing bands join;
|
||||
- check that an event's QR form (opened from Events) still shows the full form.
|
||||
- [x] 2.2 Run the full vitest (exit 0), tsc, lint and `openspec validate --strict`. Add a release note.
|
||||
|
||||
## Notes (2026-12-04)
|
||||
|
||||
- **Red first:**
|
||||
- the compact-form tests (fields, one service posted, the notice folded) and the band-join test failed first;
|
||||
- the full-form test passed from the start, as the baseline it guards.
|
||||
- **Live check** on `/p/INS/hotel-technology-native` (port 3001):
|
||||
- the hero form shows name, mobile, email, company and "Service interested in", with no job title;
|
||||
- the notice opens from "How we use your details";
|
||||
- the hero runs into the trust strip;
|
||||
- the dark call to action and the dark footer join into one ending.
|
||||
- **Fix from the live check:** joined bands had lost their colour. `Section` treated every joining block as a full-width hero. Now only a full-width hero skips the page width, and the band test also checks the colour.
|
||||
- **Not checked live:** the QR form staying full. The `RegistrationForm` test covers it (job title, checkboxes, notice open).
|
||||
- **Results:** vitest 2002 passed (exit 0); tsc clean; lint 0 errors (the 4 warnings were already there).
|
||||
|
||||
## Workflow follow-up
|
||||
|
||||
- Open a PR to `main` and merge it. Archive the change on its own branch, with its own PR.
|
||||
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-12-04
|
||||
@@ -0,0 +1,25 @@
|
||||
# Design
|
||||
|
||||
## Context
|
||||
|
||||
The HERO block renders inside `Section`, which wraps every non-HTML block in the page width (`max-w-5xl px-4`). The page's block list is `space-y-10`. Custom HTML blocks already render outside `Section`, so they run full width. The hero-with-form layout comes from add-hero-signup-form.
|
||||
|
||||
## Approaches
|
||||
|
||||
1. **A `fullWidth` option on HERO (chosen).** Explicit and opt-in, so existing heroes and templates do not change. It costs one boolean and one switch in the editor.
|
||||
2. **Make every hero with a form full width.** This needs no new field, but it silently changes existing pages and ties two unrelated choices together.
|
||||
3. **Build the hero in Custom HTML.** This cannot work: a sealed frame cannot hold the real sign-up form (see add-hero-signup-form).
|
||||
|
||||
## Decisions
|
||||
|
||||
- **Points reuse `cards`.** They use title-only cards, as the trust strip does. The DTO does not change, and the editor reuses the trust strip's item list (`PagesItemN`, `PagesAddItem`). On a HERO the validator allows 0 to 6 cards. FEATURES, STEPS and TRUST keep their 2 to 6 rule.
|
||||
- **Joins.** A block counts as "bleed" when it is HTML, or when it is a full-width HERO. When a block and the block before it are both bleed, the block gets no top margin. Two Custom HTML blocks next to each other therefore join as well. That changes current pages, but only toward what Custom HTML sections expect: built sections are designed to stack.
|
||||
- **A full-width hero is not wrapped in `Section`.** It renders outside the page width, in the same way as `HtmlSpot`. Its inner content uses a wider container (`max-w-6xl px-4`).
|
||||
- **Font.** The headline uses Tailwind's `font-serif`, the system serif. No web font is added, so there is no new dependency and no third-party request.
|
||||
- **Shade.** The full-width shade is a left-to-right gradient, from `black/75` through `black/45` to `black/10`. It stays black-based, because the design-token test refuses raw colours, and the white text sits on the dark side. On phones the layout stacks and the form card is solid, so contrast holds.
|
||||
- **Form heading and text.** These are plain text fields edited with `Text` in place, in the same way as the hero heading. They are refused on a hero without an event, so they cannot hide in saved data.
|
||||
|
||||
## Risks
|
||||
|
||||
- **Contrast with a light photo on the right.** The text sits on the left, over the darkest part of the shade, and the right side holds the solid form card. This is acceptable.
|
||||
- **Editor controls on the edge.** On the full-width canvas, the image button and the toolbar sit at the window's edge. They are already positioned inside the section by the PR #66 fix.
|
||||
@@ -0,0 +1,59 @@
|
||||
# Proposal
|
||||
|
||||
## Why
|
||||
|
||||
The INS Hotel technology page is being rebuilt in Co-Lite to match INS's standalone landing page (`~/Projects/ins-landing-page`). Since add-hero-signup-form, the form sits beside the hero text, but the hero still looks unlike the original in five ways:
|
||||
|
||||
- it is a rounded box inside the page width, with grey space around it, where the original runs edge to edge directly under the top bar;
|
||||
- its shade is near-black over the whole photo, where the original fades from dark on the left to a clear photo on the right;
|
||||
- its headline is small and pinned to the top, where the original's is large, serif and vertically centred;
|
||||
- it has no bullet points under the text;
|
||||
- the form card has no title or subtitle ("Get a free consultation" / "Tell us about your property…").
|
||||
|
||||
Marketing staff cannot fix any of these from the editor.
|
||||
|
||||
## What Changes
|
||||
|
||||
- A HERO block gains a **Full width** option (`fullWidth`). A full-width hero:
|
||||
- spans the whole window, with square corners and no page margin;
|
||||
- is taller, with a larger serif headline, vertically centred;
|
||||
- uses a lighter shade that runs from dark on the left to almost clear on the right.
|
||||
- Full-width heroes and Custom HTML blocks that sit next to each other join with no gap, so a Custom HTML top bar runs straight into the hero.
|
||||
- Custom HTML frames (found in the live check):
|
||||
- they may shrink to 20 px instead of 100 px, so a 68 px top bar leaves no blank band;
|
||||
- the page asks each frame for its height once it listens and when the frame loads, because the frame's first report could arrive before the page was ready, leaving it at 600 px.
|
||||
- A HERO block may carry up to 6 **points**, short title-only lines (`cards`, 80 characters each) shown as a bullet list under its text. The editor reuses the trust strip's item list.
|
||||
- A HERO with an event may carry a **form heading** (`formHeading`, 80 characters) and **form text** (`formText`, 200 characters), shown at the top of the form card. Both can be typed in place on the canvas.
|
||||
- The server validates the new fields:
|
||||
- `fullWidth` is a boolean;
|
||||
- the hero takes 0 to 6 points, each a non-empty title of at most 80 characters, with no icon or text;
|
||||
- the form heading and form text are refused on a hero without an event.
|
||||
- New editor labels in English and Chinese, with an SQL label file for real environments.
|
||||
|
||||
Not changing:
|
||||
- The heroes that exist today. Without the option they look as they do now.
|
||||
- The sign-up form's fields, the privacy notice and the consent box. They are shared with QR sign-up, and the notice and consent are required by the data-protection rules.
|
||||
- Field labels and the interests checkboxes.
|
||||
- The submit button colour, which follows the company's accent colour. For INS's gold button, set INS's accent colour in Companies; that is a setting, not code.
|
||||
- The red wave decoration at the bottom of the INS hero, which is left out.
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
None.
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
- `landing-pages`: adds "Full-Width Hero", "Hero Points" and "Hero Form Heading".
|
||||
|
||||
## Impact
|
||||
|
||||
- services-counter: `CmsBlock` gains `fullWidth`, `formHeading` and `formText`. `CmsBlockValidator` lets a HERO carry `cards` as points and checks the new fields.
|
||||
- mobile-api: none. Public blocks pass through as maps.
|
||||
- Portal:
|
||||
- `CmsBlocks.tsx` renders the hero layout and the joins between full-width blocks;
|
||||
- `BlockFields.tsx` gets the Full width switch, the points list and the form heading and text;
|
||||
- `cmsPages.ts` gets the types;
|
||||
- new labels in `defaultMessages.ts` and `zh_CN.seed.json`.
|
||||
- Data: no schema change, because the blocks are JSON. The new labels need a SQL label file in this change folder for real environments.
|
||||
@@ -0,0 +1,86 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Full-Width Hero
|
||||
|
||||
A HERO block MAY be marked full width. A full-width hero SHALL span the whole window with square corners, show its heading larger and centred top to bottom in the hero's opening height (not beside a long form), and use a shade that is darker on the text side than on the far side. A hero that is not marked full width SHALL look as it did before. The server SHALL refuse a `fullWidth` value that is not true or false.
|
||||
|
||||
#### Scenario: Hero runs edge to edge under a Custom HTML top bar
|
||||
|
||||
- **GIVEN** page `/p/INS/hotel-technology` with a Custom HTML top bar followed by a full-width HERO with an image and an event
|
||||
- **WHEN** a visitor opens the page in a 1280 px window
|
||||
- **THEN** the hero spans the full window width
|
||||
- **AND** the form card sits beside the heading
|
||||
|
||||
#### Scenario: Existing hero unchanged
|
||||
|
||||
- **WHEN** a visitor opens a page whose HERO block is not marked full width
|
||||
- **THEN** the hero sits inside the page width with rounded corners, as before
|
||||
|
||||
#### Scenario: Turn on full width in the editor
|
||||
|
||||
- **GIVEN** staff editing a page with a HERO block
|
||||
- **WHEN** they switch on "Full width" in the hero's settings
|
||||
- **THEN** the canvas shows the hero across the full width
|
||||
|
||||
### Requirement: Full-Width Blocks Join Without Gaps
|
||||
|
||||
A full-width HERO and a Custom HTML block next to each other SHALL join with no gap between them, and so SHALL two Custom HTML blocks next to each other. Other blocks SHALL keep their usual spacing.
|
||||
|
||||
#### Scenario: Top bar runs straight into the hero
|
||||
|
||||
- **GIVEN** a Custom HTML top bar followed by a full-width HERO
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the hero starts directly under the top bar, with no gap
|
||||
|
||||
### Requirement: Hero Points
|
||||
|
||||
A HERO block MAY carry up to 6 points, each a non-empty title of at most 80 characters, with no icon and no text. The hero SHALL show its points as a bulleted list under its text. The server SHALL refuse more than 6 points, an empty or over-long point, and a point with an icon or text, naming the field.
|
||||
|
||||
#### Scenario: Points under the hero text
|
||||
|
||||
- **GIVEN** a HERO block with points "One accountable partner instead of five vendors" and "Local support team in Malaysia"
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** both points show as a bulleted list under the hero text
|
||||
|
||||
#### Scenario: Too many points refused
|
||||
|
||||
- **WHEN** staff save a HERO block with 7 points
|
||||
- **THEN** the save is refused at `blocks[n].cards`
|
||||
|
||||
### Requirement: Hero Form Heading
|
||||
|
||||
A HERO block with an event MAY carry a form heading of at most 80 characters and a form text of at most 200 characters. The hero SHALL show them at the top of its form card, above the form. The server SHALL refuse either on a hero without an event. On the canvas, staff SHALL be able to type both in place.
|
||||
|
||||
#### Scenario: Card shows its heading
|
||||
|
||||
- **GIVEN** a HERO block with an event, form heading "Get a free consultation" and form text "Tell us about your property. It takes under a minute."
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the form card starts with that heading and text, followed by the form
|
||||
|
||||
#### Scenario: Form heading without a form refused
|
||||
|
||||
- **WHEN** staff save a HERO block with a form heading and no event
|
||||
- **THEN** the save is refused at `blocks[n].formHeading`
|
||||
|
||||
## MODIFIED Requirements
|
||||
|
||||
### Requirement: Custom HTML Frame Height
|
||||
|
||||
The frame SHALL grow or shrink to fit its content, between 20 and 20000 pixels, using height reports sent by that frame only. Before the first report it SHALL be 600 pixels tall. The frame SHALL report the height of its content, not of its own window, and SHALL report again whenever the page asks, which the page SHALL do once it listens and when the frame loads.
|
||||
|
||||
#### Scenario: A tall paste grows the frame
|
||||
|
||||
- **GIVEN** a published HTML block whose content is 3000 pixels tall
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the frame is 3000 pixels tall and shows no inner scroll bar
|
||||
|
||||
#### Scenario: A short top bar shrinks the frame
|
||||
|
||||
- **GIVEN** a published HTML block holding only a 68 pixel top bar
|
||||
- **WHEN** a visitor opens the page, even if the frame loaded before the page was ready
|
||||
- **THEN** the frame is 68 pixels tall, with no blank space below the bar
|
||||
|
||||
#### Scenario: Another frame cannot resize it
|
||||
|
||||
- **WHEN** a different window posts a height report to the page
|
||||
- **THEN** the frame's height does not change
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
-- The labels added by add-hero-full-width, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
|
||||
SET NAMES utf8mb4;
|
||||
USE `service-system`;
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesFullWidth', JSON_OBJECT('en_US', 'Full width', 'zh_CN', '全宽'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFullWidth') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '全宽') WHERE LOWER(code) = LOWER('PagesFullWidth') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesPointN', JSON_OBJECT('en_US', 'Point {number}', 'zh_CN', '要点 {number}'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesPointN') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '要点 {number}') WHERE LOWER(code) = LOWER('PagesPointN') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesAddPoint', JSON_OBJECT('en_US', 'Add point', 'zh_CN', '添加要点'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesAddPoint') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '添加要点') WHERE LOWER(code) = LOWER('PagesAddPoint') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesFormHeading', JSON_OBJECT('en_US', 'Form heading', 'zh_CN', '表单标题'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormHeading') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单标题') WHERE LOWER(code) = LOWER('PagesFormHeading') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesFormText', JSON_OBJECT('en_US', 'Form text', 'zh_CN', '表单说明'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '表单说明') WHERE LOWER(code) = LOWER('PagesFormText') AND area = 'A';
|
||||
@@ -0,0 +1,69 @@
|
||||
# Tasks
|
||||
|
||||
## 1. Server
|
||||
|
||||
- [x] 1.1 services-counter `CmsBlock`: add `fullWidth` (Boolean), `formHeading` and `formText`. `CmsBlockValidator` HERO rules:
|
||||
- allow `cards` on a HERO, 0 to 6 of them, each with a title that is required and at most 80 characters, and no icon or text;
|
||||
- `formHeading` at most 80 characters and `formText` at most 200;
|
||||
- refuse `formHeading` or `formText` without `eventUuid` (`PagesUnusedField`).
|
||||
|
||||
Verify: new validator tests fail first, then pass; `mvn -T 1C -pl solvway-services-counter verify`.
|
||||
|
||||
## 2. Portal
|
||||
|
||||
- [x] 2.1 `cmsPages.ts` types. In `CmsBlocks.tsx`:
|
||||
- the HERO shows its points as a bulleted list;
|
||||
- the form card shows `formHeading` and `formText`, editable in place;
|
||||
- a full-width HERO renders outside the page width, with a larger serif heading, vertical centring and the lighter left-to-right shade;
|
||||
- adjacent bleed blocks (HTML, or a full-width HERO) get no gap between them.
|
||||
|
||||
Verify: render tests fail first, then pass; vitest exit 0.
|
||||
- [x] 2.2 `BlockFields.tsx`:
|
||||
- the Hero gets a "Full width" switch, the points list (reusing the trust strip's item list), and the form heading and text fields, shown only when an event is picked;
|
||||
- `INLINE.HERO` includes `formHeading`, `formText` and the points;
|
||||
- add the labels to `defaultMessages.ts`, `zh_CN.seed.json` and `sql/01-hero-full-width-labels.sql`, and regenerate `local/seed/04-zh-cn-messages.sql`.
|
||||
|
||||
Verify: editor tests fail first, then pass; tsc and lint clean.
|
||||
|
||||
## 3. Verification
|
||||
|
||||
- [x] 3.1 Rebuild services-counter. Use Playwright on port 3001 to edit `/p/INS/hotel-technology` through the editor:
|
||||
- turn on Full width;
|
||||
- add the three INS points;
|
||||
- set the form heading and text;
|
||||
- publish the page.
|
||||
|
||||
Then check the published page at 1280 px and 390 px against the INS page, and check a save with 7 points shows the refusal on the canvas.
|
||||
- [x] 3.2 Run the full portal vitest (exit 0), tsc, lint, Maven verify for services-counter, and `openspec validate add-hero-full-width --strict`.
|
||||
- [x] 3.3 Add a release note to `docs/deployment.md` (label SQL).
|
||||
|
||||
## Notes (2026-12-04)
|
||||
|
||||
- **Red first:**
|
||||
- the validator tests failed on points and the form heading;
|
||||
- the render tests failed on full width, points, the card heading and the joins;
|
||||
- the editor and company-switch tests failed;
|
||||
- the frame floor, ask and answer tests failed.
|
||||
- **Changed existing tests:**
|
||||
- `CmsBlocks.html.test.tsx` "starts a header-less page flush at the top" now checks that the first block row has no top margin. It used to check for a `space-y` class, which is no longer how spacing works. It still asserts that the hidden title is outside the spacing.
|
||||
- `frameHtml.test.ts` clamp test: the floor is now 20 px, per the modified "Custom HTML Frame Height" requirement. It also checks that 68 stays 68.
|
||||
- **Live check** (port 3001, rebuilt counter), on `/p/INS/hotel-technology` through the editor:
|
||||
- Full width switched on;
|
||||
- three points and the form heading and text typed on the canvas;
|
||||
- saved and published.
|
||||
- **Published result at 1280 px:**
|
||||
- the hero runs flush under the top bar and into the rest of the page;
|
||||
- the serif headline is centred in the first screen;
|
||||
- the points show in the accent colour, and the card has its heading.
|
||||
- **Published result at 390 px:** the layout stacks, with the card below the text.
|
||||
- **Fixes from the live check:**
|
||||
- the text is centred in the opening height, not beside the long form;
|
||||
- the frame floor is 20 px;
|
||||
- the page asks frames for their height (both added to the spec).
|
||||
- **Not reachable in the UI, covered by the validator tests:**
|
||||
- 7 points, because Add point stops at 6;
|
||||
- a form heading without a form, because No form clears it.
|
||||
|
||||
## Workflow follow-up
|
||||
|
||||
- Open a PR to `main` and merge it. Archive the change on its own branch, with its own PR.
|
||||
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-12-04
|
||||
@@ -0,0 +1,44 @@
|
||||
# Proposal
|
||||
|
||||
## Why
|
||||
|
||||
Custom HTML blocks hold whole designed sections, such as the INS Hotel technology page. Their images must be served from somewhere. Today the only way to get an image link is to upload it as a hero image and read its id back, or to ask a developer. Marketing staff need to upload an image from the Custom HTML block itself and get a link they can paste into their HTML.
|
||||
|
||||
## What Changes
|
||||
|
||||
- The Custom HTML block's panel gains an **Upload image** file picker. Choosing a file uploads it at once, for the page's company, with the same checks as every page image:
|
||||
- PNG, JPEG or WebP;
|
||||
- at most 2 MB;
|
||||
- the type is checked by the file's content.
|
||||
- Each upload made while the panel is open shows:
|
||||
- a small preview;
|
||||
- its link (`/api/public/page-images/<id>`) in a read-only box;
|
||||
- a **Copy link** button.
|
||||
- A refused upload shows its reason under the picker.
|
||||
- A new page with no company chosen yet asks for one first.
|
||||
- The link is relative, so it works on the published page and inside the sealed frame. The INS top bar's logo already loads this way.
|
||||
|
||||
Not changing:
|
||||
- The server. The existing `POST /api/pages/images` upload and the public image address are used as they are.
|
||||
- Saving. The upload does not touch the page's HTML; staff paste the link where they want it.
|
||||
- Unused images. They stay stored, as an unused hero upload would. Clean-up is left for later.
|
||||
- The list of uploads, which is not saved. It shows this session's uploads only.
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
None.
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
- `landing-pages`: adds "Image Upload For Custom HTML".
|
||||
|
||||
## Impact
|
||||
|
||||
- Portal:
|
||||
- `BlockFields.tsx`, the HTML block panel;
|
||||
- the editor passes the page's company to the panel (or the panel reads it from the draft hook);
|
||||
- `uploadPageImage` already exists.
|
||||
- New labels in `defaultMessages.ts` and `zh_CN.seed.json`, a regenerated local seed, and a SQL label file in this change folder.
|
||||
- No server or schema change.
|
||||
@@ -0,0 +1,23 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Image Upload For Custom HTML
|
||||
|
||||
A Custom HTML block's panel in the editor SHALL offer an image upload for the page's company, under the same checks as other page images. On success it SHALL show the image's preview and its public link with a copy button; on refusal it SHALL show the reason. The upload SHALL NOT change the block's HTML.
|
||||
|
||||
#### Scenario: Upload an image for the HTML
|
||||
|
||||
- **GIVEN** staff editing an INS page with a Custom HTML block
|
||||
- **WHEN** they choose `lobby.webp` under "Upload image" in that block's panel
|
||||
- **THEN** the image is stored for INS and the panel shows its preview and the link `/api/public/page-images/<id>`
|
||||
- **AND** "Copy link" copies that link, and the block's HTML is unchanged
|
||||
|
||||
#### Scenario: Refused upload
|
||||
|
||||
- **WHEN** staff choose a 3 MB JPEG under "Upload image"
|
||||
- **THEN** the panel shows that the image is too large, and no link appears
|
||||
|
||||
#### Scenario: New page without a company
|
||||
|
||||
- **GIVEN** a super admin's new page with no company chosen
|
||||
- **WHEN** they choose a file under "Upload image"
|
||||
- **THEN** nothing is uploaded and the panel asks them to choose a company
|
||||
@@ -0,0 +1,7 @@
|
||||
-- The labels added by add-html-image-upload, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
|
||||
SET NAMES utf8mb4;
|
||||
USE `service-system`;
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesUploadImage', JSON_OBJECT('en_US', 'Upload image', 'zh_CN', '上传图片'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '上传图片') WHERE LOWER(code) = LOWER('PagesUploadImage') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesUploadImageHint', JSON_OBJECT('en_US', 'PNG, JPEG or WebP up to 2 MB. Paste the link into your HTML, for example in an img tag''s src.', 'zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', 'PNG、JPEG 或 WebP,最大 2 MB。将链接粘贴到您的 HTML 中,例如 img 标签的 src。') WHERE LOWER(code) = LOWER('PagesUploadImageHint') AND area = 'A';
|
||||
@@ -0,0 +1,34 @@
|
||||
# Tasks
|
||||
|
||||
## 1. Portal
|
||||
|
||||
- [x] 1.1 HTML block panel: an "Upload image" file picker (`image/png,image/jpeg,image/webp`) uploads at once through `uploadPageImage(companyId, base64)`.
|
||||
- Each success adds a row: preview, a read-only link `/api/public/page-images/<id>`, and a "Copy link" button that uses the clipboard.
|
||||
- A refusal shows the translated server reason under the picker.
|
||||
- With no company, the panel shows "Choose a company." and does not upload.
|
||||
- The block's HTML is never changed.
|
||||
|
||||
Verify: editor tests (success row and copy, refusal, no company, HTML unchanged) fail first, then pass; vitest exit 0; tsc; lint.
|
||||
- [x] 1.2 Add the labels (`PagesUploadImage`, `PagesUploadImageHint`; the copy button reuses the page-address copy button) to `defaultMessages.ts`, `zh_CN.seed.json` and `sql/01-html-image-labels.sql`, and regenerate `local/seed/04-zh-cn-messages.sql`.
|
||||
|
||||
## 2. Verification
|
||||
|
||||
- [x] 2.1 Use Playwright on port 3001, signing in through the form and opening Hotel technology from Pages.
|
||||
- In a Custom HTML block, upload an image, copy the link, and check that the panel shows the preview and the link.
|
||||
- Upload a file that is not an image and see the refusal.
|
||||
- Do not change the published page.
|
||||
- [x] 2.2 Run the full portal vitest (exit 0), tsc, lint, and `openspec validate add-html-image-upload --strict`. Add a release note to `docs/deployment.md` (label SQL).
|
||||
|
||||
## Notes (2026-12-04)
|
||||
|
||||
- **Red first:** the success, refusal and no-company editor tests all failed, because there was no "Upload image" picker yet. They pass now.
|
||||
- **Live check** (port 3001): signed in through the form, then opened Hotel technology from Pages.
|
||||
- In block 3 (Custom HTML), uploaded `hero-bg.webp`. The panel showed the preview and `/api/public/page-images/7` with a copy button.
|
||||
- A text file named `.png` was refused with "Use a PNG, JPEG or WebP image."
|
||||
- The page was not saved or published.
|
||||
- **Fix from the live check:** the link was shown twice (a read-only box and the copy button's text). It now shows once, beside its copy button, which reuses the page-address copy button with a `relative` option.
|
||||
- **Results:** vitest 1997 passed (exit 0); tsc clean; lint 0 errors (the 4 warnings were already there).
|
||||
|
||||
## Workflow follow-up
|
||||
|
||||
- Open a PR to `main` and merge it. Archive the change on its own branch, with its own PR.
|
||||
@@ -0,0 +1,2 @@
|
||||
schema: spec-driven
|
||||
created: 2026-12-04
|
||||
@@ -0,0 +1,30 @@
|
||||
# Design
|
||||
|
||||
## Context
|
||||
|
||||
Landing blocks are JSON validated by `CmsBlockValidator` and rendered by `CmsBlocks.tsx`. Card blocks (FEATURES, STEPS, TRUST, HERO points) share `cards` and the editor's card list in `BlockFields.tsx`. Text is edited in place with `Text`, which renders plain text outside the editor. The landing form's done state is `VisitorState` with the `RegThanks` heading.
|
||||
|
||||
## Approaches
|
||||
|
||||
1. **A FOOTER block built on `cards` (chosen).** Columns are cards with a title and text, the legal line is the block's `text`. The DTO gains nothing for the footer, and the editor reuses the card list. Staff get a footer that looks right without formatting.
|
||||
2. **Columns and link colours on the Rich Text block.** This keeps one block type, but staff would have to build columns and links by hand, and every rich text block would gain layout options.
|
||||
3. **Keep the footer in Custom HTML.** This is what the original page does; the native page exists to avoid it.
|
||||
|
||||
For the thank-you text, a field on the form-bearing blocks is the only sensible way: the message belongs to the page, not to the event, because one event can have several pages.
|
||||
|
||||
## Decisions
|
||||
|
||||
- **Links are found, not typed.** One helper splits plain text into text and links:
|
||||
- `+` followed by digits, spaces and dashes (at least 8 digits) becomes `tel:` with only `+` and digits;
|
||||
- an email address becomes `mailto:`;
|
||||
- `https://…` and `www.…` become `https://` links that open in a new tab with `rel="noopener noreferrer"`.
|
||||
It builds React elements, never HTML, so text stays text. `Text` gains a `links` flag that uses it outside the editor; in the editor the text stays editable as now.
|
||||
- **Footer validation.** 1 to 4 cards, each with a required title (80) and required text (300), no icon. `text` at most 300. No heading.
|
||||
- **Footer look.** `emptyBlock("FOOTER")` sets `look: "DARK"`. Links use the existing link colour (`text-primary`), which is the company's accent colour, so INS's footer links are gold.
|
||||
- **Thank-you text.** `thanksText` (200) on FORM, and on HERO only with an event, like `formHeading`. `LandingForm` takes it as `thanks` and passes it to `VisitorState`'s text, through the link helper. Choosing "No form" on a hero, or changing company, clears it along with the event.
|
||||
- **Shade.** The design-token test refuses raw colours, so the shade stays black-based: `from-black/55 to-black/10 to-70%` from the `md` width, and an even `black/60` below it. White text keeps contrast because the text sits on the darker left.
|
||||
|
||||
## Risks
|
||||
|
||||
- **Phone detection.** Only numbers written with `+` become links. A local number like "03-7623 9807" stays plain text. This is deliberate, to avoid linking dates or prices.
|
||||
- **Lighter shade over a bright photo.** The headline could lose contrast. The hero heading is large and bold, and INS uses the same shade; staff can pick a darker photo.
|
||||
@@ -0,0 +1,48 @@
|
||||
# Proposal
|
||||
|
||||
## Why
|
||||
|
||||
The INS Hotel technology page is being rebuilt in Co-Lite without Custom HTML, to match INS's standalone page (`~/Projects/ins-landing-page`). After add-compact-landing-form, the content matches, but three things still differ, and marketing staff cannot fix them from the editor:
|
||||
|
||||
- After signing up, INS shows "Thanks! Our team will contact you shortly. Prefer to talk now? Call +60 12-833 2775", with the number as a tap-to-call link. Our landing form shows the same generic thank-you on every page.
|
||||
- INS's footer has up to three columns (company and address, "Talk to us" with phone and email, website). The phone, email and web address are gold links, and the © line sits under a thin divider. Ours is one stacked column of plain rich text.
|
||||
- INS's hero shade is lighter, so more of the photo shows. Ours is near-black on the text side.
|
||||
|
||||
## What Changes
|
||||
|
||||
- **Thank-you text.** The FORM block and a HERO with an event MAY carry `thanksText` (at most 200 characters). After a visitor signs up, it shows under the "Thank you" heading. Phone numbers that start with `+`, email addresses, and `https://` or `www.` web addresses in it become links. Without it, the thank-you stays as it is now. The server refuses it on a HERO without an event.
|
||||
- **Footer block.** A new block type, FOOTER:
|
||||
- 1 to 4 columns, each a bold title (80 characters) and text (300 characters, line breaks kept);
|
||||
- an optional legal line (`text`, 300 characters) under a thin divider;
|
||||
- phone numbers, emails and web addresses in the column text become links in the link colour;
|
||||
- a new footer starts with the dark look; staff may change the look as on any block.
|
||||
- **Lighter full-width hero shade.** The full-width hero's shade runs from about half dark on the text side to almost clear at 70% of the width, like INS. On phones, where the text sits over the whole photo, the shade is an even dark layer.
|
||||
- New editor labels in English and Chinese, with an SQL label file for real environments.
|
||||
|
||||
Not changing:
|
||||
- QR and invitation sign-up thank-you screens.
|
||||
- The Rich Text block. Existing footers built with it keep working.
|
||||
- Heroes that are not full width.
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
|
||||
None.
|
||||
|
||||
### Modified Capabilities
|
||||
|
||||
- `landing-pages`: adds "Thank-You Text On Landing Forms" and "Footer Block".
|
||||
|
||||
## Impact
|
||||
|
||||
- services-counter: `CmsBlock` gains `thanksText`. `CmsBlockValidator` checks `thanksText` on FORM and HERO and validates the FOOTER type.
|
||||
- mobile-api: none. Public blocks pass through as maps.
|
||||
- Portal:
|
||||
- `cmsPages.ts`: the FOOTER type, its empty block and label;
|
||||
- a small link-finding helper used by the footer and the thank-you text;
|
||||
- `CmsBlocks.tsx` renders the footer, passes the thank-you text and lightens the shade;
|
||||
- `LandingForm.tsx` shows the thank-you text;
|
||||
- `BlockFields.tsx` gets the footer's columns and legal line, and the thank-you field on FORM and HERO;
|
||||
- labels in `defaultMessages.ts` and `zh_CN.seed.json`.
|
||||
- Data: no schema change, because the blocks are JSON. The new labels need a SQL label file in this change folder.
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Thank-You Text On Landing Forms
|
||||
|
||||
A FORM block, and a HERO block with an event, MAY carry a thank-you text of at most 200 characters. After a visitor signs up through that block's form, the page SHALL show the text, with contact links, under the thank-you heading. Without it, the thank-you SHALL look as before. The server SHALL refuse an over-long thank-you text, or one on a HERO without an event.
|
||||
|
||||
#### Scenario: Visitor sees the page's thank-you text with a call link
|
||||
|
||||
- **GIVEN** page `/p/INS/hotel-technology-native` whose hero form has the thank-you text "Prefer to talk now? Call +60 12-833 2775."
|
||||
- **WHEN** a visitor signs up through the hero form
|
||||
- **THEN** the page shows the thank-you heading and "Prefer to talk now? Call +60 12-833 2775."
|
||||
- **AND** "+60 12-833 2775" is a link to `tel:+60128332775`
|
||||
|
||||
#### Scenario: No thank-you text keeps today's message
|
||||
|
||||
- **WHEN** a visitor signs up through a FORM block without a thank-you text
|
||||
- **THEN** the page shows only the thank-you heading and the "register another" button, as before
|
||||
|
||||
#### Scenario: Thank-you text on a hero without a form is refused
|
||||
|
||||
- **WHEN** staff save a HERO block without an event but with a thank-you text
|
||||
- **THEN** the save is refused with the reason naming the hero's thank-you field
|
||||
|
||||
#### Scenario: Set the thank-you text in the editor
|
||||
|
||||
- **GIVEN** staff editing a hero that has an event
|
||||
- **WHEN** they type a thank-you text in the hero's settings and save
|
||||
- **THEN** the page keeps the text
|
||||
- **AND** choosing "No form" on the hero clears it
|
||||
|
||||
### Requirement: Footer Block
|
||||
|
||||
A page MAY hold FOOTER blocks: 1 to 4 columns, each a required title (80 characters) and text (300 characters), and an optional legal line (300 characters). The page SHALL show the columns side by side on wide screens and stacked on phones, keep line breaks, show contact links in the column text, and put the legal line under a thin divider. A new footer SHALL start with the dark look. The server SHALL refuse a footer that breaks these limits, or that has a heading or a column icon.
|
||||
|
||||
#### Scenario: Visitor sees a three-column footer with links
|
||||
|
||||
- **GIVEN** a published page whose footer has the columns "Infinity Networks Security Sdn Bhd", "Talk to us" with "+603-7623 9807" and "info@infinitynetworks.com.my", and "Website" with "www.infinitynetworks.com.my", and a legal line
|
||||
- **WHEN** a visitor opens the page in a 1280 px window
|
||||
- **THEN** the three columns sit side by side on a dark band
|
||||
- **AND** the phone links to `tel:+60376239807`, the email to `mailto:info@infinitynetworks.com.my`, and the website to `https://www.infinitynetworks.com.my`
|
||||
- **AND** the legal line sits under a divider
|
||||
|
||||
#### Scenario: Add a footer in the editor
|
||||
|
||||
- **GIVEN** staff editing a page
|
||||
- **WHEN** they add a Footer section
|
||||
- **THEN** the canvas shows a dark footer with two empty columns to type into
|
||||
- **AND** they can add columns up to 4 and type the legal line
|
||||
|
||||
#### Scenario: Footer with five columns is refused
|
||||
|
||||
- **WHEN** a page is saved with a footer of 5 columns
|
||||
- **THEN** the save is refused with the reason naming the footer's columns
|
||||
|
||||
### Requirement: Contact Links In Plain Text
|
||||
|
||||
Where this spec says text shows contact links, the page SHALL show phone numbers that start with `+` as `tel:` links holding only `+` and digits, email addresses as `mailto:` links, and `https://` or `www.` addresses as `https://` links that open in a new tab. Everything else SHALL stay plain text, never HTML.
|
||||
|
||||
#### Scenario: Text with markup stays text
|
||||
|
||||
- **GIVEN** a footer column text "<b>Call</b> +60 12-833 2775"
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** "<b>Call</b>" shows as written
|
||||
- **AND** "+60 12-833 2775" links to `tel:+60128332775`
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
-- The labels added by add-landing-thanks-and-footer, cut from the output of `npm run i18n:sql`. Run it only in an environment that already ran add-zh-cn-messages/sql/03-zh-cn-messages.sql; otherwise run that 03 file, which includes these labels.
|
||||
SET NAMES utf8mb4;
|
||||
USE `service-system`;
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesThanksText', JSON_OBJECT('en_US', 'Thank-you text', 'zh_CN', '感谢语'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesThanksText') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '感谢语') WHERE LOWER(code) = LOWER('PagesThanksText') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesBlockFooter', JSON_OBJECT('en_US', 'Footer', 'zh_CN', '页脚'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesBlockFooter') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '页脚') WHERE LOWER(code) = LOWER('PagesBlockFooter') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesColumnN', JSON_OBJECT('en_US', 'Column {number}', 'zh_CN', '第 {number} 栏'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesColumnN') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '第 {number} 栏') WHERE LOWER(code) = LOWER('PagesColumnN') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesAddColumn', JSON_OBJECT('en_US', 'Add column', 'zh_CN', '添加栏'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesAddColumn') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '添加栏') WHERE LOWER(code) = LOWER('PagesAddColumn') AND area = 'A';
|
||||
INSERT INTO message (code, content, area) SELECT 'PagesFooterLegal', JSON_OBJECT('en_US', 'Legal line', 'zh_CN', '版权声明'), 'A' FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM message WHERE LOWER(code) = LOWER('PagesFooterLegal') AND area = 'A');
|
||||
UPDATE message SET content = JSON_SET(COALESCE(content, JSON_OBJECT()), '$.zh_CN', '版权声明') WHERE LOWER(code) = LOWER('PagesFooterLegal') AND area = 'A';
|
||||
@@ -0,0 +1,52 @@
|
||||
# Tasks
|
||||
|
||||
## 1. Server
|
||||
|
||||
- [x] 1.1 services-counter `CmsBlock`: add `thanksText`. `CmsBlockValidator`:
|
||||
- `thanksText` at most 200 on FORM and HERO; refused on a HERO without `eventUuid` and on every other type (`PagesUnusedField`);
|
||||
- FOOTER: no heading; 1 to 4 cards, each with a required title (80) and required text (300) and no icon; `text` at most 300.
|
||||
|
||||
Verify: new validator tests fail first, then pass; `mvn -T 1C -pl solvway-services-counter verify`.
|
||||
|
||||
## 2. Portal
|
||||
|
||||
- [x] 2.1 Link helper and rendering:
|
||||
- a helper that turns plain text into text and links (`+` phone numbers, emails, `https://` and `www.` addresses), building elements, never HTML;
|
||||
- `Text` gains `links`;
|
||||
- `CmsBlocks.tsx` renders FOOTER (columns, line breaks, legal line under a divider), passes `thanksText` to `LandingForm`, and lightens the full-width hero shade;
|
||||
- `LandingForm.tsx` shows the thank-you text under the heading.
|
||||
|
||||
Verify: render tests fail first, then pass; vitest exit 0.
|
||||
- [x] 2.2 Editor:
|
||||
- `cmsPages.ts`: FOOTER type, label and empty block (dark look, two columns);
|
||||
- `BlockFields.tsx`: the footer's columns (1 to 4) and legal line; the thank-you field on FORM, and on HERO when an event is picked; "No form" and company change clear it;
|
||||
- labels in `defaultMessages.ts`, `zh_CN.seed.json`, `sql/01-thanks-footer-labels.sql`; regenerate `local/seed/04-zh-cn-messages.sql`.
|
||||
|
||||
Verify: editor tests fail first, then pass; tsc and lint clean.
|
||||
|
||||
## 3. Verification
|
||||
|
||||
- [x] 3.1 Rebuild services-counter. Use Playwright on port 3001 to edit `/p/INS/hotel-technology-native` through the editor:
|
||||
- set the hero's thank-you text to "Prefer to talk now? Call +60 12-833 2775.";
|
||||
- replace the rich text footer with a Footer section matching INS;
|
||||
- publish.
|
||||
|
||||
Check the published page at 1280 px and 390 px. The thank-you screen needs a real sign-up, which writes a record: check it in the editor preview path only if it does not save, otherwise ask the owner first.
|
||||
- [x] 3.2 Run the full portal vitest (exit 0), tsc, lint, Maven verify for services-counter, and `openspec validate add-landing-thanks-and-footer --strict`.
|
||||
- [x] 3.3 Add a release note to `docs/deployment.md` (label SQL).
|
||||
|
||||
## Notes (2026-12-04)
|
||||
|
||||
- **Red first:**
|
||||
- the validator tests failed on the thank-you text and the footer;
|
||||
- the render tests failed on the thank-you text, the footer and the link helper (missing module);
|
||||
- the editor tests failed on the Footer section, the hero's thank-you field and the company switch.
|
||||
- **Changed existing tests:** none. Two of my own new editor tests were fixed before going green: column names shift after a removal, and the Form block has its own thank-you field, so the hero checks are scoped to block 1.
|
||||
- **Design-token checks:** the phone shade uses an even black gradient (`bg-black/60` is refused), and the divider uses `border-muted-foreground/30` (`border-current/15` is not in Tailwind 3).
|
||||
- **Live check** (port 3001, rebuilt counter), on `/p/INS/hotel-technology-native` through the editor:
|
||||
- typed the hero's thank-you text "Prefer to talk now? Call +60 12-833 2775.";
|
||||
- added a Footer section with three columns and the legal line, and removed the old Text footer;
|
||||
- saved and published.
|
||||
- **Published result:** at 1280 px the three columns sit side by side on the dark band with gold tel, mailto and https links, and the legal line sits under a divider; at 390 px they stack. The hero shade is lighter.
|
||||
- **Not run live:** the thank-you screen itself, because it needs a real sign-up, which writes a record. The render tests cover it (thank-you text and the tel link after a mocked sign-up).
|
||||
- **Not reachable in the UI, covered by the validator tests:** 5 footer columns (Add column stops at 4), and a thank-you text on a hero without a form (No form clears it).
|
||||
@@ -0,0 +1,88 @@
|
||||
# cluster-deployment Specification
|
||||
|
||||
## Purpose
|
||||
|
||||
Describe how Co-Lite is rolled out to Kubernetes from manifests in the repository, so that public exposure, secrets, image versions and rollback are fixed in reviewed files rather than typed by hand.
|
||||
|
||||
## Requirements
|
||||
|
||||
### Requirement: One manifest set deploys the whole system
|
||||
|
||||
The repository SHALL hold Kubernetes manifests that create a Deployment and a Service for each published image. The Service names and ports MUST be the ones the gateway, mobile-api and the portal already expect (`docs/deployment.md` section 1). Each Java service MUST have liveness and readiness probes on its actuator health endpoints. The admin portal MUST have a probe that needs no session.
|
||||
|
||||
#### Scenario: Apply brings every service up
|
||||
|
||||
- **GIVEN** a cluster where the Secrets, the mounted files, the database and the image pull secret already exist
|
||||
- **WHEN** the deployer applies the `prod` overlay
|
||||
- **THEN** a Deployment and a Service exist for all ten images under the expected names and ports
|
||||
- **AND** every pod becomes ready
|
||||
|
||||
#### Scenario: Unhealthy pod gets no traffic
|
||||
|
||||
- **GIVEN** a Java service whose readiness endpoint reports down
|
||||
- **WHEN** Kubernetes checks the pod
|
||||
- **THEN** the pod is not ready and its Service sends it no requests
|
||||
|
||||
### Requirement: Only the portal and the WhatsApp webhook are public
|
||||
|
||||
The manifests SHALL route the public host, over TLS, to the admin-portal Service. They SHALL route exactly the path `/api/public/whatsapp/webhook` to the mobile-api Service. No other Service may be reachable from outside the cluster. The repository's manifest check MUST fail when a route targets any other Service or path.
|
||||
|
||||
#### Scenario: Gateway is not reachable from the internet
|
||||
|
||||
- **WHEN** the rendered `prod` manifests are checked
|
||||
- **THEN** no route targets `api-gateway` or any `service-*`
|
||||
- **AND** the only route to `mobile-api` matches exactly `/api/public/whatsapp/webhook`
|
||||
|
||||
#### Scenario: A new route is caught
|
||||
|
||||
- **GIVEN** a manifest change that adds a route to `api-gateway`
|
||||
- **WHEN** the manifest check runs
|
||||
- **THEN** it fails and names the route
|
||||
|
||||
### Requirement: Secrets never enter the repository
|
||||
|
||||
The manifests SHALL refer to Secrets and mounted files only by name. The repository MUST NOT hold any real secret value. Secret templates hold placeholders only. The script that creates the Secrets MUST read the values from files that git ignores.
|
||||
|
||||
#### Scenario: Rendered manifests hold no secret data
|
||||
|
||||
- **WHEN** the `prod` overlay is rendered
|
||||
- **THEN** it contains no `Secret` object with data
|
||||
- **AND** the manifest check fails if one appears
|
||||
|
||||
#### Scenario: Filled-in secret files cannot be committed
|
||||
|
||||
- **GIVEN** a deployer who fills in the secret files under the secrets folder
|
||||
- **WHEN** they run `git status`
|
||||
- **THEN** those files are ignored
|
||||
|
||||
### Requirement: Releases are pinned by commit and can be rolled back
|
||||
|
||||
The `prod` overlay SHALL pin every image to one commit SHA, never `latest`. Rolling back MUST be done by setting the previous SHA and applying again. The deployment docs MUST describe both steps. Before a real apply, a release check MUST refuse any cluster fact still left as a placeholder.
|
||||
|
||||
#### Scenario: latest is refused
|
||||
|
||||
- **GIVEN** a `prod` overlay where an image tag is `latest` or missing
|
||||
- **WHEN** the manifest check runs
|
||||
- **THEN** it fails and names the image
|
||||
|
||||
#### Scenario: Unfilled cluster fact refused before apply
|
||||
|
||||
- **GIVEN** a `prod` overlay that still holds a `<…>` placeholder, such as the MySQL host
|
||||
- **WHEN** the deployer runs the release check
|
||||
- **THEN** it fails and names each placeholder
|
||||
|
||||
#### Scenario: Roll back to the previous release
|
||||
|
||||
- **GIVEN** a release at SHA B that misbehaves, with SHA A deployed before it
|
||||
- **WHEN** the deployer sets the overlay to SHA A and applies it
|
||||
- **THEN** every Deployment rolls back to the SHA A images
|
||||
|
||||
### Requirement: Single-run jobs stay single
|
||||
|
||||
service-counter SHALL run as exactly one replica. It sends the daily follow-up summary, and two replicas would send it twice. The manifest check MUST fail when service-counter has more than one replica.
|
||||
|
||||
#### Scenario: Counter scaled by mistake
|
||||
|
||||
- **GIVEN** a manifest change that sets service-counter to two replicas
|
||||
- **WHEN** the manifest check runs
|
||||
- **THEN** it fails
|
||||
@@ -63,7 +63,7 @@ A page save SHALL be refused with the offending field path, writing nothing, whe
|
||||
|
||||
### Requirement: Block References Stay Inside The Company
|
||||
|
||||
A block's image SHALL be an image of the page's company, and a FORM block's event SHALL be an event of the page's company. Otherwise the save SHALL be refused on that field.
|
||||
A block's image SHALL be an image of the page's company, and the event of a FORM block or of a HERO block that names one SHALL be an event of the page's company. Otherwise the save SHALL be refused on that field.
|
||||
|
||||
#### Scenario: Another company's event
|
||||
|
||||
@@ -71,6 +71,12 @@ A block's image SHALL be an image of the page's company, and a FORM block's even
|
||||
- **WHEN** INS staff save a FORM block pointing at `CV Roadshow`
|
||||
- **THEN** the save is refused on that block's event field
|
||||
|
||||
#### Scenario: Another company's event in a hero
|
||||
|
||||
- **GIVEN** event `CV Roadshow` belongs to CV
|
||||
- **WHEN** INS staff save a HERO block whose event is `CV Roadshow`
|
||||
- **THEN** the save is refused on that block's event field
|
||||
|
||||
### Requirement: Page Content Cannot Run Scripts
|
||||
|
||||
A button SHALL have both a label and a link or neither. The link SHALL start with a single `/`, `https://`, `mailto:`, `tel:`, or `#` plus a valid block link name. A save SHALL be refused when RICH_TEXT or IMAGE_TEXT HTML holds a `script` element, an `on*` attribute or a `javascript:` URL. The public page SHALL also sanitise that HTML against an allow-list. HTML blocks are exempt: they only run sealed.
|
||||
@@ -272,7 +278,7 @@ The public frame address SHALL be `/p/<company>/<slug>/frame/<block index>` and
|
||||
|
||||
### Requirement: Custom HTML Frame Height
|
||||
|
||||
The frame SHALL grow to fit its content, between 100 and 20000 pixels, using height reports sent by that frame only. Before the first report it SHALL be 600 pixels tall.
|
||||
The frame SHALL grow or shrink to fit its content, between 20 and 20000 pixels, using height reports sent by that frame only. Before the first report it SHALL be 600 pixels tall. The frame SHALL report the height of its content, not of its own window, and SHALL report again whenever the page asks, which the page SHALL do once it listens and when the frame loads.
|
||||
|
||||
#### Scenario: A tall paste grows the frame
|
||||
|
||||
@@ -280,6 +286,12 @@ The frame SHALL grow to fit its content, between 100 and 20000 pixels, using hei
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the frame is 3000 pixels tall and shows no inner scroll bar
|
||||
|
||||
#### Scenario: A short top bar shrinks the frame
|
||||
|
||||
- **GIVEN** a published HTML block holding only a 68 pixel top bar
|
||||
- **WHEN** a visitor opens the page, even if the frame loaded before the page was ready
|
||||
- **THEN** the frame is 68 pixels tall, with no blank space below the bar
|
||||
|
||||
#### Scenario: Another frame cannot resize it
|
||||
|
||||
- **WHEN** a different window posts a height report to the page
|
||||
@@ -570,3 +582,211 @@ When a save or publish is refused on a block field, the editor SHALL select that
|
||||
- **GIVEN** a page from the Event sign-up template
|
||||
- **WHEN** staff save without choosing the form's event
|
||||
- **THEN** the form section is selected and outlined and the panel shows the message at the Event field
|
||||
|
||||
### Requirement: Hero With A Sign-Up Form
|
||||
|
||||
A HERO block MAY name an event. When it does, the hero SHALL show Co-Lite's sign-up form for that event in a card beside its heading, text and button on wide screens, and below them on narrow screens. The hero's form SHALL follow every rule of the FORM block (see "The Form Block Registers For An Event" and "The Form Block Closes With Its Event"). A HERO block without an event SHALL show no form.
|
||||
|
||||
#### Scenario: Sign up from the hero
|
||||
|
||||
- **GIVEN** page `/p/INS/hotel-technology` has a HERO block whose event is `INS website enquiries`
|
||||
- **WHEN** a new visitor submits the form in the hero from a URL with `utm_source=facebook`
|
||||
- **THEN** a new lead and an event lead with source Web page, no salesperson and UTM source `facebook` are created
|
||||
|
||||
#### Scenario: Hero form closes with its event
|
||||
|
||||
- **GIVEN** the HERO block's event ended yesterday
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the hero still shows its heading and text, and its form area says sign-up is closed
|
||||
|
||||
#### Scenario: Hero without an event
|
||||
|
||||
- **WHEN** a visitor opens a page whose HERO block names no event
|
||||
- **THEN** the hero shows no form
|
||||
- **AND** a submit addressed to that block is refused as not found
|
||||
|
||||
#### Scenario: Pick the hero's event in the editor
|
||||
|
||||
- **GIVEN** staff editing a page with a HERO block
|
||||
- **WHEN** they pick `INS website enquiries` under the hero's sign-up form setting
|
||||
- **THEN** the canvas shows the form card beside the hero text
|
||||
- **AND** choosing "No form" removes it
|
||||
|
||||
### Requirement: Full-Width Hero
|
||||
|
||||
A HERO block MAY be marked full width. A full-width hero SHALL span the whole window with square corners, show its heading larger and centred top to bottom in the hero's opening height (not beside a long form), and use a shade that is darker on the text side than on the far side. A hero that is not marked full width SHALL look as it did before. The server SHALL refuse a `fullWidth` value that is not true or false.
|
||||
|
||||
#### Scenario: Hero runs edge to edge under a Custom HTML top bar
|
||||
|
||||
- **GIVEN** page `/p/INS/hotel-technology` with a Custom HTML top bar followed by a full-width HERO with an image and an event
|
||||
- **WHEN** a visitor opens the page in a 1280 px window
|
||||
- **THEN** the hero spans the full window width
|
||||
- **AND** the form card sits beside the heading
|
||||
|
||||
#### Scenario: Existing hero unchanged
|
||||
|
||||
- **WHEN** a visitor opens a page whose HERO block is not marked full width
|
||||
- **THEN** the hero sits inside the page width with rounded corners, as before
|
||||
|
||||
#### Scenario: Turn on full width in the editor
|
||||
|
||||
- **GIVEN** staff editing a page with a HERO block
|
||||
- **WHEN** they switch on "Full width" in the hero's settings
|
||||
- **THEN** the canvas shows the hero across the full width
|
||||
|
||||
### Requirement: Full-Width Blocks Join Without Gaps
|
||||
|
||||
A full-width HERO, a Custom HTML block, and a block with a non-default look SHALL join with no gap when two of them are next to each other. Other blocks SHALL keep their usual spacing.
|
||||
|
||||
#### Scenario: Top bar runs straight into the hero
|
||||
|
||||
- **GIVEN** a Custom HTML top bar followed by a full-width HERO
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the hero starts directly under the top bar, with no gap
|
||||
|
||||
#### Scenario: Dark call to action runs into a dark footer
|
||||
|
||||
- **GIVEN** a CTA block with the Dark look followed by a text block with the Dark look
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the two bands join with no gap between them
|
||||
|
||||
### Requirement: Hero Points
|
||||
|
||||
A HERO block MAY carry up to 6 points, each a non-empty title of at most 80 characters, with no icon and no text. The hero SHALL show its points as a bulleted list under its text. The server SHALL refuse more than 6 points, an empty or over-long point, and a point with an icon or text, naming the field.
|
||||
|
||||
#### Scenario: Points under the hero text
|
||||
|
||||
- **GIVEN** a HERO block with points "One accountable partner instead of five vendors" and "Local support team in Malaysia"
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** both points show as a bulleted list under the hero text
|
||||
|
||||
#### Scenario: Too many points refused
|
||||
|
||||
- **WHEN** staff save a HERO block with 7 points
|
||||
- **THEN** the save is refused at `blocks[n].cards`
|
||||
|
||||
### Requirement: Hero Form Heading
|
||||
|
||||
A HERO block with an event MAY carry a form heading of at most 80 characters and a form text of at most 200 characters. The hero SHALL show them at the top of its form card, above the form. The server SHALL refuse either on a hero without an event. On the canvas, staff SHALL be able to type both in place.
|
||||
|
||||
#### Scenario: Card shows its heading
|
||||
|
||||
- **GIVEN** a HERO block with an event, form heading "Get a free consultation" and form text "Tell us about your property. It takes under a minute."
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the form card starts with that heading and text, followed by the form
|
||||
|
||||
#### Scenario: Form heading without a form refused
|
||||
|
||||
- **WHEN** staff save a HERO block with a form heading and no event
|
||||
- **THEN** the save is refused at `blocks[n].formHeading`
|
||||
|
||||
### Requirement: Image Upload For Custom HTML
|
||||
|
||||
A Custom HTML block's panel in the editor SHALL offer an image upload for the page's company, under the same checks as other page images. On success it SHALL show the image's preview and its public link with a copy button; on refusal it SHALL show the reason. The upload SHALL NOT change the block's HTML.
|
||||
|
||||
#### Scenario: Upload an image for the HTML
|
||||
|
||||
- **GIVEN** staff editing an INS page with a Custom HTML block
|
||||
- **WHEN** they choose `lobby.webp` under "Upload image" in that block's panel
|
||||
- **THEN** the image is stored for INS and the panel shows its preview and the link `/api/public/page-images/<id>`
|
||||
- **AND** "Copy link" copies that link, and the block's HTML is unchanged
|
||||
|
||||
#### Scenario: Refused upload
|
||||
|
||||
- **WHEN** staff choose a 3 MB JPEG under "Upload image"
|
||||
- **THEN** the panel shows that the image is too large, and no link appears
|
||||
|
||||
#### Scenario: New page without a company
|
||||
|
||||
- **GIVEN** a super admin's new page with no company chosen
|
||||
- **WHEN** they choose a file under "Upload image"
|
||||
- **THEN** nothing is uploaded and the panel asks them to choose a company
|
||||
|
||||
### Requirement: Compact Landing-Page Form
|
||||
|
||||
A landing page's sign-up form, in a FORM block or a hero, SHALL show name, mobile, email and company, the event's interests as one optional dropdown, the privacy notice folded behind a single line that opens it in full, and the consent box. It SHALL NOT show a job-title field. QR, invitation and customer sign-up forms SHALL keep their full layout.
|
||||
|
||||
#### Scenario: Short form on the page
|
||||
|
||||
- **GIVEN** a page whose hero has an event with five interests
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** the form shows name, mobile, email, company, a "Service interested in" dropdown and the consent box, with no job title and no interest checkboxes
|
||||
- **AND** the privacy notice is folded behind "How we use your details"
|
||||
|
||||
#### Scenario: Pick one service
|
||||
|
||||
- **WHEN** the visitor chooses "Cloud IP PABX" in the dropdown and submits
|
||||
- **THEN** the submission carries that one interest
|
||||
|
||||
#### Scenario: Read the notice
|
||||
|
||||
- **WHEN** the visitor opens "How we use your details"
|
||||
- **THEN** the full English and Malay notice shows above the consent box
|
||||
|
||||
#### Scenario: QR form unchanged
|
||||
|
||||
- **WHEN** a visitor opens an event's QR sign-up form
|
||||
- **THEN** it shows job title, the interest checkboxes and the full notice as before
|
||||
|
||||
### Requirement: Thank-You Text On Landing Forms
|
||||
|
||||
A FORM block, and a HERO block with an event, MAY carry a thank-you text of at most 200 characters. After a visitor signs up through that block's form, the page SHALL show the text, with contact links, under the thank-you heading. Without it, the thank-you SHALL look as before. The server SHALL refuse an over-long thank-you text, or one on a HERO without an event.
|
||||
|
||||
#### Scenario: Visitor sees the page's thank-you text with a call link
|
||||
|
||||
- **GIVEN** page `/p/INS/hotel-technology-native` whose hero form has the thank-you text "Prefer to talk now? Call +60 12-833 2775."
|
||||
- **WHEN** a visitor signs up through the hero form
|
||||
- **THEN** the page shows the thank-you heading and "Prefer to talk now? Call +60 12-833 2775."
|
||||
- **AND** "+60 12-833 2775" is a link to `tel:+60128332775`
|
||||
|
||||
#### Scenario: No thank-you text keeps today's message
|
||||
|
||||
- **WHEN** a visitor signs up through a FORM block without a thank-you text
|
||||
- **THEN** the page shows only the thank-you heading and the "register another" button, as before
|
||||
|
||||
#### Scenario: Thank-you text on a hero without a form is refused
|
||||
|
||||
- **WHEN** staff save a HERO block without an event but with a thank-you text
|
||||
- **THEN** the save is refused with the reason naming the hero's thank-you field
|
||||
|
||||
#### Scenario: Set the thank-you text in the editor
|
||||
|
||||
- **GIVEN** staff editing a hero that has an event
|
||||
- **WHEN** they type a thank-you text in the hero's settings and save
|
||||
- **THEN** the page keeps the text
|
||||
- **AND** choosing "No form" on the hero clears it
|
||||
|
||||
### Requirement: Footer Block
|
||||
|
||||
A page MAY hold FOOTER blocks: 1 to 4 columns, each a required title (80 characters) and text (300 characters), and an optional legal line (300 characters). The page SHALL show the columns side by side on wide screens and stacked on phones, keep line breaks, show contact links in the column text, and put the legal line under a thin divider. A new footer SHALL start with the dark look. The server SHALL refuse a footer that breaks these limits, or that has a heading or a column icon.
|
||||
|
||||
#### Scenario: Visitor sees a three-column footer with links
|
||||
|
||||
- **GIVEN** a published page whose footer has the columns "Infinity Networks Security Sdn Bhd", "Talk to us" with "+603-7623 9807" and "info@infinitynetworks.com.my", and "Website" with "www.infinitynetworks.com.my", and a legal line
|
||||
- **WHEN** a visitor opens the page in a 1280 px window
|
||||
- **THEN** the three columns sit side by side on a dark band
|
||||
- **AND** the phone links to `tel:+60376239807`, the email to `mailto:info@infinitynetworks.com.my`, and the website to `https://www.infinitynetworks.com.my`
|
||||
- **AND** the legal line sits under a divider
|
||||
|
||||
#### Scenario: Add a footer in the editor
|
||||
|
||||
- **GIVEN** staff editing a page
|
||||
- **WHEN** they add a Footer section
|
||||
- **THEN** the canvas shows a dark footer with two empty columns to type into
|
||||
- **AND** they can add columns up to 4 and type the legal line
|
||||
|
||||
#### Scenario: Footer with five columns is refused
|
||||
|
||||
- **WHEN** a page is saved with a footer of 5 columns
|
||||
- **THEN** the save is refused with the reason naming the footer's columns
|
||||
|
||||
### Requirement: Contact Links In Plain Text
|
||||
|
||||
Where this spec says text shows contact links, the page SHALL show phone numbers that start with `+` as `tel:` links holding only `+` and digits, email addresses as `mailto:` links, and `https://` or `www.` addresses as `https://` links that open in a new tab. Everything else SHALL stay plain text, never HTML.
|
||||
|
||||
#### Scenario: Text with markup stays text
|
||||
|
||||
- **GIVEN** a footer column text "<b>Call</b> +60 12-833 2775"
|
||||
- **WHEN** a visitor opens the page
|
||||
- **THEN** "<b>Call</b>" shows as written
|
||||
- **AND** "+60 12-833 2775" links to `tel:+60128332775`
|
||||
@@ -1,29 +1,33 @@
|
||||
"use client";
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
import { useState, type ReactNode } from "react";
|
||||
import { ArrowDown, ArrowUp, Plus, Trash2 } from "lucide-react";
|
||||
import { BLOCK_LABELS, ICONS, LOOKS, imageSrc, type CmsBlock, type CmsCard, type Look } from "@/app/lib/cmsPages";
|
||||
import { Button } from "@/app/components/ui/button";
|
||||
import { Input } from "@/app/components/ui/input";
|
||||
import { Label } from "@/app/components/ui/label";
|
||||
import { Switch } from "@/app/components/ui/switch";
|
||||
import { Textarea } from "@/app/components/ui/textarea";
|
||||
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
||||
import { RichTextEditor } from "./RichTextEditor";
|
||||
import { CopyAddress } from "./CopyAddress";
|
||||
|
||||
// One block of the page editor, ported from babyboo's BlockFields: a fieldset with move/remove and its type's fields.
|
||||
|
||||
/** Field paths (relative to the block) each type shows inline; any other error shows at the block's top. Every type also shows "anchor". */
|
||||
const INLINE: Record<string, string[]> = {
|
||||
HERO: ["imageId", "heading", "text", "buttonLabel", "buttonUrl"],
|
||||
HERO: ["imageId", "heading", "text", "buttonLabel", "buttonUrl", "eventUuid", "fullWidth", "formHeading", "formText", "thanksText", "cards"],
|
||||
RICH_TEXT: ["html"],
|
||||
IMAGE_TEXT: ["imageId", "imagePosition", "heading", "html", "buttonLabel", "buttonUrl"],
|
||||
FAQ: ["heading", "items"],
|
||||
FORM: ["heading", "eventUuid"],
|
||||
IMAGE_TEXT: ["imageId", "imagePosition", "eyebrow", "heading", "html", "buttonLabel", "buttonUrl"],
|
||||
FAQ: ["eyebrow", "heading", "items"],
|
||||
FORM: ["heading", "eventUuid", "thanksText"],
|
||||
HTML: ["html"],
|
||||
FEATURES: ["heading", "text", "cards"],
|
||||
STEPS: ["heading", "cards"],
|
||||
FEATURES: ["eyebrow", "heading", "text", "cards"],
|
||||
STEPS: ["eyebrow", "heading", "cards"],
|
||||
TRUST: ["cards"],
|
||||
CTA: ["heading", "text", "buttonLabel", "buttonUrl"],
|
||||
CTA: ["eyebrow", "heading", "text", "buttonLabel", "buttonUrl"],
|
||||
FOOTER: ["cards", "text"],
|
||||
TOPBAR: ["buttonLabel", "buttonUrl"],
|
||||
};
|
||||
const LISTED = /^(items\[\d+\]\.(question|answer)|cards\[\d+\]\.(icon|title|text))$/;
|
||||
|
||||
@@ -34,10 +38,14 @@ const ICON_LABELS: Record<string, string> = {
|
||||
"shield-check": "PagesIconShieldCheck", cloud: "PagesIconCloud", wrench: "PagesIconWrench", headset: "PagesIconHeadset",
|
||||
users: "PagesIconUsers", calendar: "PagesIconCalendar", star: "PagesIconStar",
|
||||
};
|
||||
const CARD_KINDS: Record<string, { legend: string; add: string; icon: boolean; text: boolean; empty: CmsCard }> = {
|
||||
FEATURES: { legend: "PagesCardN", add: "PagesAddCard", icon: true, text: true, empty: { icon: "star", title: "", text: "" } },
|
||||
STEPS: { legend: "PagesStepN", add: "PagesAddStep", icon: false, text: true, empty: { title: "", text: "" } },
|
||||
TRUST: { legend: "PagesItemN", add: "PagesAddItem", icon: false, text: false, empty: { title: "" } },
|
||||
// add-hero-full-width: a hero's points are title-only cards, and it may have none.
|
||||
// add-landing-thanks-and-footer: a footer's columns are title-and-text cards, 1 to 4.
|
||||
const CARD_KINDS: Record<string, { legend: string; add: string; icon: boolean; text: boolean; min: number; max: number; empty: CmsCard }> = {
|
||||
FEATURES: { legend: "PagesCardN", add: "PagesAddCard", icon: true, text: true, min: 2, max: 6, empty: { icon: "star", title: "", text: "" } },
|
||||
STEPS: { legend: "PagesStepN", add: "PagesAddStep", icon: false, text: true, min: 2, max: 6, empty: { title: "", text: "" } },
|
||||
TRUST: { legend: "PagesItemN", add: "PagesAddItem", icon: false, text: false, min: 2, max: 6, empty: { title: "" } },
|
||||
HERO: { legend: "PagesPointN", add: "PagesAddPoint", icon: false, text: false, min: 0, max: 6, empty: { title: "" } },
|
||||
FOOTER: { legend: "PagesColumnN", add: "PagesAddColumn", icon: false, text: true, min: 1, max: 4, empty: { title: "", text: "" } },
|
||||
};
|
||||
const SELECT = "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm disabled:cursor-not-allowed disabled:opacity-50";
|
||||
|
||||
@@ -76,6 +84,8 @@ export function BlockFields(props: {
|
||||
onMove: (delta: -1 | 1) => void;
|
||||
onRemove: () => void;
|
||||
onChooseImage: (file: File) => void;
|
||||
/** Uploads an image for a Custom HTML block at once (add-html-image-upload); rejects with the reason to show. */
|
||||
onUploadImage?: (file: File) => Promise<number>;
|
||||
}) {
|
||||
const { block, id, index, count, errors, saving, events, pendingImage, onChange, onMove, onRemove } = props;
|
||||
const t = useT();
|
||||
@@ -83,7 +93,7 @@ export function BlockFields(props: {
|
||||
const fid = (name: string) => `block-${id}-${name}`;
|
||||
const topErrors = Object.entries(errors).filter(([path]) => path !== "anchor" && path !== "look" && !INLINE[block.type]?.includes(path) && !LISTED.test(path));
|
||||
|
||||
const text = (name: "heading" | "text" | "buttonLabel" | "buttonUrl" | "anchor", labelCode: string) => (
|
||||
const text = (name: "heading" | "text" | "buttonLabel" | "buttonUrl" | "anchor" | "formHeading" | "formText" | "thanksText" | "eyebrow", labelCode: string) => (
|
||||
<Field id={fid(name)} label={t(labelCode)} error={errors[name]}>
|
||||
<Input id={fid(name)} value={block[name] ?? ""} disabled={saving} aria-invalid={!!errors[name]} onChange={(e) => set({ [name]: e.target.value })} />
|
||||
</Field>
|
||||
@@ -95,7 +105,39 @@ export function BlockFields(props: {
|
||||
</Field>
|
||||
);
|
||||
|
||||
// add-html-image-upload: this panel's uploads, newest first; their links are pasted into the HTML by hand.
|
||||
const [uploads, setUploads] = useState<number[]>([]);
|
||||
const [uploadError, setUploadError] = useState<string | null>(null);
|
||||
const [uploading, setUploading] = useState(false);
|
||||
async function upload(file: File) {
|
||||
if (!props.onUploadImage) return;
|
||||
setUploadError(null);
|
||||
setUploading(true);
|
||||
try {
|
||||
const imageId = await props.onUploadImage(file);
|
||||
setUploads((u) => [imageId, ...u]);
|
||||
} catch (err) {
|
||||
setUploadError(err instanceof Error ? err.message : String(err));
|
||||
} finally {
|
||||
setUploading(false);
|
||||
}
|
||||
}
|
||||
|
||||
const preview = pendingImage?.preview ?? (block.imageId ? imageSrc(block.imageId) : undefined);
|
||||
// The FORM block's event, and the hero's optional sign-up form (add-hero-signup-form): the same picker and hint.
|
||||
const eventPicker = (labelCode: string, emptyCode: string) => (
|
||||
<Field id={fid("event")} label={t(labelCode)} error={errors.eventUuid}>
|
||||
<select id={fid("event")} className={SELECT} value={block.eventUuid ?? ""} disabled={saving} aria-invalid={!!errors.eventUuid}
|
||||
onChange={(e) => set(e.target.value ? { eventUuid: e.target.value } : { eventUuid: null, formHeading: undefined, formText: undefined, thanksText: undefined })}>
|
||||
<option value="">{t(emptyCode)}</option>
|
||||
{events.map((ev) => <option key={ev.uuid} value={ev.uuid}>{ev.name}</option>)}
|
||||
{block.eventUuid && !events.some((ev) => ev.uuid === block.eventUuid) ? (
|
||||
<option value={block.eventUuid}>{t("PagesUnavailableEvent")}</option>
|
||||
) : null}
|
||||
</select>
|
||||
<p className="text-xs text-muted-foreground">{t("PagesFormEventHint")}</p>
|
||||
</Field>
|
||||
);
|
||||
const image = (
|
||||
<Field id={fid("image")} label={t("PagesImage")} error={errors.imageId}>
|
||||
<Input
|
||||
@@ -126,8 +168,8 @@ export function BlockFields(props: {
|
||||
<>
|
||||
{cards.map((card, i) => {
|
||||
const err = (f: string) => errors[`cards[${i}].${f}`];
|
||||
const cardField = (f: "title" | "text", labelCode: string, multiline: boolean) => (
|
||||
<Field id={fid(`c${i}${f}`)} label={t(labelCode)} error={err(f)}>
|
||||
const cardField = (f: "title" | "text", label: string, multiline: boolean) => (
|
||||
<Field id={fid(`c${i}${f}`)} label={label} error={err(f)}>
|
||||
{multiline
|
||||
? <Textarea id={fid(`c${i}${f}`)} rows={2} value={card[f] ?? ""} disabled={saving} aria-invalid={!!err(f)}
|
||||
onChange={(e) => setCards(cards.map((c, j) => (j === i ? { ...c, [f]: e.target.value } : c)))} />
|
||||
@@ -146,18 +188,18 @@ export function BlockFields(props: {
|
||||
</select>
|
||||
</Field>
|
||||
) : null}
|
||||
{cardField("title", "PagesCardTitle", false)}
|
||||
{kind.text ? cardField("text", "PagesCardText", true) : null}
|
||||
{cardField("title", kind.min ? t("PagesCardTitle") : t(kind.legend, { number: i + 1 }), false)}
|
||||
{kind.text ? cardField("text", t("PagesCardText"), true) : null}
|
||||
<div className="flex flex-wrap gap-1">
|
||||
<Button type="button" variant="ghost" size="sm" disabled={saving || i === 0} onClick={() => moveCard(i, -1)}>{t("PagesMoveUp")}</Button>
|
||||
<Button type="button" variant="ghost" size="sm" disabled={saving || i === cards.length - 1} onClick={() => moveCard(i, 1)}>{t("PagesMoveDown")}</Button>
|
||||
<Button type="button" variant="ghost" size="sm" disabled={saving || cards.length <= 2} onClick={() => setCards(cards.filter((_, j) => j !== i))}>{t("PagesRemoveCard")}</Button>
|
||||
<Button type="button" variant="ghost" size="sm" disabled={saving || cards.length <= kind.min} onClick={() => setCards(cards.filter((_, j) => j !== i))}>{t("PagesRemoveCard")}</Button>
|
||||
</div>
|
||||
</fieldset>
|
||||
);
|
||||
})}
|
||||
<FieldError message={errors.cards} />
|
||||
<Button type="button" variant="outline" size="sm" disabled={saving || cards.length >= 6} onClick={() => setCards([...cards, { ...kind.empty }])}>
|
||||
<Button type="button" variant="outline" size="sm" disabled={saving || cards.length >= kind.max} onClick={() => setCards([...cards, { ...kind.empty }])}>
|
||||
<Plus aria-hidden="true" className="size-4" />
|
||||
{t(kind.add)}
|
||||
</Button>
|
||||
@@ -190,6 +232,19 @@ export function BlockFields(props: {
|
||||
{text("text", "PagesText")}
|
||||
{text("buttonLabel", "PagesButtonLabel")}
|
||||
{text("buttonUrl", "PagesButtonLink")}
|
||||
<div className="flex items-center gap-2">
|
||||
<Switch id={fid("fullWidth")} checked={!!block.fullWidth} disabled={saving} onCheckedChange={(on) => set({ fullWidth: on || undefined })} />
|
||||
<Label htmlFor={fid("fullWidth")}>{t("PagesFullWidth")}</Label>
|
||||
</div>
|
||||
{cardList}
|
||||
{eventPicker("PagesHeroForm", "PagesNoForm")}
|
||||
{block.eventUuid ? (
|
||||
<>
|
||||
{text("formHeading", "PagesFormHeading")}
|
||||
{text("formText", "PagesFormText")}
|
||||
{text("thanksText", "PagesThanksText")}
|
||||
</>
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -204,6 +259,7 @@ export function BlockFields(props: {
|
||||
<option value="RIGHT">{t("PagesImageRight")}</option>
|
||||
</select>
|
||||
</Field>
|
||||
{text("eyebrow", "PagesEyebrow")}
|
||||
{text("heading", "PagesHeading")}
|
||||
{richText("PagesText")}
|
||||
{text("buttonLabel", "PagesButtonLabel")}
|
||||
@@ -213,6 +269,7 @@ export function BlockFields(props: {
|
||||
|
||||
{block.type === "FAQ" && (
|
||||
<>
|
||||
{text("eyebrow", "PagesEyebrow")}
|
||||
{text("heading", "PagesHeading")}
|
||||
{items.map((item, i) => (
|
||||
<div key={i} className="space-y-2 rounded-md border p-3">
|
||||
@@ -245,26 +302,36 @@ export function BlockFields(props: {
|
||||
<p className="text-xs text-muted-foreground">{t("PagesHtmlHint")}</p>
|
||||
</Field>
|
||||
)}
|
||||
{block.type === "HTML" && props.onUploadImage && (
|
||||
<Field id={fid("upload")} label={t("PagesUploadImage")} error={uploadError ?? undefined}>
|
||||
<Input id={fid("upload")} type="file" accept="image/png,image/jpeg,image/webp" disabled={saving || uploading}
|
||||
onChange={(e) => {
|
||||
const file = e.target.files?.[0];
|
||||
e.target.value = "";
|
||||
if (file) void upload(file);
|
||||
}} />
|
||||
<p className="text-xs text-muted-foreground">{t("PagesUploadImageHint")}</p>
|
||||
{uploads.map((imageId) => (
|
||||
<div key={imageId} className="flex items-center gap-2 rounded-md border p-2">
|
||||
{/* eslint-disable-next-line @next/next/no-img-element -- an uploaded image of unknown size */}
|
||||
<img src={imageSrc(imageId)} alt={t("PagesImagePreview")} className="size-12 rounded object-cover" />
|
||||
<CopyAddress address={imageSrc(imageId)} relative />
|
||||
</div>
|
||||
))}
|
||||
</Field>
|
||||
)}
|
||||
|
||||
{block.type === "FORM" && (
|
||||
<>
|
||||
{text("heading", "PagesHeading")}
|
||||
<Field id={fid("event")} label={t("PagesFormEvent")} error={errors.eventUuid}>
|
||||
<select id={fid("event")} className={SELECT} value={block.eventUuid ?? ""} disabled={saving} aria-invalid={!!errors.eventUuid}
|
||||
onChange={(e) => set({ eventUuid: e.target.value || null })}>
|
||||
<option value="">{t("PagesChooseEvent")}</option>
|
||||
{events.map((ev) => <option key={ev.uuid} value={ev.uuid}>{ev.name}</option>)}
|
||||
{block.eventUuid && !events.some((ev) => ev.uuid === block.eventUuid) ? (
|
||||
<option value={block.eventUuid}>{t("PagesUnavailableEvent")}</option>
|
||||
) : null}
|
||||
</select>
|
||||
<p className="text-xs text-muted-foreground">{t("PagesFormEventHint")}</p>
|
||||
</Field>
|
||||
{eventPicker("PagesFormEvent", "PagesChooseEvent")}
|
||||
{text("thanksText", "PagesThanksText")}
|
||||
</>
|
||||
)}
|
||||
|
||||
{block.type === "FEATURES" && (
|
||||
<>
|
||||
{text("eyebrow", "PagesEyebrow")}
|
||||
{text("heading", "PagesHeading")}
|
||||
<Field id={fid("text")} label={t("PagesIntro")} error={errors.text}>
|
||||
<Textarea id={fid("text")} rows={2} value={block.text ?? ""} disabled={saving} aria-invalid={!!errors.text} onChange={(e) => set({ text: e.target.value })} />
|
||||
@@ -275,6 +342,7 @@ export function BlockFields(props: {
|
||||
|
||||
{block.type === "STEPS" && (
|
||||
<>
|
||||
{text("eyebrow", "PagesEyebrow")}
|
||||
{text("heading", "PagesHeading")}
|
||||
{cardList}
|
||||
</>
|
||||
@@ -282,8 +350,24 @@ export function BlockFields(props: {
|
||||
|
||||
{block.type === "TRUST" && cardList}
|
||||
|
||||
{/* add-landing-page-polish: the top bar's button; its logo comes from the company. */}
|
||||
{block.type === "TOPBAR" && (
|
||||
<>
|
||||
{text("buttonLabel", "PagesButtonLabel")}
|
||||
{text("buttonUrl", "PagesButtonLink")}
|
||||
</>
|
||||
)}
|
||||
|
||||
{block.type === "FOOTER" && (
|
||||
<>
|
||||
{cardList}
|
||||
{text("text", "PagesFooterLegal")}
|
||||
</>
|
||||
)}
|
||||
|
||||
{block.type === "CTA" && (
|
||||
<>
|
||||
{text("eyebrow", "PagesEyebrow")}
|
||||
{text("heading", "PagesHeading")}
|
||||
{text("text", "PagesText")}
|
||||
{text("buttonLabel", "PagesButtonLabel")}
|
||||
@@ -291,7 +375,7 @@ export function BlockFields(props: {
|
||||
</>
|
||||
)}
|
||||
|
||||
{block.type !== "HTML" && (
|
||||
{block.type !== "HTML" && block.type !== "TOPBAR" && (
|
||||
<Field id={fid("look")} label={t("PagesLook")} error={errors.look}>
|
||||
<select id={fid("look")} className={SELECT} value={block.look ?? "DEFAULT"} disabled={saving} aria-invalid={!!errors.look}
|
||||
onChange={(e) => set({ look: e.target.value as Look })}>
|
||||
|
||||
@@ -58,6 +58,18 @@ describe("LandingPage: Custom HTML", () => {
|
||||
expect(frame().style.height).toBe("2400px");
|
||||
});
|
||||
|
||||
// add-hero-full-width: the frame's first report can arrive before the page listens, so the page asks once it does.
|
||||
it("asks its frame for a height report once it listens, and again when the frame loads", () => {
|
||||
const sealed = { postMessage: vi.fn() };
|
||||
const getter = vi.spyOn(HTMLIFrameElement.prototype, "contentWindow", "get").mockReturnValue(sealed as unknown as Window);
|
||||
onTestFinished(() => getter.mockRestore());
|
||||
render(<LandingPage company={company} page={page([HTML])} />);
|
||||
expect(sealed.postMessage).toHaveBeenCalledWith({ type: "colite-frame-ask" }, "*");
|
||||
sealed.postMessage.mockClear();
|
||||
act(() => { frame().dispatchEvent(new Event("load")); });
|
||||
expect(sealed.postMessage).toHaveBeenCalledWith({ type: "colite-frame-ask" }, "*");
|
||||
});
|
||||
|
||||
it("grows inside another document too: it listens on its own document's window (add-page-visual-editor)", () => {
|
||||
const host = document.createElement("iframe");
|
||||
document.body.appendChild(host);
|
||||
@@ -80,6 +92,7 @@ describe("LandingPage: Custom HTML", () => {
|
||||
render(<LandingPage company={company} page={page([HTML], true)} />);
|
||||
const title = screen.getByRole("heading", { level: 1, name: "Hotel day" });
|
||||
expect(title.parentElement!.className).not.toMatch(/space-y/);
|
||||
expect(frame().parentElement!.className).toMatch(/space-y/);
|
||||
// add-hero-full-width: spacing is a top margin on each block row after the first, so the first row has none.
|
||||
expect(frame().closest("main > div > div")).not.toHaveClass("mt-10");
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { render, screen, within } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { describe, it, expect, vi, beforeEach } from "vitest";
|
||||
import { LandingPage, type PublicBlock } from "./CmsBlocks";
|
||||
@@ -70,6 +70,97 @@ describe("LandingPage", () => {
|
||||
expect(JSON.parse(String((init as RequestInit).body))).toMatchObject({ name: "Tan", utmSource: "fb", utmMedium: "cpc", utmCampaign: "jan" });
|
||||
expect(await screen.findByText("Sign-up is closed.")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// add-hero-signup-form: a hero with an event carries the sign-up form beside its text.
|
||||
it("a hero with an event shows the sign-up form inside the hero and posts to the hero's block", async () => {
|
||||
window.history.replaceState(null, "", "/p/INS/hotel?utm_source=fb");
|
||||
const fetchMock = vi.spyOn(globalThis, "fetch").mockResolvedValueOnce(new Response(JSON.stringify({ code: "FORM_CLOSED" }), { status: 409 }));
|
||||
const user = userEvent.setup();
|
||||
render(<LandingPage company={company} page={page([{ type: "HERO", heading: "One partner", eventUuid: "77", form: info }])} />);
|
||||
const hero = screen.getByRole("heading", { name: "One partner" }).closest("section")!;
|
||||
expect(hero).toContainElement(screen.getByLabelText("Your name"));
|
||||
await user.type(screen.getByLabelText("Your name"), "Tan");
|
||||
await user.type(screen.getByLabelText("Mobile number"), "0125550101");
|
||||
await user.click(screen.getByRole("checkbox"));
|
||||
await user.click(screen.getByRole("button", { name: "Register" }));
|
||||
expect(fetchMock.mock.calls[0][0]).toBe("/api/public/pages/INS/hotel/form/0");
|
||||
});
|
||||
|
||||
it("a hero whose form closed keeps its text and says so; a hero without an event has no form", () => {
|
||||
const { unmount } = render(<LandingPage company={company} page={page([{ type: "HERO", heading: "One partner", eventUuid: "77", closed: true }])} />);
|
||||
const hero = screen.getByRole("heading", { name: "One partner" }).closest("section")!;
|
||||
expect(hero).toHaveTextContent("Sign-up is closed.");
|
||||
unmount();
|
||||
render(<LandingPage company={company} page={page([{ type: "HERO", heading: "Plain" }])} />);
|
||||
expect(screen.queryByText("Sign-up is closed.")).not.toBeInTheDocument();
|
||||
expect(screen.queryByLabelText("Your name")).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("the preview of a hero with an event shows the form's note in the hero", () => {
|
||||
render(<LandingPage company={company} page={page([{ type: "HERO", heading: "One partner", eventUuid: "77" }])} preview />);
|
||||
expect(screen.getByRole("heading", { name: "One partner" }).closest("section"))
|
||||
.toHaveTextContent("The sign-up form shows here on the published page.");
|
||||
});
|
||||
});
|
||||
|
||||
// add-hero-full-width: edge-to-edge hero, points, the form card's heading, and flush full-width neighbours.
|
||||
describe("LandingPage full-width hero", () => {
|
||||
const ins = { type: "HERO" as const, heading: "One partner", fullWidth: true, eventUuid: "77", closed: true,
|
||||
cards: [{ title: "One accountable partner" }, { title: "Local support team in Malaysia" }],
|
||||
formHeading: "Get a free consultation", formText: "Tell us about your property." };
|
||||
|
||||
it("runs outside the page width with square corners; a plain hero stays boxed in the page width", () => {
|
||||
render(<LandingPage company={company} page={page([ins, { type: "HERO", heading: "Boxed" }])} />);
|
||||
const wide = screen.getByRole("heading", { name: "One partner" }).closest("section")!;
|
||||
expect(wide.closest(".max-w-5xl")).toBeNull();
|
||||
expect(wide).not.toHaveClass("rounded-lg");
|
||||
const boxed = screen.getByRole("heading", { name: "Boxed" }).closest("section")!;
|
||||
expect(boxed.closest(".max-w-5xl")).not.toBeNull();
|
||||
expect(boxed).toHaveClass("rounded-lg");
|
||||
});
|
||||
|
||||
it("shows its points as a list under the text", () => {
|
||||
render(<LandingPage company={company} page={page([ins])} />);
|
||||
const hero = screen.getByRole("heading", { name: "One partner" }).closest("section")!;
|
||||
const items = within(hero).getAllByRole("listitem");
|
||||
expect(items.map((li) => li.textContent)).toEqual(["One accountable partner", "Local support team in Malaysia"]);
|
||||
});
|
||||
|
||||
it("starts the form card with its heading and text", () => {
|
||||
render(<LandingPage company={company} page={page([ins])} />);
|
||||
const title = screen.getByRole("heading", { name: "Get a free consultation" });
|
||||
const card = title.parentElement!.parentElement!;
|
||||
expect(card).toHaveTextContent(/^Get a free consultation\s*Tell us about your property\./);
|
||||
expect(card).toHaveTextContent("Sign-up is closed.");
|
||||
});
|
||||
|
||||
it("joins a Custom HTML block and a full-width hero with no gap; other blocks keep theirs", () => {
|
||||
render(<LandingPage company={company} frameBase="/f" page={page([
|
||||
{ type: "HTML", html: "<header>Top</header>" }, ins, { type: "HTML", html: "<p>Rest</p>" }, { type: "RICH_TEXT", html: "<p>After</p>" },
|
||||
])} />);
|
||||
const rows = Array.from(document.querySelector("main > div")!.children);
|
||||
expect(rows.map((r) => r.classList.contains("mt-10"))).toEqual([false, false, false, true]);
|
||||
});
|
||||
});
|
||||
|
||||
// add-compact-landing-form: a page's form is the short one, and coloured bands join.
|
||||
describe("LandingPage compact form and bands", () => {
|
||||
it("a page's form has no job title and a service dropdown", () => {
|
||||
render(<LandingPage company={company} page={page([{ type: "FORM", form: { ...info, interests: [{ id: 3, name: "Cloud IP PABX" }] } }])} />);
|
||||
expect(screen.queryByLabelText("Job title")).not.toBeInTheDocument();
|
||||
expect(screen.getByRole("combobox", { name: "Service interested in (optional)" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("joins a dark call to action and a dark text block with no gap", () => {
|
||||
render(<LandingPage company={company} page={page([
|
||||
{ type: "RICH_TEXT", html: "<p>Intro</p>" },
|
||||
{ type: "CTA", heading: "Talk to us", look: "DARK" },
|
||||
{ type: "RICH_TEXT", html: "<p>Footer</p>", look: "DARK" },
|
||||
])} />);
|
||||
const rows = Array.from(document.querySelector("main > div")!.children);
|
||||
expect(rows.map((r) => r.classList.contains("mt-10"))).toEqual([false, true, false]);
|
||||
expect(rows.slice(1).map((r) => r.querySelector("[data-look]")?.getAttribute("data-look"))).toEqual(["DARK", "DARK"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("utmTags", () => {
|
||||
@@ -77,3 +168,110 @@ describe("utmTags", () => {
|
||||
expect(utmTags("?utm_source=" + "x".repeat(150))).toEqual({ utmSource: "x".repeat(100), utmMedium: undefined, utmCampaign: undefined });
|
||||
});
|
||||
});
|
||||
|
||||
// add-landing-thanks-and-footer: the page's own thank-you text, and the footer block.
|
||||
describe("LandingPage thank-you text and footer", () => {
|
||||
async function signUp() {
|
||||
const user = userEvent.setup();
|
||||
await user.type(screen.getByLabelText("Your name"), "Tan");
|
||||
await user.type(screen.getByLabelText("Mobile number"), "0125550101");
|
||||
await user.click(screen.getByRole("checkbox"));
|
||||
await user.click(screen.getByRole("button", { name: "Register" }));
|
||||
}
|
||||
|
||||
it("a hero form shows its thank-you text after sign-up, with the number as a call link", async () => {
|
||||
vi.spyOn(globalThis, "fetch").mockResolvedValueOnce(new Response("", { status: 201 }));
|
||||
render(<LandingPage company={company} page={page([{ type: "HERO", heading: "One partner", eventUuid: "77", form: info,
|
||||
thanksText: "Prefer to talk now? Call +60 12-833 2775." }])} />);
|
||||
await signUp();
|
||||
const done = await screen.findByRole("status");
|
||||
expect(done).toHaveTextContent("Thank you, you're registered for INS enquiries");
|
||||
expect(done).toHaveTextContent("Prefer to talk now? Call +60 12-833 2775.");
|
||||
expect(within(done).getByRole("link", { name: "+60 12-833 2775" })).toHaveAttribute("href", "tel:+60128332775");
|
||||
});
|
||||
|
||||
it("a form block without a thank-you text keeps today's thank-you", async () => {
|
||||
vi.spyOn(globalThis, "fetch").mockResolvedValueOnce(new Response("", { status: 201 }));
|
||||
render(<LandingPage company={company} page={page([{ type: "FORM", form: info }])} />);
|
||||
await signUp();
|
||||
const done = await screen.findByRole("status");
|
||||
expect(done.querySelector("p")).toBeNull();
|
||||
expect(within(done).getByRole("button", { name: "Register another person" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const footer: PublicBlock = { type: "FOOTER", look: "DARK", text: "© 2026 Infinity Networks Security Sdn Bhd. All rights reserved.", cards: [
|
||||
{ title: "Infinity Networks Security Sdn Bhd", text: "Unit 2-6, Infinity Tower\nPetaling Jaya, Malaysia" },
|
||||
{ title: "Talk to us", text: "+603-7623 9807\ninfo@infinitynetworks.com.my" },
|
||||
{ title: "Website", text: "www.infinitynetworks.com.my" },
|
||||
] };
|
||||
|
||||
it("shows a footer's columns side by side with contact links, and the legal line under a divider", () => {
|
||||
render(<LandingPage company={company} page={page([footer])} />);
|
||||
const foot = screen.getByRole("contentinfo");
|
||||
expect(foot.closest("[data-look]")).toHaveAttribute("data-look", "DARK");
|
||||
const columns = within(foot).getAllByRole("listitem");
|
||||
expect(columns).toHaveLength(3);
|
||||
expect(columns[0].parentElement).toHaveClass("md:grid-cols-3");
|
||||
expect(within(columns[0]).getByText(/Unit 2-6/)).toHaveClass("whitespace-pre-line");
|
||||
expect(within(foot).getByRole("link", { name: "+603-7623 9807" })).toHaveAttribute("href", "tel:+60376239807");
|
||||
expect(within(foot).getByRole("link", { name: "info@infinitynetworks.com.my" })).toHaveAttribute("href", "mailto:info@infinitynetworks.com.my");
|
||||
const site = within(foot).getByRole("link", { name: "www.infinitynetworks.com.my" });
|
||||
expect(site).toHaveAttribute("href", "https://www.infinitynetworks.com.my");
|
||||
expect(site).toHaveAttribute("target", "_blank");
|
||||
expect(site).toHaveAttribute("rel", "noopener noreferrer");
|
||||
expect(within(foot).getByText(/^© 2026/)).toHaveClass("border-t");
|
||||
});
|
||||
|
||||
it("keeps markup in footer text as text", () => {
|
||||
render(<LandingPage company={company} page={page([{ type: "FOOTER", cards: [{ title: "Call", text: "<b>Call</b> +60 12-833 2775" }] }])} />);
|
||||
const foot = screen.getByRole("contentinfo");
|
||||
expect(foot.querySelector("b")).toBeNull();
|
||||
expect(foot).toHaveTextContent("<b>Call</b> +60 12-833 2775");
|
||||
expect(within(foot).getByRole("link", { name: "+60 12-833 2775" })).toHaveAttribute("href", "tel:+60128332775");
|
||||
});
|
||||
});
|
||||
|
||||
// add-landing-page-polish: the top bar, section labels and serif headings.
|
||||
describe("LandingPage polish", () => {
|
||||
const bar: PublicBlock = { type: "TOPBAR", buttonLabel: "Get My Free Consultation", buttonUrl: "#consult" };
|
||||
const hero: PublicBlock = { type: "HERO", heading: "One partner", fullWidth: true };
|
||||
|
||||
it("a top bar shows the logo and its button, stays at the top, and joins the hero", () => {
|
||||
render(<LandingPage company={company} page={{ ...page([bar, hero]), hideHeader: true }} />);
|
||||
const top = screen.getByRole("banner");
|
||||
expect(within(top).getByRole("img", { name: "INS Sdn Bhd" })).toHaveAttribute("src", "/api/public/page-images/4");
|
||||
expect(within(top).getByRole("link", { name: "Get My Free Consultation" })).toHaveAttribute("href", "#consult");
|
||||
// The row sticks, not the header: a sticky element only sticks inside its parent.
|
||||
expect(top.closest("main > div > div")).toHaveClass("sticky", "top-0");
|
||||
expect(top.closest(".max-w-5xl")).toBeNull();
|
||||
expect(screen.getAllByRole("banner")).toHaveLength(1);
|
||||
const rows = Array.from(document.querySelector("main > div")!.children);
|
||||
expect(rows.map((r) => r.classList.contains("mt-10"))).toEqual([false, false]);
|
||||
});
|
||||
|
||||
it("a top bar without a logo shows the company name, and no button without one", () => {
|
||||
render(<LandingPage company={{ ...company, logoImageId: null }} page={{ ...page([{ type: "TOPBAR" }]), hideHeader: true }} />);
|
||||
const top = screen.getByRole("banner");
|
||||
expect(top).toHaveTextContent("INS Sdn Bhd");
|
||||
expect(within(top).queryByRole("link")).toBeNull();
|
||||
});
|
||||
|
||||
it("named blocks keep clear of a sticky bar when jumped to", () => {
|
||||
render(<LandingPage company={company} page={page([bar, { type: "FORM", heading: "Join", closed: true, anchor: "consult" }])} />);
|
||||
expect(document.getElementById("consult")).toHaveClass("scroll-mt-24");
|
||||
});
|
||||
|
||||
it("shows a section's label above its heading, and section headings in serif", () => {
|
||||
render(<LandingPage company={company} page={page([
|
||||
{ type: "FEATURES", eyebrow: "Services", heading: "Everything your guests touch", cards: [{ icon: "wifi", title: "WiFi", text: "Fast." }] },
|
||||
{ type: "FAQ", eyebrow: "FAQ", heading: "Questions hotels ask us", items: [{ question: "Q", answer: "A" }], look: "DARK" },
|
||||
])} />);
|
||||
const heading = screen.getByRole("heading", { level: 2, name: "Everything your guests touch" });
|
||||
expect(heading).toHaveClass("font-serif");
|
||||
const label = heading.previousElementSibling!;
|
||||
expect(label).toHaveTextContent("Services");
|
||||
expect(label).toHaveClass("uppercase");
|
||||
expect(screen.getByRole("heading", { level: 2, name: "Questions hotels ask us" })).toHaveClass("font-serif");
|
||||
expect(screen.getByRole("heading", { level: 2, name: "Questions hotels ask us" }).previousElementSibling).toHaveClass("text-primary");
|
||||
});
|
||||
});
|
||||
@@ -42,23 +42,105 @@ function ButtonLink({ block, index, edit }: { block: CmsBlock; index: number; ed
|
||||
);
|
||||
}
|
||||
|
||||
// add-landing-page-polish: a section's serif heading, with its optional label above. The label is the accent colour,
|
||||
// darkened toward the text colour on light backgrounds, where a pale accent would be hard to read.
|
||||
const LABEL_COLOUR: Record<string, string> = {
|
||||
DARK: "text-primary",
|
||||
ACCENT: "opacity-80",
|
||||
LIGHT: "text-[color-mix(in_srgb,var(--primary)_60%,var(--foreground))]",
|
||||
};
|
||||
|
||||
const LABELLED = ["FEATURES", "STEPS", "IMAGE_TEXT", "FAQ", "CTA"];
|
||||
|
||||
function SectionHeading({ block, index, className }: { block: CmsBlock; index: number; className: string }) {
|
||||
const band = bandOf(block.look);
|
||||
return (
|
||||
<>
|
||||
{LABELLED.includes(block.type) && <Text as="p" index={index} path="eyebrow" value={block.eyebrow} max={40} code="PagesEyebrow"
|
||||
className={`mb-2 text-xs font-semibold tracking-widest uppercase ${LABEL_COLOUR[band === "DARK" || band === "ACCENT" ? band : "LIGHT"]}`} />}
|
||||
<Text as="h2" index={index} path="heading" value={block.heading} max={120} code="PagesHeading" className={`font-serif font-semibold ${className}`} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Block({ block, index, company, slug, preview, edit }: { block: PublicBlock; index: number; company: string; slug: string; preview?: boolean; edit?: boolean }) {
|
||||
const image = block.imageId ? imageSrc(block.imageId) : undefined;
|
||||
const button = <ButtonLink block={block} index={index} edit={edit} />;
|
||||
switch (block.type) {
|
||||
case "HERO":
|
||||
case "HERO": {
|
||||
const wide = !!block.fullWidth;
|
||||
const points = block.cards?.length ? (
|
||||
<ul className="space-y-2">
|
||||
{block.cards.map((card, i) => (
|
||||
<li key={i} className="flex items-baseline gap-3 before:size-2 before:shrink-0 before:rounded-full before:bg-primary">
|
||||
<Text as="span" index={index} path={`cards.${i}.title`} value={card.title} max={80} code="PagesPointN" n={i + 1} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null;
|
||||
const words = (
|
||||
<>
|
||||
<Text as="h2" index={index} path="heading" value={block.heading} max={120} code="PagesHeading"
|
||||
className={wide ? "font-serif text-4xl leading-tight font-semibold sm:text-5xl" : "text-3xl font-semibold sm:text-4xl"} />
|
||||
<Text as="p" index={index} path="text" value={block.text} max={300} code="PagesText" className="max-w-2xl text-lg" />
|
||||
{points}
|
||||
<div>{button}</div>
|
||||
</>
|
||||
);
|
||||
// add-hero-signup-form: with an event, the sign-up form sits in a card beside the text (below it on phones).
|
||||
// add-hero-full-width: the card may open with its own heading and text.
|
||||
const card = block.eventUuid ? (
|
||||
<div className="space-y-4 rounded-lg border bg-card p-6 text-card-foreground shadow-card">
|
||||
{block.formHeading || block.formText || edit ? (
|
||||
<div className="space-y-1">
|
||||
<Text as="h3" index={index} path="formHeading" value={block.formHeading} max={80} code="PagesFormHeading" className="font-serif text-2xl font-semibold" />
|
||||
<Text as="p" index={index} path="formText" value={block.formText} max={200} code="PagesFormText" className="text-sm text-muted-foreground" />
|
||||
</div>
|
||||
) : null}
|
||||
<LandingForm companyCode={company} slug={slug} index={index} info={block.closed ? undefined : block.form} preview={preview} thanks={block.thanksText} />
|
||||
</div>
|
||||
) : null;
|
||||
const back = bandOf(block.look) ? "" : "bg-muted";
|
||||
if (wide) {
|
||||
// Edge to edge; the shade is darkest behind the text and clears toward the far side. The text is centred in the
|
||||
// hero's opening height, not beside a long form, so it stays in the first screen.
|
||||
const grid = `mx-auto grid w-full max-w-6xl items-start gap-8 px-4 pt-16 pb-12 ${card ? "md:grid-cols-[minmax(0,1fr)_minmax(0,28rem)]" : ""}`;
|
||||
return (
|
||||
<section className={`relative overflow-hidden ${back}`}>
|
||||
<ImageSpot index={index} src={image} className="absolute inset-0 h-full w-full object-cover" corner />
|
||||
<HeroShade index={index} image={!!image} shaded="relative bg-gradient-to-r from-black/60 to-black/60 text-white md:from-black/55 md:to-black/10 md:to-70%" plain="">
|
||||
<div className={grid}>
|
||||
<div className="flex flex-col justify-center gap-4 md:min-h-[32rem]">{words}</div>
|
||||
{card}
|
||||
</div>
|
||||
</HeroShade>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
if (card) {
|
||||
// Top padding leaves room for the editor's image button in the corner.
|
||||
const grid = "grid items-start gap-6 px-6 pt-16 pb-6 md:grid-cols-[minmax(0,1fr)_minmax(0,26rem)] md:px-10 md:pb-10";
|
||||
return (
|
||||
<section className={`relative overflow-hidden rounded-lg ${back}`}>
|
||||
<ImageSpot index={index} src={image} className="absolute inset-0 h-full w-full object-cover" corner />
|
||||
<HeroShade index={index} image={!!image} shaded={`relative ${grid} bg-gradient-to-r from-black/80 via-black/60 to-black/40 text-white sm:min-h-96`} plain={grid}>
|
||||
<div className="flex flex-col gap-3">{words}</div>
|
||||
{card}
|
||||
</HeroShade>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<section className={`relative overflow-hidden rounded-lg ${bandOf(block.look) ? "" : "bg-muted"}`}>
|
||||
<section className={`relative overflow-hidden rounded-lg ${back}`}>
|
||||
<ImageSpot index={index} src={image} className="absolute inset-0 h-full w-full object-cover" corner />
|
||||
<HeroShade index={index} image={!!image}
|
||||
shaded="relative flex min-h-72 flex-col justify-end gap-3 bg-gradient-to-t from-black/80 via-black/50 to-transparent p-6 text-white sm:min-h-96"
|
||||
plain="flex flex-col gap-3 p-6">
|
||||
<Text as="h2" index={index} path="heading" value={block.heading} max={120} code="PagesHeading" className="text-3xl font-semibold sm:text-4xl" />
|
||||
<Text as="p" index={index} path="text" value={block.text} max={300} code="PagesText" className="max-w-2xl text-lg" />
|
||||
<div>{button}</div>
|
||||
{words}
|
||||
</HeroShade>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
case "RICH_TEXT":
|
||||
return block.html || edit ? (
|
||||
<section><RichSpot index={index} html={block.html} className={PROSE}>{block.html ? <SafeHtml html={block.html} className={PROSE} /> : null}</RichSpot></section>
|
||||
@@ -72,7 +154,7 @@ function Block({ block, index, company, slug, preview, edit }: { block: PublicBl
|
||||
</div>
|
||||
) : null}
|
||||
<div className="space-y-3">
|
||||
<Text as="h2" index={index} path="heading" value={block.heading} max={120} code="PagesHeading" className="text-2xl font-semibold" />
|
||||
<SectionHeading block={block} index={index} className="text-2xl" />
|
||||
<RichSpot index={index} html={block.html} className={PROSE}>{block.html ? <SafeHtml html={block.html} className={PROSE} /> : null}</RichSpot>
|
||||
{button}
|
||||
</div>
|
||||
@@ -81,7 +163,7 @@ function Block({ block, index, company, slug, preview, edit }: { block: PublicBl
|
||||
case "FAQ":
|
||||
return block.items?.length ? (
|
||||
<section className="space-y-3">
|
||||
<Text as="h2" index={index} path="heading" value={block.heading} max={120} code="PagesHeading" className="text-2xl font-semibold" />
|
||||
<SectionHeading block={block} index={index} className="text-2xl" />
|
||||
<div className="divide-y rounded-lg border">
|
||||
{block.items.map((item, i) => {
|
||||
const question = <Text as="span" index={index} path={`items.${i}.question`} value={item.question} max={300} code="PagesQuestionN" n={i + 1} />;
|
||||
@@ -102,15 +184,15 @@ function Block({ block, index, company, slug, preview, edit }: { block: PublicBl
|
||||
case "FORM":
|
||||
return (
|
||||
<section className="mx-auto w-full max-w-md space-y-4 rounded-lg border bg-card p-6 shadow-card">
|
||||
<Text as="h2" index={index} path="heading" value={block.heading} max={120} code="PagesHeading" className="text-2xl font-semibold" />
|
||||
<LandingForm companyCode={company} slug={slug} index={index} info={block.closed ? undefined : block.form} preview={preview} />
|
||||
<SectionHeading block={block} index={index} className="text-2xl" />
|
||||
<LandingForm companyCode={company} slug={slug} index={index} info={block.closed ? undefined : block.form} preview={preview} thanks={block.thanksText} />
|
||||
</section>
|
||||
);
|
||||
case "FEATURES":
|
||||
return (
|
||||
<section className="space-y-6">
|
||||
<div className="max-w-2xl space-y-2">
|
||||
<Text as="h2" index={index} path="heading" value={block.heading} max={120} code="PagesHeading" className="text-2xl font-semibold sm:text-3xl" />
|
||||
<SectionHeading block={block} index={index} className="text-2xl sm:text-3xl" />
|
||||
<Text as="p" index={index} path="text" value={block.text} max={300} code="PagesText" className="text-lg opacity-80" />
|
||||
</div>
|
||||
<ul className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
@@ -130,7 +212,7 @@ function Block({ block, index, company, slug, preview, edit }: { block: PublicBl
|
||||
case "STEPS":
|
||||
return (
|
||||
<section className="space-y-6">
|
||||
<Text as="h2" index={index} path="heading" value={block.heading} max={120} code="PagesHeading" className="text-2xl font-semibold sm:text-3xl" />
|
||||
<SectionHeading block={block} index={index} className="text-2xl sm:text-3xl" />
|
||||
<ol className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{(block.cards ?? []).map((card, i) => (
|
||||
<li key={i} className="flex gap-4">
|
||||
@@ -155,11 +237,26 @@ function Block({ block, index, company, slug, preview, edit }: { block: PublicBl
|
||||
case "CTA":
|
||||
return (
|
||||
<section className="flex flex-col items-center gap-4 py-4 text-center">
|
||||
<Text as="h2" index={index} path="heading" value={block.heading} max={120} code="PagesHeading" className="text-2xl font-semibold sm:text-3xl" />
|
||||
<SectionHeading block={block} index={index} className="text-2xl sm:text-3xl" />
|
||||
<Text as="p" index={index} path="text" value={block.text} max={300} code="PagesText" className="max-w-2xl text-lg opacity-80" />
|
||||
{button}
|
||||
</section>
|
||||
);
|
||||
case "FOOTER":
|
||||
// add-landing-thanks-and-footer: columns of title and text with contact links, the legal line under a divider.
|
||||
return (
|
||||
<footer role="contentinfo" className="text-sm [&_a]:text-primary [&_a]:hover:underline">
|
||||
<ul className={`grid gap-8 ${["", "", "md:grid-cols-2", "md:grid-cols-3", "md:grid-cols-4"][block.cards?.length ?? 0]}`}>
|
||||
{(block.cards ?? []).map((card, i) => (
|
||||
<li key={i} className="space-y-1.5">
|
||||
<Text as="h2" index={index} path={`cards.${i}.title`} value={card.title} max={80} code="PagesCardTitle" className="font-semibold" />
|
||||
<Text as="p" index={index} path={`cards.${i}.text`} value={card.text} max={300} code="PagesCardText" multiline links className="whitespace-pre-line opacity-80" />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<Text as="p" index={index} path="text" value={block.text} max={300} code="PagesFooterLegal" className="mt-8 border-t border-muted-foreground/30 pt-4 text-xs opacity-70" />
|
||||
</footer>
|
||||
);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -167,13 +264,39 @@ function Block({ block, index, company, slug, preview, edit }: { block: PublicBl
|
||||
|
||||
const WIDTH = "mx-auto w-full max-w-5xl px-4";
|
||||
|
||||
/** add-landing-page-polish: the company logo (or name) and an optional button, kept at the top of the window. */
|
||||
function TopBar({ block, index, company, edit }: { block: CmsBlock; index: number; company: Branding; edit: boolean }) {
|
||||
return (
|
||||
<header role="banner" id={anchorId(block.anchor)} className="border-b bg-card/95 backdrop-blur">
|
||||
<div className="mx-auto flex max-w-6xl items-center justify-between gap-3 px-4 py-3">
|
||||
{company.logoImageId ? (
|
||||
// eslint-disable-next-line @next/next/no-img-element -- the company's uploaded logo
|
||||
<img src={imageSrc(company.logoImageId)} alt={company.name} className="h-10 w-auto" />
|
||||
) : (
|
||||
<span className="text-lg font-semibold">{company.name}</span>
|
||||
)}
|
||||
<ButtonLink block={block} index={index} edit={edit} />
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks that run the full window width: Custom HTML, a full-width hero, and a coloured band (add-compact-landing-form).
|
||||
* Two of them in a row join with no gap.
|
||||
*/
|
||||
const bleeds = (block: PublicBlock) => block.type === "HTML" || block.type === "TOPBAR" || (block.type === "HERO" && !!block.fullWidth) || !!bandOf(block.look);
|
||||
|
||||
/** A block in the page width; with a non-default look, inside a full-width band of that colour. */
|
||||
function Section({ block, index, children }: { block: PublicBlock; index: number; children: ReactNode }) {
|
||||
const band = bandOf(block.look);
|
||||
if (!band) return <EditSection index={index}><div id={anchorId(block.anchor)} className={WIDTH}>{children}</div></EditSection>;
|
||||
// add-hero-full-width: a full-width hero sets its own width.
|
||||
if (block.type === "HERO" && block.fullWidth) return <EditSection index={index}><div id={anchorId(block.anchor)}>{children}</div></EditSection>;
|
||||
// add-landing-page-polish: a #name jump lands clear of a sticky top bar.
|
||||
if (!band) return <EditSection index={index}><div id={anchorId(block.anchor)} className={`scroll-mt-24 ${WIDTH}`}>{children}</div></EditSection>;
|
||||
return (
|
||||
<EditSection index={index}>
|
||||
<div id={anchorId(block.anchor)} data-look={band} className={`py-12 ${BANDS[band]}`}>
|
||||
<div id={anchorId(block.anchor)} data-look={band} className={`scroll-mt-16 py-12 ${BANDS[band]}`}>
|
||||
<div className={WIDTH}>{children}</div>
|
||||
</div>
|
||||
</EditSection>
|
||||
@@ -213,10 +336,17 @@ export function LandingPage({ company, page, banner, preview, frameBase, edit }:
|
||||
</header>}
|
||||
<main className={page.hideHeader ? "pb-8" : "py-8"}>
|
||||
<h1 className={page.hideHeader ? "sr-only" : `${WIDTH} mb-10 text-3xl font-semibold sm:text-4xl`}>{page.title}</h1>
|
||||
<div className="space-y-10">
|
||||
{page.blocks.map((block, i) => block.type === "HTML"
|
||||
? <HtmlSpot key={i} index={i}><HtmlFrame id={anchorId(block.anchor)} src={`${frames}/${i}${edit ? `?v=${edit.frameVersion}` : ""}`} title={page.title} /></HtmlSpot>
|
||||
: <Section key={i} block={block} index={i}><Block block={block} index={i} company={company.code} slug={page.slug} preview={preview} edit={!!edit} /></Section>)}
|
||||
<div>
|
||||
{page.blocks.map((block, i) => (
|
||||
// A top bar's row is what sticks: a sticky element only sticks inside its parent, and the rows share the page's.
|
||||
<div key={i} className={block.type === "TOPBAR" ? "sticky top-0 z-20" : i > 0 && !(bleeds(block) && bleeds(page.blocks[i - 1])) ? "mt-10" : undefined}>
|
||||
{block.type === "TOPBAR"
|
||||
? <EditSection index={i}><TopBar block={block} index={i} company={company} edit={!!edit} /></EditSection>
|
||||
: block.type === "HTML"
|
||||
? <HtmlSpot index={i}><HtmlFrame id={anchorId(block.anchor)} src={`${frames}/${i}${edit ? `?v=${edit.frameVersion}` : ""}`} title={page.title} /></HtmlSpot>
|
||||
: <Section block={block} index={i}><Block block={block} index={i} company={company.code} slug={page.slug} preview={preview} edit={!!edit} /></Section>}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { createContext, useContext, useLayoutEffect, useRef, type ElementType, t
|
||||
import dynamic from "next/dynamic";
|
||||
import { ImagePlus } from "lucide-react";
|
||||
import { BLOCK_LABELS, type CmsBlock } from "@/app/lib/cmsPages";
|
||||
import { contactLinks } from "@/app/lib/contactLinks";
|
||||
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
||||
|
||||
// add-page-visual-editor: the landing page in edit mode, on the on-page editor's canvas. The public page and the
|
||||
@@ -45,7 +46,7 @@ export function setField(block: CmsBlock, path: string, value: string): CmsBlock
|
||||
* A plain text field: the text as-is on the public page; in edit mode the same element, typed into in place. It is
|
||||
* never re-rendered from its value while focused, so the caret stays where it is.
|
||||
*/
|
||||
export function Text({ as: Tag, index, path, value, max, code, n, className, multiline }: {
|
||||
export function Text({ as: Tag, index, path, value, max, code, n, className, multiline, links }: {
|
||||
as: ElementType;
|
||||
index: number;
|
||||
path: string;
|
||||
@@ -56,9 +57,11 @@ export function Text({ as: Tag, index, path, value, max, code, n, className, mul
|
||||
n?: number;
|
||||
className?: string;
|
||||
multiline?: boolean;
|
||||
/** Outside the editor, show contact details as links (add-landing-thanks-and-footer). */
|
||||
links?: boolean;
|
||||
}) {
|
||||
const edit = useEdit();
|
||||
if (!edit) return value ? <Tag className={className}>{value}</Tag> : null;
|
||||
if (!edit) return value ? <Tag className={className}>{links ? contactLinks(value) : value}</Tag> : null;
|
||||
return <EditableText as={Tag} edit={edit} index={index} path={path} value={value ?? ""} max={max} code={code} n={n} className={className} multiline={multiline} />;
|
||||
}
|
||||
|
||||
@@ -102,7 +105,7 @@ export function ImageSpot({ index, src, className, corner }: { index: number; sr
|
||||
<>
|
||||
{img}
|
||||
<button type="button" aria-label={t("PagesImage")} onClick={open}
|
||||
className="absolute top-3 right-3 z-10 flex size-10 cursor-pointer items-center justify-center rounded-full bg-background/90 text-foreground shadow hover:bg-background">
|
||||
className="absolute top-3 left-3 z-10 flex size-10 cursor-pointer items-center justify-center rounded-full bg-background/90 text-foreground shadow hover:bg-background">
|
||||
<ImagePlus aria-hidden="true" className="size-5" />
|
||||
</button>
|
||||
</>
|
||||
|
||||
@@ -5,14 +5,14 @@ import { Check, Copy } from "lucide-react";
|
||||
import { Button } from "@/app/components/ui/button";
|
||||
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
||||
|
||||
/** A page address with a button that copies its full URL (this site's origin plus the path). */
|
||||
export function CopyAddress({ address }: { address: string }) {
|
||||
/** A page address with a button that copies its full URL (this site's origin plus the path), or the path itself when `relative`. */
|
||||
export function CopyAddress({ address, relative }: { address: string; relative?: boolean }) {
|
||||
const t = useT();
|
||||
const [state, setState] = useState<"idle" | "copied" | "failed">("idle");
|
||||
|
||||
async function copy() {
|
||||
try {
|
||||
await navigator.clipboard.writeText(`${window.location.origin}${address}`);
|
||||
await navigator.clipboard.writeText(relative ? address : `${window.location.origin}${address}`);
|
||||
setState("copied");
|
||||
setTimeout(() => setState("idle"), 2000);
|
||||
} catch {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { FRAME_SANDBOX, frameAnchor, nextFrameHeight, START_HEIGHT, type FrameHeight } from "@/app/lib/frameHtml";
|
||||
import { FRAME_ASK_MESSAGE, FRAME_SANDBOX, frameAnchor, nextFrameHeight, START_HEIGHT, type FrameHeight } from "@/app/lib/frameHtml";
|
||||
|
||||
// add-hero-full-width: the frame may have reported before this page listened; ask on mount, and again when it loads.
|
||||
const ask = (frame: HTMLIFrameElement | null) => frame?.contentWindow?.postMessage({ type: FRAME_ASK_MESSAGE }, "*");
|
||||
|
||||
/** A Custom HTML block: the sealed frame, sized by height reports and scrolled to by #name requests from that frame's own window only. */
|
||||
export function HtmlFrame({ id, src, title }: { id?: string; src: string; title: string }) {
|
||||
@@ -22,7 +25,8 @@ export function HtmlFrame({ id, src, title }: { id?: string; src: string; title:
|
||||
if (block?.closest("main")) block.scrollIntoView({ behavior: "smooth" });
|
||||
};
|
||||
host.addEventListener("message", onMessage);
|
||||
ask(ref.current);
|
||||
return () => host.removeEventListener("message", onMessage);
|
||||
}, []);
|
||||
return <iframe ref={ref} id={id} src={src} title={title} sandbox={FRAME_SANDBOX} loading="lazy" className="block w-full border-0" style={{ height: `${size.height}px` }} />;
|
||||
return <iframe ref={ref} id={id} src={src} title={title} sandbox={FRAME_SANDBOX} loading="lazy" onLoad={(e) => ask(e.currentTarget)} className="block w-full border-0" style={{ height: `${size.height}px` }} />;
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import { VisitorState } from "@/app/components/registration/VisitorCard";
|
||||
import { RegistrationForm } from "@/app/components/registration/RegistrationForm";
|
||||
import { publicCall, type RegistrationBody, type RegistrationInfo } from "@/app/lib/services/publicRegistration";
|
||||
import { useT } from "@/app/lib/i18n/MessagesProvider";
|
||||
import { contactLinks } from "@/app/lib/contactLinks";
|
||||
|
||||
const UTM = ["utm_source", "utm_medium", "utm_campaign"] as const;
|
||||
|
||||
@@ -18,7 +19,8 @@ export function utmTags(search: string): { utmSource?: string; utmMedium?: strin
|
||||
}
|
||||
|
||||
// A landing page's FORM block: the QR sign-up form, posting to the page's block, with the visitor's UTM tags.
|
||||
export function LandingForm({ companyCode, slug, index, info, preview }: { companyCode: string; slug: string; index: number; info?: RegistrationInfo; preview?: boolean }) {
|
||||
// add-landing-thanks-and-footer: `thanks` is the page's own text under the thank-you, with contact links.
|
||||
export function LandingForm({ companyCode, slug, index, info, preview, thanks }: { companyCode: string; slug: string; index: number; info?: RegistrationInfo; preview?: boolean; thanks?: string }) {
|
||||
const t = useT();
|
||||
const [phase, setPhase] = useState<"form" | "done" | "closed">(info ? "form" : "closed");
|
||||
|
||||
@@ -26,6 +28,7 @@ export function LandingForm({ companyCode, slug, index, info, preview }: { compa
|
||||
if (phase === "closed" || !info) return <VisitorState icon={AlertCircle} heading={t("PagesFormClosed")} role="status" />;
|
||||
if (phase === "done") {
|
||||
return <VisitorState icon={CheckCircle2} heading={t("RegThanks", { event: info.eventName })} role="status"
|
||||
text={thanks ? contactLinks(thanks) : undefined}
|
||||
action={<Button className="h-11" onClick={() => setPhase("form")}>{t("RegAnother")}</Button>} />;
|
||||
}
|
||||
const submit = (body: RegistrationBody) =>
|
||||
@@ -33,5 +36,5 @@ export function LandingForm({ companyCode, slug, index, info, preview }: { compa
|
||||
method: "POST",
|
||||
body: JSON.stringify({ ...body, ...utmTags(window.location.search) }),
|
||||
});
|
||||
return <RegistrationForm info={info} submit={submit} onDone={() => setPhase("done")} onInactive={() => setPhase("closed")} />;
|
||||
return <RegistrationForm info={info} submit={submit} onDone={() => setPhase("done")} onInactive={() => setPhase("closed")} compact />;
|
||||
}
|
||||
@@ -64,4 +64,42 @@ describe("PageEditor: Custom HTML", () => {
|
||||
expect(box.closest("div")).toHaveTextContent("Too long.");
|
||||
expect(box).toHaveAttribute("aria-invalid", "true");
|
||||
});
|
||||
|
||||
// add-html-image-upload: upload an image from the block's panel and copy its link; the HTML stays as it was.
|
||||
it("uploads an image at once for the page's company and shows its link to copy", async () => {
|
||||
mocks.uploadPageImage.mockResolvedValueOnce({ id: 42 });
|
||||
const user = userEvent.setup();
|
||||
render(<PageEditor pageId={5} />);
|
||||
await screen.findByLabelText("HTML");
|
||||
await user.upload(screen.getByLabelText("Upload image"), new File(["png"], "lobby.png", { type: "image/png" }));
|
||||
expect(await screen.findByText("/api/public/page-images/42")).toBeInTheDocument();
|
||||
expect(mocks.uploadPageImage).toHaveBeenCalledWith(2, btoa("png"));
|
||||
expect(screen.getByRole("img", { name: "Image preview" })).toHaveAttribute("src", "/api/public/page-images/42");
|
||||
const write = vi.spyOn(navigator.clipboard, "writeText");
|
||||
await user.click(screen.getByRole("button", { name: "Copy link /api/public/page-images/42" }));
|
||||
expect(write).toHaveBeenCalledWith("/api/public/page-images/42");
|
||||
expect(screen.getByLabelText("HTML")).toHaveValue("<h1>Designed</h1>");
|
||||
expect(mocks.savePage).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("shows a refused upload's reason and no link", async () => {
|
||||
mocks.uploadPageImage.mockRejectedValueOnce(new ApiError("x", 422, { code: "PagesImageTooLarge" }));
|
||||
const user = userEvent.setup();
|
||||
render(<PageEditor pageId={5} />);
|
||||
await screen.findByLabelText("HTML");
|
||||
await user.upload(screen.getByLabelText("Upload image"), new File(["big"], "big.jpg", { type: "image/jpeg" }));
|
||||
expect(await screen.findByText("The image is larger than 2 MB.")).toBeInTheDocument();
|
||||
expect(screen.queryByText(/\/api\/public\/page-images\//)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("asks a super admin's new page for a company before uploading", async () => {
|
||||
mocks.useAdminAuth.mockReturnValue({ isSuper: true, companyCode: null });
|
||||
memoryRouter.reset("/pages/new");
|
||||
const user = userEvent.setup();
|
||||
render(<PageEditor />);
|
||||
await user.click(screen.getByRole("button", { name: "Add Custom HTML" }));
|
||||
await user.upload(await screen.findByLabelText("Upload image"), new File(["png"], "lobby.png", { type: "image/png" }));
|
||||
expect(await screen.findByText("Choose a company.")).toBeInTheDocument();
|
||||
expect(mocks.uploadPageImage).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -76,6 +76,50 @@ describe("PageEditor: sections", () => {
|
||||
expect(within(within(block).getByRole("group", { name: "Step 6" })).getByRole("button", { name: "Remove" })).toBeEnabled();
|
||||
});
|
||||
|
||||
// add-landing-thanks-and-footer: a dark footer of 1 to 4 columns with a legal line.
|
||||
it("adds a dark footer with columns and a legal line, and keeps 1 to 4 columns", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<PageEditor pageId={5} />);
|
||||
await screen.findByDisplayValue("How it works");
|
||||
await user.click(screen.getByRole("button", { name: "Add Footer" }));
|
||||
const block = group("Block 3: Footer");
|
||||
expect(within(block).getByLabelText("Look")).toHaveValue("DARK");
|
||||
const col1 = within(block).getByRole("group", { name: "Column 1" });
|
||||
await user.type(within(col1).getByLabelText("Title"), "Talk to us");
|
||||
await user.type(within(col1).getByLabelText("Text"), "+603-7623 9807");
|
||||
await user.click(within(within(block).getByRole("group", { name: "Column 2" })).getByRole("button", { name: "Remove" }));
|
||||
expect(within(col1).getByRole("button", { name: "Remove" })).toBeDisabled();
|
||||
await user.type(within(block).getByLabelText("Legal line"), "© 2026 INS");
|
||||
const add = within(block).getByRole("button", { name: "Add column" });
|
||||
for (let i = 0; i < 3; i++) await user.click(add);
|
||||
expect(add).toBeDisabled();
|
||||
for (const n of [4, 3, 2]) await user.click(within(within(block).getByRole("group", { name: `Column ${n}` })).getByRole("button", { name: "Remove" }));
|
||||
await user.click(screen.getByRole("button", { name: "Save" }));
|
||||
await waitFor(() => expect(mocks.savePage).toHaveBeenCalled());
|
||||
expect(mocks.savePage.mock.calls[0][1].blocks[2]).toEqual({
|
||||
type: "FOOTER", look: "DARK", text: "© 2026 INS", cards: [{ title: "Talk to us", text: "+603-7623 9807" }],
|
||||
});
|
||||
});
|
||||
|
||||
// add-landing-page-polish: the top bar's button, and a label above a section's heading.
|
||||
it("adds a top bar with a button and no look, and saves a section label", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<PageEditor pageId={5} />);
|
||||
await screen.findByDisplayValue("How it works");
|
||||
await user.type(within(group("Block 1: Steps")).getByLabelText("Label"), "How we work");
|
||||
await user.click(screen.getByRole("button", { name: "Add Top bar" }));
|
||||
const block = group("Block 3: Top bar");
|
||||
expect(within(block).queryByLabelText("Look")).not.toBeInTheDocument();
|
||||
expect(within(block).queryByLabelText("Label")).not.toBeInTheDocument();
|
||||
await user.type(within(block).getByLabelText("Button label"), "Get My Free Consultation");
|
||||
await user.type(within(block).getByLabelText("Button link"), "#consult");
|
||||
await user.click(screen.getByRole("button", { name: "Save" }));
|
||||
await waitFor(() => expect(mocks.savePage).toHaveBeenCalled());
|
||||
const blocks = mocks.savePage.mock.calls[0][1].blocks;
|
||||
expect(blocks[0]).toMatchObject({ type: "STEPS", eyebrow: "How we work" });
|
||||
expect(blocks[2]).toEqual({ type: "TOPBAR", buttonLabel: "Get My Free Consultation", buttonUrl: "#consult" });
|
||||
});
|
||||
|
||||
it("offers no look for a Custom HTML block", async () => {
|
||||
render(<PageEditor pageId={5} />);
|
||||
await screen.findByDisplayValue("How it works");
|
||||
|
||||
@@ -56,7 +56,8 @@ describe("PageEditor", () => {
|
||||
const user = userEvent.setup();
|
||||
render(<PageEditor pageId={5} />);
|
||||
const picker = await screen.findByLabelText("Event");
|
||||
await waitFor(() => expect(screen.getByRole("option", { name: "Website enquiries" })).toBeInTheDocument());
|
||||
// Scoped to the FORM block's picker: since add-hero-signup-form the hero offers the same events in its own picker.
|
||||
await waitFor(() => expect(within(picker).getByRole("option", { name: "Website enquiries" })).toBeInTheDocument());
|
||||
expect(screen.queryByRole("option", { name: "Old fair" })).not.toBeInTheDocument();
|
||||
expect(picker).toHaveValue("3312726793093644288");
|
||||
expect(screen.getByRole("link", { name: "View page" })).toHaveAttribute("href", "/p/INS/hotel");
|
||||
@@ -106,6 +107,72 @@ describe("PageEditor", () => {
|
||||
expect(memoryRouter.push).toHaveBeenCalledWith("/pages");
|
||||
});
|
||||
|
||||
// add-hero-signup-form: the hero's own event picker, "No form" by default; its event is saved with the hero.
|
||||
it("gives a hero a sign-up form for a chosen event, and No form takes it away", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<PageEditor pageId={5} />);
|
||||
const picker = await screen.findByLabelText("Sign-up form");
|
||||
expect(picker).toHaveValue("");
|
||||
expect(within(picker).getByRole("option", { name: "No form" })).toBeInTheDocument();
|
||||
await waitFor(() => expect(within(picker).getByRole("option", { name: "Website enquiries" })).toBeInTheDocument());
|
||||
await user.selectOptions(picker, "3312726793093644288");
|
||||
await user.click(screen.getByRole("button", { name: "Save" }));
|
||||
await waitFor(() => expect(mocks.savePage).toHaveBeenCalledTimes(1));
|
||||
expect(mocks.savePage.mock.calls[0][1].blocks[0]).toMatchObject({ type: "HERO", eventUuid: "3312726793093644288" });
|
||||
await user.selectOptions(screen.getByLabelText("Sign-up form"), "");
|
||||
await user.click(screen.getByRole("button", { name: "Save" }));
|
||||
await waitFor(() => expect(mocks.savePage).toHaveBeenCalledTimes(2));
|
||||
expect(mocks.savePage.mock.calls[1][1].blocks[0].eventUuid ?? null).toBeNull();
|
||||
});
|
||||
|
||||
// add-hero-full-width: Full width, points, and the form card's heading and text (only while the hero has a form).
|
||||
it("saves a full-width hero with points and a form heading; No form drops the heading and text", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<PageEditor pageId={5} />);
|
||||
const picker = await screen.findByLabelText("Sign-up form");
|
||||
expect(screen.queryByLabelText("Form heading")).not.toBeInTheDocument();
|
||||
await user.click(screen.getByRole("switch", { name: "Full width" }));
|
||||
await user.click(screen.getByRole("button", { name: "Add point" }));
|
||||
await user.type(screen.getByRole("textbox", { name: "Point 1" }), "Local support team");
|
||||
await waitFor(() => expect(within(picker).getByRole("option", { name: "Website enquiries" })).toBeInTheDocument());
|
||||
await user.selectOptions(picker, "3312726793093644288");
|
||||
await user.type(screen.getByLabelText("Form heading"), "Get a free consultation");
|
||||
await user.type(screen.getByLabelText("Form text"), "It takes a minute.");
|
||||
await user.click(screen.getByRole("button", { name: "Save" }));
|
||||
await waitFor(() => expect(mocks.savePage).toHaveBeenCalledTimes(1));
|
||||
expect(mocks.savePage.mock.calls[0][1].blocks[0]).toMatchObject({
|
||||
type: "HERO", fullWidth: true, cards: [{ title: "Local support team" }],
|
||||
formHeading: "Get a free consultation", formText: "It takes a minute.",
|
||||
});
|
||||
await user.selectOptions(screen.getByLabelText("Sign-up form"), "");
|
||||
expect(screen.queryByLabelText("Form heading")).not.toBeInTheDocument();
|
||||
await user.click(screen.getByRole("button", { name: "Save" }));
|
||||
await waitFor(() => expect(mocks.savePage).toHaveBeenCalledTimes(2));
|
||||
const hero = mocks.savePage.mock.calls[1][1].blocks[0];
|
||||
expect([hero.formHeading, hero.formText]).toEqual([undefined, undefined]);
|
||||
});
|
||||
|
||||
// add-landing-thanks-and-footer: the hero's thank-you text, only while it has a form.
|
||||
it("saves a hero's thank-you text; No form drops it", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<PageEditor pageId={5} />);
|
||||
const picker = await screen.findByLabelText("Sign-up form");
|
||||
// The FORM block (block 2) has its own thank-you field; these checks are the hero's.
|
||||
const hero = () => within(screen.getByRole("group", { name: /^Block 1/ }));
|
||||
expect(hero().queryByLabelText("Thank-you text")).not.toBeInTheDocument();
|
||||
await waitFor(() => expect(within(picker).getByRole("option", { name: "Website enquiries" })).toBeInTheDocument());
|
||||
await user.selectOptions(picker, "3312726793093644288");
|
||||
await user.type(hero().getByLabelText("Thank-you text"), "Call +60 12-833 2775.");
|
||||
await user.click(screen.getByRole("button", { name: "Save" }));
|
||||
await waitFor(() => expect(mocks.savePage).toHaveBeenCalledTimes(1));
|
||||
expect(mocks.savePage.mock.calls[0][1].blocks[0]).toMatchObject({ type: "HERO", thanksText: "Call +60 12-833 2775." });
|
||||
await user.selectOptions(screen.getByLabelText("Sign-up form"), "");
|
||||
expect(hero().queryByLabelText("Thank-you text")).not.toBeInTheDocument();
|
||||
await user.click(screen.getByRole("button", { name: "Save" }));
|
||||
await waitFor(() => expect(mocks.savePage).toHaveBeenCalledTimes(2));
|
||||
expect(mocks.savePage.mock.calls[1][1].blocks[0].thanksText).toBeUndefined();
|
||||
});
|
||||
|
||||
it("a super admin must choose a company for a new page", async () => {
|
||||
mocks.useAdminAuth.mockReturnValue({ isSuper: true, companyCode: null });
|
||||
const user = userEvent.setup();
|
||||
|
||||
@@ -223,6 +223,7 @@ function FormEditor({ p, ask }: { p: Draft; ask: Ask }) {
|
||||
onMove={(delta) => p.moveBlock(index, delta)}
|
||||
onRemove={() => p.removeBlock(row.key)}
|
||||
onChooseImage={(file) => p.chooseImage(row.key, file)}
|
||||
onUploadImage={p.uploadImage}
|
||||
/>
|
||||
))}
|
||||
<FieldError message={errors.blocks} />
|
||||
|
||||
@@ -49,6 +49,33 @@ describe("moveItem", () => {
|
||||
});
|
||||
|
||||
describe("usePageDraft for the on-page editor", () => {
|
||||
it("a company switch clears the event of every FORM block and of a hero's sign-up form", async () => {
|
||||
mocks.getPage.mockResolvedValueOnce({ ...stored, blocks: [
|
||||
{ type: "HERO" as const, heading: "Hi", eventUuid: "77" }, { type: "FORM" as const, eventUuid: "77" }, { type: "HERO" as const, heading: "Plain" },
|
||||
] });
|
||||
const { result } = await loaded();
|
||||
act(() => result.current.changeCompany(3));
|
||||
expect(result.current.rows.map((r) => r.block.eventUuid ?? null)).toEqual([null, null, null]);
|
||||
});
|
||||
|
||||
// add-hero-full-width: the form card's heading and text go with the form, or the server refuses the save.
|
||||
it("a company switch also drops a hero's form heading and text", async () => {
|
||||
mocks.getPage.mockResolvedValueOnce({ ...stored, blocks: [
|
||||
{ type: "HERO" as const, heading: "Hi", eventUuid: "77", formHeading: "Get a free consultation", formText: "Quick." },
|
||||
] });
|
||||
const { result } = await loaded();
|
||||
act(() => result.current.changeCompany(3));
|
||||
expect(result.current.rows[0].block).toEqual({ type: "HERO", heading: "Hi", eventUuid: null });
|
||||
});
|
||||
|
||||
// add-landing-thanks-and-footer: a hero's thank-you text goes with its form too.
|
||||
it("a company switch also drops a hero's thank-you text", async () => {
|
||||
mocks.getPage.mockResolvedValueOnce({ ...stored, blocks: [{ type: "HERO" as const, heading: "Hi", eventUuid: "77", thanksText: "Call us." }] });
|
||||
const { result } = await loaded();
|
||||
act(() => result.current.changeCompany(3));
|
||||
expect(result.current.rows[0].block).toEqual({ type: "HERO", heading: "Hi", eventUuid: null });
|
||||
});
|
||||
|
||||
it("keeps the company's branding from the loaded page", async () => {
|
||||
const { result } = await loaded();
|
||||
expect(result.current.branding).toEqual(stored.company);
|
||||
|
||||
Loaded 100 of 119 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user