feat(intelligence): add threat assessment dossier table to mission details
New Intelligence tab on the Missions collection holds a threatAssessment.likelihoods array (category + 5-level likelihood select). Renders a color-coded, dossier-styled table on the mission details page, ordered after Mission Details and above the briefing. Rows match the free-text category to a lucide glyph (helicopter, plane, armor, infantry, etc.) so the estimate scans at a glance.
This commit is contained in:
parent
db98adbcee
commit
32365e6612
7 changed files with 39194 additions and 1 deletions
|
|
@ -22,6 +22,7 @@ import { MissionObjectives } from "@/components/frontend/intelligence/MissionObj
|
|||
import { hasPermission } from "@/utils/access-control/hasPermission";
|
||||
import { redactText } from "@/lib/redaction";
|
||||
import { MissionFactions } from "@/components/frontend/intelligence/MissionFactions";
|
||||
import { MissionThreatAssessment } from "@/components/frontend/intelligence/MissionThreatAssessment";
|
||||
import { MissionRoles } from "@/components/frontend/intelligence/MissionRoles";
|
||||
import { MissionRoleSignups } from "@/components/frontend/intelligence/MissionRoleSignups";
|
||||
import { MissionLogistics } from "@/components/frontend/intelligence/MissionLogistics";
|
||||
|
|
@ -506,6 +507,11 @@ export default async function MissionDetailPage({ params }: MissionDetailPagePro
|
|||
</ItemContent>
|
||||
</Item>
|
||||
|
||||
<MissionThreatAssessment
|
||||
likelihoods={mission.threatAssessment?.likelihoods ?? null}
|
||||
missionId={mission.id}
|
||||
/>
|
||||
|
||||
<MissionBriefingSection briefing={mission.briefing ?? null} />
|
||||
|
||||
<MissionObjectives
|
||||
|
|
|
|||
|
|
@ -757,6 +757,57 @@ export const Missions: CollectionConfig = {
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Intelligence",
|
||||
description:
|
||||
"Analyst estimates of the threat the unit is likely to face during this operation.",
|
||||
fields: [
|
||||
{
|
||||
name: "threatAssessment",
|
||||
type: "group",
|
||||
label: "Threat Assessment",
|
||||
admin: {
|
||||
description:
|
||||
"Likelihood that the unit will encounter each enemy force type during the mission. Rendered as a color-coded table on the mission page.",
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: "likelihoods",
|
||||
type: "array",
|
||||
labels: { singular: "Likelihood", plural: "Likelihoods" },
|
||||
admin: {
|
||||
description:
|
||||
"One row per enemy force type. Leave empty to hide the table on the mission page.",
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: "category",
|
||||
type: "text",
|
||||
required: true,
|
||||
admin: {
|
||||
description:
|
||||
'Enemy force type, e.g. "Light Infantry", "Armor", "Rotary Air".',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "likelihood",
|
||||
type: "select",
|
||||
required: true,
|
||||
defaultValue: "possible",
|
||||
options: [
|
||||
{ label: "Very Unlikely", value: "veryUnlikely" },
|
||||
{ label: "Unlikely", value: "unlikely" },
|
||||
{ label: "Possible", value: "possible" },
|
||||
{ label: "Likely", value: "likely" },
|
||||
{ label: "Very Likely", value: "veryLikely" },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: "Dedicated Server",
|
||||
description: "Server-specific details, like the IP, port, mission file, mod list, etc.",
|
||||
|
|
|
|||
330
src/components/frontend/intelligence/MissionThreatAssessment.tsx
Normal file
330
src/components/frontend/intelligence/MissionThreatAssessment.tsx
Normal file
|
|
@ -0,0 +1,330 @@
|
|||
import {
|
||||
BiohazardIcon,
|
||||
BinocularsIcon,
|
||||
CastleIcon,
|
||||
FlameIcon,
|
||||
HelicopterIcon,
|
||||
PackageIcon,
|
||||
PlaneIcon,
|
||||
PlaneTakeoffIcon,
|
||||
RadarIcon,
|
||||
RadioIcon,
|
||||
RocketIcon,
|
||||
ShieldIcon,
|
||||
ShipIcon,
|
||||
TruckIcon,
|
||||
UsersIcon,
|
||||
type LucideIcon,
|
||||
} from "lucide-react";
|
||||
|
||||
type Likelihood = "veryUnlikely" | "unlikely" | "possible" | "likely" | "veryLikely";
|
||||
|
||||
interface LikelihoodEntry {
|
||||
category: string;
|
||||
likelihood: Likelihood;
|
||||
id?: string | null;
|
||||
}
|
||||
|
||||
interface MissionThreatAssessmentProps {
|
||||
likelihoods: LikelihoodEntry[] | null;
|
||||
/** Optional mission id, used to derive the deterministic REF code in the strip. */
|
||||
missionId?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tactical dossier readout of the analyst threat estimate. Higher likelihood of
|
||||
* an enemy force type reads as more dangerous, so the ramp runs cool (slate) for
|
||||
* "Very Unlikely" up to red for "Very Likely". The value is always spelled out,
|
||||
* so color is reinforcement only, never the sole signal.
|
||||
*/
|
||||
const likelihoodStyles: Record<
|
||||
Likelihood,
|
||||
{ label: string; className: string; dot: string }
|
||||
> = {
|
||||
veryUnlikely: { label: "Very Unlikely", className: "text-slate-300", dot: "bg-slate-300" },
|
||||
unlikely: { label: "Unlikely", className: "text-sky-400", dot: "bg-sky-400" },
|
||||
possible: { label: "Possible", className: "text-amber-400", dot: "bg-amber-400" },
|
||||
likely: { label: "Likely", className: "text-orange-400", dot: "bg-orange-400" },
|
||||
veryLikely: { label: "Very Likely", className: "text-red-400", dot: "bg-red-400" },
|
||||
};
|
||||
|
||||
/**
|
||||
* Heuristic force-type glyph. Categories are free text, so we match on
|
||||
* substrings in priority order (first hit wins): specific platforms before
|
||||
* generic domains, and air-defense before the bare "defense" catch-all. Unknown
|
||||
* categories simply render without an icon. Keywords are lowercase; matching is
|
||||
* case-insensitive `includes`.
|
||||
*/
|
||||
const CATEGORY_ICON_RULES: { Icon: LucideIcon; keywords: string[] }[] = [
|
||||
{ Icon: HelicopterIcon, keywords: ["heli", "rotary", "rotor", "chopper", "dustoff"] },
|
||||
{
|
||||
Icon: PlaneIcon,
|
||||
keywords: [
|
||||
"plane",
|
||||
"jet",
|
||||
"aircraft",
|
||||
"fighter",
|
||||
"bomber",
|
||||
"fixed-wing",
|
||||
"fixed wing",
|
||||
"air wing",
|
||||
"airwing",
|
||||
"air support",
|
||||
],
|
||||
},
|
||||
{ Icon: PlaneTakeoffIcon, keywords: ["drone", "uav", "quadcopter", "fpv", "mavic", "loitering"] },
|
||||
{
|
||||
Icon: ShieldIcon,
|
||||
keywords: [
|
||||
"air defense",
|
||||
"air defence",
|
||||
"airdefence",
|
||||
"iads",
|
||||
"anti-air",
|
||||
"antiair",
|
||||
"surface-to-air",
|
||||
"sam site",
|
||||
"patriot",
|
||||
"tunguska",
|
||||
"pantsir",
|
||||
"shilka",
|
||||
"tor-m2",
|
||||
"tor m2",
|
||||
],
|
||||
},
|
||||
{
|
||||
Icon: RocketIcon,
|
||||
keywords: [
|
||||
"rocket",
|
||||
"missile",
|
||||
"artillery",
|
||||
"arty",
|
||||
"mortar",
|
||||
"howitzer",
|
||||
"mlrs",
|
||||
"cannon",
|
||||
"gun line",
|
||||
"gunline",
|
||||
"field gun",
|
||||
],
|
||||
},
|
||||
{
|
||||
Icon: ShipIcon,
|
||||
keywords: [
|
||||
"naval",
|
||||
"navy",
|
||||
"ship",
|
||||
"boat",
|
||||
"maritime",
|
||||
"amphibious",
|
||||
"harbor",
|
||||
"harbour",
|
||||
"riverine",
|
||||
"lhd",
|
||||
"srf",
|
||||
],
|
||||
},
|
||||
{
|
||||
Icon: TruckIcon,
|
||||
keywords: [
|
||||
"armor",
|
||||
"armour",
|
||||
"tank",
|
||||
"afv",
|
||||
"apc",
|
||||
"ifv",
|
||||
"mbt",
|
||||
"mech",
|
||||
"technical",
|
||||
"gun truck",
|
||||
"mrap",
|
||||
],
|
||||
},
|
||||
{
|
||||
Icon: UsersIcon,
|
||||
keywords: [
|
||||
"infantry",
|
||||
"rifle",
|
||||
"foot",
|
||||
"dismount",
|
||||
"soldier",
|
||||
"troop",
|
||||
"grunt",
|
||||
"para",
|
||||
"ranger",
|
||||
"commando",
|
||||
"squad",
|
||||
"insurgent",
|
||||
],
|
||||
},
|
||||
{
|
||||
Icon: CastleIcon,
|
||||
keywords: [
|
||||
"static",
|
||||
"fortif",
|
||||
"bunker",
|
||||
"defense",
|
||||
"defence",
|
||||
"outpost",
|
||||
"emplacement",
|
||||
"objective",
|
||||
"obstacle",
|
||||
"minefield",
|
||||
"landmine",
|
||||
"ied",
|
||||
"ambush",
|
||||
],
|
||||
},
|
||||
{
|
||||
Icon: BinocularsIcon,
|
||||
keywords: [
|
||||
"recon",
|
||||
"scout",
|
||||
"surveil",
|
||||
"observation",
|
||||
"spotter",
|
||||
"sniper",
|
||||
"designator",
|
||||
"jtac",
|
||||
"marc",
|
||||
],
|
||||
},
|
||||
{
|
||||
Icon: RadarIcon,
|
||||
keywords: ["radar", "sensor", "counter-battery", "counter battery", "sigint", "c4isr", "c4i"],
|
||||
},
|
||||
{
|
||||
Icon: RadioIcon,
|
||||
keywords: ["comms", "communication", "radio", "electronic", "jammer", "ecm", "signal", "network"],
|
||||
},
|
||||
{
|
||||
Icon: PackageIcon,
|
||||
keywords: [
|
||||
"logistic",
|
||||
"supply",
|
||||
"resupply",
|
||||
"convoy",
|
||||
"fuel",
|
||||
"ammo",
|
||||
"ammunition",
|
||||
"transport",
|
||||
"cargo",
|
||||
"truck",
|
||||
],
|
||||
},
|
||||
{ Icon: FlameIcon, keywords: ["flame", "incendiary", "thermite", "phosphorus"] },
|
||||
{
|
||||
Icon: BiohazardIcon,
|
||||
keywords: ["chemical", "biochem", "cbrn", "nbc", "radiolog", "toxic", "nerve agent", "mustard"],
|
||||
},
|
||||
];
|
||||
|
||||
function resolveCategoryIcon(category: string): LucideIcon | null {
|
||||
const value = category.toLowerCase();
|
||||
for (const rule of CATEGORY_ICON_RULES) {
|
||||
if (rule.keywords.some((keyword) => value.includes(keyword))) {
|
||||
return rule.Icon;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function MissionThreatAssessment({
|
||||
likelihoods,
|
||||
missionId,
|
||||
}: MissionThreatAssessmentProps) {
|
||||
if (!likelihoods || likelihoods.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const refCode = missionId != null ? String(missionId).padStart(3, "0") : null;
|
||||
|
||||
return (
|
||||
<section
|
||||
aria-label="Threat Assessment"
|
||||
className="relative overflow-hidden rounded-none border border-border/70 bg-card"
|
||||
>
|
||||
{/* Faint grid texture: constant opacity, never brightens. */}
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className="pointer-events-none absolute inset-0 z-[1] opacity-[0.04]"
|
||||
style={{
|
||||
backgroundImage:
|
||||
"linear-gradient(to right, white 1px, transparent 1px), linear-gradient(to bottom, white 1px, transparent 1px)",
|
||||
backgroundSize: "28px 28px",
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Corner brackets. */}
|
||||
<div aria-hidden="true" className="pointer-events-none absolute inset-2 z-30">
|
||||
<span className="absolute left-0 top-0 size-3 border-l border-t border-white/25" />
|
||||
<span className="absolute right-0 top-0 size-3 border-r border-t border-white/25" />
|
||||
<span className="absolute bottom-0 left-0 size-3 border-b border-l border-white/25" />
|
||||
<span className="absolute bottom-0 right-0 size-3 border-b border-r border-white/25" />
|
||||
</div>
|
||||
|
||||
{/* Classification strip. */}
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className="relative z-20 flex items-center justify-between border-b border-white/15 bg-black/50 px-5 py-1.5 backdrop-blur-sm"
|
||||
>
|
||||
<span className="flex items-center gap-1.5 font-mono text-[9px] uppercase tracking-widest text-white/60">
|
||||
<RadarIcon className="size-3" />
|
||||
Threat Assessment // Intel
|
||||
</span>
|
||||
{refCode && (
|
||||
<span className="font-mono text-[9px] uppercase tracking-widest text-white/60">
|
||||
REF {refCode}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Likelihood rows. */}
|
||||
<table className="relative z-10 w-full border-collapse text-sm">
|
||||
<caption className="sr-only">
|
||||
Likelihood of encountering each enemy force type during this operation.
|
||||
</caption>
|
||||
<thead>
|
||||
<tr className="border-b border-white/15">
|
||||
<th
|
||||
scope="col"
|
||||
className="px-5 pb-2 pt-3 text-left font-mono text-[9px] font-medium uppercase tracking-widest text-white/40"
|
||||
>
|
||||
Force Type
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="px-5 pb-2 pt-3 text-right font-mono text-[9px] font-medium uppercase tracking-widest text-white/40"
|
||||
>
|
||||
Likelihood
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-white/10">
|
||||
{likelihoods.map((entry, index) => {
|
||||
const style = likelihoodStyles[entry.likelihood] ?? likelihoodStyles.possible;
|
||||
const Icon = resolveCategoryIcon(entry.category);
|
||||
return (
|
||||
<tr key={entry.id ?? `${entry.category}-${index}`}>
|
||||
<th scope="row" className="px-5 py-2.5 text-left align-middle">
|
||||
<span className="flex items-center gap-2 font-mono text-xs font-medium uppercase tracking-wider text-white/70">
|
||||
{Icon && <Icon aria-hidden="true" className="size-3.5 shrink-0 text-white/40" />}
|
||||
<span>{entry.category}</span>
|
||||
</span>
|
||||
</th>
|
||||
<td className="px-5 py-2.5 text-right align-middle">
|
||||
<span
|
||||
className={`inline-flex items-center justify-end gap-2 whitespace-nowrap font-mono text-xs font-semibold uppercase tracking-wider ${style.className}`}
|
||||
>
|
||||
<span aria-hidden="true" className={`size-1.5 shrink-0 ${style.dot}`} />
|
||||
{style.label}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
38748
src/migrations/20261010_050644_add_mission_threat_assessment.json
Normal file
38748
src/migrations/20261010_050644_add_mission_threat_assessment.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,23 @@
|
|||
import { MigrateUpArgs, MigrateDownArgs, sql } from '@payloadcms/db-postgres'
|
||||
|
||||
export async function up({ db, payload, req }: MigrateUpArgs): Promise<void> {
|
||||
await db.execute(sql`
|
||||
CREATE TYPE "public"."enum_missions_threat_assessment_likelihoods_likelihood" AS ENUM('veryUnlikely', 'unlikely', 'possible', 'likely', 'veryLikely');
|
||||
CREATE TABLE "missions_threat_assessment_likelihoods" (
|
||||
"_order" integer NOT NULL,
|
||||
"_parent_id" integer NOT NULL,
|
||||
"id" varchar PRIMARY KEY NOT NULL,
|
||||
"category" varchar NOT NULL,
|
||||
"likelihood" "enum_missions_threat_assessment_likelihoods_likelihood" DEFAULT 'possible' NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE "missions_threat_assessment_likelihoods" ADD CONSTRAINT "missions_threat_assessment_likelihoods_parent_id_fk" FOREIGN KEY ("_parent_id") REFERENCES "public"."missions"("id") ON DELETE cascade ON UPDATE no action;
|
||||
CREATE INDEX "missions_threat_assessment_likelihoods_order_idx" ON "missions_threat_assessment_likelihoods" USING btree ("_order");
|
||||
CREATE INDEX "missions_threat_assessment_likelihoods_parent_id_idx" ON "missions_threat_assessment_likelihoods" USING btree ("_parent_id");`)
|
||||
}
|
||||
|
||||
export async function down({ db, payload, req }: MigrateDownArgs): Promise<void> {
|
||||
await db.execute(sql`
|
||||
DROP TABLE "missions_threat_assessment_likelihoods" CASCADE;
|
||||
DROP TYPE "public"."enum_missions_threat_assessment_likelihoods_likelihood";`)
|
||||
}
|
||||
|
|
@ -119,6 +119,7 @@ import * as migration_20261007_183000_add_missing_mcp_key_capabilities from './2
|
|||
import * as migration_20261009_160740_add_campaign_on_hold_status from './20261009_160740_add_campaign_on_hold_status';
|
||||
import * as migration_20261009_185259_add_wiki_featured_curation from './20261009_185259_add_wiki_featured_curation';
|
||||
import * as migration_20261009_201920_add_contribution_entries from './20261009_201920_add_contribution_entries';
|
||||
import * as migration_20261010_050644_add_mission_threat_assessment from './20261010_050644_add_mission_threat_assessment';
|
||||
|
||||
export const migrations = [
|
||||
{
|
||||
|
|
@ -724,6 +725,11 @@ export const migrations = [
|
|||
{
|
||||
up: migration_20261009_201920_add_contribution_entries.up,
|
||||
down: migration_20261009_201920_add_contribution_entries.down,
|
||||
name: '20261009_201920_add_contribution_entries'
|
||||
name: '20261009_201920_add_contribution_entries',
|
||||
},
|
||||
{
|
||||
up: migration_20261010_050644_add_mission_threat_assessment.up,
|
||||
down: migration_20261010_050644_add_mission_threat_assessment.down,
|
||||
name: '20261010_050644_add_mission_threat_assessment'
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -3784,6 +3784,24 @@ export interface Mission {
|
|||
id?: string | null;
|
||||
}[]
|
||||
| null;
|
||||
/**
|
||||
* Likelihood that the unit will encounter each enemy force type during the mission. Rendered as a color-coded table on the mission page.
|
||||
*/
|
||||
threatAssessment?: {
|
||||
/**
|
||||
* One row per enemy force type. Leave empty to hide the table on the mission page.
|
||||
*/
|
||||
likelihoods?:
|
||||
| {
|
||||
/**
|
||||
* Enemy force type, e.g. "Light Infantry", "Armor", "Rotary Air".
|
||||
*/
|
||||
category: string;
|
||||
likelihood: 'veryUnlikely' | 'unlikely' | 'possible' | 'likely' | 'veryLikely';
|
||||
id?: string | null;
|
||||
}[]
|
||||
| null;
|
||||
};
|
||||
gameDetails: {
|
||||
serverDetails: {
|
||||
serverIp: string;
|
||||
|
|
@ -8994,6 +9012,17 @@ export interface MissionsSelect<T extends boolean = true> {
|
|||
threatLevel?: T;
|
||||
id?: T;
|
||||
};
|
||||
threatAssessment?:
|
||||
| T
|
||||
| {
|
||||
likelihoods?:
|
||||
| T
|
||||
| {
|
||||
category?: T;
|
||||
likelihood?: T;
|
||||
id?: T;
|
||||
};
|
||||
};
|
||||
gameDetails?:
|
||||
| T
|
||||
| {
|
||||
|
|
|
|||
Loading…
Reference in a new issue