From dbf162bf747bef3f7c99c0e5c8182b5fd1400022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=85=E8=86=80=E5=96=B5?= Date: Sat, 17 Oct 2026 21:13:20 +0800 Subject: [PATCH] feat(admin-console): improve route and filter management (#10) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(nuxt): pre-bundle the CommonJS deps of the markdown stack `debug` and `extend` are imported by micromark and unified through @elysola/ui. Served unbundled by the dev server they have no default export, so the console page failed with a 500 in `nuxt dev`. * docs(deployment): list the fragments and feishu link migrations The manual `d1 execute` fallback stopped at 0008, and AGENTS.md named 0001..0010 although 0011 already exists. * feat(storage): persist the per-group route order Routes used to load in id order, so the order saved from the console was lost on the next read. Migration 0012 adds `d1_routes.position`: saving writes each route's index within its own group (saving one group never shifts another), and routes load by `group_id, position, id`. A database without the column keeps working: only a "no such column" / "has no column named" error falls back to the legacy statements, and nothing is cached, so a later migration is picked up on the next call. * feat(console): add in-app destructive-action confirmation Deleting a route or a group used `window.confirm`, which blocks the page and ignores the console theme. A promise-based `useConfirm()` now drives one built on the reka-ui AlertDialog that @elysola/ui ships; reka-ui is pre-bundled so dev keeps a single copy and the dialog stacks with the Rc dialogs. A request never outlives its asker: one made after the asking component unmounted resolves false, and one still open when it unmounts is cancelled. * feat(console): confirm member and webhook removal Removing a member, revoking an invite link and disabling a group's webhook endpoint took effect on the first click. They now ask first; disabling the webhook explains that senders still using the secret will be rejected, and its button is styled as destructive. * feat(console): confirm removing filled editor rows Filter conditions and groups, delivery targets, saved fragments and forge hosts vanished on a single click, taking whatever had been typed with them. Rows holding content now ask first, while empty, never-filled rows (`isBlankNode`: default operator, no path, no values, not negated) are still removed directly. * fix(i18n): remove duplicate button glyphs "New Route", "New Group" and the group cards' "Open" link render a Plus or ArrowRight icon next to their label, so the "+" and "→" baked into the strings appeared twice. * style(console): redesign route cards for narrow screens The card was one flex row whose badges, filter chips, targets and five hand-drawn icon buttons squeezed the route name on small screens. It is now a grid driven by a container query: name and actions share the top line, the filter summary (clamped to two lines) and targets follow, and the tags wrap below; from 40rem the tags move up beside the title. Targets of the same platform collapse into one tag with a count, long ids truncate instead of widening the page, and the actions use lucide icons with accessible labels. * feat(console): reorder a group's routes by drag or keyboard The per-card up/down arrows saved after every single step, so moving a route five places took five writes. A Reorder mode on the group page now swaps each card's switch for a drag handle: pointer drags (mouse and touch) slide the neighbours out of the way and auto-scroll near the viewport edges, Arrow Up/Down on a focused handle moves a card by one and is announced to screen readers, and nothing is written until Save order. Cancel or Escape (unless a dialog or list owns it) drops the draft. The cards move into a new RouteList component that owns the drag state. * style(members): align member cards and invite actions * style(group-editor): size forge and log target controls Keep source hosts, platform selectors and remove actions aligned without stretching short controls across the dialog. Wrap component roots explicitly so their internal markup cannot break the grid. * style(route-editor): group options and delivery target fields Give each target labeled fields and a compact platform header, widen the filter workspace, and align fragment controls. Scroll failed validation into view when the footer is far from the affected section. * feat(filters): add bilingual suggestions and value validation Catalog forge events, actions, payload paths and known values with searchable English and Chinese descriptions. Match-value validation mirrors the server and only rejects inputs that cannot match. * feat(filters): add searchable creatable value inputs Build a theme-aligned combobox on the shared reka-ui primitives. Rank stored keys before bilingual descriptions, allow validated custom values, and preserve unconfirmed multi-value drafts instead of silently committing them. * feat(filter-editor): integrate searchable condition inputs Replace chip-only values with context-aware bilingual inputs and a compact condition grid. Preserve drafts across tree changes, block saves and tests until drafts are resolved, and keep keyword filters free of hidden operators. * feat(filters): split pasted values without breaking regexes Accept multiple values separated by commas or lines while retaining commas inside wrapped expressions and raw regex patterns. Pasting replaces the selected range and keeps rejected values as an explicit draft. * fix(filters): adapt suggestions to the selected operator Offer literal prefixes and suffixes for substring operators, escaped anchored patterns for regex, and numeric suggestions only for comparisons. Suggestion syntax must mean what the selected matcher actually reads. * fix(filters): preserve regex meaning when changing operators Swap wrapped and raw regex sources only when both compile identically after saving. Leave literal, glob, multiline and Unicode-sensitive comparisons unchanged rather than inventing non-equivalent conversions. * a11y(filter-editor): label type and operator controls Associate each fixed select with a stable per-condition label while keeping the compact visual layout unchanged. * fix(editors): ignore accidental backdrop dismissal Do not discard unsaved route or group edits when the user clicks outside the dialog. Preserve Escape, Cancel and explicit close, including popovers and confirmation dialogs stacked above the editor. * feat(dispatch)!: scope stop and fallback to each group A match in one group must not suppress delivery in another group. Track regular matches and stopped scopes independently, and document the routing-table boundary. BREAKING CHANGE: stop and fallback no longer apply globally across groups. Put mutually exclusive routes in the same group and define fallback routes in each group that needs its own catch-all. * fix(dispatch): honor stop on a matching fallback route Once a fallback matches with stop enabled, skip later routes of the same group without affecting other groups. Cover multiple fallback routes in the group-isolation regression test. * style(console): pin theme and language controls to the right Separate utility controls from page actions so narrow screens retain a readable title column and right-aligned actions below. Wrap long headings without letting them push controls out of view. * style(groups): place creation beside the aligned group count Keep the new-group action inside the group list at every width and align the label and count on one baseline with a consistent type scale. * style(groups): align card footers and keep role badges intact Give long names two lines, show the current role in its own non-wrapping row, and anchor every card footer to the grid-row bottom regardless of optional source metadata. * style(logs): prevent filter labels and metadata overflow Keep filter labels on one line and allow long channel, thread and repository identifiers to wrap instead of widening the page. * style(console): scale the sidebar and hide mobile tab tracks Narrow the sidebar proportionally while retaining enough room for both locales. Keep mobile navigation swipeable without a visible horizontal scrollbar. * feat(console): give each group its own routes URL Resolve the selected group from /admin/groups/{groupId}, validate console paths, and use browser history for back navigation. Keep Groups active and let an active mobile-tab tap return to the list. Scope pending route loads to their group and retain the count beside long headings. * feat(console): confirm leaving unsaved page work Guard route changes when an editor or changed order draft is open. Cancel superseded questions and restore the shown history entry when repeated Back or Forward navigation is refused; only completed navigation resets page work. * feat(console): confirm sign-out from desktop and mobile Expose sign-out in the mobile topbar when the sidebar is hidden. Both entry points use the in-app confirmation before navigating to the server logout endpoint. * fix(console): keep topbar tools clear of very narrow headings Below 360px, place the full-width heading beneath the breadcrumb and utility row so the three top-right buttons cannot overlap it. * feat(console): prioritize group titles over actions Place New Route after Reorder in the group bar. Measure available space and remove the reorder label first, then the creation label, before truncating the group title; remeasure on resize, locale and font changes. * fix(editors): focus the dialog without selecting its name field Cancel the non-bubbling FocusScope mount event in the capture phase and focus the dialog itself. Keep keyboard navigation working without highlighting the name or opening the touch keyboard automatically. * perf(console): preserve one instance across admin navigation Use a fixed page key instead of remounting the whole console for each URL. Refresh each view when shown and isolate overview metrics and logs so page filters cannot leak into the dashboard. * fix(console-data): discard superseded load responses Only the latest request may update a list, its error or loading state. Invalidate pending group loads after a save so an older response cannot restore stale configuration during persistent-console navigation. * fix(routes): serialize writes and reject unloaded route lists Whole-list saves must start from loaded data and wait for other route writes. Lock switches and actions during saves, recheck deletion after confirmation, and rebuild saved ordering from the newest route objects. * fix(editors): scope async results and fragment writes to sessions A completed save or dry run must not close or overwrite a newer editor. Keep fragment state scoped by group, reject writes until the real list is ready, and retain in-flight fragment locks across navigation. * fix(groups): serialize edits and isolate group detail panels Prevent overlapping whole-list writes, avoid duplicate ids after rename, and discard delete confirmations prepared on a page that has since been left. Key member and webhook panels by group so local state cannot cross tenants. * fix(console): omit the empty action row outside overview Render the refresh-action container only where it has content so narrow layouts do not reserve a blank row after creation controls move into their page bars. * perf(metrics): send all seven queries in one D1 batch Avoid seven sequential network round trips and read totals, breakdowns and recent failures in one consistent transaction. Reuse the failed-send statement and row mapping while retaining group scoping. * fix(admin-api): bypass browser cache locks for live requests Use no-store on both client requests and admin responses. Personalized live data must not be reused, and one stalled same-URL cache entry must not block later log requests behind the browser cache lock. * docs(routes): Clarify fallback hints and document group-scoped stop and fallback upgrade behavior --- AGENTS.md | 32 +- README.md | 4 +- README.zh.md | 4 +- app/assets/css/main.css | 676 ++++++++++--- app/components/AdminHome.vue | 2 +- app/components/ConfirmDialog.vue | 156 +++ app/components/ConsolePage.vue | 900 ++++++++++++++--- app/components/FilterCombobox.vue | 460 +++++++++ app/components/FilterNodeEditor.vue | 333 ++++--- app/components/GroupEditor.vue | 171 ++-- app/components/MembersPanel.vue | 105 +- app/components/RouteCard.vue | 345 +++---- app/components/RouteEditor.vue | 378 ++++--- app/components/RouteList.vue | 265 +++++ app/components/TagInput.vue | 15 - app/components/WebhookPanel.vue | 8 + app/composables/useApi.ts | 4 + app/composables/useAudit.ts | 11 +- app/composables/useBackdropGuard.ts | 46 + app/composables/useConfirm.ts | 65 ++ app/composables/useDialogFocus.ts | 26 + app/composables/useFilterNode.ts | 83 +- app/composables/useFragments.ts | 55 +- app/composables/useGroupRoutes.ts | 54 +- app/composables/useGroups.ts | 16 +- app/composables/useI18n.ts | 138 ++- app/composables/useLogs.ts | 11 +- app/composables/useMetrics.ts | 11 +- app/pages/admin/[...slug].vue | 12 + app/utils/admin-path.ts | 27 + app/utils/filter-catalog.ts | 1362 ++++++++++++++++++++++++++ config.example.yaml | 2 +- docs/guide/configuration.md | 4 +- docs/guide/deployment.md | 3 + docs/guide/filters.md | 2 + docs/guide/routes.md | 10 +- docs/zh/guide/configuration.md | 4 +- docs/zh/guide/deployment.md | 3 + docs/zh/guide/filters.md | 2 + docs/zh/guide/routes.md | 10 +- migrations/0012_route_position.sql | 5 + nuxt.config.ts | 10 + server/lib/core/dispatch.ts | 19 +- server/lib/lib/send-log.ts | 32 +- server/lib/observability/metrics.ts | 96 +- server/lib/storage/config-store.ts | 90 +- server/lib/types.ts | 14 +- server/routes/admin/api/[...slug].ts | 10 +- tests/admin-api-route.test.ts | 14 + tests/admin-path.test.ts | 36 + tests/config-store.test.ts | 107 +- tests/delivery-metrics.test.ts | 10 + tests/discord.test.ts | 43 + tests/filter-catalog.test.ts | 342 +++++++ tests/filter-node.test.ts | 120 +++ 55 files changed, 5778 insertions(+), 985 deletions(-) create mode 100644 app/components/ConfirmDialog.vue create mode 100644 app/components/FilterCombobox.vue create mode 100644 app/components/RouteList.vue delete mode 100644 app/components/TagInput.vue create mode 100644 app/composables/useBackdropGuard.ts create mode 100644 app/composables/useConfirm.ts create mode 100644 app/composables/useDialogFocus.ts create mode 100644 app/utils/admin-path.ts create mode 100644 app/utils/filter-catalog.ts create mode 100644 migrations/0012_route_position.sql create mode 100644 tests/admin-api-route.test.ts create mode 100644 tests/admin-path.test.ts create mode 100644 tests/filter-catalog.test.ts create mode 100644 tests/filter-node.test.ts diff --git a/AGENTS.md b/AGENTS.md index ca0609e..832eea8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,16 +9,16 @@ Core pipeline: GitHub Webhook → Worker (verify + filter + format) → Discord ## Key Decisions - Runtime: Cloudflare Workers via the Nitro `cloudflare_module` preset (`_worker.js`), H3 event handlers in `server/routes/` -- UI: Vue 3 + Tailwind CSS v4 (`@tailwindcss/vite`) + `@elysola/ui` (Nuxt module, `Rc` prefix); admin console is a client-side SPA (`routeRules: "/admin/**": { ssr: false }`), home/legal pages render server-side +- UI: Vue 3 + Tailwind CSS v4 (`@tailwindcss/vite`) + `@elysola/ui` (Nuxt module, `Rc` prefix); admin console is a client-side SPA (`routeRules: "/admin/**": { ssr: false }`), home/legal pages render server-side; app-level composites (`FilterCombobox`, `ConfirmDialog`) are built on the reka-ui primitives that `@elysola/ui` ships (same copy, pre-bundled via `vite.optimizeDeps.include` so dev keeps a single instance and dialogs/popovers stack correctly) and styled like their Rc counterparts - Styling: Elysola UI supplies semantic components and blue theme tokens; `app/assets/css/main.css` retains `--wh-*` RGB-triplet aliases for app-specific Tailwind utilities and bespoke layouts (avoiding collision with Elysola's `--surface`/`--text`/`--border` hex tokens); theme switching supports auto/light/dark via `useTheme` / `ThemeToggle`, toggling `.dark` with inline anti-flash head script - Discord interactions: HTTPS Interactions Endpoint (`POST /discord/interactions`, Ed25519-signed) — no Discord Gateway / Durable Object; bot stays offline, messages always sent via REST -- Storage: D1 is the source of truth for config (routes/groups via `d1_routes`/`d1_groups`, see `server/lib/storage/config-store.ts`), send/audit logs, dedup (`dedup_keys`), delivery state (`delivery_state`) and message tracking (`message_tracking` via `server/lib/storage/d1.ts` `canUseD1` gate). KV keeps only cache + short-lived/ephemeral state (tokens, OAuth state, admin sessions, `msg:*`-adjacent locks, per-group secrets `tenant:*`, invites, i18n overrides) with explicit TTLs. R2 parks oversized queue payloads (`webhooks/YYYY/MM/DD/*.json`, `server/lib/storage/payload.ts`) instead of KV. A `storage-prune` scheduled task cleans up expired dedup/delivery/message-tracking rows +- Storage: D1 is the source of truth for config (routes/groups via `d1_routes`/`d1_groups`, see `server/lib/storage/config-store.ts`; each route's per-group order lives in `d1_routes.position` — migration 0012 — and routes load ordered by `group_id, position, id`, falling back to id order on an unmigrated database), send/audit logs, dedup (`dedup_keys`), delivery state (`delivery_state`) and message tracking (`message_tracking` via `server/lib/storage/d1.ts` `canUseD1` gate). KV keeps only cache + short-lived/ephemeral state (tokens, OAuth state, admin sessions, `msg:*`-adjacent locks, per-group secrets `tenant:*`, invites, i18n overrides) with explicit TTLs. R2 parks oversized queue payloads (`webhooks/YYYY/MM/DD/*.json`, `server/lib/storage/payload.ts`) instead of KV. A `storage-prune` scheduled task cleans up expired dedup/delivery/message-tracking rows - Signature verification: Web Crypto API (HMAC-SHA256 for GitHub/Gitea, Ed25519 for Discord, timing-safe secret-token compare for Telegram) - Webhook providers: pluggable forge adapters under `server/lib/providers/` (github, gitea) — each verifies its own signature format and normalizes its payload to a GitHub-shaped `WebhookEvent`; a `custom` provider accepts arbitrary signed JSON posts (`X-WebHooker-Signature`) as `custom` events; GitLab etc. can be added later - Per-group webhook ingress: optional `POST /webhook/{groupId}` with a per-group secret in KV (`tenant:{groupId}`) — Gitea/classic-GitHub/custom webhooks are verified against the group's secret instead of the operator's global ones; only that group's routes fire. The legacy `POST /webhook` (global secrets, all routes) stays untouched - GitHub App tenant isolation: `Group.installationId` binds a group to one GitHub App installation; events whose `payload.installation.id` differs are rejected at dispatch (hard isolation on top of the optional `owners` list). The App's Setup URL points at `GET /auth/github/install`, which renders a choice page (create `inst-{installationId}` or bind to a group the signed-in user owns, verified by role); `POST /auth/github/install/bind` performs the provisioning. `installation.created` webhook events auto-provision as a fallback (create `inst-{installationId}` or bind existing groups whose `owners` match the installing account) - GitHub OAuth: octokit (token is stored hashed for reverse lookup) -- Admin WebUI: `/admin` config console, OAuth-session protected via `ADMIN_USER_IDS` whitelist (local-only `DEBUG_MODE=true` bypasses authentication); left sidebar navigation (Overview / Groups / Send Logs / Audit / Stats) + topbar, deep-linkable routes (`/admin` overview · `/admin/groups` · `/admin/logs` · `/admin/audit` · `/admin/metrics`); the overview dashboard (`AdminHome.vue`) aggregates delivery KPIs, a routes table and recent send logs; the stats page (`MetricsPanel.vue`) renders KPI cards plus per-platform/per-event ok/failed bar legends and a per-status breakdown, and filters by group (`?groupId=`); the route/group editors (`RouteEditor.vue` / `GroupEditor.vue`) are centered, scrollable `RcDialog` forms with an eyebrow header and sectioned bodies +- Admin WebUI: `/admin` config console, OAuth-session protected via `ADMIN_USER_IDS` whitelist (local-only `DEBUG_MODE=true` bypasses authentication); left sidebar navigation (Overview / Groups / Send Logs / Audit / Stats) + topbar, deep-linkable routes (`/admin` overview · `/admin/groups` · `/admin/groups/{groupId}` a group's routes, members and webhook · `/admin/logs` · `/admin/audit` · `/admin/metrics`, parsed by `app/utils/admin-path.ts`; the admin page's `validate` 404s any other path) — the page has a fixed `key`, so one console instance (and its in-flight saves) persists across these URLs while each view refreshes its data when shown; every page is a history entry, so the browser's back button returns from a group to the list (no in-page back button) and leaving with an open editor or an unsaved route order asks first; route switches/actions lock while a route write is in flight; sign-out asks for confirmation (sidebar, or a top-right button on narrow screens); editor dialogs open without focusing a field (`useDialogFocus`); the overview dashboard (`AdminHome.vue`) aggregates delivery KPIs, a routes table and recent send logs; the stats page (`MetricsPanel.vue`) renders KPI cards plus per-platform/per-event ok/failed bar legends and a per-status breakdown, and filters by group (`?groupId=`); the route/group editors (`RouteEditor.vue` / `GroupEditor.vue`) are centered, scrollable `RcDialog` forms with an eyebrow header and sectioned bodies - Access control: every group has role-based members (`owner` / `admin` / `viewer`); super admins bypass; legacy `adminIds` are read as owners (backward compatible); owners manage members + invites; `owners` field stays super-only - Invites: single-use 7-day links (`invite:{token}`) for joining a group as admin/viewer; `ALLOW_SELF_SIGNUP=1` gives access-less users a personal group on first login (self-service SaaS entry) - Audit log: every admin operation (logins, group/route/member/invite changes) recorded in D1 `audit_logs`; pruned by the scheduled trigger after `AUDIT_RETENTION_DAYS` (default 90) @@ -26,7 +26,7 @@ Core pipeline: GitHub Webhook → Worker (verify + filter + format) → Discord - Per-group forge branding: optional `Group.forgeSources` (a list of `{ host, type: "github" | "gitea", name? }` the group defines itself) labels each message's footer with the first entry whose type matches the event's provider and whose host matches the repository URL's hostname (GitHub matches `github.com`, so two Gitea instances can be `git1.example.com`/`git2.example.com`); the label is the entry's optional `name` (fallback: host); links are derived from the repo URL and footer icons use raster PNGs Discord renders (GitHub's `fluidicon.png`, Gitea's `/assets/img/favicon.png` — `.ico` favicons are silently ignored); Discord shows the footer icon + name, Telegram a linked name - Delivery queue: when the `QUEUE` binding is present, webhook ingress enqueues one message per event (not per target) to a Cloudflare Queue (`webhooker-delivery`); a Nitro `cloudflare:queue` plugin consumes batches, dispatches, and retries retryable failures (5xx/network/429-exhaustion) with exponential backoff (5s/30s/2m/10m) up to the queue `max_retries`, after which the DLQ (`webhooker-delivery-dlq`) marks the delivery dead. Oversized payloads (>~100 KB) are parked in R2 (`webhooks/YYYY/MM/DD/*.json`, falling back to KV `queue:payload:*` without the R2 binding) and resolved by the consumer; delivery state is tracked as the D1 `delivery_state` table (KV `delivery-state:*` fallback). Without the `QUEUE` binding, dispatch stays inline (existing behavior) - Storage quotas: the design avoids KV write pressure (Workers Free KV allows ~1,000 writes/day) by keeping high-frequency ephemeral writes in D1 instead — webhook dedup (`dedup_keys`, atomic `ON CONFLICT` UPSERT), delivery state and message tracking all use D1 rows via `canUseD1` (prepare+batch probe) with automatic KV fallback when D1 is unavailable or unmigrated. D1 Free allows 100,000 rows written/day, so the per-event KV write cost drops to ~0; config stays cached in memory + KV with D1 authoritative -- Filter DSL: a route's flat `filters` can be replaced by a nested `ast` (`all`/`any`/`not` nodes, `server/lib/events/filter-ast.ts`) that takes precedence when present; the `field` filter type reads any payload value by JSONPath (`path`, arrays expand so any element matches) and 12 comparison operators (`op`: `eq`/`ne`/`contains`/`startsWith`/`endsWith`/`regex`/`gt`/`gte`/`lt`/`lte`/`in`/`exists`) extend the legacy glob/regex/case-insensitive-exact semantics; named filter fragments (D1 `d1_fragments` via `server/lib/fragments.ts`, per-group) are editor-side templates inlined into the route's `ast` on insert — the matcher never resolves fragment references; the route editor (`RouteEditor.vue`) exposes a recursive AST builder (`FilterNodeEditor.vue`), chip multi-value input (`TagInput.vue`), live explanation and a stateless `POST /admin/api/test-match` dry-run +- Filter DSL: a route's flat `filters` can be replaced by a nested `ast` (`all`/`any`/`not` nodes, `server/lib/events/filter-ast.ts`) that takes precedence when present; the `field` filter type reads any payload value by JSONPath (`path`, arrays expand so any element matches) and 12 comparison operators (`op`: `eq`/`ne`/`contains`/`startsWith`/`endsWith`/`regex`/`gt`/`gte`/`lt`/`lte`/`in`/`exists`) extend the legacy glob/regex/case-insensitive-exact semantics; named filter fragments (D1 `d1_fragments` via `server/lib/fragments.ts`, per-group) are editor-side templates inlined into the route's `ast` on insert — the matcher never resolves fragment references; the route editor (`RouteEditor.vue`) exposes a recursive AST builder (`FilterNodeEditor.vue`: plain selects for filter type/operator, an all/any segmented toggle, NOT toggle + delete pinned per condition), searchable multi-value / path inputs (`FilterCombobox.vue`) fed by a bilingual suggestion catalog (`app/utils/filter-catalog.ts`: GitHub events/actions from `@octokit/webhooks` plus Gitea extras, common payload paths and their known values, English keys searchable in either language) where custom values are allowed but rejected when the matcher could never match them (`validateFilterValue`), a live explanation and a stateless `POST /admin/api/test-match` dry-run - Local dev: wrangler + Miniflare ## Architecture @@ -37,12 +37,16 @@ app/ # Vue 3 UI (Nuxt app dir) ├── assets/css/main.css # Tailwind v4 entry: Elysola-compatible RGB aliases + bespoke layout classes + Vue transition glue ├── pages/ # index (landing), terms, privacy, admin/[...slug] (console SPA) ├── components/ # ConsolePage (sidebar shell + topbar), AdminHome (overview dashboard), -│ # RouteCard/Editor (RouteEditor has FilterNodeEditor AST builder + TagInput chips), -│ # GroupEditor, MembersPanel, WebhookPanel, -│ # SendLogs, AuditLog, MetricsPanel, AppToasts, LegalLayout -├── composables/ # useI18n, useToasts, useGroups, useGroupRoutes, useFilterNode (AST helpers), useFragments, useLogs, useAudit, useInvites, useWebhook +│ # RouteList (drag/keyboard reorder mode) + RouteCard, RouteEditor (FilterNodeEditor +│ # AST builder + FilterCombobox searchable inputs), GroupEditor, MembersPanel, WebhookPanel, +│ # ConfirmDialog (app-wide destructive-action confirm), SendLogs, AuditLog, MetricsPanel, +│ # AppToasts, LegalLayout +├── composables/ # useI18n, useToasts, useConfirm (promise-based confirm), useBackdropGuard (editor dialogs ignore +│ # backdrop clicks), useDialogFocus (editor dialogs open without focusing a field), useGroups, useGroupRoutes, useFilterNode (AST helpers), useFragments, useLogs, +│ # useAudit, useInvites, useWebhook ├── types.ts # shared client types (Route, Group, Filter, ...) -└── utils/legal.ts # terms/privacy HTML bodies (zh/en) +└── utils/ # legal.ts (terms/privacy HTML bodies, zh/en), format.ts, admin-path.ts (console URL parsing), + # filter-catalog.ts (bilingual filter suggestions + value/path validators) server/ # Nitro server ├── routes/ # H3 handlers: /health, /webhook[/:groupId], /discord/interactions, /telegram/webhook, │ # /auth/github*, /admin/{login,logout,invite,api/**}, /api/{comment,merge,close,react,richheader} @@ -123,10 +127,10 @@ server/ # Nitro server │ ├── tenants.ts # Per-group webhook secret CRUD (KV tenant:{groupId}, 32-byte random hex) │ └── richheader.ts # GET /api/richheader: Open Graph page for Telegram avatar link-preview card ├── observability/ # delivery metrics aggregation - │ └── metrics.ts # DeliveryMetrics + getDeliveryMetrics (SQL GROUP BY over send_logs: totals, per platform/event/status, duration, attempts, recent failures) + │ └── metrics.ts # DeliveryMetrics + getDeliveryMetrics (SQL GROUP BY over send_logs in one D1 batch: totals, per platform/event/status, duration, attempts, recent failures) ├── storage/ # storage primitives: canUseD1 probe, D1 config store (L1 memory → L2 KV cache → L3 D1), R2 payload store │ ├── d1.ts # canUseD1(db) — prepare+batch probe for D1 availability (falls back to KV) - │ ├── config-store.ts # ConfigStore (loadRoutes/saveRoutes/loadGroups/saveGroups/invalidateCache) backed by d1_groups/d1_routes, seeds from KV + syncs cache + │ ├── config-store.ts # ConfigStore (loadRoutes/saveRoutes/loadGroups/saveGroups/invalidateCache) backed by d1_groups/d1_routes (per-group `position` order when migrated), seeds from KV + syncs cache │ └── payload.ts # PayloadStore backed by R2 (webhooks/YYYY/MM/DD/*.json), no-binding stub throws └── lib/ # shared infra ├── i18n.ts # loadTranslations (KV i18n:{lang} overrides), t() with param interpolation @@ -157,7 +161,7 @@ tests/__snapshots__/ # formatter snapshot golden files (toMatchSnapshot) - Store named filter fragments (D1 `d1_fragments`, per group, `GET`/`PUT /admin/api/groups/:groupId/fragments`) as editor-side templates; inserting a fragment inlines its node into the route's `ast` — dispatch never resolves fragment references - Offer a stateless filter dry-run (`POST /admin/api/test-match`, body `{ node | filters, event?, payload }`) that evaluates in memory and returns `{ matched, explanation }` — no event payload is stored - Validate route/group config against valibot schemas on load (non-destructive: invalid entries log a warning but still load); `CONFIG_SCHEMA_VERSION` marks the schema version and `migrateRoutes`/`migrateGroups` migrate legacy shapes (e.g. `target` → `targets`) -- Filter routes by group owner restriction (`Group.owners`), group source-platform restriction (`Group.providers`: github/gitea), GitHub App installation restriction (`Group.installationId`), and skip fallback routes whenever a regular route matched; stop evaluating further routes when a matched route has `stop: true` +- Filter routes by group owner restriction (`Group.owners`), group source-platform restriction (`Group.providers`: github/gitea), GitHub App installation restriction (`Group.installationId`), and skip a group's fallback routes whenever a regular route of that group matched; stop evaluating the group's further routes when a matched route has `stop: true` (both scoped per group, so one group's routes never silence another's) - Auto-provision GitHub App installs: the App's Setup URL flow (`/auth/github/install` choice page + `POST /auth/github/install/bind`, owner-role verified for existing groups) and the `installation.created` webhook fallback both create `inst-{installationId}` groups or bind existing groups - Enforce role-based access on every admin API: super admins bypass, `owner` manages the group (routes/members/invites/settings), `admin` edits routes, `viewer` is read-only; legacy `adminIds` groups resolve to `owner` members - Issue single-use 7-day group invite links (`invite:{token}`); accepting joins as admin/viewer (never owner); `ALLOW_SELF_SIGNUP=1` creates a deterministic personal group (`u-{userId}`) on first login @@ -168,7 +172,7 @@ tests/__snapshots__/ # formatter snapshot golden files (toMatchSnapshot) - Route messages to Discord channels/threads and Telegram chats/topics via REST - Edit already-sent messages in place for `workflow_run` / `check_run` progress (stable `updateKey`, `message_tracking` via D1 with KV `msg:*` fallback); `workflow_run` keys on the workflow id while `check_run` keys on check name + commit SHA (falling back to the run id) so providers that emit a fresh run id per phase — e.g. Cloudflare Pages — still edit the same message - Record every dispatch attempt to D1 `send_logs` (route id, event, target, ok/error, duration, error code) -- Aggregate delivery metrics (`server/lib/observability/metrics.ts`) from `send_logs` — totals, ok/failed counts + failure rate, per-platform/per-event/per-status breakdowns, average duration and attempts, recent failures; `getDeliveryMetrics(db, groupId?)` scopes every query by `group_id` when a group is passed +- Aggregate delivery metrics (`server/lib/observability/metrics.ts`) from `send_logs` — totals, ok/failed counts + failure rate, per-platform/per-event/per-status breakdowns, average duration and attempts, recent failures; `getDeliveryMetrics(db, groupId?)` sends all seven queries as one D1 `batch` (a single round trip and a consistent snapshot) and scopes every query by `group_id` when a group is passed - Expose admin observability endpoints — `GET /admin/api/metrics?groupId=` (delivery metrics, optional group scope; recent failures group-scoped for non-super) and `GET /admin/api/delivery/:deliveryId` (all send-log attempts for one delivery, group-scoped) — through the `/admin/api/[...slug]` catch-all route (`server/routes/admin/api/[...slug].ts`) that wires every admin API handler to its method+path - Serve a per-group webhook ingress (`POST /webhook/{groupId}`, per-group secret in KV `tenant:{groupId}`) for Gitea/classic-GitHub/custom senders; only that group's routes fire; dedup keys are provider- and tenant-scoped (`delivery:{provider}:{groupId}:{id}` via `idempotencyStore`, D1 `dedup_keys` with KV fallback) - Issue a per-request correlation id (`requestId`) in webhook responses and dispatch logs @@ -276,7 +280,7 @@ bunx wrangler d1 create webhooker bunx wrangler queues create webhooker-delivery bunx wrangler queues create webhooker-delivery-dlq # Queues are declared in wrangler.jsonc (QUEUE binding); no env var needed -bun run db:migrate:prod # wrangler d1 migrations apply webhooker --remote (migrations/0001..0010) +bun run db:migrate:prod # wrangler d1 migrations apply webhooker --remote (migrations/0001..0012) # R2 bucket for oversized payloads (P0): bunx wrangler r2 bucket create webhooker-payloads bunx wrangler deploy ``` diff --git a/README.md b/README.md index 19290be..86a182a 100644 --- a/README.md +++ b/README.md @@ -103,11 +103,11 @@ Routes are stored in D1 (`d1_routes`, seeded from legacy KV `config:routes` on f ] ``` -`target.platform` selects the push target: `discord` (default), `telegram`, or `feishu`. Discord targets require `target.channelId` (optional `threadId` for a thread); Telegram targets require `target.chatId` (optional `topicId` for a topic); Feishu targets require `target.chatId` (optional `topicId` for a topic). A route may also set `stop: true` (skip later routes). Routes belong to **groups** (D1 `d1_groups`, seeded from legacy KV `config:groups`) that scope admin access and can restrict which org/user events flow in. See the [Routes & Targets](https://webhooker.docs.elysola.org/guide/routes) and [Groups & Access Control](https://webhooker.docs.elysola.org/guide/groups) guides for the full schema. +`target.platform` selects the push target: `discord` (default), `telegram`, or `feishu`. Discord targets require `target.channelId` (optional `threadId` for a thread); Telegram targets require `target.chatId` (optional `topicId` for a topic); Feishu targets require `target.chatId` (optional `topicId` for a topic). A route may also set `stop: true` (skip later routes of its group). Routes belong to **groups** (D1 `d1_groups`, seeded from legacy KV `config:groups`) that scope admin access and can restrict which org/user events flow in. See the [Routes & Targets](https://webhooker.docs.elysola.org/guide/routes) and [Groups & Access Control](https://webhooker.docs.elysola.org/guide/groups) guides for the full schema. ### Web UI (`/admin`) -The built-in config console lets you manage routes and groups in the browser (add / edit / delete / toggle / reorder), inspect send logs, manage group members and invite links, and read the audit log — no KV access needed: +The built-in config console lets you manage routes and groups in the browser (add / edit / delete / toggle / drag to reorder — the saved order is the evaluation order), inspect send logs, manage group members and invite links, and read the audit log — no KV access needed: 1. Set `ADMIN_USER_IDS` to the GitHub user IDs (or logins) allowed to manage the console, e.g. `ADMIN_USER_IDS=12345,RhenCloud`. 2. Visit `/admin` and sign in with GitHub. Users with no access get `403` — unless `ALLOW_SELF_SIGNUP=1` (they receive a personal group) or they follow a group invite link. diff --git a/README.zh.md b/README.zh.md index 433f5ea..3c5b025 100644 --- a/README.zh.md +++ b/README.zh.md @@ -103,11 +103,11 @@ bunx wrangler dev # 启动本地开发服务器 ] ``` -`target.platform` 选择推送目标:`discord`(默认)、`telegram` 或 `feishu`。Discord 目标需 `target.channelId`(可选 `threadId` 指向子区);Telegram 目标需 `target.chatId`(可选 `topicId` 指向话题);飞书目标需 `target.chatId`(可选 `topicId` 指向子话题)。路由还可设置 `stop: true`(跳过后续路由)。路由隶属于**分组**(D1 `d1_groups`,首次加载时从旧版 KV `config:groups` 同步),分组用于限定管理权限,并可限制哪些组织/用户的事件流入。完整模式见[路由与目标](https://webhooker.docs.elysola.org/zh/guide/routes)与[分组与访问控制](https://webhooker.docs.elysola.org/zh/guide/groups)指南。 +`target.platform` 选择推送目标:`discord`(默认)、`telegram` 或 `feishu`。Discord 目标需 `target.channelId`(可选 `threadId` 指向子区);Telegram 目标需 `target.chatId`(可选 `topicId` 指向话题);飞书目标需 `target.chatId`(可选 `topicId` 指向子话题)。路由还可设置 `stop: true`(跳过本分组的后续路由)。路由隶属于**分组**(D1 `d1_groups`,首次加载时从旧版 KV `config:groups` 同步),分组用于限定管理权限,并可限制哪些组织/用户的事件流入。完整模式见[路由与目标](https://webhooker.docs.elysola.org/zh/guide/routes)与[分组与访问控制](https://webhooker.docs.elysola.org/zh/guide/groups)指南。 ### Web 控制台(`/admin`) -内置的配置控制台让你在浏览器中管理路由与分组(新增 / 编辑 / 删除 / 开关 / 排序)、查看发送日志、管理组成员与邀请链接、阅读审计日志——无需直接操作 D1 或 KV: +内置的配置控制台让你在浏览器中管理路由与分组(新增 / 编辑 / 删除 / 开关 / 拖动排序——保存的顺序即评估顺序)、查看发送日志、管理组成员与邀请链接、阅读审计日志——无需直接操作 D1 或 KV: 1. 设置 `ADMIN_USER_IDS` 为允许管理控制台的 GitHub 用户 ID(或登录名),例如 `ADMIN_USER_IDS=12345,RhenCloud`。 2. 访问 `/admin` 并用 GitHub 登录。无任何权限的用户收到 `403`——除非开启 `ALLOW_SELF_SIGNUP=1`(自动获得个人分组)或通过分组邀请链接加入。 diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 7072cc2..9dbdc54 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -213,26 +213,6 @@ @apply px-6 py-3 text-sm; } - .icon-btn { - @apply grid h-[30px] w-[30px] place-items-center cursor-pointer rounded-sm border border-border bg-transparent text-[13px] text-muted transition-all duration-150; - } - - .icon-btn:hover { - @apply border-accent bg-accent-dim text-accent; - } - - .icon-btn:disabled { - @apply cursor-not-allowed opacity-35; - } - - .icon-btn:disabled:hover { - @apply border-border bg-transparent text-muted; - } - - .icon-btn.danger:hover { - @apply border-bad bg-bad-dim text-bad; - } - /* ---- Cards ---- */ .card { @apply animate-rise rounded border border-border bg-surface p-5 transition-[border-color,transform] duration-150; @@ -283,8 +263,15 @@ } /* ---- Route cards ---- */ + .route-list { + @apply flex flex-col gap-2.5; + container-type: inline-size; + } + .route-card { - @apply flex animate-rise items-center gap-4 rounded-xl border border-border bg-surface px-5 py-3.5 shadow-xs transition-all duration-150; + @apply block animate-rise rounded-xl border border-border bg-surface px-4 py-3 shadow-xs transition-all duration-150; + /* Only the entry delay keeps the hidden state: inline transforms (drag) must win afterwards. */ + animation-fill-mode: backwards; } .route-card:hover { @@ -295,28 +282,70 @@ @apply opacity-60; } - .route-card-main { - @apply min-w-0 flex-1 space-y-2.5; + /* Mobile-first: title row with actions, then filters/targets, then the tags. */ + .route-row { + @apply grid items-center gap-x-3 gap-y-2; + grid-template-columns: auto minmax(0, 1fr) auto; + grid-template-areas: + "lead title actions" + "body body body" + "tags tags tags"; } - .route-card-header { - @apply flex flex-wrap items-center gap-2.5; + .route-lead { + @apply flex items-center; + grid-area: lead; } - .route-card-title { - @apply flex min-w-0 flex-wrap items-center gap-2; + .route-title { + @apply flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1; + grid-area: title; } .route-name { - @apply text-[15px] font-semibold tracking-tight text-text; + @apply min-w-0 text-[15px] font-semibold tracking-tight text-text; + overflow-wrap: anywhere; } .route-id { @apply rounded-md bg-surface-2 px-1.5 py-0.5 font-mono text-[11px] text-faint; } - .route-card-badges { - @apply ml-auto flex flex-wrap items-center gap-1.5; + .route-position { + @apply grid h-5 min-w-5 place-items-center rounded-md bg-accent-dim px-1 font-mono text-[11px] font-semibold text-accent-text tabular-nums; + } + + .route-tags { + @apply flex flex-wrap items-center justify-end gap-1.5; + grid-area: tags; + } + + .route-actions { + @apply flex items-center gap-0.5; + grid-area: actions; + } + + .route-body { + @apply min-w-0 space-y-2; + grid-area: body; + } + + @container (min-width: 40rem) { + .route-row { + grid-template-columns: auto minmax(0, 1fr) auto auto; + grid-template-areas: + "lead title tags actions" + ". body body body"; + } + } + + .route-summary { + @apply line-clamp-2 text-[12.5px] leading-relaxed text-muted; + overflow-wrap: anywhere; + } + + .route-summary.is-empty { + @apply italic text-faint; } .route-badge { @@ -324,18 +353,18 @@ } .route-badge-dot { - @apply inline-block h-1.5 w-1.5 rounded-full; + @apply inline-block h-1.5 w-1.5 rounded-full bg-current; } - .route-badge-dc { + .route-badge-discord { @apply border-accent/20 bg-accent-dim/30 text-accent-text; } - .route-badge-tg { + .route-badge-telegram { @apply border-info/20 bg-info-dim/30 text-info; } - .route-badge-fs { + .route-badge-feishu { @apply border-warn/20 bg-warn-dim/30 text-warn; } @@ -351,44 +380,12 @@ @apply border-accent/30 bg-accent-dim/20 text-accent-text; } - .route-card-filters { - @apply flex flex-wrap items-center gap-2 text-xs; - } - - .route-chip { - @apply inline-flex items-center gap-1.5 rounded-md border border-border bg-surface-2 px-2.5 py-1 text-[11.5px]; - } - - .route-chip-type { - @apply font-bold uppercase tracking-wider text-faint text-[10px]; - } - - .route-chip-val { - @apply font-medium text-text; - } - - .route-chip.exclude { - @apply border-bad/20 bg-bad-dim/20; - } - - .route-chip.exclude .route-chip-type { - @apply text-bad; - } - - .route-chip-empty { - @apply italic text-muted; - } - .route-card-targets { @apply flex flex-wrap items-center gap-2 text-xs; } - .route-target { - @apply inline-flex items-center; - } - .route-target-row { - @apply inline-flex items-center gap-1.5 rounded-md border border-border/80 bg-surface-2/60 px-2 py-0.5 text-xs; + @apply inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md border border-border/80 bg-surface-2/60 px-2 py-0.5 text-xs; } .route-target-label { @@ -396,19 +393,53 @@ } .route-target-id { - @apply font-mono text-[11.5px] text-text; + @apply min-w-0 truncate font-mono text-[11.5px] text-text; } - .route-card-actions { - @apply flex shrink-0 items-center gap-1 self-center; + /* ---- Route reordering ---- */ + .route-handle { + @apply grid h-9 w-9 cursor-grab place-items-center rounded-lg text-muted transition-colors hover:bg-surface-2 hover:text-text; + touch-action: none; } - .route-action-btn { - @apply flex h-7 w-7 items-center justify-center rounded-md text-muted transition-colors hover:bg-surface-2 hover:text-text disabled:pointer-events-none disabled:opacity-25; + .route-handle:disabled { + @apply cursor-not-allowed opacity-40 hover:bg-transparent; } - .route-action-btn-danger:hover { - @apply bg-bad-dim/30 text-bad; + .route-handle:focus-visible { + @apply outline-2 outline-offset-2 outline-accent; + } + + .route-list.is-reordering .route-card { + @apply select-none; + } + + .route-list.is-dragging .route-card { + transition: transform 180ms ease; + } + + .route-list.is-dragging .route-handle { + @apply cursor-grabbing; + } + + .route-list .route-card.is-dragged { + @apply relative z-10 border-accent shadow-lg; + transition: none; + } + + .route-list .route-card.is-dragged.is-settling { + transition: transform 150ms ease; + } + + .route-list.is-committing .route-card { + transition: none !important; + } + + @media (prefers-reduced-motion: reduce) { + .route-list.is-dragging .route-card, + .route-list .route-card.is-dragged.is-settling { + transition: none; + } } /* ---- Toggle switch ---- */ @@ -522,6 +553,11 @@ padding: 0 !important; } + /* The dialog itself takes focus on open (useDialogFocus); its fields show the ring. */ + .editor-dialog:focus { + outline: none; + } + .editor-dialog > div:first-child { margin-bottom: 0 !important; flex-shrink: 0 !important; @@ -559,10 +595,6 @@ @apply truncate text-base font-extrabold tracking-tight; } - .editor-head .icon-btn { - @apply h-8 w-8 rounded-full; - } - .editor-body { @apply flex-1 overflow-y-auto px-6 py-5; scrollbar-width: thin; @@ -668,29 +700,52 @@ @apply w-full; } - .target-row { - @apply mb-2 grid grid-cols-[minmax(130px,1fr)_auto] items-center gap-2 rounded-sm border border-border bg-surface-2 p-2.5 max-sm:grid-cols-[1fr_auto]; - grid-template-areas: - "select del" - "in1 in2"; + .option-list { + @apply mb-4 flex flex-col gap-3; } - .target-row select { - @apply w-full rounded border border-border-strong bg-surface px-2 py-1.5 font-ui text-[12.5px] font-medium text-text; - grid-area: select; + .option-row { + @apply flex flex-col items-start gap-1; } - .target-row input.tg-in1 { - grid-area: in1; + /* Indented to line up with the checkbox label text. */ + .option-hint { + @apply m-0 pl-[1.625rem] text-[11.5px] leading-snug text-faint; } - .target-row input.tg-in2 { - grid-area: in2; + .ctl-md { + @apply w-full max-w-64; } - .target-row > .icon-btn { - grid-area: del; - justify-self: end; + .ctl-stack { + @apply mt-2 flex w-full max-w-md flex-col gap-2; + } + + .target-card { + @apply mb-2 flex flex-col gap-2.5 rounded-lg border border-border bg-surface-2 p-3; + } + + .target-card-head { + @apply flex items-center justify-between gap-2; + } + + .target-platform { + @apply w-44 max-w-full; + } + + .target-field { + @apply grid items-center gap-x-3 gap-y-1; + grid-template-columns: 7rem minmax(0, 28rem); + } + + .target-field > label { + @apply text-xs font-semibold text-muted; + } + + @media (max-width: 640px) { + .target-field { + grid-template-columns: minmax(0, 1fr); + } } .add-filter { @@ -698,91 +753,404 @@ } .forge-source-row { - @apply mb-2 grid items-center gap-2 rounded-sm border border-border bg-surface-2 p-2.5; + @apply mb-2 grid items-center gap-2 rounded-lg border border-border bg-surface-2 p-2.5; grid-template-areas: "host type del" "name name name"; - grid-template-columns: 1fr auto auto; + grid-template-columns: minmax(0, 1fr) 8rem auto; } .forge-source-row .f-host { grid-area: host; } - .forge-source-row .select.forge-type { + .forge-source-row .f-type { grid-area: type; - @apply w-[110px]; + } + + .forge-source-row .f-del { + grid-area: del; } .forge-source-row .f-name { grid-area: name; } - .forge-source-row > .icon-btn { - grid-area: del; - justify-self: end; + /* ---- Filter combobox (FilterCombobox.vue; its popover is portaled, so not scoped) ---- */ + .filter-combo { + position: relative; + width: 100%; + min-width: 0; + } + .filter-combo-anchor { + display: flex; + min-height: 2.25rem; + width: 100%; + align-items: center; + gap: 0.25rem; + border-radius: 0.5rem; + background: rgb(var(--wh-surface)); + padding: 0 0.375rem 0 0.75rem; + box-shadow: + inset 0 0 0 1px rgb(var(--wh-border-strong)), + 0 1px 2px rgb(0 0 0 / 0.05); + cursor: text; + transition: box-shadow 150ms ease; + } + .filter-combo-anchor:focus-within { + box-shadow: inset 0 0 0 2px rgb(var(--wh-accent)); + } + .filter-combo-anchor.is-invalid { + box-shadow: inset 0 0 0 1px rgb(var(--wh-bad)); + } + .filter-combo-anchor.is-invalid:focus-within { + box-shadow: inset 0 0 0 2px rgb(var(--wh-bad)); + } + .filter-combo-anchor.is-multi { + flex-wrap: wrap; + padding: 0.25rem 0.375rem 0.25rem 0.375rem; + } + .filter-combo-chip { + display: inline-flex; + max-width: 100%; + align-items: center; + gap: 0.25rem; + border-radius: 0.375rem; + background: rgb(var(--wh-accent-dim)); + padding: 0.125rem 0.25rem 0.125rem 0.5rem; + color: rgb(var(--wh-accent-text)); + font-family: var(--font-mono); + font-size: 0.72rem; + font-weight: 500; + line-height: 1.25rem; + } + .filter-combo-chip.is-invalid { + background: rgb(var(--wh-bad-dim)); + color: rgb(var(--wh-bad)); + text-decoration: line-through; + text-decoration-color: rgb(var(--wh-bad) / 0.6); + } + .filter-combo-chip.is-invalid .filter-combo-chip-x { + color: rgb(var(--wh-bad)); + } + .filter-combo-chip-text { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + .filter-combo-chip-x { + display: grid; + flex: none; + width: 1.125rem; + height: 1.125rem; + place-items: center; + border-radius: 9999px; + color: rgb(var(--wh-accent)); + cursor: pointer; + } + .filter-combo-chip-x:hover { + background: rgb(var(--wh-accent) / 0.15); + } + .filter-combo-chip-x:focus-visible { + outline: 2px solid rgb(var(--wh-accent)); + outline-offset: 1px; + } + .filter-combo-input { + min-width: 4rem; + flex: 1 1 4rem; + border: 0; + background: transparent; + padding: 0.375rem 0; + color: rgb(var(--wh-text)); + font-size: 0.8125rem; + outline: none; + } + .filter-combo-anchor.is-multi .filter-combo-input { + padding-left: 0.375rem; + } + .filter-combo-input.is-mono { + font-family: var(--font-mono); + font-size: 0.78rem; + } + .filter-combo-input::placeholder { + color: rgb(var(--wh-faint)); + } + .filter-combo-trigger { + display: grid; + flex: none; + width: 1.5rem; + height: 1.5rem; + place-items: center; + border-radius: 0.375rem; + color: rgb(var(--wh-faint)); + } + .filter-combo-trigger:hover { + color: rgb(var(--wh-text)); + } + .filter-combo-error { + margin: 0.3rem 0 0; + color: rgb(var(--wh-bad)); + font-size: 0.72rem; + } + .filter-combo-pending { + margin: 0.3rem 0 0; + color: rgb(var(--wh-warn)); + font-size: 0.72rem; + } + .filter-combo-content { + z-index: 55; + width: max(var(--reka-combobox-trigger-width), 17rem); + max-width: calc(100vw - 1rem); + overflow: hidden; + border-radius: 0.5rem; + background: rgb(var(--wh-surface)); + box-shadow: + inset 0 0 0 1px rgb(var(--wh-border)), + 0 4px 6px -1px rgb(0 0 0 / 0.1), + 0 2px 4px -2px rgb(0 0 0 / 0.1); + color: rgb(var(--wh-text)); + } + .filter-combo-content[data-state="open"] { + animation: filter-combo-in 120ms ease-out; + } + @keyframes filter-combo-in { + from { + opacity: 0; + transform: translateY(-2px); + } + } + .filter-combo-viewport { + max-height: min(18rem, var(--reka-combobox-content-available-height, 18rem)); + overflow-y: auto; + padding: 0.25rem; + overscroll-behavior: contain; + } + .filter-combo-group { + padding: 0.5rem 0.625rem 0.25rem; + color: rgb(var(--wh-faint)); + font-size: 0.65rem; + font-weight: 700; + letter-spacing: 0.08em; + text-transform: uppercase; + } + .filter-combo-item { + position: relative; + display: flex; + min-height: 2rem; + align-items: center; + gap: 0.75rem; + border-radius: 0.375rem; + padding: 0.375rem 2rem 0.375rem 0.625rem; + font-size: 0.8125rem; + outline: none; + cursor: pointer; + user-select: none; + } + .filter-combo-item[data-highlighted] { + background: rgb(var(--wh-surface-3)); + } + .filter-combo-item-value { + flex: none; + font-family: var(--font-mono); + font-size: 0.78rem; + } + .filter-combo-item-hint { + min-width: 0; + flex: 1 1 auto; + overflow: hidden; + color: rgb(var(--wh-muted)); + font-size: 0.75rem; + text-align: right; + text-overflow: ellipsis; + white-space: nowrap; + } + .filter-combo-item-check { + position: absolute; + right: 0.5rem; + display: grid; + place-items: center; + color: rgb(var(--wh-accent)); + } + .filter-combo-item.is-create { + color: rgb(var(--wh-accent)); + font-weight: 600; + } + .filter-combo-item-create { + min-width: 0; + overflow-wrap: anywhere; + } + .filter-combo-note { + margin: 0; + padding: 0.75rem 0.625rem; + color: rgb(var(--wh-faint)); + font-size: 0.75rem; + text-align: center; + } + .filter-combo-note.is-error { + color: rgb(var(--wh-bad)); + text-align: left; + } + @media (pointer: coarse) { + .filter-combo-item { + min-height: 2.5rem; + } + } + @media (prefers-reduced-motion: reduce) { + .filter-combo-content[data-state="open"] { + animation: none; + } } + /* ---- Filter tree editor ---- */ .node-editor { - @apply mb-1; + container-type: inline-size; } .node-nested { - @apply ml-4 border-l border-border pl-3; + @apply ml-3 border-l border-border pl-2.5; } + @container (max-width: 26rem) { + .node-nested { + @apply ml-1 pl-1.5; + } + } + + /* + * A condition: type · path · operator on one line with the NOT toggle and + * delete pinned top-right, values below. Narrow containers stack the fields + * under the type. Field filters add a path, keyword filters have no + * operator, and `exists` has no values. + */ .leaf-row { - @apply mb-1.5 flex flex-wrap items-center gap-2 rounded-sm border border-border bg-surface-2 p-2.5; + @apply grid items-start gap-2 rounded-lg border border-border bg-surface p-2.5; + grid-template-columns: minmax(0, 1fr) auto; + grid-template-areas: + "type actions" + "op op" + "values values"; } - .node-select { - @apply w-[120px] shrink-0 rounded border border-border-strong bg-surface px-2 py-1.5 font-ui text-[12.5px] font-medium text-text; + .leaf-row.is-field { + grid-template-areas: + "type actions" + "path path" + "op op" + "values values"; } - .node-path { - @apply w-[160px] shrink-0; + .leaf-row.is-keyword { + grid-template-areas: + "type actions" + "values values"; } - .node-values { - @apply min-w-[180px] flex-1; + .leaf-row.no-values { + grid-template-areas: + "type actions" + "op op"; } - .node-exclude { - @apply flex shrink-0 cursor-pointer items-center gap-1.5 text-[12px] font-medium text-muted; + .leaf-row.is-field.no-values { + grid-template-areas: + "type actions" + "path path" + "op op"; + } + + @container (min-width: 34rem) { + .leaf-row { + grid-template-columns: 9.5rem 9.5rem minmax(0, 1fr) auto; + grid-template-areas: + "type op . actions" + "values values values values"; + } + + .leaf-row.is-field { + grid-template-columns: 9.5rem minmax(0, 1fr) 9.5rem auto; + grid-template-areas: + "type path op actions" + "values values values values"; + } + + .leaf-row.is-keyword { + grid-template-columns: 9.5rem minmax(0, 1fr) auto; + grid-template-areas: + "type . actions" + "values values values"; + } + + .leaf-row.no-values { + grid-template-areas: "type op . actions"; + } + + .leaf-row.is-field.no-values { + grid-template-areas: "type path op actions"; + } + } + + .leaf-row.is-negated { + @apply border-bad/40; + } + + .leaf-type { + @apply min-w-0; + grid-area: type; + } + + .leaf-path { + @apply min-w-0; + grid-area: path; + } + + .leaf-op { + @apply min-w-0; + grid-area: op; + } + + .leaf-values { + @apply min-w-0; + grid-area: values; + } + + .leaf-actions { + @apply flex items-center gap-1 justify-self-end; + grid-area: actions; } .node-group { - @apply mb-1.5 rounded-sm border border-border bg-surface-2 p-2.5; + @apply flex flex-col gap-2 rounded-lg border border-border bg-surface-2 p-2.5; } .node-group-head { - @apply mb-2 flex flex-wrap items-center gap-2; + @apply flex flex-wrap items-center gap-2; } - .node-combo { - @apply w-[130px] rounded border border-border-strong bg-surface px-2 py-1.5 font-ui text-[12.5px] font-semibold text-text; + .node-kind > * { + @apply whitespace-nowrap; } - .node-combo-label { - @apply inline-flex items-center rounded border border-border-strong bg-surface px-2 py-1.5 font-ui text-[12.5px] font-semibold text-text; - } - - .node-actions { - @apply ml-auto flex flex-wrap items-center gap-1.5; - } - - .node-add { - @apply px-2 py-1 text-[12px]; + .node-not-label { + @apply inline-flex items-center rounded-md bg-bad-dim px-2.5 py-1 text-xs font-semibold text-bad; } .node-children { - @apply flex flex-col gap-1.5; + @apply flex flex-col gap-2; } .node-empty { @apply py-1 text-[12px] italic text-muted; } + .node-add { + @apply flex flex-wrap items-center gap-1; + } + + .test-event { + @apply max-w-sm; + } + .test-payload { @apply font-mono text-[12px]; } @@ -816,7 +1184,7 @@ } .fragment-row { - @apply flex items-center gap-2 rounded-sm border border-border bg-surface-2 p-2; + @apply flex items-center gap-2 rounded-lg border border-border bg-surface-2 py-1.5 pl-3 pr-1.5; } .fragment-name { @@ -828,7 +1196,11 @@ } .fragment-save { - @apply flex items-center gap-2; + @apply flex max-w-lg items-center gap-2; + } + + .fragment-save-input { + @apply min-w-0 flex-1; } .log-block { @@ -908,11 +1280,12 @@ } .log-filters { - @apply flex items-center gap-1.5; + @apply flex min-w-0 items-center gap-1.5; } + /* Never squeezed into a column of single characters on narrow screens. */ .filter-label { - @apply text-[11px] font-bold uppercase tracking-wider text-muted; + @apply shrink-0 whitespace-nowrap text-[11px] font-bold uppercase tracking-wider text-muted; } .filter-select { @@ -967,6 +1340,11 @@ @apply mr-1 font-semibold tracking-wider text-faint; } + /* Long ids (channel/thread, repo) wrap instead of widening the page. */ + .log-meta span { + @apply min-w-0 [overflow-wrap:anywhere]; + } + .log-meta code { @apply rounded-[5px] bg-surface-2 px-1.5 py-px font-mono text-text; } @@ -1029,8 +1407,9 @@ } /* ---- Members / invites ---- */ + /* RcCard (padding="md") already pads the body; no second padding here. */ .members-panel { - @apply mt-7 rounded border border-border bg-surface p-5; + @apply mt-7 rounded border border-border bg-surface; } .panel-head { @@ -1045,17 +1424,31 @@ @apply my-3.5 mb-2 text-xs; } - .member-list { - @apply m-0 mb-3 flex list-none flex-col gap-2 p-0; + /* Members flow as compact cards: name, role and remove on one line. */ + .member-grid { + @apply m-0 mb-3.5 grid list-none gap-2.5 p-0; + grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); + } + + .member-card { + @apply grid items-center gap-2 rounded-lg border border-border bg-surface-2 py-1.5 pl-3.5 pr-1.5; + grid-template-columns: minmax(0, 1fr) auto auto; + } + + .member-name { + @apply truncate text-[15px] font-semibold tracking-tight text-text; + } + + .member-role { + @apply flex w-32 shrink-0 justify-end; } - .member-row, .invite-row { - @apply flex flex-wrap items-center gap-2.5 rounded-sm border border-border bg-surface-2 px-3 py-2; + @apply flex flex-wrap items-center gap-x-2.5 gap-y-1.5 rounded-lg border border-border bg-surface-2 py-1.5 pl-3 pr-1.5; } - .member-login { - @apply min-w-[120px] flex-1 text-[13px] font-semibold; + .invite-actions { + @apply ml-auto flex items-center gap-1; } .role-pill { @@ -1079,12 +1472,9 @@ @apply flex flex-wrap items-center gap-2; } - .text-input { - @apply min-w-[200px] rounded border border-border bg-surface px-2.5 py-1.5 text-[13px] text-text outline-none; - } - - .text-input:focus { - @apply border-accent; + .member-add-login { + @apply min-w-0 max-w-xs; + flex: 1 1 14rem; } .invite-box { diff --git a/app/components/AdminHome.vue b/app/components/AdminHome.vue index fc6613d..f1d9d85 100644 --- a/app/components/AdminHome.vue +++ b/app/components/AdminHome.vue @@ -89,7 +89,7 @@ function fmtTime(ts: number): string {

{{ t("overview.recent") }}

- + {{ t("overview.viewAll") }}
diff --git a/app/components/ConfirmDialog.vue b/app/components/ConfirmDialog.vue new file mode 100644 index 0000000..30b97e5 --- /dev/null +++ b/app/components/ConfirmDialog.vue @@ -0,0 +1,156 @@ + + + + + diff --git a/app/components/ConsolePage.vue b/app/components/ConsolePage.vue index a6181eb..1a5d84b 100644 --- a/app/components/ConsolePage.vue +++ b/app/components/ConsolePage.vue @@ -21,17 +21,17 @@
-
+

WebHooker / {{ activeNav }}

-

{{ pageTitle }}

+

{{ pageTitle }}

-
+
{{ t("status.loading") }} - {{ t("metrics.refresh") }} {{ t("app.langToggle") }}{{ t("app.langToggle") }} + {{ t("app.newRoute") }}{{ + t("app.signOut") + }} - {{ t("app.newGroup") }} +
+ {{ t("metrics.refresh") }}
-
+
+
+ + {{ + t("group.allGroups") + }} + +
+ +
+

{{ groupsError }}

+ {{ t("status.loading") }} +
+ @@ -679,7 +1131,9 @@ async function onDeleteGroup(group: Group): Promise { diff --git a/app/components/FilterCombobox.vue b/app/components/FilterCombobox.vue new file mode 100644 index 0000000..5b974f2 --- /dev/null +++ b/app/components/FilterCombobox.vue @@ -0,0 +1,460 @@ + + + diff --git a/app/components/FilterNodeEditor.vue b/app/components/FilterNodeEditor.vue index 4bd8c60..eb2e601 100644 --- a/app/components/FilterNodeEditor.vue +++ b/app/components/FilterNodeEditor.vue @@ -1,7 +1,16 @@