实现业务附件受控入库 V1(05-28-business-attachment-governance-v1)
这个提交包含在:
@@ -0,0 +1,46 @@
|
||||
import type { ComponentPropsWithoutRef } from "react";
|
||||
import {
|
||||
ATTACHMENT_TYPE_LABEL,
|
||||
GOVERNANCE_STATUS_LABEL,
|
||||
SENSITIVITY_LEVEL_LABEL,
|
||||
attachmentRequiresDownloadReason,
|
||||
type AttachmentGovernanceFields,
|
||||
} from "../../lib/attachmentGovernance";
|
||||
import { cn } from "../../lib/utils";
|
||||
|
||||
function governanceStatusClass(value: string) {
|
||||
if (value === "approved" || value === "archived") return "badge-success";
|
||||
if (value === "pending_review" || value === "under_approval" || value === "returned") return "badge-warning";
|
||||
if (value === "rejected" || value === "quarantined") return "badge-error";
|
||||
return "badge-neutral";
|
||||
}
|
||||
|
||||
function sensitivityClass(value: string) {
|
||||
if (value === "restricted") return "badge-error";
|
||||
if (value === "confidential") return "badge-warning";
|
||||
if (value === "index_only") return "badge-neutral";
|
||||
return "badge-neutral";
|
||||
}
|
||||
|
||||
export function AttachmentGovernanceBadges({
|
||||
attachment,
|
||||
className,
|
||||
...props
|
||||
}: ComponentPropsWithoutRef<"div"> & {
|
||||
attachment: Pick<AttachmentGovernanceFields, "governanceStatus" | "sensitivityLevel" | "attachmentType" | "downloadPolicy">;
|
||||
}) {
|
||||
return (
|
||||
<div className={cn("flex flex-wrap items-center gap-1.5", className)} {...props}>
|
||||
<span className={governanceStatusClass(attachment.governanceStatus)}>
|
||||
{GOVERNANCE_STATUS_LABEL[attachment.governanceStatus] ?? attachment.governanceStatus}
|
||||
</span>
|
||||
<span className="badge-neutral">
|
||||
{ATTACHMENT_TYPE_LABEL[attachment.attachmentType] ?? attachment.attachmentType}
|
||||
</span>
|
||||
<span className={sensitivityClass(attachment.sensitivityLevel)}>
|
||||
{SENSITIVITY_LEVEL_LABEL[attachment.sensitivityLevel] ?? attachment.sensitivityLevel}
|
||||
</span>
|
||||
{attachmentRequiresDownloadReason(attachment) ? <span className="badge-warning">需填用途</span> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户