Skip to content

Commit 235d8fd

Browse files
authored
Remove dead policies code (#7783)
# Description of Changes In #7681, we redefined what Policies were and merged the Policies page into the Pipelines page. This left over a lot of now dead/redundant Policies code which should be removed because the Pipelines code already covers it all. This PR does not remove _all_ of the Policies code because some of it is still being used in the UI now, but as in-editor pipelines and as pipeline templates. That code needs to be renamed to get it to the correct naming, but this PR is big enough as it is to just delete all the dead code, so that'll come in another PR.
1 parent 83dd31e commit 235d8fd

48 files changed

Lines changed: 152 additions & 2636 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

frontend/editor/public/locales/en-US/translation.toml

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6996,45 +6996,6 @@ dismiss = "Dismiss overlay"
69966996
enforcingTitle = "Enforcing policy..."
69976997
viewAnyway = "View file (policy still enforcing)"
69986998

6999-
[policyOption]
7000-
autoRedactPhi = "Auto-redact PHI"
7001-
blockExport = "Block export"
7002-
ccpa = "CCPA"
7003-
contracts = "Contracts"
7004-
documents = "Documents"
7005-
fedramp = "FedRAMP"
7006-
financialReports = "Financial reports"
7007-
flagForReview = "Flag for review"
7008-
gdpr = "GDPR"
7009-
hipaa = "HIPAA"
7010-
hold = "Hold"
7011-
hrRecords = "HR records"
7012-
indefinite = "Indefinite"
7013-
insurance = "Insurance"
7014-
invoices = "Invoices"
7015-
iso27001 = "ISO 27001"
7016-
legalFilings = "Legal filings"
7017-
medicalPhi = "Medical / PHI"
7018-
never = "Never"
7019-
ninetyDays = "90 days"
7020-
oneYear = "1 year"
7021-
p60 = "60%"
7022-
p70 = "70%"
7023-
p80 = "80%"
7024-
p90 = "90%"
7025-
p95 = "95%"
7026-
pciDss = "PCI DSS"
7027-
quarantineDocument = "Quarantine document"
7028-
routeToBucket = "Route to bucket"
7029-
s3Bucket = "S3 bucket"
7030-
sevenYears = "7 years"
7031-
sharePoint = "SharePoint"
7032-
soc2 = "SOC 2"
7033-
taxDocuments = "Tax documents"
7034-
thirtyDays = "30 days"
7035-
threeYears = "3 years"
7036-
webhook = "Webhook"
7037-
70386999
[portal]
70397000
comingSoon = "Coming soon"
70407001

@@ -8663,7 +8624,6 @@ defaultName = "{{category}} Pipeline"
86638624

86648625
[portal.policies.card]
86658626
comingSoon = "Upgrade to Enterprise"
8666-
notSetUp = "Not set up"
86678627
requiresAiEngine = "Requires AI engine"
86688628

86698629
[portal.policies.categories.classification]
@@ -8791,7 +8751,6 @@ onEveryUpload = "On every upload"
87918751
outputAsNewFile = "as a new file"
87928752
outputAsNewVersion = "as a new version"
87938753
recentActivity = "Recent activity"
8794-
retry = "Retry"
87958754
showLess = "Show less"
87968755
showMore = "Show more"
87978756
sources = "Sources"
@@ -8802,7 +8761,6 @@ delete = "Delete"
88028761
editSettings = "Edit settings"
88038762
pause = "Pause"
88048763
resume = "Resume"
8805-
runNow = "Run now"
88068764

88078765
[portal.policies.detail.clearHistory]
88088766
body = "This pipeline will forget every file it has already processed and reprocess everything currently in its sources on the next run. The files themselves are not changed. This cannot be undone."
@@ -9027,29 +8985,6 @@ docsEnforced = "Docs processed"
90278985
active = "Active"
90288986
paused = "Paused"
90298987

9030-
[portal.policies.summary.active]
9031-
description = "Enforcing on upload/export"
9032-
label = "Active policies"
9033-
9034-
[portal.policies.summary.categories]
9035-
description = "Available to configure"
9036-
label = "Categories"
9037-
9038-
[portal.policies.summary.docsEnforced]
9039-
description = "Across active policies"
9040-
label = "Docs enforced"
9041-
9042-
[portal.policies.summary.paused]
9043-
description = "Configured but not firing"
9044-
label = "Paused"
9045-
9046-
[portal.policies.table]
9047-
appliesTo = "Applies to"
9048-
docs = "Docs enforced"
9049-
enforces = "Enforces"
9050-
policy = "Policy"
9051-
status = "Status"
9052-
90538988
[portal.policies.wizard.actions]
90548989
cancel = "Cancel"
90558990
customise = "Customise"
@@ -9103,9 +9038,6 @@ setUp = "Set up {{category}} pipeline"
91039038
[portal.policies.wizard.workflow]
91049039
description = "Choose what this pipeline does to every document it processes."
91059040

9106-
[portal.policySummary.action]
9107-
setUp = "Set up"
9108-
91099041
[portal.processorFlow]
91109042
footnote = "Counts are over the last 24 hours. Flow speed is illustrative."
91119043
liveBadge = "Live"

frontend/editor/src/core/i18n/translationAudit.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,6 @@ export const I18N_PROJECTS: TranslationProject[] = [
109109
// "portal.policies.operations" - the shape heuristic treats that interpolation as one
110110
// segment, so this whole catalogue-driven family is matched here instead.
111111
/^portal\.policies\.operations\./,
112-
// Policy field labels + option display copy are looked up with keys
113-
// derived from catalogue data (t(`policies.field.${key}`),
114-
// t(`policyOption.${id}`)) in the PolicyFieldRows and setup wizards —
115-
// invisible to the static scan. The raw catalogue value is the fallback.
116-
/^policies\.field\./,
117-
/^policyOption\./,
118112
// A failure's disabled reason arrives from the server as a key and is rendered with
119113
// t(thatKey), so nothing in source names it, but the copy still has to exist.
120114
/^portal\.failures\.disabled\./,

frontend/editor/src/core/ui/Modal.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { useEffect, useId, type ReactNode } from "react";
1+
import { useEffect, useId, useRef, type ReactNode } from "react";
22
import { createPortal } from "react-dom";
33
import { FocusTrap } from "@mantine/core";
44
import { Button } from "@app/ui/Button";
5+
import { useIsOverflowing } from "@app/hooks/useIsOverflowing";
56
import "@app/ui/Modal.css";
67

78
export type ModalWidth = "sm" | "md" | "lg" | "xl";
@@ -43,6 +44,11 @@ export function Modal({
4344
children,
4445
}: ModalProps) {
4546
const titleId = useId();
47+
const bodyRef = useRef<HTMLDivElement>(null);
48+
// A body that overflows must be reachable by keyboard to scroll; only its non-focusable
49+
// content (header close + footer live outside it). tabindex lands only when it scrolls, so
50+
// fitting modals gain no stray tab stop (axe scrollable-region-focusable).
51+
const bodyScrolls = useIsOverflowing(bodyRef);
4652

4753
useEffect(() => {
4854
if (!open || disableEscapeClose) return;
@@ -152,7 +158,13 @@ export function Modal({
152158
/>
153159
</header>
154160
)}
155-
<div className="sui-modal__body">{children}</div>
161+
<div
162+
ref={bodyRef}
163+
className="sui-modal__body"
164+
tabIndex={bodyScrolls ? 0 : undefined}
165+
>
166+
{children}
167+
</div>
156168
{footer && <footer className="sui-modal__footer">{footer}</footer>}
157169
</div>
158170
</FocusTrap>

frontend/editor/src/portal/api/pipelines.ts

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import {
33
type SupportingFileBindings,
44
type ToolApiStep,
55
} from "@app/hooks/tools/shared/toolAutomation";
6+
import type {
7+
PolicyRunView,
8+
PolicyRunStatus,
9+
RunOutputFile,
10+
} from "@app/policies/types";
611

712
/**
813
* Pipelines service layer: the backend contract.
@@ -132,37 +137,10 @@ export interface TriggerInfo {
132137
supportedSourceTypes: string[];
133138
}
134139

135-
export type PolicyRunStatus =
136-
| "PENDING"
137-
| "RUNNING"
138-
| "WAITING_FOR_INPUT"
139-
| "COMPLETED"
140-
| "FAILED"
141-
| "CANCELLED";
142-
143-
/** One file a run produced, downloadable via /api/v1/general/files/{fileId}. */
144-
export interface RunOutputFile {
145-
fileId: string;
146-
fileName: string | null;
147-
}
148-
149-
/** A run's current state. Mirrors the backend `PolicyRunView`. */
150-
export interface PolicyRunView {
151-
runId: string;
152-
policyId: string | null;
153-
status: PolicyRunStatus;
154-
currentStep: number;
155-
stepCount: number;
156-
/** Human-readable failure message; set when status is FAILED. */
157-
error: string | null;
158-
errorCode: string | null;
159-
/**
160-
* Files the run produced, present once it completes. Whole-run, not per step: the backend keeps
161-
* one flat list, so nothing here can be attributed to an individual step.
162-
*/
163-
outputs?: RunOutputFile[] | null;
164-
createdAt: number;
165-
}
140+
// One run view for the whole app: the builder test-run poll and the catalogue runs list read the
141+
// same backend PolicyRunView, so the type is defined once in the codec (imported above) and
142+
// re-exported here for callers that reach it through the pipelines API.
143+
export type { PolicyRunView, PolicyRunStatus, RunOutputFile };
166144

167145
/** GET /api/v1/policies/overview: KPI strip + one row per policy for the admin. */
168146
export async function fetchPipelines(): Promise<PipelinesOverviewResponse> {

frontend/editor/src/portal/api/policies.ts

Lines changed: 4 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,7 @@ import type {
2929
WirePolicy,
3030
} from "@app/policies/types";
3131

32-
export type {
33-
PolicyActivityItem,
34-
PolicyDecodedState,
35-
PolicyRunView,
36-
PolicyStats,
37-
WireOutputOptions,
38-
WireOutputSpec,
39-
WirePolicy,
40-
} from "@app/policies/types";
32+
export type { PolicyRunView, WirePolicy } from "@app/policies/types";
4133

4234
// Re-export the wire step type under the legacy name components depend on.
4335
export type { WirePipelineStep as PipelineStep } from "@app/policies/types";
@@ -46,9 +38,7 @@ export type { WirePipelineStep as PipelineStep } from "@app/policies/types";
4638
/* Catalogue model — portal-specific */
4739
/* ──────────────────────────────────────────────────────────────────────── */
4840

49-
export type PolicyStatus = "active" | "paused";
50-
51-
export type PolicyRowStatus = "active" | "paused" | "setup";
41+
type PolicyStatus = "active" | "paused";
5242

5343
export type PolicyFieldType = "toggle" | "select" | "chips" | "text";
5444

@@ -130,15 +120,7 @@ export interface DecoratedPolicy {
130120
activity: import("@app/policies/types").PolicyActivityItem[];
131121
}
132122

133-
export interface PoliciesSummary {
134-
active: number;
135-
paused: number;
136-
categories: number;
137-
docsEnforced: number;
138-
}
139-
140123
export interface PoliciesResponse {
141-
summary: PoliciesSummary;
142124
catalogue: CatalogueEntry[];
143125
}
144126

@@ -156,7 +138,7 @@ export interface CatalogueEntry {
156138
* i18n keys keyed by endpoint; labels stored steps in the detail view. Mostly
157139
* {@link ToolEndpoint}s, plus the AI classify endpoint, which isn't part of the generated union.
158140
*/
159-
export const ENDPOINT_LABELS: Partial<
141+
const ENDPOINT_LABELS: Partial<
160142
Record<ToolEndpoint | "/api/v1/ai/tools/classify-and-label", string>
161143
> = {
162144
"/api/v1/security/auto-redact": "portal.policies.endpoints.autoRedact",
@@ -423,17 +405,6 @@ export const POLICY_CONFIG: Record<string, PolicyConfigDef> = {
423405
},
424406
};
425407

426-
export const POLICY_DOC_TYPES: string[] = [
427-
"contracts",
428-
"invoices",
429-
"taxDocuments",
430-
"hrRecords",
431-
"insurance",
432-
"medicalPhi",
433-
"legalFilings",
434-
"financialReports",
435-
];
436-
437408
// ── Client-side catalogue assembly ───────────────────────────────────────────
438409

439410
function decoratePolicy(
@@ -517,25 +488,7 @@ export function assemblePolicies(
517488
return { category, config: POLICY_CONFIG[category.id], policy };
518489
});
519490

520-
const active = wirePolicies.filter((p) => p.enabled).length;
521-
const paused = wirePolicies.filter((p) => !p.enabled).length;
522-
const enabledPolicyIds = new Set(
523-
wirePolicies.filter((p) => p.enabled).map((p) => p.id),
524-
);
525-
const docsEnforced = runs.filter(
526-
(r) =>
527-
r.status === "COMPLETED" &&
528-
r.policyId != null &&
529-
enabledPolicyIds.has(r.policyId),
530-
).length;
531-
const summary: PoliciesSummary = {
532-
active,
533-
paused,
534-
categories: POLICY_CATEGORIES.length,
535-
docsEnforced,
536-
};
537-
538-
return { summary, catalogue };
491+
return { catalogue };
539492
}
540493

541494
/**
@@ -613,13 +566,6 @@ export function parseSimplePolicy(
613566
};
614567
}
615568

616-
/** GET /api/v1/policies/{id} — one stored policy's raw record. */
617-
export async function fetchPolicy(id: string): Promise<WirePolicy> {
618-
return apiClient.local.json<WirePolicy>(
619-
`/api/v1/policies/${encodeURIComponent(id)}`,
620-
);
621-
}
622-
623569
/**
624570
* POST /api/v1/policies — create (blank id) or update (matched id). The
625571
* backend stamps owner + teamId server-side and returns the stored record.

frontend/editor/src/portal/components/policies/CatalogueSummary.stories.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

frontend/editor/src/portal/components/policies/CatalogueSummary.tsx

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)