refactor(lab): canonize selected evidence reports
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
import type { ReactNode } from "react";
|
||||
import {
|
||||
Select,
|
||||
StatusBadge,
|
||||
} from "@nodedc/ui-react";
|
||||
import { Select, StatusBadge } from "@nodedc/ui-react";
|
||||
|
||||
export interface LaboratoryOption<T extends string> {
|
||||
id: T;
|
||||
label: string;
|
||||
status?: "progress" | "retained" | "failed" | "unreviewed";
|
||||
}
|
||||
|
||||
export type LaboratoryExecutionClass =
|
||||
@@ -103,6 +101,20 @@ export function LaboratorySelector<T extends string>({
|
||||
options={options.map((option) => ({
|
||||
value: option.id,
|
||||
label: option.label,
|
||||
icon: option.status ? (
|
||||
<span
|
||||
className="laboratory-status-dot"
|
||||
data-status={option.status}
|
||||
aria-label={option.status === "progress"
|
||||
? "Есть подтверждённый прогресс"
|
||||
: option.status === "retained"
|
||||
? "Сохранено для сравнения"
|
||||
: option.status === "failed"
|
||||
? "Gate не пройден"
|
||||
: "Требует классификации"}
|
||||
>
|
||||
</span>
|
||||
) : undefined,
|
||||
}))}
|
||||
variant="split"
|
||||
menuWidth="anchor"
|
||||
|
||||
@@ -1,26 +1,41 @@
|
||||
import { useState, type ReactNode } from "react";
|
||||
import { Button, Icon } from "@nodedc/ui-react";
|
||||
|
||||
import type { LaboratoryAnnotationAction } from "../../workspaces/contracts";
|
||||
import type {
|
||||
LaboratoryAnnotationAction,
|
||||
LaboratoryViewAction,
|
||||
} from "../../workspaces/contracts";
|
||||
|
||||
export function useLaboratoryAnnotationHeader(): {
|
||||
control: ReactNode;
|
||||
setAction: (action: LaboratoryAnnotationAction | null) => void;
|
||||
setViewAction: (action: LaboratoryViewAction | null) => void;
|
||||
} {
|
||||
const [action, setAction] = useState<LaboratoryAnnotationAction | null>(null);
|
||||
const [viewAction, setViewAction] = useState<LaboratoryViewAction | null>(null);
|
||||
return {
|
||||
setAction,
|
||||
control: action ? (
|
||||
<Button
|
||||
size="compact"
|
||||
shape="pill"
|
||||
variant="accent"
|
||||
icon={<Icon name="edit" size={16} />}
|
||||
disabled={action.disabled}
|
||||
onClick={action.onClick}
|
||||
>
|
||||
{action.label}
|
||||
</Button>
|
||||
setViewAction,
|
||||
control: action || viewAction ? (
|
||||
<div className="laboratory-header-tools">
|
||||
{viewAction ? (
|
||||
<Button shape="pill" variant="secondary" onClick={viewAction.onClick}>
|
||||
{viewAction.label}
|
||||
</Button>
|
||||
) : null}
|
||||
{action ? (
|
||||
<Button
|
||||
size="compact"
|
||||
shape="pill"
|
||||
variant="accent"
|
||||
icon={<Icon name="edit" size={16} />}
|
||||
disabled={action.disabled}
|
||||
onClick={action.onClick}
|
||||
>
|
||||
{action.label}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
) : null,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user