diff --git a/CLAUDE.md b/CLAUDE.md index 341dcf6..f6d03f1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -32,7 +32,7 @@ These constraints were set by the project lead at kickoff. They apply to every c The structural, security, observability, and quality choices are recorded as ADRs and summarized below. Any change to these requires updating the corresponding ADR. - **Workspace:** Nx monorepo with the `apps` preset, managed by pnpm — see [ADR-0002](docs/decisions/0002-adopt-nx-monorepo-apps-preset.md). -- **Naming:** workspace `apf-portal`; apps `portal-shell` (frontend) and `portal-bff` (backend); libs `feature-` and `shared-` — see [ADR-0003](docs/decisions/0003-workspace-and-app-naming-convention.md). +- **Naming:** workspace `apf-portal`; apps `portal-shell` (end-user SPA), `portal-admin` (admin SPA, skeleton in place — see ADR-0020), and `portal-bff` (backend); libs `feature-` and `shared-` — see [ADR-0003](docs/decisions/0003-workspace-and-app-naming-convention.md). - **Frontend (`portal-shell`):** Angular at the latest LTS major — standalone APIs, zoneless change detection, Signals, **CSR only (no SSR)**, Vitest, SCSS — see [ADR-0004](docs/decisions/0004-frontend-stack-angular-csr-zoneless-signals.md). - **Backend (`portal-bff`):** NestJS at the latest stable major, mounted on the Express adapter (Fastify adapter swappable later) — see [ADR-0005](docs/decisions/0005-backend-stack-nestjs.md). - **Persistence:** PostgreSQL (latest stable major) via Prisma — see [ADR-0006](docs/decisions/0006-persistence-postgresql-prisma.md). @@ -60,7 +60,7 @@ If asked to "build", "test", or "run" anything, first verify whether the workspa ## Commands once the workspace exists -App-scoped — `` is one of `portal-shell`, `portal-bff`: +App-scoped — `` is one of `portal-shell`, `portal-admin`, `portal-bff`: ```bash pnpm nx serve # dev server diff --git a/apps/portal-admin-e2e/eslint.config.mjs b/apps/portal-admin-e2e/eslint.config.mjs new file mode 100644 index 0000000..b2e9fac --- /dev/null +++ b/apps/portal-admin-e2e/eslint.config.mjs @@ -0,0 +1,12 @@ +import playwright from 'eslint-plugin-playwright'; +import baseConfig from '../../eslint.config.mjs'; + +export default [ + playwright.configs['flat/recommended'], + ...baseConfig, + { + files: ['**/*.ts', '**/*.js'], + // Override or add rules here + rules: {}, + }, +]; diff --git a/apps/portal-admin-e2e/playwright.config.ts b/apps/portal-admin-e2e/playwright.config.ts new file mode 100644 index 0000000..ca10d23 --- /dev/null +++ b/apps/portal-admin-e2e/playwright.config.ts @@ -0,0 +1,68 @@ +import { defineConfig, devices } from '@playwright/test'; +import { nxE2EPreset } from '@nx/playwright/preset'; +import { workspaceRoot } from '@nx/devkit'; + +// For CI, you may want to set BASE_URL to the deployed application. +const baseURL = process.env['BASE_URL'] || 'http://localhost:4200'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// require('dotenv').config(); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + ...nxE2EPreset(__filename, { testDir: './src' }), + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + baseURL, + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + }, + /* Run your local dev server before starting the tests */ + webServer: { + command: 'pnpm exec nx run portal-admin:serve', + url: 'http://localhost:4200', + reuseExistingServer: true, + cwd: workspaceRoot, + }, + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + }, + + { + name: 'firefox', + use: { ...devices['Desktop Firefox'] }, + }, + + { + name: 'webkit', + use: { ...devices['Desktop Safari'] }, + }, + + // Uncomment for mobile browsers support + /* { + name: 'Mobile Chrome', + use: { ...devices['Pixel 5'] }, + }, + { + name: 'Mobile Safari', + use: { ...devices['iPhone 12'] }, + }, */ + + // Uncomment for branded browsers + /* { + name: 'Microsoft Edge', + use: { ...devices['Desktop Edge'], channel: 'msedge' }, + }, + { + name: 'Google Chrome', + use: { ...devices['Desktop Chrome'], channel: 'chrome' }, + } */ + ], +}); diff --git a/apps/portal-admin-e2e/project.json b/apps/portal-admin-e2e/project.json new file mode 100644 index 0000000..af4feaf --- /dev/null +++ b/apps/portal-admin-e2e/project.json @@ -0,0 +1,9 @@ +{ + "name": "portal-admin-e2e", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "projectType": "application", + "sourceRoot": "apps/portal-admin-e2e/src", + "implicitDependencies": ["portal-admin"], + "// targets": "to see all targets run: nx show project portal-admin-e2e --web", + "targets": {} +} diff --git a/apps/portal-admin-e2e/src/example.spec.ts b/apps/portal-admin-e2e/src/example.spec.ts new file mode 100644 index 0000000..fa8f1f3 --- /dev/null +++ b/apps/portal-admin-e2e/src/example.spec.ts @@ -0,0 +1,8 @@ +import { test, expect } from '@playwright/test'; + +test('has title', async ({ page }) => { + await page.goto('/'); + + // Expect h1 to contain a substring. + expect(await page.locator('h1').innerText()).toContain('Welcome'); +}); diff --git a/apps/portal-admin-e2e/tsconfig.json b/apps/portal-admin-e2e/tsconfig.json new file mode 100644 index 0000000..0b670c6 --- /dev/null +++ b/apps/portal-admin-e2e/tsconfig.json @@ -0,0 +1,24 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "allowJs": true, + "outDir": "../../dist/out-tsc", + "sourceMap": false, + "module": "commonjs", + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true + }, + "include": [ + "**/*.ts", + "**/*.js", + "playwright.config.ts", + "src/**/*.spec.ts", + "src/**/*.spec.js", + "src/**/*.test.ts", + "src/**/*.test.js", + "src/**/*.d.ts" + ] +} diff --git a/apps/portal-admin/.postcssrc.json b/apps/portal-admin/.postcssrc.json new file mode 100644 index 0000000..e092dc7 --- /dev/null +++ b/apps/portal-admin/.postcssrc.json @@ -0,0 +1,5 @@ +{ + "plugins": { + "@tailwindcss/postcss": {} + } +} diff --git a/apps/portal-admin/eslint.config.mjs b/apps/portal-admin/eslint.config.mjs new file mode 100644 index 0000000..af5ff32 --- /dev/null +++ b/apps/portal-admin/eslint.config.mjs @@ -0,0 +1,34 @@ +import nx from '@nx/eslint-plugin'; +import baseConfig from '../../eslint.config.mjs'; + +export default [ + ...nx.configs['flat/angular'], + ...nx.configs['flat/angular-template'], + ...baseConfig, + { + files: ['**/*.ts'], + rules: { + '@angular-eslint/directive-selector': [ + 'error', + { + type: 'attribute', + prefix: 'app', + style: 'camelCase', + }, + ], + '@angular-eslint/component-selector': [ + 'error', + { + type: 'element', + prefix: 'app', + style: 'kebab-case', + }, + ], + }, + }, + { + files: ['**/*.html'], + // Override or add rules here + rules: {}, + }, +]; diff --git a/apps/portal-admin/project.json b/apps/portal-admin/project.json new file mode 100644 index 0000000..6b61193 --- /dev/null +++ b/apps/portal-admin/project.json @@ -0,0 +1,123 @@ +{ + "name": "portal-admin", + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "projectType": "application", + "prefix": "app", + "sourceRoot": "apps/portal-admin/src", + "tags": ["scope:portal-admin", "type:app"], + "i18n": { + "sourceLocale": { + "code": "en", + "baseHref": "/en/" + }, + "locales": { + "fr": { + "translation": "apps/portal-admin/src/locale/messages.fr.xlf", + "baseHref": "/fr/" + } + } + }, + "targets": { + "build": { + "executor": "@angular/build:application", + "outputs": ["{options.outputPath}"], + "options": { + "outputPath": "dist/apps/portal-admin", + "browser": "apps/portal-admin/src/main.ts", + "polyfills": ["@angular/localize/init"], + "tsConfig": "apps/portal-admin/tsconfig.app.json", + "inlineStyleLanguage": "scss", + "assets": [ + { + "glob": "**/*", + "input": "apps/portal-admin/public" + } + ], + "styles": ["apps/portal-admin/src/styles.css"] + }, + "configurations": { + "production": { + "localize": ["en", "fr"], + "i18nMissingTranslation": "error", + "budgets": [ + { + "type": "initial", + "maximumWarning": "1.5mb", + "maximumError": "1.5mb" + }, + { + "type": "anyScript", + "maximumWarning": "500kb", + "maximumError": "500kb" + }, + { + "type": "anyComponentStyle", + "maximumWarning": "5kb", + "maximumError": "6kb" + }, + { + "type": "bundle", + "name": "styles", + "maximumWarning": "150kb", + "maximumError": "150kb" + } + ], + "outputHashing": "all" + }, + "development": { + "optimization": false, + "extractLicenses": false, + "sourceMap": true + } + }, + "defaultConfiguration": "production" + }, + "extract-i18n": { + "executor": "@angular/build:extract-i18n", + "options": { + "buildTarget": "portal-admin:build", + "outputPath": "apps/portal-admin/src/locale", + "outFile": "messages.xlf" + } + }, + "serve": { + "continuous": true, + "executor": "@angular/build:dev-server", + "options": { + "port": 4300 + }, + "configurations": { + "production": { + "buildTarget": "portal-admin:build:production" + }, + "development": { + "buildTarget": "portal-admin:build:development" + } + }, + "defaultConfiguration": "development" + }, + "lint": { + "executor": "@nx/eslint:lint" + }, + "test": { + "executor": "@angular/build:unit-test", + "options": { + "watch": false + }, + "configurations": { + "watch": { + "watch": true + } + } + }, + "serve-static": { + "continuous": true, + "executor": "@nx/web:file-server", + "options": { + "buildTarget": "portal-admin:build", + "port": 4300, + "staticFilePath": "dist/apps/portal-admin/browser" + } + } + } +} diff --git a/apps/portal-admin/public/favicon.ico b/apps/portal-admin/public/favicon.ico new file mode 100644 index 0000000..317ebcb Binary files /dev/null and b/apps/portal-admin/public/favicon.ico differ diff --git a/apps/portal-admin/src/app/app.config.ts b/apps/portal-admin/src/app/app.config.ts new file mode 100644 index 0000000..bef26c2 --- /dev/null +++ b/apps/portal-admin/src/app/app.config.ts @@ -0,0 +1,7 @@ +import { ApplicationConfig, provideBrowserGlobalErrorListeners } from '@angular/core'; +import { provideRouter } from '@angular/router'; +import { appRoutes } from './app.routes'; + +export const appConfig: ApplicationConfig = { + providers: [provideBrowserGlobalErrorListeners(), provideRouter(appRoutes)], +}; diff --git a/apps/portal-admin/src/app/app.html b/apps/portal-admin/src/app/app.html new file mode 100644 index 0000000..b138539 --- /dev/null +++ b/apps/portal-admin/src/app/app.html @@ -0,0 +1,4 @@ + +
+ +
diff --git a/apps/portal-admin/src/app/app.routes.ts b/apps/portal-admin/src/app/app.routes.ts new file mode 100644 index 0000000..fcb3747 --- /dev/null +++ b/apps/portal-admin/src/app/app.routes.ts @@ -0,0 +1,22 @@ +import { Route } from '@angular/router'; + +const homeTitle = $localize`:@@route.home.title:APF Portal Admin`; + +export const appRoutes: Route[] = [ + { + path: '', + pathMatch: 'full', + loadComponent: () => import('./pages/home/home').then((m) => m.Home), + title: homeTitle, + }, + // Catch-all — unknown paths bounce to home. Same role as the + // wildcard in portal-shell (per PR #96): in production each locale + // bundle ships with its own `` and the + // router never sees the locale segment, so this only fires for + // genuine 404 paths; in dev (`nx serve`) it stops the router from + // throwing NG04002 when a stray `/fr/`-style URL is typed. + { + path: '**', + redirectTo: '', + }, +]; diff --git a/apps/portal-admin/src/app/app.scss b/apps/portal-admin/src/app/app.scss new file mode 100644 index 0000000..2e6c7fe --- /dev/null +++ b/apps/portal-admin/src/app/app.scss @@ -0,0 +1,23 @@ +// Skip-link (WCAG 2.4.1 "Bypass Blocks"). Hidden by default, fully +// visible and focusable when reached via Tab from the address bar. +// Plain CSS rather than the `sr-only` Tailwind utilities so the +// visual state on focus is as predictable as possible across themes. +.skip-link { + position: absolute; + top: -40px; + left: 0.75rem; + z-index: 50; + padding: 0.5rem 0.75rem; + background: var(--color-brand-primary-500); + color: #fff; + border-radius: 0.25rem; + text-decoration: none; + transition: top 0.15s ease-out; + + &:focus, + &:focus-visible { + top: 0.5rem; + outline: 2px solid var(--color-brand-accent-300); + outline-offset: 2px; + } +} diff --git a/apps/portal-admin/src/app/app.spec.ts b/apps/portal-admin/src/app/app.spec.ts new file mode 100644 index 0000000..f11a31e --- /dev/null +++ b/apps/portal-admin/src/app/app.spec.ts @@ -0,0 +1,20 @@ +import { TestBed } from '@angular/core/testing'; +import { provideRouter } from '@angular/router'; +import { App } from './app'; + +describe('App', () => { + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [App], + providers: [provideRouter([])], + }).compileComponents(); + }); + + it('renders the layout shell — skip link, main landmark', async () => { + const fixture = TestBed.createComponent(App); + await fixture.whenStable(); + const root = fixture.nativeElement as HTMLElement; + expect(root.querySelector('a.skip-link')).not.toBeNull(); + expect(root.querySelector('main#main-content')).not.toBeNull(); + }); +}); diff --git a/apps/portal-admin/src/app/app.ts b/apps/portal-admin/src/app/app.ts new file mode 100644 index 0000000..d620f53 --- /dev/null +++ b/apps/portal-admin/src/app/app.ts @@ -0,0 +1,11 @@ +import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { RouterOutlet } from '@angular/router'; + +@Component({ + selector: 'app-root', + imports: [RouterOutlet], + templateUrl: './app.html', + styleUrl: './app.scss', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class App {} diff --git a/apps/portal-admin/src/app/pages/home/home.html b/apps/portal-admin/src/app/pages/home/home.html new file mode 100644 index 0000000..b446b12 --- /dev/null +++ b/apps/portal-admin/src/app/pages/home/home.html @@ -0,0 +1,24 @@ +
+

+ APF Portal Admin +

+

+ Administrative back-office for the APF Portal. The first functional modules — content + management, menu administration, user list, audit log viewer — land in upcoming PRs per + ADR-0020. +

+ +

+ Skeleton — coming soon +

+
diff --git a/apps/portal-admin/src/app/pages/home/home.ts b/apps/portal-admin/src/app/pages/home/home.ts new file mode 100644 index 0000000..e4eafc4 --- /dev/null +++ b/apps/portal-admin/src/app/pages/home/home.ts @@ -0,0 +1,16 @@ +import { ChangeDetectionStrategy, Component } from '@angular/core'; + +/** + * Smoke-test landing page for portal-admin. + * + * v1 ships a placeholder. The real admin shell (header + sidebar + + * footer with the "Admin" badge, per ADR-0020) lands in a follow-up + * PR together with the first functional module (CMS pages, menu + * management, user list, or audit log viewer). + */ +@Component({ + selector: 'app-home', + templateUrl: './home.html', + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class Home {} diff --git a/apps/portal-admin/src/index.html b/apps/portal-admin/src/index.html new file mode 100644 index 0000000..01c8014 --- /dev/null +++ b/apps/portal-admin/src/index.html @@ -0,0 +1,13 @@ + + + + + APF Portal Admin + + + + + + + + diff --git a/apps/portal-admin/src/locale/messages.fr.xlf b/apps/portal-admin/src/locale/messages.fr.xlf new file mode 100644 index 0000000..d1bd242 --- /dev/null +++ b/apps/portal-admin/src/locale/messages.fr.xlf @@ -0,0 +1,32 @@ + + + + + + + Skip to main content + Aller au contenu principal + + + + + APF Portal Admin + Administration APF Portal + + + + + APF Portal Admin + Administration APF Portal + + + Administrative back-office for the APF Portal. The first functional modules — content management, menu administration, user list, audit log viewer — land in upcoming PRs per ADR-0020. + Back-office d’administration pour le portail APF. Les premiers modules fonctionnels — gestion de contenu, gestion du menu, liste des utilisateurs, visualiseur d’audit log — arrivent dans les PRs à venir conformément à l’ADR-0020. + + + Skeleton — coming soon + Squelette — bientôt disponible + + + + diff --git a/apps/portal-admin/src/main.ts b/apps/portal-admin/src/main.ts new file mode 100644 index 0000000..190f341 --- /dev/null +++ b/apps/portal-admin/src/main.ts @@ -0,0 +1,5 @@ +import { bootstrapApplication } from '@angular/platform-browser'; +import { appConfig } from './app/app.config'; +import { App } from './app/app'; + +bootstrapApplication(App, appConfig).catch((err) => console.error(err)); diff --git a/apps/portal-admin/src/styles.css b/apps/portal-admin/src/styles.css new file mode 100644 index 0000000..435b0bf --- /dev/null +++ b/apps/portal-admin/src/styles.css @@ -0,0 +1,18 @@ +/* + * Global styles for portal-admin. + * + * Same baseline as portal-shell — Tailwind CSS 4 (CSS-first config), + * class-based dark mode, brand palette tokens shared from + * `libs/shared/tokens`. The two apps wear the same visual chrome so + * an APF user moving between portal and admin doesn't feel a context + * switch in the design system itself; what differentiates the admin + * surface is the data density and the "Admin" badge in the shell + * (added once the admin shell PR ships). + */ + +@import 'tailwindcss'; + +@custom-variant dark (&:where(.dark, .dark *)); + +/* Brand palette tokens — shared with portal-shell. */ +@import '../../../libs/shared/tokens/src/brand-tokens.css'; diff --git a/apps/portal-admin/tsconfig.app.json b/apps/portal-admin/tsconfig.app.json new file mode 100644 index 0000000..2ee35fa --- /dev/null +++ b/apps/portal-admin/tsconfig.app.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["@angular/localize"] + }, + "include": ["src/**/*.ts"], + "exclude": ["src/**/*.spec.ts", "src/**/*.test.ts"] +} diff --git a/apps/portal-admin/tsconfig.json b/apps/portal-admin/tsconfig.json new file mode 100644 index 0000000..29d6db1 --- /dev/null +++ b/apps/portal-admin/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "emitDecoratorMetadata": false, + "module": "preserve" + }, + "angularCompilerOptions": { + "enableI18nLegacyMessageIdFormat": false, + "strictInjectionParameters": true, + "strictInputAccessModifiers": true, + "strictTemplates": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/apps/portal-admin/tsconfig.spec.json b/apps/portal-admin/tsconfig.spec.json new file mode 100644 index 0000000..51f034e --- /dev/null +++ b/apps/portal-admin/tsconfig.spec.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "types": ["vitest/globals", "@angular/localize"] + }, + "include": ["src/**/*.ts", "src/**/*.d.ts"] +}