feat(FN-3787): add approval workflow and share blocks to reports plugin
Added an approval workflow to the reports plugin comprising a state machine (`approval.ts`), share blocks logic (`share-blocks.ts`), API routes for approvals, and two new dashboard panels (ReportApprovalPanel and ShareBlocksPanel), with corresponding tests; also updated the plugin README and added a Fusion-Task-Id: FN-3787
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { ReportRecord } from "./types.js";
|
||||
import type { ShareBlocks } from "../share-blocks.js";
|
||||
|
||||
const BASE = "/api/plugins/reports";
|
||||
|
||||
@@ -51,3 +52,34 @@ export function getReportPreviewHtml(id: string, projectId?: string): Promise<st
|
||||
export function getReportExportUrl(id: string, projectId?: string): string {
|
||||
return `${BASE}/reports/${encodeURIComponent(id)}/export.html${qp({ projectId })}`;
|
||||
}
|
||||
|
||||
export async function approveReport(id: string, note?: string): Promise<ReportRecord> {
|
||||
const data = await request<{ report: ReportRecord }>(`/reports/${encodeURIComponent(id)}/approve`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(note ? { note } : {}),
|
||||
});
|
||||
return data.report;
|
||||
}
|
||||
|
||||
export async function rejectReport(id: string, note?: string): Promise<ReportRecord> {
|
||||
const data = await request<{ report: ReportRecord }>(`/reports/${encodeURIComponent(id)}/reject`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(note ? { note } : {}),
|
||||
});
|
||||
return data.report;
|
||||
}
|
||||
|
||||
export async function publishReport(id: string): Promise<ReportRecord> {
|
||||
const data = await request<{ report: ReportRecord }>(`/reports/${encodeURIComponent(id)}/publish`, {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: "{}",
|
||||
});
|
||||
return data.report;
|
||||
}
|
||||
|
||||
export async function getShareBlocks(id: string): Promise<ShareBlocks> {
|
||||
return request<ShareBlocks>(`/reports/${encodeURIComponent(id)}/share-blocks`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user