Move dashboard frontend out of ui namespace (#538)
This commit is contained in:
parent
d5527f9e53
commit
0f82735149
60
.github/workflows/build-and-release.yml
vendored
60
.github/workflows/build-and-release.yml
vendored
@ -109,41 +109,41 @@ jobs:
|
||||
with:
|
||||
node-version: 20
|
||||
cache: yarn
|
||||
cache-dependency-path: ui/homepage/yarn.lock
|
||||
cache-dependency-path: ui/dashboard/yarn.lock
|
||||
|
||||
- name: Install homepage dependencies
|
||||
- name: Install dashboard dependencies
|
||||
if: github.ref == 'refs/heads/main'
|
||||
working-directory: ui/homepage
|
||||
working-directory: ui/dashboard
|
||||
run: yarn install --frozen-lockfile
|
||||
|
||||
- name: Run homepage export scripts
|
||||
- name: Run dashboard export scripts
|
||||
if: github.ref == 'refs/heads/main'
|
||||
working-directory: ui/homepage
|
||||
working-directory: ui/dashboard
|
||||
run: yarn prebuild
|
||||
|
||||
- name: Build homepage static bundle
|
||||
- name: Build dashboard static bundle
|
||||
if: github.ref == 'refs/heads/main'
|
||||
working-directory: ui/homepage
|
||||
working-directory: ui/dashboard
|
||||
run: yarn build:static
|
||||
|
||||
- name: Create homepage static archive
|
||||
- name: Create dashboard static archive
|
||||
if: github.ref == 'refs/heads/main'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
mkdir -p release-artifacts
|
||||
src="ui/homepage/out"
|
||||
src="ui/dashboard/out"
|
||||
if [[ ! -d "$src" ]]; then
|
||||
echo "Homepage static export directory not found" >&2
|
||||
echo "Dashboard static export directory not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
tar -czf release-artifacts/homepage-static-export.tar.gz -C "$src" .
|
||||
tar -czf release-artifacts/dashboard-static-export.tar.gz -C "$src" .
|
||||
|
||||
- name: Upload homepage static bundle artifact
|
||||
if: github.ref == 'refs/heads/main'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: homepage-static-export
|
||||
path: ui/homepage/out
|
||||
- name: Upload dashboard static bundle artifact
|
||||
if: github.ref == 'refs/heads/main'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: dashboard-static-export
|
||||
path: ui/dashboard/out
|
||||
|
||||
- name: Prepare release assets
|
||||
run: |
|
||||
@ -155,8 +155,8 @@ jobs:
|
||||
files+=("${file}")
|
||||
done < <(printf '%s\n' release-artifacts/xcontrol-*)
|
||||
fi
|
||||
if [[ -f "release-artifacts/homepage-static-export.tar.gz" ]]; then
|
||||
files+=("release-artifacts/homepage-static-export.tar.gz")
|
||||
if [[ -f "release-artifacts/dashboard-static-export.tar.gz" ]]; then
|
||||
files+=("release-artifacts/dashboard-static-export.tar.gz")
|
||||
fi
|
||||
if [[ ${#files[@]} -eq 0 ]]; then
|
||||
echo "No release assets were found" >&2
|
||||
@ -227,22 +227,22 @@ jobs:
|
||||
mv artifacts/bin/xcontrol-server-linux-amd64 artifacts/bin/xcontrol-server
|
||||
chmod +x artifacts/bin/xcontrol-server
|
||||
|
||||
- name: Download homepage static bundle
|
||||
- name: Download dashboard static bundle
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: homepage-static-export
|
||||
path: artifacts/homepage
|
||||
name: dashboard-static-export
|
||||
path: artifacts/dashboard
|
||||
if-no-artifact-found: ignore
|
||||
|
||||
- name: Check homepage static bundle availability
|
||||
id: homepage_static_export
|
||||
- name: Check dashboard static bundle availability
|
||||
id: dashboard_static_export
|
||||
run: |
|
||||
set -euo pipefail
|
||||
artifact="artifacts/homepage/homepage-static-export.tar.gz"
|
||||
artifact="artifacts/dashboard/dashboard-static-export.tar.gz"
|
||||
if [[ -f "${artifact}" ]]; then
|
||||
echo "available=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "Homepage static export artifact was not downloaded; skipping sync." >&2
|
||||
echo "Dashboard static export artifact was not downloaded; skipping sync." >&2
|
||||
echo "available=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
@ -283,14 +283,14 @@ jobs:
|
||||
ssh "$REMOTE_HOST" "sudo install -m 755 /tmp/xcontrol-server /usr/bin/xcontrol-server"
|
||||
fi
|
||||
|
||||
- name: Sync homepage static export
|
||||
if: steps.homepage_static_export.outputs.available == 'true'
|
||||
- name: Sync dashboard static export
|
||||
if: steps.dashboard_static_export.outputs.available == 'true'
|
||||
env:
|
||||
REMOTE_HOST: ${{ secrets.VPS_USER }}@${{ matrix.site }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
artifact="artifacts/homepage/homepage-static-export.tar.gz"
|
||||
dest_root="artifacts/homepage/out"
|
||||
artifact="artifacts/dashboard/dashboard-static-export.tar.gz"
|
||||
dest_root="artifacts/dashboard/out"
|
||||
|
||||
rm -rf "${dest_root}"
|
||||
mkdir -p "${dest_root}"
|
||||
|
||||
10
.github/workflows/security-check.yml
vendored
10
.github/workflows/security-check.yml
vendored
@ -20,18 +20,18 @@ jobs:
|
||||
with:
|
||||
node-version: 20
|
||||
cache: yarn
|
||||
cache-dependency-path: ui/homepage/yarn.lock
|
||||
cache-dependency-path: ui/dashboard/yarn.lock
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: ui/homepage
|
||||
working-directory: ui/dashboard
|
||||
run: yarn install --frozen-lockfile
|
||||
|
||||
- name: Run ESLint
|
||||
working-directory: ui/homepage
|
||||
working-directory: ui/dashboard
|
||||
run: yarn lint
|
||||
|
||||
- name: Run npm audit (production)
|
||||
working-directory: ui/homepage
|
||||
working-directory: ui/dashboard
|
||||
run: npm audit --production
|
||||
continue-on-error: true
|
||||
|
||||
@ -39,7 +39,7 @@ jobs:
|
||||
uses: returntocorp/semgrep-action@v1
|
||||
with:
|
||||
config: p/ci
|
||||
paths: ui/homepage
|
||||
paths: ui/dashboard
|
||||
|
||||
go-security:
|
||||
name: go-security
|
||||
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@ -29,4 +29,4 @@ account/xcontrol-account
|
||||
account/xcontrol-account.log
|
||||
server/xcontrol-server
|
||||
server/xcontrol-server.log
|
||||
ui/homepage/.yarn/
|
||||
ui/dashboard/.yarn/
|
||||
|
||||
28
Makefile
28
Makefile
@ -7,9 +7,9 @@ NODE_MAJOR ?= 22
|
||||
export PATH := $(GO_BIN):$(PATH)
|
||||
|
||||
.PHONY: install install-openresty install-redis install-postgresql init-db \
|
||||
build update-homepage-manifests build-server build-homepage \
|
||||
start start-openresty start-server start-homepage \
|
||||
stop stop-server stop-homepage stop-openresty restart
|
||||
build update-dashboard-manifests build-server build-dashboard \
|
||||
start start-openresty start-server start-dashboard \
|
||||
stop stop-server stop-dashboard stop-openresty restart
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Dependency installation
|
||||
@ -86,7 +86,7 @@ init-db:
|
||||
# Build targets
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
build: update-homepage-manifests build-cli build-server build-homepage
|
||||
build: update-dashboard-manifests build-cli build-server build-dashboard
|
||||
|
||||
build-cli:
|
||||
$(MAKE) -C rag-server/cmd/rag-server-cli build
|
||||
@ -94,32 +94,32 @@ build-cli:
|
||||
build-server:
|
||||
$(MAKE) -C rag-server build
|
||||
|
||||
build-homepage:
|
||||
$(MAKE) -C ui/homepage build SKIP_SYNC=1
|
||||
build-dashboard:
|
||||
$(MAKE) -C dashboard build SKIP_SYNC=1
|
||||
|
||||
update-homepage-manifests:
|
||||
$(MAKE) -C ui/homepage sync-dl-index
|
||||
update-dashboard-manifests:
|
||||
$(MAKE) -C dashboard sync-dl-index
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Run targets
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
start: start-openresty start-server start-homepage start-dl start-docs
|
||||
start: start-openresty start-server start-dashboard start-dl start-docs
|
||||
|
||||
start-server:
|
||||
$(MAKE) -C rag-server start
|
||||
|
||||
start-homepage:
|
||||
$(MAKE) -C ui/homepage start
|
||||
start-dashboard:
|
||||
$(MAKE) -C dashboard start
|
||||
|
||||
|
||||
stop: stop-server stop-homepage stop-openresty
|
||||
stop: stop-server stop-dashboard stop-openresty
|
||||
|
||||
stop-server:
|
||||
$(MAKE) -C rag-server stop
|
||||
|
||||
stop-homepage:
|
||||
$(MAKE) -C ui/homepage stop
|
||||
stop-dashboard:
|
||||
$(MAKE) -C dashboard stop
|
||||
|
||||
start-openresty:
|
||||
ifeq ($(OS),Darwin)
|
||||
|
||||
@ -6,7 +6,7 @@ This repository contains the API server, agent code and a Next.js-based UI.
|
||||
|
||||
## Components
|
||||
|
||||
- **ui-homepage**
|
||||
- **dashboard**
|
||||
- **ui-panel**
|
||||
- **xcontrol-cli**
|
||||
- **xcontrol-server**
|
||||
@ -50,7 +50,7 @@ make init-db # initialize database (optional)
|
||||
|
||||
## Frontend configuration
|
||||
|
||||
The Next.js homepage now resolves service endpoints through `ui/homepage/config/runtime-service-config.yaml`. The runtime
|
||||
The Next.js dashboard now resolves service endpoints through `dashboard/config/runtime-service-config.yaml`. The runtime
|
||||
configuration selects values based on `NEXT_PUBLIC_RUNTIME_ENV` (falling back to `NODE_ENV` and the file's
|
||||
`defaultEnvironment`). Use `NEXT_PUBLIC_ACCOUNT_SERVICE_URL` for ad-hoc overrides, otherwise adjust the YAML file to specify
|
||||
environment-specific URLs such as `http://localhost:8080` for development/test and `https://account.svc.plus` for production.
|
||||
@ -89,7 +89,7 @@ make test
|
||||
make start
|
||||
```
|
||||
|
||||
This launches the server, homepage and panel. Use `make stop` to stop all components.
|
||||
This launches the server, dashboard and panel. Use `make stop` to stop all components.
|
||||
|
||||
The API server also accepts a custom configuration file:
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
# Build static homepage
|
||||
# Build static dashboard
|
||||
FROM node:20 AS build
|
||||
WORKDIR /app
|
||||
COPY ui/homepage/package.json ui/homepage/yarn.lock ./
|
||||
COPY dashboard/package.json dashboard/yarn.lock ./
|
||||
RUN yarn install --frozen-lockfile
|
||||
COPY ui/homepage .
|
||||
COPY dashboard .
|
||||
RUN yarn build
|
||||
|
||||
FROM nginx:alpine
|
||||
@ -20,12 +20,12 @@ icon:
|
||||
exit 1; \
|
||||
fi
|
||||
@mkdir -p public/icons
|
||||
@$(MAGICK) ../logo.png -resize 32x32 public/icons/cloudnative_32.png
|
||||
@$(MAGICK) ../logo.png -resize 64x64 -background none -define icon:auto-resize=64,48,32,16 public/favicon.ico
|
||||
@$(MAGICK) ../ui/logo.png -resize 32x32 public/icons/cloudnative_32.png
|
||||
@$(MAGICK) ../ui/logo.png -resize 64x64 -background none -define icon:auto-resize=64,48,32,16 public/favicon.ico
|
||||
@echo "✅ Icons generated successfully."
|
||||
|
||||
init:
|
||||
@echo "🔧 Installing dependencies for homepage..."
|
||||
@echo "🔧 Installing dependencies for dashboard..."
|
||||
@if [ -z "$(YARN)" ]; then \
|
||||
echo "⚠️ Yarn not found. Attempting to install..."; \
|
||||
if [ "$(OS)" = "Darwin" ]; then \
|
||||
@ -48,18 +48,18 @@ init:
|
||||
yarn install
|
||||
|
||||
dev:
|
||||
@echo "🚀 Starting Next.js dev server (homepage)..."
|
||||
@echo "🚀 Starting Next.js dev server (dashboard)..."
|
||||
yarn dev -p 3001
|
||||
|
||||
start:
|
||||
@echo "🚀 Starting Next.js dev server (homepage) in background..."
|
||||
@nohup yarn dev -p 3001 >/tmp/homepage.log 2>&1 & echo $$! > homepage.pid
|
||||
@echo "🚀 Starting Next.js dev server (dashboard) in background..."
|
||||
@nohup yarn dev -p 3001 >/tmp/dashboard.log 2>&1 & echo $$! > dashboard.pid
|
||||
|
||||
stop:
|
||||
@echo "🛑 Stopping Next.js dev server (homepage)..."
|
||||
@if [ -f homepage.pid ]; then \
|
||||
kill `cat homepage.pid` >/dev/null 2>&1 || true; \
|
||||
rm homepage.pid; \
|
||||
@echo "🛑 Stopping Next.js dev server (dashboard)..."
|
||||
@if [ -f dashboard.pid ]; then \
|
||||
kill `cat dashboard.pid` >/dev/null 2>&1 || true; \
|
||||
rm dashboard.pid; \
|
||||
else \
|
||||
echo "No running server"; \
|
||||
fi
|
||||
@ -75,7 +75,7 @@ build: init
|
||||
@if [ -z "$(SKIP_SYNC)" ]; then \
|
||||
$(MAKE) sync-dl-index; \
|
||||
fi
|
||||
@echo "🔨 Building homepage..."
|
||||
@echo "🔨 Building dashboard..."
|
||||
yarn next build
|
||||
|
||||
sync-dl-index:
|
||||
@ -89,7 +89,7 @@ sync-dl-index:
|
||||
fi
|
||||
|
||||
export:
|
||||
@echo "📦 Exporting homepage static site to ./out ..."
|
||||
@echo "📦 Exporting dashboard static site to ./out ..."
|
||||
@NEXT_SHOULD_EXPORT=true yarn next export
|
||||
|
||||
clean:
|
||||
23
dashboard/app/AppProviders.tsx
Normal file
23
dashboard/app/AppProviders.tsx
Normal file
@ -0,0 +1,23 @@
|
||||
'use client'
|
||||
|
||||
import type { ReactNode } from 'react'
|
||||
|
||||
import { collectExtensionProviders } from '@cms'
|
||||
import { LanguageProvider } from '@i18n/LanguageProvider'
|
||||
import { UserProvider } from '@lib/userStore'
|
||||
|
||||
const extensionProviders = collectExtensionProviders()
|
||||
|
||||
export function AppProviders({ children }: { children: ReactNode }) {
|
||||
let tree: ReactNode = (
|
||||
<LanguageProvider>
|
||||
<UserProvider>{children}</UserProvider>
|
||||
</LanguageProvider>
|
||||
)
|
||||
|
||||
for (const Provider of extensionProviders) {
|
||||
tree = <Provider>{tree}</Provider>
|
||||
}
|
||||
|
||||
return tree
|
||||
}
|
||||
@ -5,7 +5,7 @@ Cloud IaC Catalog 提供跨云厂商(AWS、GCP、Azure、阿里云)的核心
|
||||
## 开发调试
|
||||
|
||||
```bash
|
||||
cd ui/homepage
|
||||
cd dashboard
|
||||
yarn install
|
||||
yarn dev
|
||||
```
|
||||
31
dashboard/app/layout.tsx
Normal file
31
dashboard/app/layout.tsx
Normal file
@ -0,0 +1,31 @@
|
||||
export const dynamic = 'error'
|
||||
|
||||
import { Fragment } from 'react'
|
||||
|
||||
import './globals.css'
|
||||
import { applyExtensionLayouts, getActiveTheme } from '@cms'
|
||||
import { AppProviders } from './AppProviders'
|
||||
|
||||
export const metadata = {
|
||||
title: 'CloudNative Suite',
|
||||
description: 'Unified tools for your cloud native stack',
|
||||
}
|
||||
|
||||
const theme = getActiveTheme()
|
||||
const ThemeProvider = theme.Provider ?? Fragment
|
||||
const htmlAttributes = theme.htmlAttributes ?? { lang: 'en' }
|
||||
const bodyClassName = theme.bodyClassName ?? 'bg-gray-50 text-gray-900'
|
||||
|
||||
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
||||
const content = applyExtensionLayouts(children)
|
||||
|
||||
return (
|
||||
<html {...htmlAttributes}>
|
||||
<body className={bodyClassName}>
|
||||
<ThemeProvider>
|
||||
<AppProviders>{content}</AppProviders>
|
||||
</ThemeProvider>
|
||||
</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
10
dashboard/app/page.tsx
Normal file
10
dashboard/app/page.tsx
Normal file
@ -0,0 +1,10 @@
|
||||
export const dynamic = 'error'
|
||||
|
||||
import { getActiveTemplate } from '@cms'
|
||||
|
||||
const template = getActiveTemplate()
|
||||
const HomePageTemplate = template.pages.home
|
||||
|
||||
export default function HomePage() {
|
||||
return <HomePageTemplate />
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user