Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Template =
| "environment-selector"
| "relationship-entity"
| "relationship-rule"
| "policy-summary"
| "advanced";

const TEMPLATES: { value: Template; label: string; description: string }[] = [
Expand All @@ -57,6 +58,12 @@ const TEMPLATES: { value: Template; label: string; description: string }[] = [
description:
"Re-evaluate relationships for all entities in the workspace. Useful after changing a rule.",
},
{
value: "policy-summary",
label: "Policy Summary Eval",
description:
"Re-evaluate policy summaries for an environment + version pair.",
},
{
value: "advanced",
label: "Advanced",
Expand Down Expand Up @@ -307,6 +314,63 @@ function RelationshipRuleForm({
);
}

function PolicySummaryForm({
workspaceId,
onDone,
}: {
workspaceId: string;
onDone: () => void;
}) {
const [environmentId, setEnvironmentId] = useState("");
const [versionId, setVersionId] = useState("");
const invalidate = useInvalidateAll();
const mutation = trpc.reconcile.triggerPolicySummary.useMutation({
onSuccess: () => {
invalidate();
onDone();
},
});

return (
<form
onSubmit={(e) => {
e.preventDefault();
mutation.mutate({ workspaceId, environmentId, versionId });
}}
className="flex flex-col gap-4"
>
<div className="flex flex-col gap-1.5">
<Label htmlFor="ps-environmentId">Environment ID *</Label>
<Input
id="ps-environmentId"
placeholder="UUID of the environment"
value={environmentId}
onChange={(e) => setEnvironmentId(e.target.value)}
required
/>
</div>
<div className="flex flex-col gap-1.5">
<Label htmlFor="ps-versionId">Version ID *</Label>
<Input
id="ps-versionId"
placeholder="UUID of the deployment version"
value={versionId}
onChange={(e) => setVersionId(e.target.value)}
required
/>
</div>
<DialogFooter>
<Button type="submit" disabled={mutation.isPending}>
{mutation.isPending ? "Triggering…" : "Trigger Eval"}
</Button>
</DialogFooter>
{mutation.error && (
<p className="text-sm text-destructive">{mutation.error.message}</p>
)}
</form>
);
}

function AdvancedForm({
workspaceId,
onDone,
Expand Down Expand Up @@ -579,6 +643,9 @@ export const CreateWorkItemDialog: React.FC<{
{template === "relationship-rule" && (
<RelationshipRuleForm workspaceId={workspaceId} onDone={close} />
)}
{template === "policy-summary" && (
<PolicySummaryForm workspaceId={workspaceId} onDone={close} />
)}
{template === "advanced" && (
<AdvancedForm workspaceId={workspaceId} onDone={close} />
)}
Expand Down
2 changes: 2 additions & 0 deletions apps/workspace-engine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"workspace-engine/svc/controllers/environmentresourceselectoreval"
"workspace-engine/svc/controllers/jobdispatch"
"workspace-engine/svc/controllers/jobverificationmetric"
"workspace-engine/svc/controllers/policysummary"
"workspace-engine/svc/controllers/relationshipeval"
httpsvc "workspace-engine/svc/http"
"workspace-engine/svc/routerregistrar"
Expand Down Expand Up @@ -67,6 +68,7 @@ func main() {
jobverificationmetric.New(WorkerID, db.GetPool(ctx)),
relationshipeval.New(WorkerID, db.GetPool(ctx)),
desiredrelease.New(WorkerID, db.GetPool(ctx)),
policysummary.New(WorkerID, db.GetPool(ctx)),
)

if err := runner.Run(ctx); err != nil {
Expand Down
87 changes: 87 additions & 0 deletions apps/workspace-engine/pkg/db/batch.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions apps/workspace-engine/pkg/db/computed_resources.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading