Compare commits
20 Commits
sprint/9-u
...
88dfa74663
| Author | SHA1 | Date | |
|---|---|---|---|
| 88dfa74663 | |||
|
|
2c7fcec7cd | ||
|
|
11ce3cfb86 | ||
|
|
790ced4204 | ||
|
|
1324a0c8ce | ||
|
|
5d34a5e171 | ||
|
|
1819089925 | ||
|
|
9a8c5f52ab | ||
|
|
59eaa342a9 | ||
|
|
004d075cad | ||
|
|
bca39dcca7 | ||
|
|
89fb38b107 | ||
| 65857134ef | |||
|
|
208c6e6428 | ||
|
|
91533c214c | ||
|
|
0fab40b486 | ||
|
|
ee5fda6059 | ||
|
|
774ae05748 | ||
|
|
c31f985e7a | ||
| 24d4a3b146 |
26
CHANGELOG.md
26
CHANGELOG.md
@@ -6,6 +6,32 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added — Sprint 11 (Spectrum UX port: 4 primitives + compact density global)
|
||||||
|
|
||||||
|
**Frontend only** (233 vitest passing — baseline 212 + 21 new tests across 4 new specs)
|
||||||
|
|
||||||
|
- `frontend/src/hooks/useHashTab.ts` — NEW. Pure-TS hook that reads `window.location.hash`, falls back to a default tab id, and listens to `hashchange` (cleanup on unmount). No style dependency.
|
||||||
|
- `frontend/src/components/Tabs.tsx` — NEW. `<Tabs items activeId onChange>` component. Underline variant: `tab-underline` / `tab-underline-active` CSS recipes. Count pill: `tab-count-pill` / `tab-count-pill-active` (`rounded-pill` exception per DESIGN.md). `role="tablist"` + `aria-selected` on tabs. Zero transitions.
|
||||||
|
- `frontend/src/components/AlertBanner.tsx` — NEW. `<AlertBanner variant="error|warn|success|info" title? children>`. Border-l-4 semantic strip, `bg-paper`, Lucide icon at `size={16}`. ARIA: `role="alert"` for error/warn, `role="status"` for success/info. No shadow, no radius, no transition.
|
||||||
|
- `frontend/src/components/BackLink.tsx` — NEW. `<BackLink to children>` renders `ArrowLeft` (Lucide, 14px) + text with `caption-md text-graphite hover:text-primary`. Replaces 3 hand-rolled back-link instances.
|
||||||
|
- `frontend/src/styles/index.css` — Added recipes: `.tab-underline`, `.tab-underline-active`, `.tab-count-pill`, `.tab-count-pill-active`, `.alert-error`, `.alert-warn`, `.alert-success`, `.alert-info`, `.table-compact` (32px row density, global).
|
||||||
|
- `frontend/src/pages/EngagementDetailPage.tsx` — Refactored to 3-tab layout (Schedule / Description / Simulations) wired via `useHashTab('schedule')`. Count pill on Simulations tab. BackLink replaces hand-rolled link.
|
||||||
|
- `frontend/src/pages/SimulationFormPage.tsx` — Done banner and SOC-blocked banner migrated to `<AlertBanner>`. Both back-link instances replaced with `<BackLink>`.
|
||||||
|
- `frontend/src/pages/TemplateFormPage.tsx` — Back-link replaced with `<BackLink>`.
|
||||||
|
- `frontend/src/pages/EngagementsListPage.tsx` — Table marked `table-compact`, inline `px-xl py-md` padding removed from th/td (recipe handles it).
|
||||||
|
- `frontend/src/pages/TemplatesListPage.tsx` — Same compact table treatment.
|
||||||
|
- `frontend/src/pages/UsersAdminPage.tsx` — Same compact table treatment.
|
||||||
|
- `frontend/src/components/SimulationList.tsx` — Same compact table treatment.
|
||||||
|
- `DESIGN.md` — Added `### Navigation › Sub-page tabs` subsection; updated `### Data Tables` row min-height 44px → 32px with WCAG SC 2.5.5 rationale; added `### Inline Banners` subsection under `### Toast Notifications`.
|
||||||
|
|
||||||
|
**Tests added** (21 new assertions across 4 new spec files):
|
||||||
|
- `tests/hooks/useHashTab.test.tsx` — 4 tests (default, hash read on mount, navigate(), empty-hash fallback)
|
||||||
|
- `tests/components/Tabs.test.tsx` — 7 tests (render, aria-selected, active class, count pill, count-pill-active, onChange, brutalism)
|
||||||
|
- `tests/components/AlertBanner.test.tsx` — 6 tests (4 variants × role + class, title prop, brutalism)
|
||||||
|
- `tests/components/BackLink.test.tsx` — 4 tests (render, href, brutalism, svg icon)
|
||||||
|
|
||||||
|
**No backend changes.** No DB schema change. No migration.
|
||||||
|
|
||||||
### Changed — Sprint 7 (Terminal-SOC design refresh)
|
### Changed — Sprint 7 (Terminal-SOC design refresh)
|
||||||
|
|
||||||
**Frontend** (136 vitest passing — unchanged count, 3 assertions updated for new token names)
|
**Frontend** (136 vitest passing — unchanged count, 3 assertions updated for new token names)
|
||||||
|
|||||||
31
DESIGN.md
31
DESIGN.md
@@ -216,11 +216,23 @@ Shadows (`box-shadow`) are not used anywhere.
|
|||||||
- Text `{colors.slab-text}`, caption-md, `rounded-none`
|
- Text `{colors.slab-text}`, caption-md, `rounded-none`
|
||||||
- Active state: 2px primary bottom border
|
- Active state: 2px primary bottom border
|
||||||
|
|
||||||
|
#### Sub-page tabs
|
||||||
|
|
||||||
|
Used inside pages that need content partitioning without a URL change (e.g. EngagementDetailPage: Schedule / Description / Simulations).
|
||||||
|
|
||||||
|
- **Container**: `flex items-end border-b border-hairline gap-xs` — sits on the `{colors.hairline}` bottom line.
|
||||||
|
- **`.tab-underline`**: `text-graphite caption-bold cursor-pointer border-b-2 border-transparent hover:text-ink px-xs`. Hover is **instant** — no `transition-*`.
|
||||||
|
- **`.tab-underline-active`**: `text-primary border-primary` — 2px primary underline, primary text.
|
||||||
|
- **Count pill** (optional, e.g. simulation count): `.tab-count-pill` — `rounded-pill bg-cloud text-graphite text-[11px] px-xs py-0 font-mono`. `rounded-pill` is the documented exception.
|
||||||
|
- **Active count pill**: `.tab-count-pill-active` — `bg-primary-soft text-primary`.
|
||||||
|
- ARIA: `role="tablist"` on container; `role="tab"` + `aria-selected` on each button.
|
||||||
|
|
||||||
### Data Tables
|
### Data Tables
|
||||||
|
|
||||||
- `table-layout: fixed`, `word-break: break-word`
|
- `table-layout: fixed`, `word-break: break-word`
|
||||||
- Header row: background `{colors.cloud}`, `body-emphasis` text, 1px `{colors.hairline}` bottom border
|
- Header row: background `{colors.cloud}`, `body-emphasis` text, 1px `{colors.hairline}` bottom border
|
||||||
- Data cells: 44px min-height, 1px `{colors.hairline}` bottom border
|
- Data cells: **32px min-height** (compact density, all surfaces). Class: `.table-compact`.
|
||||||
|
- **WCAG SC 2.5.5 tradeoff**: the recommended 44×44px touch target is intentionally not met on data rows. Mimic is a BAS operator console used at desktop on mouse/keyboard — density and scanability take priority over touch target size. Action buttons within rows retain icon ≥ 24px with adequate padding to preserve a usable hit area.
|
||||||
- ID / date / technique columns: `font-mono`
|
- ID / date / technique columns: `font-mono`
|
||||||
- Zebra striping optional — use `{colors.cloud}` for odd rows if table is wide
|
- Zebra striping optional — use `{colors.cloud}` for odd rows if table is wide
|
||||||
|
|
||||||
@@ -229,6 +241,23 @@ Shadows (`box-shadow`) are not used anywhere.
|
|||||||
- Angular (`rounded-none`), 4px left border strip in semantic color (success/warn/bloom-deep/primary)
|
- Angular (`rounded-none`), 4px left border strip in semantic color (success/warn/bloom-deep/primary)
|
||||||
- Background `{colors.paper}`, 1px `{colors.hairline}` border
|
- Background `{colors.paper}`, 1px `{colors.hairline}` border
|
||||||
|
|
||||||
|
#### Inline Banners
|
||||||
|
|
||||||
|
For persistent in-page status messages (not ephemeral toasts). Use `<AlertBanner variant="...">` component.
|
||||||
|
|
||||||
|
Four variants — all share: `bg-paper border border-hairline border-l-4 rounded-none px-md py-sm flex items-start gap-sm`.
|
||||||
|
|
||||||
|
| Variant | Left strip color | ARIA role | Lucide icon |
|
||||||
|
|---------|-----------------|-----------|-------------|
|
||||||
|
| `error` | `border-l-bloom-deep` | `role="alert"` | `AlertCircle` |
|
||||||
|
| `warn` | `border-l-warn` | `role="alert"` | `AlertTriangle` |
|
||||||
|
| `success` | `border-l-success` | `role="status"` | `CheckCircle` |
|
||||||
|
| `info` | `border-l-primary` | `role="status"` | `Info` |
|
||||||
|
|
||||||
|
- Icon: Lucide at `size={16}`, `aria-hidden`, `mt-[2px] shrink-0` for baseline alignment.
|
||||||
|
- No shadow, no rounded corners, no transition.
|
||||||
|
- Optional `title` prop renders as `font-medium text-ink` above the message body.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Do's and Don'ts
|
## Do's and Don'ts
|
||||||
|
|||||||
2
SPEC.md
2
SPEC.md
@@ -82,7 +82,7 @@ Couche d'intégration C2 permettant d'exécuter les commandes d'une simulation
|
|||||||
| `engagement_id` | int FK `engagements.id` ON DELETE CASCADE, **UNIQUE** | |
|
| `engagement_id` | int FK `engagements.id` ON DELETE CASCADE, **UNIQUE** | |
|
||||||
| `url` | text | endpoint Mythic, ex. `https://lab.internal:7443` |
|
| `url` | text | endpoint Mythic, ex. `https://lab.internal:7443` |
|
||||||
| `api_token_encrypted` | text | Fernet ciphertext, jamais en clair |
|
| `api_token_encrypted` | text | Fernet ciphertext, jamais en clair |
|
||||||
| `verify_tls` | bool, défaut `true` | `false` autorisé pour labs auto-signés |
|
| `verify_tls` | bool, défaut `false` | Désactivé par défaut — Mimic cible des labs Mythic avec certs auto-signés. Cocher pour forcer la vérification TLS en prod. |
|
||||||
| `created_at`, `updated_at` | datetime | |
|
| `created_at`, `updated_at` | datetime | |
|
||||||
|
|
||||||
`c2_task` (lien simulation ↔ tâche Mythic) :
|
`c2_task` (lien simulation ↔ tâche Mythic) :
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ def upsert_c2_config(eid: int):
|
|||||||
if not parsed.hostname:
|
if not parsed.hostname:
|
||||||
return jsonify({"error": "url must contain a hostname"}), 400
|
return jsonify({"error": "url must contain a hostname"}), 400
|
||||||
|
|
||||||
verify_tls = data.get("verify_tls", True)
|
verify_tls = data.get("verify_tls", False)
|
||||||
if not isinstance(verify_tls, bool):
|
if not isinstance(verify_tls, bool):
|
||||||
return jsonify({"error": "verify_tls must be a boolean"}), 400
|
return jsonify({"error": "verify_tls must be a boolean"}), 400
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class C2Config(db.Model): # type: ignore[name-defined]
|
|||||||
)
|
)
|
||||||
url = db.Column(db.Text, nullable=False)
|
url = db.Column(db.Text, nullable=False)
|
||||||
api_token_encrypted = db.Column(db.Text, nullable=False)
|
api_token_encrypted = db.Column(db.Text, nullable=False)
|
||||||
verify_tls = db.Column(db.Boolean, nullable=False, default=True)
|
verify_tls = db.Column(db.Boolean, nullable=False, default=False)
|
||||||
created_at = db.Column(
|
created_at = db.Column(
|
||||||
db.DateTime, nullable=False, default=lambda: datetime.now(UTC)
|
db.DateTime, nullable=False, default=lambda: datetime.now(UTC)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import os
|
|||||||
from backend.app.services.c2.adapter import C2Adapter
|
from backend.app.services.c2.adapter import C2Adapter
|
||||||
|
|
||||||
|
|
||||||
def get_adapter(url: str, api_token: str, verify_tls: bool = True) -> C2Adapter:
|
def get_adapter(url: str, api_token: str, verify_tls: bool = False) -> C2Adapter:
|
||||||
"""Return the correct C2Adapter based on MIMIC_C2_ADAPTER (default: mythic)."""
|
"""Return the correct C2Adapter based on MIMIC_C2_ADAPTER (default: mythic)."""
|
||||||
adapter_name = os.environ.get("MIMIC_C2_ADAPTER", "mythic").lower()
|
adapter_name = os.environ.get("MIMIC_C2_ADAPTER", "mythic").lower()
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
# Contract pinned from MythicMeta/Mythic_Scripting master @ 2026-06-10 (raw.githubusercontent.com/MythicMeta/Mythic_Scripting/master/mythic/mythic.py)
|
# Contract pinned from MythicMeta/Mythic_Scripting master @ 2026-06-10 (raw.githubusercontent.com/MythicMeta/Mythic_Scripting/master/mythic/mythic.py)
|
||||||
|
# Sprint 10 correction: /graphql/ MUST have trailing slash (matches mythic_utilities.get_http_transport).
|
||||||
"""Mythic 3.x C2 adapter.
|
"""Mythic 3.x C2 adapter.
|
||||||
|
|
||||||
Transport: POST https://<host>:7443/graphql
|
Transport: POST https://<host>:7443/graphql/
|
||||||
Header: apitoken: <token>
|
Header: apitoken: <token>
|
||||||
Backend: Hasura-proxied Postgres behind nginx.
|
Backend: Hasura-proxied Postgres behind nginx.
|
||||||
|
|
||||||
@@ -15,6 +16,8 @@ from __future__ import annotations
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
import urllib3
|
||||||
|
from urllib3.exceptions import InsecureRequestWarning
|
||||||
|
|
||||||
from backend.app.services.c2.adapter import (
|
from backend.app.services.c2.adapter import (
|
||||||
C2Adapter,
|
C2Adapter,
|
||||||
@@ -113,10 +116,14 @@ query GetTaskOutput($display_id: Int!) {
|
|||||||
class MythicAdapter(C2Adapter):
|
class MythicAdapter(C2Adapter):
|
||||||
"""Real Mythic 3.x adapter using GraphQL over HTTP."""
|
"""Real Mythic 3.x adapter using GraphQL over HTTP."""
|
||||||
|
|
||||||
def __init__(self, url: str, api_token: str, verify_tls: bool = True) -> None:
|
def __init__(self, url: str, api_token: str, verify_tls: bool = False) -> None:
|
||||||
self._url = url.rstrip("/") + "/graphql"
|
self._url = url.rstrip("/") + "/graphql/"
|
||||||
self._token = api_token
|
self._token = api_token
|
||||||
self._verify = verify_tls
|
self._verify = verify_tls
|
||||||
|
if not verify_tls:
|
||||||
|
# Lab/red-team Mythic instances commonly use self-signed certs.
|
||||||
|
# Suppress urllib3 warnings once per process when verification is off.
|
||||||
|
urllib3.disable_warnings(InsecureRequestWarning)
|
||||||
|
|
||||||
def _headers(self) -> dict[str, str]:
|
def _headers(self) -> dict[str, str]:
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
"""flip c2_config.verify_tls server_default to false
|
||||||
|
|
||||||
|
Revision ID: 0008_c2_verify_tls_default_false
|
||||||
|
Revises: 0007
|
||||||
|
Create Date: 2026-06-21 00:00:00.000000
|
||||||
|
"""
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from alembic import op
|
||||||
|
|
||||||
|
revision = "0008_c2_verify_tls_default_false"
|
||||||
|
down_revision = "0007"
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade() -> None:
|
||||||
|
with op.batch_alter_table("c2_config") as batch_op:
|
||||||
|
batch_op.alter_column(
|
||||||
|
"verify_tls",
|
||||||
|
existing_type=sa.Boolean(),
|
||||||
|
existing_nullable=False,
|
||||||
|
server_default=sa.false(),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade() -> None:
|
||||||
|
with op.batch_alter_table("c2_config") as batch_op:
|
||||||
|
batch_op.alter_column(
|
||||||
|
"verify_tls",
|
||||||
|
existing_type=sa.Boolean(),
|
||||||
|
existing_nullable=False,
|
||||||
|
server_default=sa.true(),
|
||||||
|
)
|
||||||
@@ -9,7 +9,7 @@ from backend.app.services.c2.adapter import C2Error
|
|||||||
from backend.app.services.c2.mythic import MythicAdapter
|
from backend.app.services.c2.mythic import MythicAdapter
|
||||||
|
|
||||||
_BASE_URL = "https://mythic.lab:7443"
|
_BASE_URL = "https://mythic.lab:7443"
|
||||||
_GQL_URL = _BASE_URL + "/graphql"
|
_GQL_URL = _BASE_URL + "/graphql/"
|
||||||
_TOKEN = "fake-api-token"
|
_TOKEN = "fake-api-token"
|
||||||
|
|
||||||
|
|
||||||
@@ -143,9 +143,19 @@ class TestMythicAdapterNoRedirects:
|
|||||||
"""Adapter must not follow HTTP redirects (allow_redirects=False)."""
|
"""Adapter must not follow HTTP redirects (allow_redirects=False)."""
|
||||||
with rm_module.Mocker() as m:
|
with rm_module.Mocker() as m:
|
||||||
# Simulate a redirect response; requests-mock won't auto-follow it.
|
# Simulate a redirect response; requests-mock won't auto-follow it.
|
||||||
m.post(_GQL_URL, status_code=301, headers={"Location": "https://evil.example/graphql"})
|
m.post(_GQL_URL, status_code=301, headers={"Location": "https://evil.example/graphql/"})
|
||||||
# With allow_redirects=False the 301 is treated as a non-2xx → raise_for_status raises.
|
# With allow_redirects=False the 301 is treated as a non-2xx → raise_for_status raises.
|
||||||
with pytest.raises(C2Error):
|
with pytest.raises(C2Error):
|
||||||
adapter.list_callbacks()
|
adapter.list_callbacks()
|
||||||
# Exactly one request was made — no follow-up to Location.
|
# Exactly one request was made — no follow-up to Location.
|
||||||
assert len(m.request_history) == 1
|
assert len(m.request_history) == 1
|
||||||
|
|
||||||
|
|
||||||
|
class TestMythicAdapterUrlConstruction:
|
||||||
|
def test_mythic_adapter_url_has_trailing_slash(self):
|
||||||
|
a1 = MythicAdapter(url="https://x:7443", api_token="t")
|
||||||
|
assert a1._url == "https://x:7443/graphql/"
|
||||||
|
a2 = MythicAdapter(url="https://x:7443/", api_token="t")
|
||||||
|
assert a2._url == "https://x:7443/graphql/"
|
||||||
|
a3 = MythicAdapter(url="https://x:7443///", api_token="t")
|
||||||
|
assert a3._url == "https://x:7443/graphql/"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from backend.app.services.c2.adapter import C2Error
|
|||||||
from backend.app.services.c2.mythic import MythicAdapter
|
from backend.app.services.c2.mythic import MythicAdapter
|
||||||
|
|
||||||
_BASE_URL = "https://mythic.lab:7443"
|
_BASE_URL = "https://mythic.lab:7443"
|
||||||
_GQL_URL = _BASE_URL + "/graphql"
|
_GQL_URL = _BASE_URL + "/graphql/"
|
||||||
_TOKEN = "fake-api-token"
|
_TOKEN = "fake-api-token"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from backend.app.services.c2.adapter import C2Error, C2HistoricalTask
|
|||||||
from backend.app.services.c2.mythic import MythicAdapter
|
from backend.app.services.c2.mythic import MythicAdapter
|
||||||
|
|
||||||
_BASE_URL = "https://mythic.lab:7443"
|
_BASE_URL = "https://mythic.lab:7443"
|
||||||
_GQL_URL = _BASE_URL + "/graphql"
|
_GQL_URL = _BASE_URL + "/graphql/"
|
||||||
_TOKEN = "fake-api-token"
|
_TOKEN = "fake-api-token"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -206,13 +206,13 @@ def test_get_config_returns_has_token_not_cleartext(
|
|||||||
assert "s3cr3t" not in str(body)
|
assert "s3cr3t" not in str(body)
|
||||||
|
|
||||||
|
|
||||||
def test_get_config_verify_tls_default_true(
|
def test_get_config_verify_tls_default_false(
|
||||||
client: FlaskClient, admin_token: str
|
client: FlaskClient, admin_token: str
|
||||||
) -> None:
|
) -> None:
|
||||||
eng = _make_engagement(client, admin_token)
|
eng = _make_engagement(client, admin_token)
|
||||||
_put_config(client, admin_token, eng["id"])
|
_put_config(client, admin_token, eng["id"], verify_tls=False)
|
||||||
resp = client.get(f"/api/engagements/{eng['id']}/c2-config", headers=_h(admin_token))
|
resp = client.get(f"/api/engagements/{eng['id']}/c2-config", headers=_h(admin_token))
|
||||||
assert resp.get_json()["verify_tls"] is True
|
assert resp.get_json()["verify_tls"] is False
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|||||||
30
frontend/src/components/AlertBanner.tsx
Normal file
30
frontend/src/components/AlertBanner.tsx
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import type { ReactNode } from 'react';
|
||||||
|
import { AlertCircle, AlertTriangle, CheckCircle, Info } from 'lucide-react';
|
||||||
|
|
||||||
|
type AlertVariant = 'error' | 'warn' | 'success' | 'info';
|
||||||
|
|
||||||
|
interface AlertBannerProps {
|
||||||
|
variant: AlertVariant;
|
||||||
|
title?: string;
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CONFIG: Record<AlertVariant, { cls: string; Icon: typeof AlertCircle; role: string }> = {
|
||||||
|
error: { cls: 'alert-error', Icon: AlertCircle, role: 'alert' },
|
||||||
|
warn: { cls: 'alert-warn', Icon: AlertTriangle, role: 'alert' },
|
||||||
|
success: { cls: 'alert-success', Icon: CheckCircle, role: 'status' },
|
||||||
|
info: { cls: 'alert-info', Icon: Info, role: 'status' },
|
||||||
|
};
|
||||||
|
|
||||||
|
export function AlertBanner({ variant, title, children }: AlertBannerProps): JSX.Element {
|
||||||
|
const { cls, Icon, role } = CONFIG[variant];
|
||||||
|
return (
|
||||||
|
<div role={role} className={cls}>
|
||||||
|
<Icon size={16} aria-hidden className="mt-[2px] shrink-0" />
|
||||||
|
<div className="flex flex-col gap-xxs text-[14px]">
|
||||||
|
{title ? <span className="font-medium text-ink">{title}</span> : null}
|
||||||
|
<span className="text-charcoal">{children}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
17
frontend/src/components/BackLink.tsx
Normal file
17
frontend/src/components/BackLink.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import { ArrowLeft } from 'lucide-react';
|
||||||
|
import type { ReactNode } from 'react';
|
||||||
|
|
||||||
|
interface BackLinkProps {
|
||||||
|
to: string;
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function BackLink({ to, children }: BackLinkProps): JSX.Element {
|
||||||
|
return (
|
||||||
|
<Link to={to} className="inline-flex items-center gap-xxs caption-md text-graphite hover:text-primary">
|
||||||
|
<ArrowLeft size={14} aria-hidden />
|
||||||
|
{children}
|
||||||
|
</Link>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ export function C2ConfigCard({ engagementId }: C2ConfigCardProps): JSX.Element {
|
|||||||
|
|
||||||
const [url, setUrl] = useState('');
|
const [url, setUrl] = useState('');
|
||||||
const [token, setToken] = useState('');
|
const [token, setToken] = useState('');
|
||||||
const [verifyTls, setVerifyTls] = useState(true);
|
const [verifyTls, setVerifyTls] = useState(false);
|
||||||
const [replaceToken, setReplaceToken] = useState(false);
|
const [replaceToken, setReplaceToken] = useState(false);
|
||||||
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
||||||
const [testResult, setTestResult] = useState<{ ok: boolean; message: string } | null>(null);
|
const [testResult, setTestResult] = useState<{ ok: boolean; message: string } | null>(null);
|
||||||
@@ -71,7 +71,7 @@ export function C2ConfigCard({ engagementId }: C2ConfigCardProps): JSX.Element {
|
|||||||
push('C2 configuration removed', 'success');
|
push('C2 configuration removed', 'success');
|
||||||
setUrl('');
|
setUrl('');
|
||||||
setToken('');
|
setToken('');
|
||||||
setVerifyTls(true);
|
setVerifyTls(false);
|
||||||
setReplaceToken(false);
|
setReplaceToken(false);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
push(extractApiError(err, 'Could not remove C2 configuration'), 'error');
|
push(extractApiError(err, 'Could not remove C2 configuration'), 'error');
|
||||||
@@ -166,19 +166,25 @@ export function C2ConfigCard({ engagementId }: C2ConfigCardProps): JSX.Element {
|
|||||||
)}
|
)}
|
||||||
</FormField>
|
</FormField>
|
||||||
|
|
||||||
<div className="flex items-center gap-sm">
|
<div className="flex flex-col gap-xs">
|
||||||
<input
|
<div className="flex items-center gap-sm">
|
||||||
id="c2-verify-tls"
|
<input
|
||||||
data-testid="c2-verify-tls"
|
id="c2-verify-tls"
|
||||||
type="checkbox"
|
data-testid="c2-verify-tls"
|
||||||
checked={verifyTls}
|
type="checkbox"
|
||||||
onChange={(e) => setVerifyTls(e.target.checked)}
|
checked={verifyTls}
|
||||||
disabled={disabled}
|
onChange={(e) => setVerifyTls(e.target.checked)}
|
||||||
className="h-4 w-4 accent-primary"
|
disabled={disabled}
|
||||||
/>
|
className="h-4 w-4 accent-primary"
|
||||||
<label htmlFor="c2-verify-tls" className="text-[14px] text-ink">
|
/>
|
||||||
Verify TLS certificate
|
<label htmlFor="c2-verify-tls" className="text-[14px] text-ink">
|
||||||
</label>
|
Verify TLS certificate
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<p className="text-[12px] text-graphite">
|
||||||
|
Uncheck only for lab Mythic with self-signed certificates. Disabling
|
||||||
|
verification exposes the API token to MITM.
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex items-center gap-md flex-wrap">
|
<div className="flex items-center gap-md flex-wrap">
|
||||||
|
|||||||
@@ -172,25 +172,25 @@ export function SimulationList({ engagementId }: SimulationListProps): JSX.Eleme
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="card-product overflow-hidden p-0">
|
<div className="card-product overflow-hidden p-0">
|
||||||
<table className="w-full text-left">
|
<table className="table-compact w-full text-left">
|
||||||
<thead className="bg-cloud border-b border-hairline">
|
<thead className="bg-cloud border-b border-hairline">
|
||||||
<tr className="text-[12px] uppercase tracking-[0.5px] text-graphite">
|
<tr>
|
||||||
<th className="px-xl py-md">Name</th>
|
<th>Name</th>
|
||||||
<th className="px-xl py-md">MITRE</th>
|
<th>MITRE</th>
|
||||||
<th className="px-xl py-md">Status</th>
|
<th>Status</th>
|
||||||
<th className="px-xl py-md">Executed at</th>
|
<th>Executed at</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{data.map((sim) => (
|
{data.map((sim) => (
|
||||||
<tr
|
<tr
|
||||||
key={sim.id}
|
key={sim.id}
|
||||||
className="border-b border-hairline last:border-0 hover:bg-cloud cursor-pointer"
|
className="hover:bg-cloud cursor-pointer"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
navigate(`/engagements/${engagementId}/simulations/${sim.id}/edit`)
|
navigate(`/engagements/${engagementId}/simulations/${sim.id}/edit`)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<td className="px-xl py-md">
|
<td>
|
||||||
<Link
|
<Link
|
||||||
to={`/engagements/${engagementId}/simulations/${sim.id}/edit`}
|
to={`/engagements/${engagementId}/simulations/${sim.id}/edit`}
|
||||||
className="text-ink font-medium hover:underline"
|
className="text-ink font-medium hover:underline"
|
||||||
@@ -199,7 +199,7 @@ export function SimulationList({ engagementId }: SimulationListProps): JSX.Eleme
|
|||||||
{sim.name}
|
{sim.name}
|
||||||
</Link>
|
</Link>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-xl py-md text-charcoal text-[14px] font-mono">
|
<td className="text-charcoal font-mono">
|
||||||
{(() => {
|
{(() => {
|
||||||
const items = [
|
const items = [
|
||||||
...(sim.tactics ?? []).map((t) => t.id),
|
...(sim.tactics ?? []).map((t) => t.id),
|
||||||
@@ -210,10 +210,10 @@ export function SimulationList({ engagementId }: SimulationListProps): JSX.Eleme
|
|||||||
return `${items[0]} +${items.length - 1}`;
|
return `${items[0]} +${items.length - 1}`;
|
||||||
})()}
|
})()}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-xl py-md">
|
<td>
|
||||||
<SimulationStatusBadge status={sim.status} />
|
<SimulationStatusBadge status={sim.status} />
|
||||||
</td>
|
</td>
|
||||||
<td className="px-xl py-md text-charcoal text-[14px] font-mono">
|
<td className="text-charcoal font-mono">
|
||||||
{formatDate(sim.executed_at)}
|
{formatDate(sim.executed_at)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
58
frontend/src/components/Tabs.tsx
Normal file
58
frontend/src/components/Tabs.tsx
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
import type { KeyboardEvent } from 'react';
|
||||||
|
|
||||||
|
interface TabItem {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
count?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TabsProps {
|
||||||
|
items: TabItem[];
|
||||||
|
activeId: string;
|
||||||
|
onChange: (id: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Tabs({ items, activeId, onChange }: TabsProps): JSX.Element {
|
||||||
|
function handleKeyDown(e: KeyboardEvent<HTMLButtonElement>, index: number) {
|
||||||
|
if (e.key === 'ArrowRight') {
|
||||||
|
e.preventDefault();
|
||||||
|
onChange(items[(index + 1) % items.length].id);
|
||||||
|
} else if (e.key === 'ArrowLeft') {
|
||||||
|
e.preventDefault();
|
||||||
|
onChange(items[(index - 1 + items.length) % items.length].id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
role="tablist"
|
||||||
|
className="flex items-end border-b border-hairline gap-xs"
|
||||||
|
>
|
||||||
|
{items.map((item, index) => {
|
||||||
|
const isActive = item.id === activeId;
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={item.id}
|
||||||
|
id={`tab-${item.id}`}
|
||||||
|
role="tab"
|
||||||
|
aria-selected={isActive}
|
||||||
|
aria-controls={`tabpanel-${item.id}`}
|
||||||
|
type="button"
|
||||||
|
onClick={() => onChange(item.id)}
|
||||||
|
onKeyDown={(e) => handleKeyDown(e, index)}
|
||||||
|
className={`tab-underline${isActive ? ' tab-underline-active' : ''} pb-xs`}
|
||||||
|
>
|
||||||
|
{item.label}
|
||||||
|
{item.count !== undefined ? (
|
||||||
|
<span
|
||||||
|
className={`ml-xxs tab-count-pill${isActive ? ' tab-count-pill-active' : ''}`}
|
||||||
|
>
|
||||||
|
{item.count}
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
26
frontend/src/hooks/useHashTab.ts
Normal file
26
frontend/src/hooks/useHashTab.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
|
|
||||||
|
function readHash(defaultId: string): string {
|
||||||
|
const hash = window.location.hash.slice(1); // strip leading '#'
|
||||||
|
return hash || defaultId;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useHashTab(defaultId: string): [string, (id: string) => void] {
|
||||||
|
const [activeId, setActiveId] = useState<string>(() => readHash(defaultId));
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
function onHashChange() {
|
||||||
|
setActiveId(readHash(defaultId));
|
||||||
|
}
|
||||||
|
window.addEventListener('hashchange', onHashChange);
|
||||||
|
return () => window.removeEventListener('hashchange', onHashChange);
|
||||||
|
}, [defaultId]);
|
||||||
|
|
||||||
|
const navigate = useCallback((id: string) => {
|
||||||
|
// replaceState: no history entry (Back button unaffected), no anchor-jump scroll
|
||||||
|
history.replaceState(null, '', '#' + id);
|
||||||
|
setActiveId(id);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return [activeId, navigate];
|
||||||
|
}
|
||||||
@@ -1,12 +1,19 @@
|
|||||||
import { Link, useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { extractApiError } from '@/api/client';
|
import { extractApiError } from '@/api/client';
|
||||||
import { useAuth } from '@/hooks/useAuth';
|
import { useAuth } from '@/hooks/useAuth';
|
||||||
import { useEngagement } from '@/hooks/useEngagements';
|
import { useEngagement } from '@/hooks/useEngagements';
|
||||||
|
import { useHashTab } from '@/hooks/useHashTab';
|
||||||
|
import { useEngagementSimulations } from '@/hooks/useSimulations';
|
||||||
import { LoadingState } from '@/components/LoadingState';
|
import { LoadingState } from '@/components/LoadingState';
|
||||||
import { ErrorState } from '@/components/ErrorState';
|
import { ErrorState } from '@/components/ErrorState';
|
||||||
import { StatusBadge } from '@/components/StatusBadge';
|
import { StatusBadge } from '@/components/StatusBadge';
|
||||||
import { SimulationList } from '@/components/SimulationList';
|
import { SimulationList } from '@/components/SimulationList';
|
||||||
import { ExportEngagementButton } from '@/components/ExportEngagementButton';
|
import { ExportEngagementButton } from '@/components/ExportEngagementButton';
|
||||||
|
import { BackLink } from '@/components/BackLink';
|
||||||
|
import { Tabs } from '@/components/Tabs';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
|
type TabId = 'schedule' | 'description' | 'simulations';
|
||||||
|
|
||||||
export function EngagementDetailPage(): JSX.Element {
|
export function EngagementDetailPage(): JSX.Element {
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
@@ -14,6 +21,10 @@ export function EngagementDetailPage(): JSX.Element {
|
|||||||
const { canEditEngagements } = useAuth();
|
const { canEditEngagements } = useAuth();
|
||||||
|
|
||||||
const detail = useEngagement(numericId);
|
const detail = useEngagement(numericId);
|
||||||
|
const simsQuery = useEngagementSimulations(numericId);
|
||||||
|
|
||||||
|
const [activeTabRaw, setActiveTab] = useHashTab('schedule');
|
||||||
|
const activeTab = activeTabRaw as TabId;
|
||||||
|
|
||||||
if (detail.isLoading) return <LoadingState label="Loading engagement…" />;
|
if (detail.isLoading) return <LoadingState label="Loading engagement…" />;
|
||||||
if (detail.isError) {
|
if (detail.isError) {
|
||||||
@@ -27,14 +38,19 @@ export function EngagementDetailPage(): JSX.Element {
|
|||||||
if (!detail.data) return <ErrorState message="Engagement not found" />;
|
if (!detail.data) return <ErrorState message="Engagement not found" />;
|
||||||
|
|
||||||
const eng = detail.data;
|
const eng = detail.data;
|
||||||
|
const simCount = simsQuery.data?.length;
|
||||||
|
|
||||||
|
const tabs = [
|
||||||
|
{ id: 'schedule', label: 'Schedule' },
|
||||||
|
{ id: 'description', label: 'Description' },
|
||||||
|
{ id: 'simulations', label: 'Simulations', count: simCount },
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-xl">
|
<div className="flex flex-col gap-xl">
|
||||||
<header className="flex items-start justify-between gap-md">
|
<header className="flex items-start justify-between gap-md">
|
||||||
<div className="flex flex-col gap-sm">
|
<div className="flex flex-col gap-sm">
|
||||||
<Link to="/engagements" className="btn-text-link text-[14px]">
|
<BackLink to="/engagements">Back to engagements</BackLink>
|
||||||
← Back to engagements
|
|
||||||
</Link>
|
|
||||||
<h1 className="text-[32px] font-medium leading-none">{eng.name}</h1>
|
<h1 className="text-[32px] font-medium leading-none">{eng.name}</h1>
|
||||||
<div className="flex items-center gap-md">
|
<div className="flex items-center gap-md">
|
||||||
<StatusBadge status={eng.status} />
|
<StatusBadge status={eng.status} />
|
||||||
@@ -53,32 +69,42 @@ export function EngagementDetailPage(): JSX.Element {
|
|||||||
) : null}
|
) : null}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<section className="grid grid-cols-1 md:grid-cols-2 gap-md">
|
<Tabs items={tabs} activeId={activeTab} onChange={setActiveTab} />
|
||||||
<div className="card-product">
|
|
||||||
<h2 className="text-[20px] font-medium mb-md">Schedule</h2>
|
|
||||||
<dl className="grid grid-cols-2 gap-md text-[14px]">
|
|
||||||
<dt className="text-graphite">Start date</dt>
|
|
||||||
<dd className="text-ink font-mono">{eng.start_date}</dd>
|
|
||||||
<dt className="text-graphite">End date</dt>
|
|
||||||
<dd className="text-ink font-mono">{eng.end_date ?? '—'}</dd>
|
|
||||||
<dt className="text-graphite">Status</dt>
|
|
||||||
<dd className="text-ink capitalize">{eng.status}</dd>
|
|
||||||
<dt className="text-graphite">Created at</dt>
|
|
||||||
<dd className="text-ink font-mono">{eng.created_at}</dd>
|
|
||||||
</dl>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="card-product">
|
<div
|
||||||
<h2 className="text-[20px] font-medium mb-md">Description</h2>
|
role="tabpanel"
|
||||||
<p className="text-[16px] text-charcoal whitespace-pre-line">
|
id={`tabpanel-${activeTab}`}
|
||||||
{eng.description?.trim() ? eng.description : 'No description provided.'}
|
aria-labelledby={`tab-${activeTab}`}
|
||||||
</p>
|
>
|
||||||
</div>
|
{activeTab === 'schedule' && (
|
||||||
</section>
|
<div className="card-product">
|
||||||
|
<h2 className="text-[20px] font-medium mb-md">Schedule</h2>
|
||||||
|
<dl className="grid grid-cols-2 gap-md text-[14px]">
|
||||||
|
<dt className="text-graphite">Start date</dt>
|
||||||
|
<dd className="text-ink font-mono">{eng.start_date}</dd>
|
||||||
|
<dt className="text-graphite">End date</dt>
|
||||||
|
<dd className="text-ink font-mono">{eng.end_date ?? '—'}</dd>
|
||||||
|
<dt className="text-graphite">Status</dt>
|
||||||
|
<dd className="text-ink capitalize">{eng.status}</dd>
|
||||||
|
<dt className="text-graphite">Created at</dt>
|
||||||
|
<dd className="text-ink font-mono">{eng.created_at}</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<section>
|
{activeTab === 'description' && (
|
||||||
<SimulationList engagementId={eng.id} />
|
<div className="card-product">
|
||||||
</section>
|
<h2 className="text-[20px] font-medium mb-md">Description</h2>
|
||||||
|
<p className="text-[16px] text-charcoal whitespace-pre-line">
|
||||||
|
{eng.description?.trim() ? eng.description : 'No description provided.'}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{activeTab === 'simulations' && (
|
||||||
|
<SimulationList engagementId={eng.id} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,32 +69,32 @@ export function EngagementsListPage(): JSX.Element {
|
|||||||
|
|
||||||
{!isLoading && !isError && data && data.length > 0 ? (
|
{!isLoading && !isError && data && data.length > 0 ? (
|
||||||
<div className="card-product overflow-hidden p-0">
|
<div className="card-product overflow-hidden p-0">
|
||||||
<table className="w-full text-left">
|
<table className="table-compact w-full text-left">
|
||||||
<thead className="bg-cloud border-b border-hairline">
|
<thead className="bg-cloud border-b border-hairline">
|
||||||
<tr className="text-[12px] uppercase tracking-[0.5px] text-graphite">
|
<tr>
|
||||||
<th className="px-xl py-md">Name</th>
|
<th>Name</th>
|
||||||
<th className="px-xl py-md">Status</th>
|
<th>Status</th>
|
||||||
<th className="px-xl py-md">Start</th>
|
<th>Start</th>
|
||||||
<th className="px-xl py-md">End</th>
|
<th>End</th>
|
||||||
<th className="px-xl py-md">Created by</th>
|
<th>Created by</th>
|
||||||
<th className="px-xl py-md text-right">Actions</th>
|
<th className="text-right">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{data.map((eng) => (
|
{data.map((eng) => (
|
||||||
<tr key={eng.id} className="border-b border-hairline last:border-0">
|
<tr key={eng.id}>
|
||||||
<td className="px-xl py-md">
|
<td>
|
||||||
<Link to={`/engagements/${eng.id}`} className="text-ink font-medium hover:underline">
|
<Link to={`/engagements/${eng.id}`} className="text-ink font-medium hover:underline">
|
||||||
{eng.name}
|
{eng.name}
|
||||||
</Link>
|
</Link>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-xl py-md">
|
<td>
|
||||||
<StatusBadge status={eng.status} />
|
<StatusBadge status={eng.status} />
|
||||||
</td>
|
</td>
|
||||||
<td className="px-xl py-md text-charcoal font-mono">{formatDate(eng.start_date)}</td>
|
<td className="text-charcoal font-mono">{formatDate(eng.start_date)}</td>
|
||||||
<td className="px-xl py-md text-charcoal font-mono">{formatDate(eng.end_date)}</td>
|
<td className="text-charcoal font-mono">{formatDate(eng.end_date)}</td>
|
||||||
<td className="px-xl py-md text-charcoal">{eng.created_by.username}</td>
|
<td className="text-charcoal">{eng.created_by.username}</td>
|
||||||
<td className="px-xl py-md text-right">
|
<td className="text-right">
|
||||||
<div className="inline-flex gap-sm">
|
<div className="inline-flex gap-sm">
|
||||||
<Link to={`/engagements/${eng.id}`} className="btn-text-link">
|
<Link to={`/engagements/${eng.id}`} className="btn-text-link">
|
||||||
View
|
View
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import { MitreTechniquesField } from '@/components/MitreTechniquesField';
|
|||||||
import { ExecuteViaC2Modal } from '@/components/ExecuteViaC2Modal';
|
import { ExecuteViaC2Modal } from '@/components/ExecuteViaC2Modal';
|
||||||
import { ImportC2HistoryModal } from '@/components/ImportC2HistoryModal';
|
import { ImportC2HistoryModal } from '@/components/ImportC2HistoryModal';
|
||||||
import { C2TasksPanel } from '@/components/C2TasksPanel';
|
import { C2TasksPanel } from '@/components/C2TasksPanel';
|
||||||
|
import { AlertBanner } from '@/components/AlertBanner';
|
||||||
|
import { BackLink } from '@/components/BackLink';
|
||||||
|
|
||||||
interface RedteamFormState {
|
interface RedteamFormState {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -238,9 +240,7 @@ export function SimulationFormPage(): JSX.Element {
|
|||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-xl max-w-2xl">
|
<div className="flex flex-col gap-xl max-w-2xl">
|
||||||
<header>
|
<header>
|
||||||
<Link to={`/engagements/${engagementId}`} className="btn-text-link text-[14px]">
|
<BackLink to={`/engagements/${engagementId}`}>Back to engagement</BackLink>
|
||||||
← Back to engagement
|
|
||||||
</Link>
|
|
||||||
<h1 className="text-[32px] font-medium leading-none mt-sm">New simulation</h1>
|
<h1 className="text-[32px] font-medium leading-none mt-sm">New simulation</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
@@ -279,9 +279,7 @@ export function SimulationFormPage(): JSX.Element {
|
|||||||
<div className="flex flex-col gap-xl">
|
<div className="flex flex-col gap-xl">
|
||||||
<header className="flex items-start justify-between gap-md">
|
<header className="flex items-start justify-between gap-md">
|
||||||
<div className="flex flex-col gap-sm">
|
<div className="flex flex-col gap-sm">
|
||||||
<Link to={`/engagements/${engagementId}`} className="btn-text-link text-[14px]">
|
<BackLink to={`/engagements/${engagementId}`}>Back to engagement</BackLink>
|
||||||
← Back to engagement
|
|
||||||
</Link>
|
|
||||||
<h1 className="text-[32px] font-medium leading-none">{rt.name || simulation?.name}</h1>
|
<h1 className="text-[32px] font-medium leading-none">{rt.name || simulation?.name}</h1>
|
||||||
{status ? (
|
{status ? (
|
||||||
<div className="flex items-center gap-md">
|
<div className="flex items-center gap-md">
|
||||||
@@ -298,22 +296,17 @@ export function SimulationFormPage(): JSX.Element {
|
|||||||
|
|
||||||
{/* Done banner */}
|
{/* Done banner */}
|
||||||
{isDone && (
|
{isDone && (
|
||||||
<div
|
<AlertBanner variant="success">
|
||||||
role="status"
|
|
||||||
className="rounded-none px-xl py-md bg-cloud border border-hairline text-[14px] text-charcoal"
|
|
||||||
>
|
|
||||||
This simulation is <strong>done</strong> and read-only. Use Reopen to make changes.
|
This simulation is <strong>done</strong> and read-only. Use Reopen to make changes.
|
||||||
</div>
|
</AlertBanner>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* SOC banner */}
|
{/* SOC banner */}
|
||||||
{socBlocked && (
|
{socBlocked && (
|
||||||
<div
|
<div data-testid="soc-blocked-banner">
|
||||||
role="alert"
|
<AlertBanner variant="warn">
|
||||||
data-testid="soc-blocked-banner"
|
Simulation not yet ready for review — the red team must mark it as "Review required" before you can fill in the SOC section.
|
||||||
className="rounded-none px-xl py-md bg-fog border border-hairline text-[14px] text-charcoal"
|
</AlertBanner>
|
||||||
>
|
|
||||||
Simulation not yet ready for review — the red team must mark it as "Review required" before you can fill in the SOC section.
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { FormField, TextArea, TextInput } from '@/components/FormField';
|
|||||||
import { LoadingState } from '@/components/LoadingState';
|
import { LoadingState } from '@/components/LoadingState';
|
||||||
import { ErrorState } from '@/components/ErrorState';
|
import { ErrorState } from '@/components/ErrorState';
|
||||||
import { ConfirmDialog } from '@/components/ConfirmDialog';
|
import { ConfirmDialog } from '@/components/ConfirmDialog';
|
||||||
|
import { BackLink } from '@/components/BackLink';
|
||||||
import { MitreTechniqueTag, MitreTacticTag } from '@/components/MitreTechniqueTag';
|
import { MitreTechniqueTag, MitreTacticTag } from '@/components/MitreTechniqueTag';
|
||||||
import { MitreTechniquePicker } from '@/components/MitreTechniquePicker';
|
import { MitreTechniquePicker } from '@/components/MitreTechniquePicker';
|
||||||
import { MitreMatrixModal } from '@/components/MitreMatrixModal';
|
import { MitreMatrixModal } from '@/components/MitreMatrixModal';
|
||||||
@@ -127,9 +128,7 @@ export function TemplateFormPage(): JSX.Element {
|
|||||||
<div className="flex flex-col gap-xl">
|
<div className="flex flex-col gap-xl">
|
||||||
<header className="flex items-start justify-between gap-md">
|
<header className="flex items-start justify-between gap-md">
|
||||||
<div className="flex flex-col gap-sm">
|
<div className="flex flex-col gap-sm">
|
||||||
<Link to="/admin/templates" className="btn-text-link text-[14px]">
|
<BackLink to="/admin/templates">Back to templates</BackLink>
|
||||||
← Back to templates
|
|
||||||
</Link>
|
|
||||||
<h1 className="text-[32px] font-medium leading-none">
|
<h1 className="text-[32px] font-medium leading-none">
|
||||||
{isNew ? 'New template' : (existing.data?.name ?? 'Edit template')}
|
{isNew ? 'New template' : (existing.data?.name ?? 'Edit template')}
|
||||||
</h1>
|
</h1>
|
||||||
|
|||||||
@@ -69,20 +69,20 @@ export function TemplatesListPage(): JSX.Element {
|
|||||||
|
|
||||||
{!isLoading && !isError && data && data.length > 0 ? (
|
{!isLoading && !isError && data && data.length > 0 ? (
|
||||||
<div className="card-product overflow-hidden p-0">
|
<div className="card-product overflow-hidden p-0">
|
||||||
<table className="w-full text-left">
|
<table className="table-compact w-full text-left">
|
||||||
<thead className="bg-cloud border-b border-hairline">
|
<thead className="bg-cloud border-b border-hairline">
|
||||||
<tr className="text-[12px] uppercase tracking-[0.5px] text-graphite">
|
<tr>
|
||||||
<th className="px-xl py-md">Name</th>
|
<th>Name</th>
|
||||||
<th className="px-xl py-md">MITRE</th>
|
<th>MITRE</th>
|
||||||
<th className="px-xl py-md">Created by</th>
|
<th>Created by</th>
|
||||||
<th className="px-xl py-md">Updated</th>
|
<th>Updated</th>
|
||||||
<th className="px-xl py-md text-right">Actions</th>
|
<th className="text-right">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{data.map((t) => (
|
{data.map((t) => (
|
||||||
<tr key={t.id} className="border-b border-hairline last:border-0">
|
<tr key={t.id}>
|
||||||
<td className="px-xl py-md">
|
<td>
|
||||||
<Link
|
<Link
|
||||||
to={`/admin/templates/${t.id}/edit`}
|
to={`/admin/templates/${t.id}/edit`}
|
||||||
className="text-ink font-medium hover:underline"
|
className="text-ink font-medium hover:underline"
|
||||||
@@ -90,12 +90,12 @@ export function TemplatesListPage(): JSX.Element {
|
|||||||
{t.name}
|
{t.name}
|
||||||
</Link>
|
</Link>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-xl py-md text-charcoal text-[14px]">
|
<td className="text-charcoal">
|
||||||
{mitreCount(t) === 0 ? '—' : mitreCount(t)}
|
{mitreCount(t) === 0 ? '—' : mitreCount(t)}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-xl py-md text-charcoal">{t.created_by.username}</td>
|
<td className="text-charcoal">{t.created_by.username}</td>
|
||||||
<td className="px-xl py-md text-charcoal font-mono">{formatDate(t.updated_at)}</td>
|
<td className="text-charcoal font-mono">{formatDate(t.updated_at)}</td>
|
||||||
<td className="px-xl py-md text-right">
|
<td className="text-right">
|
||||||
<div className="inline-flex gap-sm">
|
<div className="inline-flex gap-sm">
|
||||||
<Link to={`/admin/templates/${t.id}/edit`} className="btn-text-link">
|
<Link to={`/admin/templates/${t.id}/edit`} className="btn-text-link">
|
||||||
Edit
|
Edit
|
||||||
|
|||||||
@@ -188,13 +188,13 @@ export function UsersAdminPage(): JSX.Element {
|
|||||||
|
|
||||||
{!list.isLoading && !list.isError && list.data && list.data.length > 0 ? (
|
{!list.isLoading && !list.isError && list.data && list.data.length > 0 ? (
|
||||||
<div className="card-product overflow-hidden p-0">
|
<div className="card-product overflow-hidden p-0">
|
||||||
<table className="w-full text-left">
|
<table className="table-compact w-full text-left">
|
||||||
<thead className="bg-cloud border-b border-hairline">
|
<thead className="bg-cloud border-b border-hairline">
|
||||||
<tr className="text-[12px] uppercase tracking-[0.5px] text-graphite">
|
<tr>
|
||||||
<th className="px-xl py-md">Username</th>
|
<th>Username</th>
|
||||||
<th className="px-xl py-md">Role</th>
|
<th>Role</th>
|
||||||
<th className="px-xl py-md">Created</th>
|
<th>Created</th>
|
||||||
<th className="px-xl py-md text-right">Actions</th>
|
<th className="text-right">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -204,8 +204,8 @@ export function UsersAdminPage(): JSX.Element {
|
|||||||
// Fragment must carry the key — `<>` cannot, which broke
|
// Fragment must carry the key — `<>` cannot, which broke
|
||||||
// per-row reconciliation (reset-password state leaked across rows).
|
// per-row reconciliation (reset-password state leaked across rows).
|
||||||
<Fragment key={u.id}>
|
<Fragment key={u.id}>
|
||||||
<tr className="border-b border-hairline last:border-0">
|
<tr>
|
||||||
<td className="px-xl py-md text-ink">
|
<td className="text-ink">
|
||||||
<span className="font-mono font-medium">{u.username}</span>
|
<span className="font-mono font-medium">{u.username}</span>
|
||||||
{isSelf ? (
|
{isSelf ? (
|
||||||
<span className="ml-sm font-sans text-[12px] text-graphite">
|
<span className="ml-sm font-sans text-[12px] text-graphite">
|
||||||
@@ -213,7 +213,7 @@ export function UsersAdminPage(): JSX.Element {
|
|||||||
</span>
|
</span>
|
||||||
) : null}
|
) : null}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-xl py-md">
|
<td>
|
||||||
<Select
|
<Select
|
||||||
value={u.role}
|
value={u.role}
|
||||||
onChange={(e) => onRoleChange(u, e.target.value as Role)}
|
onChange={(e) => onRoleChange(u, e.target.value as Role)}
|
||||||
@@ -222,8 +222,8 @@ export function UsersAdminPage(): JSX.Element {
|
|||||||
disabled={patchMutation.isPending}
|
disabled={patchMutation.isPending}
|
||||||
/>
|
/>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-xl py-md text-charcoal font-mono">{u.created_at}</td>
|
<td className="text-charcoal font-mono">{u.created_at}</td>
|
||||||
<td className="px-xl py-md text-right">
|
<td className="text-right">
|
||||||
<div className="inline-flex gap-sm">
|
<div className="inline-flex gap-sm">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -248,6 +248,7 @@ export function UsersAdminPage(): JSX.Element {
|
|||||||
</tr>
|
</tr>
|
||||||
{resetOpen === u.id ? (
|
{resetOpen === u.id ? (
|
||||||
<tr className="border-b border-hairline last:border-0 bg-cloud">
|
<tr className="border-b border-hairline last:border-0 bg-cloud">
|
||||||
|
{/* Aerated row — inline form needs room; compact-density tradeoff intentional */}
|
||||||
<td colSpan={4} className="px-xl py-md">
|
<td colSpan={4} className="px-xl py-md">
|
||||||
<form
|
<form
|
||||||
onSubmit={(e) => onResetPassword(u, e)}
|
onSubmit={(e) => onResetPassword(u, e)}
|
||||||
|
|||||||
@@ -147,4 +147,48 @@
|
|||||||
.tag-mitre {
|
.tag-mitre {
|
||||||
@apply inline-flex items-center bg-cloud text-ink border border-hairline rounded-none px-2 py-[2px] font-mono text-[12px] leading-[1.33];
|
@apply inline-flex items-center bg-cloud text-ink border border-hairline rounded-none px-2 py-[2px] font-mono text-[12px] leading-[1.33];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ─── Sub-page tabs (L1) ─────────────────────────────────────────────── */
|
||||||
|
.tab-underline {
|
||||||
|
@apply text-graphite text-caption-bold cursor-pointer border-b-2 border-transparent hover:text-ink px-xs;
|
||||||
|
}
|
||||||
|
.tab-underline-active {
|
||||||
|
@apply text-primary border-primary;
|
||||||
|
}
|
||||||
|
/* Count pill — rounded-pill is the allowed exception per DESIGN.md */
|
||||||
|
.tab-count-pill {
|
||||||
|
@apply inline-flex items-center rounded-pill bg-cloud text-graphite text-[11px] px-xs py-0 font-mono;
|
||||||
|
}
|
||||||
|
.tab-count-pill-active {
|
||||||
|
@apply bg-primary-soft text-primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ─── Inline alert banners (L2) ─────────────────────────────────────── */
|
||||||
|
.alert-error {
|
||||||
|
@apply bg-paper border border-hairline border-l-4 border-l-bloom-deep rounded-none px-md py-sm flex items-start gap-sm;
|
||||||
|
}
|
||||||
|
.alert-warn {
|
||||||
|
@apply bg-paper border border-hairline border-l-4 border-l-warn rounded-none px-md py-sm flex items-start gap-sm;
|
||||||
|
}
|
||||||
|
.alert-success {
|
||||||
|
@apply bg-paper border border-hairline border-l-4 border-l-success rounded-none px-md py-sm flex items-start gap-sm;
|
||||||
|
}
|
||||||
|
.alert-info {
|
||||||
|
@apply bg-paper border border-hairline border-l-4 border-l-primary rounded-none px-md py-sm flex items-start gap-sm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ─── Compact table density (L4) — 32px row height, global ──────────── */
|
||||||
|
.table-compact thead tr {
|
||||||
|
@apply text-[12px] uppercase tracking-[0.5px] text-graphite;
|
||||||
|
}
|
||||||
|
.table-compact th {
|
||||||
|
@apply px-md py-xxs;
|
||||||
|
}
|
||||||
|
.table-compact td {
|
||||||
|
@apply px-md py-xxs text-caption-md;
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
.table-compact tbody tr {
|
||||||
|
@apply border-b border-hairline last:border-0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
48
frontend/tests/components/AlertBanner.test.tsx
Normal file
48
frontend/tests/components/AlertBanner.test.tsx
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
import { render, screen } from '@testing-library/react';
|
||||||
|
import { AlertBanner } from '@/components/AlertBanner';
|
||||||
|
|
||||||
|
describe('AlertBanner', () => {
|
||||||
|
it('renders error variant with alert role and alert-error class', () => {
|
||||||
|
const { container } = render(<AlertBanner variant="error">Error message</AlertBanner>);
|
||||||
|
const el = container.firstChild as HTMLElement;
|
||||||
|
expect(el).toHaveAttribute('role', 'alert');
|
||||||
|
expect(el).toHaveClass('alert-error');
|
||||||
|
expect(screen.getByText('Error message')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders warn variant with alert role and alert-warn class', () => {
|
||||||
|
const { container } = render(<AlertBanner variant="warn">Warning message</AlertBanner>);
|
||||||
|
const el = container.firstChild as HTMLElement;
|
||||||
|
expect(el).toHaveAttribute('role', 'alert');
|
||||||
|
expect(el).toHaveClass('alert-warn');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders success variant with status role and alert-success class', () => {
|
||||||
|
const { container } = render(<AlertBanner variant="success">Done!</AlertBanner>);
|
||||||
|
const el = container.firstChild as HTMLElement;
|
||||||
|
expect(el).toHaveAttribute('role', 'status');
|
||||||
|
expect(el).toHaveClass('alert-success');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders info variant with status role and alert-info class', () => {
|
||||||
|
const { container } = render(<AlertBanner variant="info">FYI</AlertBanner>);
|
||||||
|
const el = container.firstChild as HTMLElement;
|
||||||
|
expect(el).toHaveAttribute('role', 'status');
|
||||||
|
expect(el).toHaveClass('alert-info');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders optional title when provided', () => {
|
||||||
|
render(<AlertBanner variant="info" title="Heads up">Detail text</AlertBanner>);
|
||||||
|
expect(screen.getByText('Heads up')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Detail text')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has no rounded-md, transition-*, or shadow-* (brutalism)', () => {
|
||||||
|
const { container } = render(<AlertBanner variant="error">Test</AlertBanner>);
|
||||||
|
const el = container.firstChild as HTMLElement;
|
||||||
|
expect(el).not.toHaveClass('rounded-md');
|
||||||
|
expect(el.className).not.toMatch(/transition-/);
|
||||||
|
expect(el.className).not.toMatch(/shadow-/);
|
||||||
|
});
|
||||||
|
});
|
||||||
39
frontend/tests/components/BackLink.test.tsx
Normal file
39
frontend/tests/components/BackLink.test.tsx
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
import { render, screen } from '@testing-library/react';
|
||||||
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
|
import { BackLink } from '@/components/BackLink';
|
||||||
|
|
||||||
|
function renderBackLink(to: string, label: string) {
|
||||||
|
return render(
|
||||||
|
<MemoryRouter>
|
||||||
|
<BackLink to={to}>{label}</BackLink>
|
||||||
|
</MemoryRouter>,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('BackLink', () => {
|
||||||
|
it('renders children as link text', () => {
|
||||||
|
renderBackLink('/engagements', 'Back to engagements');
|
||||||
|
expect(screen.getByText('Back to engagements')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders as an anchor with the correct href', () => {
|
||||||
|
renderBackLink('/engagements', 'Back to engagements');
|
||||||
|
const link = screen.getByRole('link');
|
||||||
|
expect(link).toHaveAttribute('href', '/engagements');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has no rounded-md, transition-*, or shadow-* (brutalism)', () => {
|
||||||
|
renderBackLink('/engagements', 'Back');
|
||||||
|
const link = screen.getByRole('link');
|
||||||
|
expect(link).not.toHaveClass('rounded-md');
|
||||||
|
expect(link.className).not.toMatch(/transition-/);
|
||||||
|
expect(link.className).not.toMatch(/shadow-/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('contains the ArrowLeft icon (svg element)', () => {
|
||||||
|
const { container } = renderBackLink('/engagements', 'Back');
|
||||||
|
const svg = container.querySelector('svg');
|
||||||
|
expect(svg).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
84
frontend/tests/components/Tabs.test.tsx
Normal file
84
frontend/tests/components/Tabs.test.tsx
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
import { describe, it, expect, vi } from 'vitest';
|
||||||
|
import { render, screen, fireEvent } from '@testing-library/react';
|
||||||
|
import { Tabs } from '@/components/Tabs';
|
||||||
|
|
||||||
|
const ITEMS = [
|
||||||
|
{ id: 'schedule', label: 'Schedule' },
|
||||||
|
{ id: 'description', label: 'Description' },
|
||||||
|
{ id: 'simulations', label: 'Simulations', count: 5 },
|
||||||
|
];
|
||||||
|
|
||||||
|
describe('Tabs', () => {
|
||||||
|
it('renders all tab labels', () => {
|
||||||
|
render(<Tabs items={ITEMS} activeId="schedule" onChange={vi.fn()} />);
|
||||||
|
expect(screen.getByText('Schedule')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Description')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('Simulations')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('marks the active tab with aria-selected=true', () => {
|
||||||
|
render(<Tabs items={ITEMS} activeId="description" onChange={vi.fn()} />);
|
||||||
|
const descBtn = screen.getByRole('tab', { name: /Description/i });
|
||||||
|
expect(descBtn).toHaveAttribute('aria-selected', 'true');
|
||||||
|
const schedBtn = screen.getByRole('tab', { name: /Schedule/i });
|
||||||
|
expect(schedBtn).toHaveAttribute('aria-selected', 'false');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('applies tab-underline-active class to the active tab', () => {
|
||||||
|
render(<Tabs items={ITEMS} activeId="schedule" onChange={vi.fn()} />);
|
||||||
|
const activeBtn = screen.getByRole('tab', { name: /Schedule/i });
|
||||||
|
expect(activeBtn).toHaveClass('tab-underline-active');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('renders count pill for the simulations tab', () => {
|
||||||
|
render(<Tabs items={ITEMS} activeId="schedule" onChange={vi.fn()} />);
|
||||||
|
const pill = screen.getByText('5');
|
||||||
|
expect(pill).toHaveClass('tab-count-pill');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('applies tab-count-pill-active when the tab with count is active', () => {
|
||||||
|
render(<Tabs items={ITEMS} activeId="simulations" onChange={vi.fn()} />);
|
||||||
|
const pill = screen.getByText('5');
|
||||||
|
expect(pill).toHaveClass('tab-count-pill-active');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('calls onChange with the tab id when clicked', () => {
|
||||||
|
const onChange = vi.fn();
|
||||||
|
render(<Tabs items={ITEMS} activeId="schedule" onChange={onChange} />);
|
||||||
|
fireEvent.click(screen.getByRole('tab', { name: /Description/i }));
|
||||||
|
expect(onChange).toHaveBeenCalledWith('description');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('sets aria-controls and id on each tab button', () => {
|
||||||
|
render(<Tabs items={ITEMS} activeId="schedule" onChange={vi.fn()} />);
|
||||||
|
const schedBtn = screen.getByRole('tab', { name: /Schedule/i });
|
||||||
|
expect(schedBtn).toHaveAttribute('id', 'tab-schedule');
|
||||||
|
expect(schedBtn).toHaveAttribute('aria-controls', 'tabpanel-schedule');
|
||||||
|
const simsBtn = screen.getByRole('tab', { name: /Simulations/i });
|
||||||
|
expect(simsBtn).toHaveAttribute('id', 'tab-simulations');
|
||||||
|
expect(simsBtn).toHaveAttribute('aria-controls', 'tabpanel-simulations');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ArrowRight moves focus to the next tab', () => {
|
||||||
|
const onChange = vi.fn();
|
||||||
|
render(<Tabs items={ITEMS} activeId="schedule" onChange={onChange} />);
|
||||||
|
fireEvent.keyDown(screen.getByRole('tab', { name: /Schedule/i }), { key: 'ArrowRight' });
|
||||||
|
expect(onChange).toHaveBeenCalledWith('description');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('ArrowLeft wraps around to the last tab', () => {
|
||||||
|
const onChange = vi.fn();
|
||||||
|
render(<Tabs items={ITEMS} activeId="schedule" onChange={onChange} />);
|
||||||
|
fireEvent.keyDown(screen.getByRole('tab', { name: /Schedule/i }), { key: 'ArrowLeft' });
|
||||||
|
expect(onChange).toHaveBeenCalledWith('simulations');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has no rounded-md, transition-*, or shadow-* on tab buttons (brutalism)', () => {
|
||||||
|
render(<Tabs items={ITEMS} activeId="schedule" onChange={vi.fn()} />);
|
||||||
|
for (const btn of screen.getAllByRole('tab')) {
|
||||||
|
expect(btn).not.toHaveClass('rounded-md');
|
||||||
|
expect(btn.className).not.toMatch(/transition-/);
|
||||||
|
expect(btn.className).not.toMatch(/shadow-/);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
43
frontend/tests/hooks/useHashTab.test.tsx
Normal file
43
frontend/tests/hooks/useHashTab.test.tsx
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||||
|
import { renderHook, act } from '@testing-library/react';
|
||||||
|
import { useHashTab } from '@/hooks/useHashTab';
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
window.location.hash = '';
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
window.location.hash = '';
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('useHashTab', () => {
|
||||||
|
it('returns the default id when hash is empty', () => {
|
||||||
|
const { result } = renderHook(() => useHashTab('schedule'));
|
||||||
|
expect(result.current[0]).toBe('schedule');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('reads the hash on mount', () => {
|
||||||
|
window.location.hash = 'simulations';
|
||||||
|
const { result } = renderHook(() => useHashTab('schedule'));
|
||||||
|
expect(result.current[0]).toBe('simulations');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('navigate() updates activeId and sets hash via replaceState (no history entry)', () => {
|
||||||
|
const { result } = renderHook(() => useHashTab('schedule'));
|
||||||
|
act(() => {
|
||||||
|
result.current[1]('description');
|
||||||
|
});
|
||||||
|
expect(result.current[0]).toBe('description');
|
||||||
|
expect(window.location.hash).toBe('#description');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('falls back to defaultId when hash becomes empty', () => {
|
||||||
|
window.location.hash = 'simulations';
|
||||||
|
const { result } = renderHook(() => useHashTab('schedule'));
|
||||||
|
act(() => {
|
||||||
|
window.location.hash = '';
|
||||||
|
window.dispatchEvent(new HashChangeEvent('hashchange'));
|
||||||
|
});
|
||||||
|
expect(result.current[0]).toBe('schedule');
|
||||||
|
});
|
||||||
|
});
|
||||||
193
tasks/todo.md
193
tasks/todo.md
@@ -1,73 +1,164 @@
|
|||||||
# Sprint 9 — UI: engagement 2-col + global contrast pass
|
# Sprint 11 — Spectrum UX port : 4 primitives + compact density global
|
||||||
|
|
||||||
**Base**: `sprint/8-c2` (sprint 8 not yet merged on origin/main, but its `C2ConfigCard` is the right pane).
|
**Base** : `origin/main` (PR #12 mergée — sprint 8 + 9 + 10 en).
|
||||||
**Scope**: frontend-only. No backend, no schema. No new features.
|
**Branch** : `sprint/11-spectrum-ux`.
|
||||||
|
**Scope** : frontend-only sprint, 5 livrables coordonnés. Pas de backend, pas de schéma, pas de nouvelle API. Pas de modif tokens couleurs/spacing/font dans tailwind.config.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Decisions (locked)
|
## Contexte
|
||||||
|
|
||||||
1. **Engagement page** : passer en **2 colonnes** sur desktop (`lg:grid-cols-2`), `[engagement form | C2ConfigCard]`. Mobile/tablet : stack vertical (comportement actuel).
|
Analyse Spectrum (`/home/user/Documents/01_Projects/spectrum`) faite via workflow. Résultat : Spectrum n'a **pas de design system** (Tailwind raw + violet ramp + recipes inlinées 30× partout). Mimic est structurellement meilleur. On ne porte pas la philosophie Spectrum — on extrait **5 patterns isolés** qui survivent au brutalisme Mimic.
|
||||||
2. **Contraste global** : le problème est que `canvas` (page bg) et `paper` (card bg) sont **tous deux `#ffffff`** en light mode. Les cartes ne ressortent que par leur hairline 1px → fatigue oculaire confirmée par l'utilisateur.
|
|
||||||
3. **Fix retenu** : **tinter le canvas light** d'un neutre froid très pâle. `paper` reste blanc pur. Les cartes "lèvent" naturellement sans casser le brutalisme.
|
## Constraints absolues
|
||||||
- Proposition : `canvas` light `#f3f5f8` (gris-bleu très pâle, cohérent avec l'electric blue), `paper` light `#ffffff`.
|
|
||||||
- Dark mode **inchangé** (`canvas #111827` / `paper #1f2937` déjà différenciés).
|
1. **Primary `#024ad8` (Electric Blue) reste**. Pas de violet, pas de spectrum ramp.
|
||||||
4. **Pas de shadow**, pas de radius. La brutalité reste intacte — seul le contraste de surface change.
|
2. **Brutalisme reste** : `rounded-none` sur containers (sauf status pills + tab count pills + avatars), zero `transition-*`, zero `shadow-*`, hairline 1px borders.
|
||||||
5. **Hairline** : à vérifier sur le nouveau canvas. Si nécessaire, passer `hairline` light de la valeur actuelle à un poil plus sombre pour préserver la lisibilité du bord sur tinted canvas. Mais éviter si la lecture est déjà bonne.
|
3. **Pas de modif `tailwind.config.*`** sauf si une nouvelle classe utility est strictement nécessaire (justifier dans le PR).
|
||||||
|
4. **DESIGN.md amendments additives uniquement** — pas de modif des tokens existants.
|
||||||
|
5. **Mono uniquement pour data** (IDs MITRE, dates ISO, commands, etc.) — rule sprint 7.
|
||||||
|
|
||||||
|
## Décisions binding (lockées par user)
|
||||||
|
|
||||||
|
- **Q1 → B** : Tabs primitive **+ consumer EngagementDetailPage** (3 tabs : Schedule / Description / Simulations au lieu du stack vertical actuel).
|
||||||
|
- **Q2 → B** : **Compact density GLOBAL** — toutes les tables passent à 32px row, pas opt-in. User accepte le tradeoff WCAG (touch target) sur Engagements list.
|
||||||
|
- **Q3 → A** : AlertBanner + refactor `SimulationFormPage` (Done banner + SOC-blocked banner).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Task A — EngagementFormPage 2-col
|
## Livrables
|
||||||
|
|
||||||
**File** : `frontend/src/pages/EngagementFormPage.tsx`
|
### Livrable 1 — `Tabs` primitive + `useHashTab` hook + consumer
|
||||||
|
|
||||||
- Remplacer le wrapper `<div className="flex flex-col gap-xl max-w-2xl">` par un container plus large + grid 2-col responsive.
|
|
||||||
- Header reste en haut, full width.
|
|
||||||
- Body : `grid grid-cols-1 lg:grid-cols-2 gap-xl` avec :
|
|
||||||
- Col gauche : `<form>` engagement (déjà en `card-product`).
|
|
||||||
- Col droite : `<C2ConfigCard>` (seulement quand `editing && canEditEngagements`).
|
|
||||||
- Si pas en edit (création) : col droite vide → garder la grid mais que la col gauche se déploie via `lg:col-span-2` (pour pas avoir un vide à droite). Acceptable alternative : `flex` + `max-w-2xl` quand non-editing.
|
|
||||||
- Pas de modif sur la logique de form, validation, mutations.
|
|
||||||
|
|
||||||
## Task B — Contrast pass (tokens)
|
|
||||||
|
|
||||||
**Files** :
|
**Files** :
|
||||||
- `DESIGN.md` § Surface : mettre à jour `canvas` light = `#f3f5f8`, conserver `paper` light = `#ffffff`. Documenter dans la même section que "canvas tints lift paper cards in light mode without violating brutalism".
|
- `frontend/src/hooks/useHashTab.ts` (NEW) — ~30 LoC. Reads `window.location.hash`, falls back to default ID, listens to `hashchange`, updates URL without reload. TypeScript pur, zéro style.
|
||||||
- Token source de vérité (Tailwind config ou CSS vars). Localiser et appliquer la même MAJ. Probablement `frontend/tailwind.config.js` ou un `frontend/src/styles/tokens.css` / `index.css`.
|
- `frontend/src/components/Tabs.tsx` (NEW) — composant `<Tabs items={[{id, label, count?}]} activeId onChange />`. Underline variant.
|
||||||
- Vérifier qu'aucun composant ne hardcode `#ffffff` pour la page bg (devrait utiliser `bg-canvas`).
|
- `frontend/src/styles/index.css` — nouvelles recipes :
|
||||||
- Tests CSS smoke : `bg-canvas` continue de matcher, dark mode inchangé.
|
- `.tab-underline` — `text-graphite caption-bold cursor-pointer border-b-2 border-transparent hover:text-ink` (instantané, pas de transition)
|
||||||
|
- `.tab-underline-active` — `text-primary border-primary` (override)
|
||||||
|
- `.tab-count-pill` — `rounded-pill bg-cloud text-graphite text-[11px] px-xs py-0 font-mono`
|
||||||
|
- `.tab-count-pill-active` — `bg-primary-soft text-primary` (override)
|
||||||
|
- `frontend/src/pages/EngagementDetailPage.tsx` — refactor en 3 tabs :
|
||||||
|
- Tab 1 "Schedule" (id `schedule`, default) — dates + statut + bouton "Edit engagement"
|
||||||
|
- Tab 2 "Description" (id `description`) — texte description
|
||||||
|
- Tab 3 "Simulations" (id `simulations`) — la liste actuelle de simulations
|
||||||
|
- Count pills sur tab 3 = nombre de simulations
|
||||||
|
- Tabs branchées sur `useHashTab('schedule')`
|
||||||
|
- `DESIGN.md` — nouvelle subsection `### Navigation › Sub-page tabs` (additive)
|
||||||
|
|
||||||
## Task C — Visual regression check
|
**Brutalism check** :
|
||||||
|
- Tab : `border-b-2` only, pas de bg, pas de rounded, pas de transition
|
||||||
|
- Pill : `rounded-pill` autorisé (exception status pill DESIGN.md L125)
|
||||||
|
- Hover : `hover:text-ink` instantané
|
||||||
|
|
||||||
- `pnpm vitest run` clean.
|
### Livrable 2 — `AlertBanner` component + 4 recipes
|
||||||
- `pnpm tsc --noEmit` clean.
|
|
||||||
- `pnpm lint` clean.
|
**Files** :
|
||||||
- Screenshots avant/après (au moins) :
|
- `frontend/src/components/AlertBanner.tsx` (NEW) — `<AlertBanner variant="error|warn|success|info" title? children />`. Brutalist : border-l-4 strip semantic, fill `bg-paper`, border `border-hairline` partout sauf le strip gauche, `rounded-none`. Icon Lucide à gauche (`AlertCircle` error, `AlertTriangle` warn, `CheckCircle` success, `Info` info) à `size={16}`.
|
||||||
- EngagementsListPage (cards-on-canvas)
|
- `frontend/src/styles/index.css` — 4 nouvelles recipes :
|
||||||
- EngagementDetailPage
|
- `.alert-error` — `bg-paper border border-hairline border-l-4 border-l-bloom-deep px-md py-sm flex items-start gap-sm`
|
||||||
- EngagementFormPage (edit, avec C2ConfigCard à droite)
|
- `.alert-warn` — same + `border-l-warn`
|
||||||
- SimulationFormPage (déjà 2-col sprint 7, vérifier que le tinted canvas n'écrase pas)
|
- `.alert-success` — same + `border-l-success`
|
||||||
- LoginPage
|
- `.alert-info` — same + `border-l-primary`
|
||||||
- Dark mode : passe rapide pour confirmer aucune régression.
|
- `frontend/src/pages/SimulationFormPage.tsx` — refactor 2 banners hand-rollés (~L300 Done banner + ~L310 SOC-blocked banner) → `<AlertBanner variant="success">` / `<AlertBanner variant="warn">`.
|
||||||
|
- `DESIGN.md` — extend `### Toast Notifications` avec subsection `### Inline Banners` (additive, mêmes 4 variants).
|
||||||
|
|
||||||
|
**Note** : `bloom-deep`, `warn`, `success`, `primary` sont les tokens existants — pas de nouveau token couleur.
|
||||||
|
|
||||||
|
### Livrable 3 — `BackLink` component (dédup)
|
||||||
|
|
||||||
|
**Files** :
|
||||||
|
- `frontend/src/components/BackLink.tsx` (NEW) — `<BackLink to="/engagements">Back to engagements</BackLink>`. Renders `← {children}` (ArrowLeft Lucide size=14, gap-xxs). Style : `text-graphite hover:text-primary caption-md` instantané.
|
||||||
|
- Refactor consumers (3 instances hand-rollées) :
|
||||||
|
- `frontend/src/pages/EngagementDetailPage.tsx` (~L35)
|
||||||
|
- `frontend/src/pages/SimulationFormPage.tsx` (back-link en edit mode)
|
||||||
|
- `frontend/src/pages/TemplateFormPage.tsx` (back-link en edit mode)
|
||||||
|
|
||||||
|
### Livrable 4 — `.table-compact` recipe + apply GLOBAL
|
||||||
|
|
||||||
|
**Files** :
|
||||||
|
- `frontend/src/styles/index.css` — nouvelle recipe (mais appliquée comme default, pas opt-in cette sprint per user decision Q2-B) :
|
||||||
|
- Soit : modifier la recipe `.card-product table` existante pour passer à 32px row, `caption-md` text, `py-xxs px-xs` cells, divider `border-hairline`.
|
||||||
|
- Soit : ajouter `.table-compact` puis l'appliquer à TOUTES les list pages (Engagements, Templates, Users, etc.).
|
||||||
|
- **Choix builder** : pick the cleaner path. Préférer modifier le default si toutes les tables doivent suivre, sinon `.table-compact` + apply partout.
|
||||||
|
- Apply sur :
|
||||||
|
- `frontend/src/pages/EngagementsListPage.tsx`
|
||||||
|
- `frontend/src/pages/TemplatesListPage.tsx`
|
||||||
|
- `frontend/src/pages/UsersAdminPage.tsx`
|
||||||
|
- `frontend/src/components/SimulationList.tsx` (utilisé dans EngagementDetailPage)
|
||||||
|
- Toute autre table dans le code (grep `<table` dans `frontend/src/`)
|
||||||
|
- `DESIGN.md` — `### Data Tables` section : modifier la ligne "Row min-height 44px" → "Row min-height 32px (compact density, all surfaces)". Documenter le tradeoff WCAG (touch target dérogé en faveur de la densité opérateur — c'est un BAS tool, pas un site grand public).
|
||||||
|
|
||||||
|
**ATTENTION** : WCAG SC 2.5.5 (Target Size: Minimum) recommande 44×44. Tu déroges. Garder les boutons d'action des rows ≥ 24px d'icône avec padding pour préserver le hit area minimal. Tester en clavier + lecteur d'écran nicht regressé.
|
||||||
|
|
||||||
|
### Livrable 5 — DESIGN.md amendments + CHANGELOG
|
||||||
|
|
||||||
|
**Files** :
|
||||||
|
- `DESIGN.md` :
|
||||||
|
- `### Navigation` : nouvelle subsection "Sub-page tabs" (livrable 1)
|
||||||
|
- `### Toast Notifications` : nouvelle subsection "Inline Banners" (livrable 2)
|
||||||
|
- `### Data Tables` : ligne row min-height passe à 32px + paragraphe rationale (livrable 4)
|
||||||
|
- `CHANGELOG.md` : entrée Sprint 11 listant chaque primitive + ses tokens DESIGN.md.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Sequencing
|
## Sequencing
|
||||||
|
|
||||||
1. **frontend-builder** : Task A + B + C. Une seule passe, commits atomiques.
|
1. **frontend-builder** : livrables 1 + 2 + 3 + 4 + 5 en cascade. Une seule passe. Commits atomiques :
|
||||||
2. **design-reviewer** : revue visuelle après merge des commits builder. Focus :
|
```
|
||||||
- Lecture confortable cards-on-tinted-canvas.
|
feat(frontend): add Tabs primitive + useHashTab hook
|
||||||
- Hairline encore visible.
|
feat(frontend): refactor EngagementDetailPage to 3-tab layout
|
||||||
- Dark mode inchangé.
|
feat(frontend): add AlertBanner component + 4 semantic variants
|
||||||
- Pas de régression sur components qui pourraient ré-utiliser `bg-canvas` pour autre chose (dropdowns, modals).
|
refactor(frontend): migrate SimulationFormPage banners to AlertBanner
|
||||||
|
feat(frontend): add BackLink helper + dedup 3 hand-rolled instances
|
||||||
|
feat(frontend): compact table density (32px row) global
|
||||||
|
docs(design): add tabs / inline banners / compact-table-density to DESIGN.md
|
||||||
|
```
|
||||||
|
(collapse OK si plus efficace ; ~5-7 commits attendus)
|
||||||
|
2. **design-reviewer** : visual + token compliance check. Focus :
|
||||||
|
- Underline tabs : pas de transition, pas de bg fill, border-b instantané
|
||||||
|
- Count pill : `rounded-pill` est dans l'exception DESIGN.md, OK
|
||||||
|
- AlertBanner : `border-l-4` semantic OK, pas de shadow
|
||||||
|
- BackLink : caption + icon align baseline
|
||||||
|
- 32px tables : densité lisible ? Hit area boutons d'action OK ?
|
||||||
|
3. **code-reviewer** : sprint diff. Focus :
|
||||||
|
- Aucune transition / shadow / rounded leak
|
||||||
|
- useHashTab : `hashchange` listener cleanup dans useEffect return
|
||||||
|
- Tabs : prop API stable, fallback default ID si hash invalide
|
||||||
|
- AlertBanner : ARIA `role="alert"` ou `role="status"` selon variant
|
||||||
|
- BackLink : `to` est `string` ou objet React Router ? Choisir un seul
|
||||||
|
4. **spec-reviewer** : `SPEC.md` n'a pas vocation à mentionner ces primitives, **skip ce sprint** sauf si tu détectes une feature côté backend qui aurait dérivé.
|
||||||
|
|
||||||
---
|
## Contraintes tests
|
||||||
|
|
||||||
|
- `vitest --run` baseline **212/212** doit tenir.
|
||||||
|
- **Ajouter 4 specs** (1 par new component) :
|
||||||
|
- `Tabs.test.tsx` — active state, hash sync, count pill render
|
||||||
|
- `AlertBanner.test.tsx` — 4 variants rendent les bonnes classes
|
||||||
|
- `BackLink.test.tsx` — render + click navigation
|
||||||
|
- `useHashTab.test.tsx` — hash read/write
|
||||||
|
- `tsc --noEmit` + `eslint --max-warnings=0` clean.
|
||||||
|
- Brutalism unit assertions : pour chaque new component, un test qui vérifie `expect(el).not.toHaveClass('rounded-md')` (sauf pill counter) + `.not.toHaveClass(/transition-/)` + `.not.toHaveClass(/shadow-/)`.
|
||||||
|
|
||||||
|
## Out of scope (explicite)
|
||||||
|
|
||||||
|
- ❌ Side nav / drawer / breadcrumb component — top nav + BackLink suffit
|
||||||
|
- ❌ Global engagement selector top-bar (Spectrum pattern rejeté)
|
||||||
|
- ❌ Editor dynamic-column grid — pas d'éditeur dans Mimic
|
||||||
|
- ❌ Dark mode rework
|
||||||
|
- ❌ Toast queue system (les toasts actuels via `useToast` restent)
|
||||||
|
- ❌ PDF/document deliverable
|
||||||
|
- ❌ Color palette changes
|
||||||
|
- ❌ Tokens spacing/typo dans tailwind.config
|
||||||
|
|
||||||
## Definition of Done
|
## Definition of Done
|
||||||
|
|
||||||
- EngagementFormPage en édition : 2 colonnes desktop, stack mobile.
|
- ✅ 5 primitives livrées + EngagementDetailPage refactorée en tabs + SimulationFormPage banners migrés + BackLink dédup × 3
|
||||||
- Page bg différencié de card bg en light mode (eyes confort).
|
- ✅ vitest **212+/212+** (4 new specs ajoutées), tsc + lint clean
|
||||||
- Vitest + typecheck + lint verts.
|
- ✅ pytest **469/469** intact (zéro backend touché)
|
||||||
- Design-reviewer APPROVED.
|
- ✅ Toutes tables passent à 32px row density (validation visuelle)
|
||||||
- Screenshots livrés ou écueil documenté.
|
- ✅ Design-reviewer APPROVED (brutalism check sur les 4 new recipes)
|
||||||
- Commits conventional, branche `sprint/9-ui-contrast`.
|
- ✅ Code-reviewer APPROVED
|
||||||
|
- ✅ DESIGN.md amendé (3 subsections additives)
|
||||||
|
- ✅ CHANGELOG.md entrée sprint 11
|
||||||
|
- ✅ PR ouverte sur Gitea avec body
|
||||||
|
|||||||
Reference in New Issue
Block a user