DataGrid - initial commit
This commit is contained in:
Binary file not shown.
41
src/components/DismissibleAlert.tsx
Normal file
41
src/components/DismissibleAlert.tsx
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { useEffect, useState, type ReactNode } from "react";
|
||||||
|
import { X } from "lucide-react";
|
||||||
|
|
||||||
|
type AlertTone = "success" | "info" | "warning" | "danger";
|
||||||
|
|
||||||
|
type DismissibleAlertProps = {
|
||||||
|
tone?: AlertTone;
|
||||||
|
children: ReactNode;
|
||||||
|
dismissible?: boolean;
|
||||||
|
className?: string;
|
||||||
|
compact?: boolean;
|
||||||
|
resetKey?: string | number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function DismissibleAlert({
|
||||||
|
tone = "info",
|
||||||
|
children,
|
||||||
|
dismissible = true,
|
||||||
|
className = "",
|
||||||
|
compact = false,
|
||||||
|
resetKey
|
||||||
|
}: DismissibleAlertProps) {
|
||||||
|
const [visible, setVisible] = useState(true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setVisible(true);
|
||||||
|
}, [resetKey, children]);
|
||||||
|
|
||||||
|
if (!visible) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`alert ${tone}${compact ? " compact-alert" : ""} alert-dismissible ${className}`.trim()}>
|
||||||
|
<div className="alert-message">{children}</div>
|
||||||
|
{dismissible && (
|
||||||
|
<button type="button" className="alert-dismiss" aria-label="Dismiss notice" onClick={() => setVisible(false)}>
|
||||||
|
<X size={16} strokeWidth={2.4} aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
672
src/components/table/DataGrid.tsx
Normal file
672
src/components/table/DataGrid.tsx
Normal file
@@ -0,0 +1,672 @@
|
|||||||
|
import { forwardRef, useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactNode } from "react";
|
||||||
|
import { createPortal } from "react-dom";
|
||||||
|
import { ArrowDown, ArrowUp, ChevronsUpDown, Filter, GripVertical, X } from "lucide-react";
|
||||||
|
|
||||||
|
export type DataGridSortDirection = "asc" | "desc";
|
||||||
|
export type DataGridFilterType = "text" | "number" | "integer" | "boolean" | "date";
|
||||||
|
|
||||||
|
type TypedFilterOperator = "contains" | "eq" | "gt" | "gte" | "lt" | "lte" | "before" | "after";
|
||||||
|
|
||||||
|
export type DataGridColumn<T> = {
|
||||||
|
id: string;
|
||||||
|
header: ReactNode;
|
||||||
|
width?: number | string;
|
||||||
|
minWidth?: number;
|
||||||
|
maxWidth?: number;
|
||||||
|
resizable?: boolean;
|
||||||
|
sortable?: boolean;
|
||||||
|
filterable?: boolean;
|
||||||
|
filterType?: DataGridFilterType;
|
||||||
|
sticky?: "start" | "end";
|
||||||
|
align?: "left" | "center" | "right";
|
||||||
|
className?: string;
|
||||||
|
headerClassName?: string;
|
||||||
|
render?: (row: T, index: number) => ReactNode;
|
||||||
|
value?: (row: T, index: number) => unknown;
|
||||||
|
sortValue?: (row: T, index: number) => unknown;
|
||||||
|
filterValue?: (row: T, index: number) => unknown;
|
||||||
|
};
|
||||||
|
|
||||||
|
type DataGridState = {
|
||||||
|
sort?: { columnId: string; direction: DataGridSortDirection };
|
||||||
|
filters?: Record<string, string>;
|
||||||
|
widths?: Record<string, number>;
|
||||||
|
};
|
||||||
|
|
||||||
|
type DataGridProps<T> = {
|
||||||
|
id: string;
|
||||||
|
rows: T[];
|
||||||
|
columns: DataGridColumn<T>[];
|
||||||
|
getRowKey: (row: T, index: number) => string;
|
||||||
|
emptyText?: ReactNode;
|
||||||
|
fit?: "content" | "container";
|
||||||
|
className?: string;
|
||||||
|
rowClassName?: (row: T, index: number) => string | undefined;
|
||||||
|
storageKey?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type FilterPosition = {
|
||||||
|
top: number;
|
||||||
|
left: number;
|
||||||
|
width: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const STORAGE_PREFIX = "multimailer.datagrid.";
|
||||||
|
const FILTER_POPOVER_WIDTH = 320;
|
||||||
|
const FILTER_POPOVER_MARGIN = 12;
|
||||||
|
|
||||||
|
export default function DataGrid<T>({
|
||||||
|
id,
|
||||||
|
rows,
|
||||||
|
columns,
|
||||||
|
getRowKey,
|
||||||
|
emptyText = "No rows found.",
|
||||||
|
fit = "content",
|
||||||
|
className = "",
|
||||||
|
rowClassName,
|
||||||
|
storageKey
|
||||||
|
}: DataGridProps<T>) {
|
||||||
|
const localStorageKey = storageKey ?? `${STORAGE_PREFIX}${id}`;
|
||||||
|
const [state, setState] = useState<DataGridState>(() => loadState(localStorageKey));
|
||||||
|
const [resizeState, setResizeState] = useState<{ columnId: string; startX: number; startWidth: number } | null>(null);
|
||||||
|
const [openFilterColumnId, setOpenFilterColumnId] = useState<string | null>(null);
|
||||||
|
const [filterPosition, setFilterPosition] = useState<FilterPosition | null>(null);
|
||||||
|
const gridRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const headerCellRefs = useRef<Record<string, HTMLDivElement | null>>({});
|
||||||
|
const filterButtonRefs = useRef<Record<string, HTMLButtonElement | null>>({});
|
||||||
|
const filterPopoverRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const [measuredWidths, setMeasuredWidths] = useState<Record<string, number>>({});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
try {
|
||||||
|
window.localStorage.setItem(localStorageKey, JSON.stringify(state));
|
||||||
|
} catch {
|
||||||
|
// Local storage is an enhancement only.
|
||||||
|
}
|
||||||
|
}, [localStorageKey, state]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const filtersFromUrl: Record<string, string> = {};
|
||||||
|
for (const column of columns) {
|
||||||
|
const exact = params.get(`grid.${id}.${column.id}`) ?? params.get(`filter.${id}.${column.id}`);
|
||||||
|
if (exact) filtersFromUrl[column.id] = exact;
|
||||||
|
}
|
||||||
|
const table = params.get("table");
|
||||||
|
const filter = params.get("filter");
|
||||||
|
if (table === id && filter?.includes(":")) {
|
||||||
|
const [columnId, ...parts] = filter.split(":");
|
||||||
|
const value = parts.join(":");
|
||||||
|
if (columnId && value) filtersFromUrl[columnId] = value;
|
||||||
|
}
|
||||||
|
if (Object.keys(filtersFromUrl).length > 0) {
|
||||||
|
setState((current) => ({ ...current, filters: { ...(current.filters ?? {}), ...filtersFromUrl } }));
|
||||||
|
}
|
||||||
|
}, [id, columns]);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
function measure() {
|
||||||
|
const next: Record<string, number> = {};
|
||||||
|
for (const column of columns) {
|
||||||
|
const element = headerCellRefs.current[column.id];
|
||||||
|
if (!element) continue;
|
||||||
|
const width = Math.round(element.getBoundingClientRect().width);
|
||||||
|
if (width > 0) next[column.id] = width;
|
||||||
|
}
|
||||||
|
setMeasuredWidths((current) => shallowEqualNumberRecords(current, next) ? current : next);
|
||||||
|
}
|
||||||
|
|
||||||
|
measure();
|
||||||
|
if (typeof ResizeObserver === "undefined") {
|
||||||
|
window.addEventListener("resize", measure);
|
||||||
|
return () => window.removeEventListener("resize", measure);
|
||||||
|
}
|
||||||
|
|
||||||
|
const observer = new ResizeObserver(measure);
|
||||||
|
for (const column of columns) {
|
||||||
|
const element = headerCellRefs.current[column.id];
|
||||||
|
if (element) observer.observe(element);
|
||||||
|
}
|
||||||
|
return () => observer.disconnect();
|
||||||
|
}, [columns, state.widths]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!resizeState) return;
|
||||||
|
const activeResize = resizeState;
|
||||||
|
function onMove(event: MouseEvent) {
|
||||||
|
const column = columns.find((item) => item.id === activeResize.columnId);
|
||||||
|
const minWidth = column?.minWidth ?? 80;
|
||||||
|
const maxWidth = column?.maxWidth ?? 2000;
|
||||||
|
const nextWidth = Math.min(maxWidth, Math.max(minWidth, activeResize.startWidth + event.clientX - activeResize.startX));
|
||||||
|
setState((current) => ({ ...current, widths: { ...(current.widths ?? {}), [activeResize.columnId]: nextWidth } }));
|
||||||
|
}
|
||||||
|
function onUp() {
|
||||||
|
setResizeState(null);
|
||||||
|
}
|
||||||
|
window.addEventListener("mousemove", onMove);
|
||||||
|
window.addEventListener("mouseup", onUp);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("mousemove", onMove);
|
||||||
|
window.removeEventListener("mouseup", onUp);
|
||||||
|
};
|
||||||
|
}, [resizeState, columns]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!openFilterColumnId) return undefined;
|
||||||
|
const activeFilterColumnId = openFilterColumnId;
|
||||||
|
function update() {
|
||||||
|
updateFilterPosition(activeFilterColumnId);
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
window.addEventListener("resize", update);
|
||||||
|
window.addEventListener("scroll", update, true);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("resize", update);
|
||||||
|
window.removeEventListener("scroll", update, true);
|
||||||
|
};
|
||||||
|
}, [openFilterColumnId]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!openFilterColumnId) return undefined;
|
||||||
|
const activeFilterColumnId = openFilterColumnId;
|
||||||
|
function onPointerDown(event: MouseEvent) {
|
||||||
|
const target = event.target as Node | null;
|
||||||
|
const popover = filterPopoverRef.current;
|
||||||
|
const trigger = filterButtonRefs.current[activeFilterColumnId];
|
||||||
|
if (target && (popover?.contains(target) || trigger?.contains(target))) return;
|
||||||
|
setOpenFilterColumnId(null);
|
||||||
|
}
|
||||||
|
function onKeyDown(event: KeyboardEvent) {
|
||||||
|
if (event.key === "Escape") setOpenFilterColumnId(null);
|
||||||
|
}
|
||||||
|
window.addEventListener("mousedown", onPointerDown);
|
||||||
|
window.addEventListener("keydown", onKeyDown);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("mousedown", onPointerDown);
|
||||||
|
window.removeEventListener("keydown", onKeyDown);
|
||||||
|
};
|
||||||
|
}, [openFilterColumnId]);
|
||||||
|
|
||||||
|
const filterTypes = useMemo(() => {
|
||||||
|
const result: Record<string, DataGridFilterType> = {};
|
||||||
|
for (const column of columns) result[column.id] = column.filterType ?? inferFilterType(column, rows);
|
||||||
|
return result;
|
||||||
|
}, [columns, rows]);
|
||||||
|
|
||||||
|
const visibleRows = useMemo(() => {
|
||||||
|
const filters = state.filters ?? {};
|
||||||
|
const filtered = rows.filter((row, rowIndex) => columns.every((column) => {
|
||||||
|
const filterValue = filters[column.id] ?? "";
|
||||||
|
if (!filterValue.trim()) return true;
|
||||||
|
const rawValue = valueForFilter(column, row, rowIndex);
|
||||||
|
return matchesFilter(rawValue, filterValue, filterTypes[column.id]);
|
||||||
|
}));
|
||||||
|
if (!state.sort) return filtered;
|
||||||
|
const sortColumn = columns.find((column) => column.id === state.sort?.columnId);
|
||||||
|
if (!sortColumn) return filtered;
|
||||||
|
return [...filtered].sort((a, b) => {
|
||||||
|
const aIndex = rows.indexOf(a);
|
||||||
|
const bIndex = rows.indexOf(b);
|
||||||
|
const aValue = sortColumn.sortValue?.(a, aIndex) ?? sortColumn.value?.(a, aIndex) ?? "";
|
||||||
|
const bValue = sortColumn.sortValue?.(b, bIndex) ?? sortColumn.value?.(b, bIndex) ?? "";
|
||||||
|
const result = compareValues(aValue, bValue);
|
||||||
|
return state.sort?.direction === "desc" ? -result : result;
|
||||||
|
});
|
||||||
|
}, [rows, columns, state.filters, state.sort, filterTypes]);
|
||||||
|
|
||||||
|
const stretchedColumnIds = useMemo(() => chooseStretchedColumns(columns, state.widths), [columns, state.widths]);
|
||||||
|
const templateColumns = columns.map((column) => widthForColumn(column, state.widths?.[column.id], stretchedColumnIds.has(column.id))).join(" ");
|
||||||
|
const hasFlexibleColumns = columns.some((column) => stretchedColumnIds.has(column.id) || isFlexibleColumn(column, state.widths?.[column.id]));
|
||||||
|
const stickyOffsets = useMemo(() => computeStickyOffsets(columns, state.widths, measuredWidths), [columns, state.widths, measuredWidths]);
|
||||||
|
const gridClassName = `data-grid ${hasFlexibleColumns ? "data-grid-has-flex" : "data-grid-fixed-only"}`;
|
||||||
|
const activeFilterColumn = openFilterColumnId ? columns.find((column) => column.id === openFilterColumnId) : undefined;
|
||||||
|
|
||||||
|
function toggleSort(column: DataGridColumn<T>) {
|
||||||
|
if (!column.sortable) return;
|
||||||
|
setState((current) => {
|
||||||
|
if (current.sort?.columnId !== column.id) return { ...current, sort: { columnId: column.id, direction: "asc" } };
|
||||||
|
if (current.sort.direction === "asc") return { ...current, sort: { columnId: column.id, direction: "desc" } };
|
||||||
|
return { ...current, sort: undefined };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function patchFilter(columnId: string, value: string) {
|
||||||
|
setState((current) => ({ ...current, filters: { ...(current.filters ?? {}), [columnId]: value } }));
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearFilter(columnId: string) {
|
||||||
|
setState((current) => {
|
||||||
|
const nextFilters = { ...(current.filters ?? {}) };
|
||||||
|
delete nextFilters[columnId];
|
||||||
|
return { ...current, filters: nextFilters };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateFilterPosition(columnId: string) {
|
||||||
|
const element = filterButtonRefs.current[columnId];
|
||||||
|
if (!element) return;
|
||||||
|
const rect = element.getBoundingClientRect();
|
||||||
|
const width = Math.min(FILTER_POPOVER_WIDTH, Math.max(240, window.innerWidth - FILTER_POPOVER_MARGIN * 2));
|
||||||
|
const left = Math.min(Math.max(FILTER_POPOVER_MARGIN, rect.left), window.innerWidth - width - FILTER_POPOVER_MARGIN);
|
||||||
|
const top = Math.min(rect.bottom + 8, window.innerHeight - 120);
|
||||||
|
setFilterPosition({ top, left, width });
|
||||||
|
}
|
||||||
|
|
||||||
|
function toggleFilterPopover(columnId: string) {
|
||||||
|
setOpenFilterColumnId((current) => {
|
||||||
|
if (current === columnId) return null;
|
||||||
|
window.requestAnimationFrame(() => updateFilterPosition(columnId));
|
||||||
|
return columnId;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`data-grid-shell data-grid-${fit} ${className}`.trim()} ref={gridRef}>
|
||||||
|
<div className={gridClassName} role="table" aria-label={id} style={{ gridTemplateColumns: templateColumns }}>
|
||||||
|
{columns.map((column, columnIndex) => {
|
||||||
|
const sorted = state.sort?.columnId === column.id ? state.sort.direction : undefined;
|
||||||
|
const hasFilter = Boolean((state.filters?.[column.id] ?? "").trim());
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={`header-${column.id}`}
|
||||||
|
role="columnheader"
|
||||||
|
ref={(element) => { headerCellRefs.current[column.id] = element; }}
|
||||||
|
className={`data-grid-cell data-grid-header-cell ${column.headerClassName ?? ""} ${column.sortable ? "is-sortable" : ""} ${sorted ? "is-sorted" : ""} ${stickyClass(column)}`.trim()}
|
||||||
|
style={stickyStyle(column, stickyOffsets[columnIndex])}
|
||||||
|
>
|
||||||
|
<button type="button" className="data-grid-header-button" disabled={!column.sortable} onClick={() => toggleSort(column)}>
|
||||||
|
<span>{column.header}</span>
|
||||||
|
{column.sortable && <SortIcon direction={sorted} />}
|
||||||
|
</button>
|
||||||
|
{column.filterable && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
ref={(element) => { filterButtonRefs.current[column.id] = element; }}
|
||||||
|
className={`data-grid-filter-trigger${hasFilter ? " has-filter" : ""}${openFilterColumnId === column.id ? " is-open" : ""}`}
|
||||||
|
aria-label={`Filter ${String(column.header)}`}
|
||||||
|
aria-expanded={openFilterColumnId === column.id}
|
||||||
|
onClick={(event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
toggleFilterPopover(column.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Filter size={14} aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
{column.resizable && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="data-grid-resize-handle"
|
||||||
|
aria-label={`Resize ${String(column.header)}`}
|
||||||
|
onMouseDown={(event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
const headerElement = headerCellRefs.current[column.id];
|
||||||
|
const currentWidth = headerElement ? Math.round(headerElement.getBoundingClientRect().width) : columnPixelWidth(column, state.widths?.[column.id], measuredWidths[column.id]);
|
||||||
|
setResizeState({ columnId: column.id, startX: event.clientX, startWidth: currentWidth });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<GripVertical size={14} aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{visibleRows.length === 0 ? (
|
||||||
|
<div className="data-grid-empty" role="row">
|
||||||
|
<div role="cell">{emptyText}</div>
|
||||||
|
</div>
|
||||||
|
) : visibleRows.map((row, visibleIndex) => {
|
||||||
|
const originalIndex = rows.indexOf(row);
|
||||||
|
const rowClass = rowClassName?.(row, originalIndex);
|
||||||
|
const parityClass = visibleIndex % 2 === 0 ? "data-grid-row-even" : "data-grid-row-odd";
|
||||||
|
return columns.map((column, columnIndex) => (
|
||||||
|
<div
|
||||||
|
key={`${getRowKey(row, originalIndex)}-${column.id}`}
|
||||||
|
role="cell"
|
||||||
|
className={`data-grid-cell data-grid-body-cell ${parityClass} ${column.align ? `align-${column.align}` : ""} ${column.className ?? ""} ${rowClass ?? ""} ${stickyClass(column)}`.trim()}
|
||||||
|
style={stickyStyle(column, stickyOffsets[columnIndex])}
|
||||||
|
>
|
||||||
|
{column.render ? column.render(row, originalIndex) : stringifyCell(column.value?.(row, originalIndex))}
|
||||||
|
</div>
|
||||||
|
));
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
{activeFilterColumn && filterPosition && createPortal(
|
||||||
|
<FilterPopover
|
||||||
|
ref={filterPopoverRef}
|
||||||
|
column={activeFilterColumn}
|
||||||
|
filterType={filterTypes[activeFilterColumn.id]}
|
||||||
|
value={state.filters?.[activeFilterColumn.id] ?? ""}
|
||||||
|
position={filterPosition}
|
||||||
|
onChange={(value) => patchFilter(activeFilterColumn.id, value)}
|
||||||
|
onClear={() => clearFilter(activeFilterColumn.id)}
|
||||||
|
onClose={() => setOpenFilterColumnId(null)}
|
||||||
|
/>,
|
||||||
|
document.body
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type FilterPopoverProps = {
|
||||||
|
column: Pick<DataGridColumn<unknown>, "id" | "header">;
|
||||||
|
filterType: DataGridFilterType;
|
||||||
|
value: string;
|
||||||
|
position: FilterPosition;
|
||||||
|
onChange: (value: string) => void;
|
||||||
|
onClear: () => void;
|
||||||
|
onClose: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
const FilterPopover = forwardRef<HTMLDivElement, FilterPopoverProps>(function FilterPopover(
|
||||||
|
{ column, filterType, value, position, onChange, onClear, onClose },
|
||||||
|
ref
|
||||||
|
) {
|
||||||
|
const parsed = parseTypedFilter(value, filterType);
|
||||||
|
const operatorOptions = filterType === "date" ? DATE_OPERATORS : NUMBER_OPERATORS;
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={ref}
|
||||||
|
className="data-grid-filter-popover"
|
||||||
|
style={{ top: position.top, left: position.left, width: position.width }}
|
||||||
|
role="dialog"
|
||||||
|
aria-label={`Filter ${String(column.header)}`}
|
||||||
|
>
|
||||||
|
<div className="data-grid-filter-popover-header">
|
||||||
|
<strong>Filter {column.header}</strong>
|
||||||
|
<button type="button" aria-label="Close filter" onClick={onClose}><X size={15} /></button>
|
||||||
|
</div>
|
||||||
|
{filterType === "boolean" ? (
|
||||||
|
<label className="data-grid-filter-field">
|
||||||
|
<span>Value</span>
|
||||||
|
<select value={value} onChange={(event) => onChange(event.target.value)} autoFocus>
|
||||||
|
<option value="">All</option>
|
||||||
|
<option value="true">Yes / active</option>
|
||||||
|
<option value="false">No / inactive</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
) : filterType === "number" || filterType === "integer" || filterType === "date" ? (
|
||||||
|
<div className="data-grid-filter-stack">
|
||||||
|
<label className="data-grid-filter-field">
|
||||||
|
<span>Match</span>
|
||||||
|
<select
|
||||||
|
value={parsed.operator}
|
||||||
|
onChange={(event) => onChange(formatTypedFilter(event.target.value as TypedFilterOperator, parsed.value))}
|
||||||
|
>
|
||||||
|
{operatorOptions.map((option) => <option key={option.value} value={option.value}>{option.label}</option>)}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
<label className="data-grid-filter-field">
|
||||||
|
<span>Value</span>
|
||||||
|
<div className="data-grid-filter-input-wrap">
|
||||||
|
<input
|
||||||
|
type={filterType === "date" ? "date" : "number"}
|
||||||
|
step={filterType === "integer" ? 1 : undefined}
|
||||||
|
value={parsed.value}
|
||||||
|
onChange={(event) => onChange(formatTypedFilter(parsed.operator, event.target.value))}
|
||||||
|
autoFocus
|
||||||
|
/>
|
||||||
|
{value && <button type="button" aria-label="Clear filter" onClick={onClear}><X size={14} /></button>}
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<label className="data-grid-filter-field">
|
||||||
|
<span>Contains</span>
|
||||||
|
<div className="data-grid-filter-input-wrap">
|
||||||
|
<input value={value} placeholder="Filter" onChange={(event) => onChange(event.target.value)} autoFocus />
|
||||||
|
{value && <button type="button" aria-label="Clear filter" onClick={onClear}><X size={14} /></button>}
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
function SortIcon({ direction }: { direction?: DataGridSortDirection }) {
|
||||||
|
if (direction === "asc") return <ArrowUp size={14} aria-label="Sorted ascending" />;
|
||||||
|
if (direction === "desc") return <ArrowDown size={14} aria-label="Sorted descending" />;
|
||||||
|
return <ChevronsUpDown size={14} aria-hidden="true" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadState(key: string): DataGridState {
|
||||||
|
try {
|
||||||
|
const value = window.localStorage.getItem(key);
|
||||||
|
if (!value) return {};
|
||||||
|
return JSON.parse(value) as DataGridState;
|
||||||
|
} catch {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function widthForColumn<T>(column: DataGridColumn<T>, savedWidth?: number, stretch = false): string {
|
||||||
|
if (stretch) {
|
||||||
|
const baseWidth = savedWidth ?? fixedWidthFloor(column);
|
||||||
|
return `minmax(${baseWidth}px, 1fr)`;
|
||||||
|
}
|
||||||
|
if (savedWidth) {
|
||||||
|
return isFlexibleWidth(column.width) ? `minmax(${savedWidth}px, 1fr)` : `${savedWidth}px`;
|
||||||
|
}
|
||||||
|
if (typeof column.width === "number") return `${column.width}px`;
|
||||||
|
if (column.width) return column.width;
|
||||||
|
return `minmax(${column.minWidth ?? 140}px, 1fr)`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function chooseStretchedColumns<T>(columns: DataGridColumn<T>[], savedWidths?: Record<string, number>): Set<string> {
|
||||||
|
if (columns.length === 0) return new Set();
|
||||||
|
|
||||||
|
const nonStickyResizable = columns.filter((column) => column.resizable && !column.sticky);
|
||||||
|
if (nonStickyResizable.length > 0) return new Set(nonStickyResizable.map((column) => column.id));
|
||||||
|
|
||||||
|
const resizable = columns.filter((column) => column.resizable);
|
||||||
|
if (resizable.length > 0) return new Set(resizable.map((column) => column.id));
|
||||||
|
|
||||||
|
const flexible = columns.filter((column) => isFlexibleColumn(column, savedWidths?.[column.id]));
|
||||||
|
if (flexible.length > 0) return new Set();
|
||||||
|
|
||||||
|
const nonStickyColumns = columns.filter((column) => !column.sticky);
|
||||||
|
const fallback = nonStickyColumns[nonStickyColumns.length - 1] ?? columns[columns.length - 1];
|
||||||
|
return new Set(fallback ? [fallback.id] : []);
|
||||||
|
}
|
||||||
|
|
||||||
|
function fixedWidthFloor<T>(column: DataGridColumn<T>): number {
|
||||||
|
const parsed = parsePixelWidth(column.width);
|
||||||
|
if (typeof column.width === "number") return column.width;
|
||||||
|
return parsed ?? column.minWidth ?? 140;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isFlexibleColumn<T>(column: DataGridColumn<T>, savedWidth?: number): boolean {
|
||||||
|
if (savedWidth && !isFlexibleWidth(column.width)) return false;
|
||||||
|
return isFlexibleWidth(column.width);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isFlexibleWidth(width?: string | number): boolean {
|
||||||
|
if (width === undefined) return true;
|
||||||
|
if (typeof width === "number") return false;
|
||||||
|
const normalized = width.toLowerCase();
|
||||||
|
return normalized.includes("fr") || normalized.includes("minmax") || normalized.includes("auto");
|
||||||
|
}
|
||||||
|
|
||||||
|
function columnPixelWidth<T>(column: DataGridColumn<T>, savedWidth?: number, measuredWidth?: number): number {
|
||||||
|
if (measuredWidth) return measuredWidth;
|
||||||
|
if (savedWidth) return savedWidth;
|
||||||
|
if (typeof column.width === "number") return column.width;
|
||||||
|
const parsed = parsePixelWidth(column.width);
|
||||||
|
if (parsed) return parsed;
|
||||||
|
return column.minWidth ?? 160;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parsePixelWidth(width?: string | number): number | null {
|
||||||
|
if (typeof width === "number") return width;
|
||||||
|
if (!width) return null;
|
||||||
|
const pxMatch = width.match(/(\d+(?:\.\d+)?)px/);
|
||||||
|
if (!pxMatch) return null;
|
||||||
|
const parsed = Number.parseFloat(pxMatch[1]);
|
||||||
|
return Number.isFinite(parsed) ? parsed : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function computeStickyOffsets<T>(columns: DataGridColumn<T>[], savedWidths?: Record<string, number>, measuredWidths?: Record<string, number>): Record<number, number> {
|
||||||
|
const offsets: Record<number, number> = {};
|
||||||
|
let left = 0;
|
||||||
|
columns.forEach((column, index) => {
|
||||||
|
if (column.sticky === "start") {
|
||||||
|
offsets[index] = left;
|
||||||
|
left += columnPixelWidth(column, savedWidths?.[column.id], measuredWidths?.[column.id]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let right = 0;
|
||||||
|
[...columns].reverse().forEach((column, reverseIndex) => {
|
||||||
|
const index = columns.length - 1 - reverseIndex;
|
||||||
|
if (column.sticky === "end") {
|
||||||
|
offsets[index] = right;
|
||||||
|
right += columnPixelWidth(column, savedWidths?.[column.id], measuredWidths?.[column.id]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return offsets;
|
||||||
|
}
|
||||||
|
|
||||||
|
function stickyClass<T>(column: DataGridColumn<T>): string {
|
||||||
|
if (column.sticky === "start") return "is-sticky-start";
|
||||||
|
if (column.sticky === "end") return "is-sticky-end";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function stickyStyle<T>(column: DataGridColumn<T>, offset?: number): CSSProperties | undefined {
|
||||||
|
if (!column.sticky) return undefined;
|
||||||
|
return column.sticky === "start" ? { left: offset ?? 0 } : { right: offset ?? 0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
function valueForFilter<T>(column: DataGridColumn<T>, row: T, rowIndex: number): unknown {
|
||||||
|
return column.filterValue?.(row, rowIndex) ?? column.value?.(row, rowIndex) ?? column.render?.(row, rowIndex) ?? "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function matchesFilter(value: unknown, filterValue: string, filterType: DataGridFilterType): boolean {
|
||||||
|
if (!filterValue.trim()) return true;
|
||||||
|
if (filterType === "boolean") {
|
||||||
|
const expected = parseBooleanFilter(filterValue);
|
||||||
|
if (expected === null) return stringifyCell(value).toLowerCase().includes(filterValue.toLowerCase());
|
||||||
|
const actual = normalizeBoolean(value);
|
||||||
|
return actual === null ? stringifyCell(value).toLowerCase().includes(filterValue.toLowerCase()) : actual === expected;
|
||||||
|
}
|
||||||
|
if (filterType === "number" || filterType === "integer") {
|
||||||
|
const parsed = parseTypedFilter(filterValue, filterType);
|
||||||
|
if (!parsed.value.trim()) return true;
|
||||||
|
const actual = parseNumberValue(value);
|
||||||
|
const expected = Number(parsed.value);
|
||||||
|
if (!Number.isFinite(actual) || !Number.isFinite(expected)) return false;
|
||||||
|
return compareByOperator(actual, expected, parsed.operator);
|
||||||
|
}
|
||||||
|
if (filterType === "date") {
|
||||||
|
const parsed = parseTypedFilter(filterValue, filterType);
|
||||||
|
if (!parsed.value.trim()) return true;
|
||||||
|
const actual = parseDateValue(value);
|
||||||
|
const expected = parseDateValue(parsed.value);
|
||||||
|
if (!Number.isFinite(actual) || !Number.isFinite(expected)) return false;
|
||||||
|
return compareByOperator(actual, expected, parsed.operator);
|
||||||
|
}
|
||||||
|
return stringifyCell(value).toLowerCase().includes(filterValue.trim().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
function inferFilterType<T>(column: DataGridColumn<T>, rows: T[]): DataGridFilterType {
|
||||||
|
const samples = rows.slice(0, 25)
|
||||||
|
.map((row, index) => valueForFilter(column, row, index))
|
||||||
|
.filter((value) => stringifyCell(value).trim() !== "");
|
||||||
|
if (samples.length === 0) return "text";
|
||||||
|
if (samples.every((value) => normalizeBoolean(value) !== null)) return "boolean";
|
||||||
|
if (samples.every((value) => Number.isFinite(parseNumberValue(value)))) {
|
||||||
|
return samples.every((value) => Number.isInteger(parseNumberValue(value))) ? "integer" : "number";
|
||||||
|
}
|
||||||
|
if (samples.every((value) => Number.isFinite(parseDateValue(value)))) return "date";
|
||||||
|
return "text";
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseBooleanFilter(value: string): boolean | null {
|
||||||
|
const normalized = value.trim().toLowerCase();
|
||||||
|
if (!normalized) return null;
|
||||||
|
if (["true", "yes", "1", "active", "on"].includes(normalized)) return true;
|
||||||
|
if (["false", "no", "0", "inactive", "off"].includes(normalized)) return false;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeBoolean(value: unknown): boolean | null {
|
||||||
|
if (typeof value === "boolean") return value;
|
||||||
|
if (typeof value === "number") return value !== 0;
|
||||||
|
const normalized = stringifyCell(value).trim().toLowerCase();
|
||||||
|
if (!normalized) return null;
|
||||||
|
if (["true", "yes", "1", "active", "required", "individual", "warn", "on", "enabled", "success", "ok", "can override", "mock"].includes(normalized)) return true;
|
||||||
|
if (["false", "no", "0", "inactive", "optional", "off", "global only", "locked", "current", "disabled", "none"].includes(normalized)) return false;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseNumberValue(value: unknown): number {
|
||||||
|
if (typeof value === "number") return value;
|
||||||
|
const text = stringifyCell(value).replace(/[^0-9.,+-]/g, "").replace(",", ".");
|
||||||
|
if (!text.trim()) return NaN;
|
||||||
|
return Number(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseDateValue(value: unknown): number {
|
||||||
|
if (value instanceof Date) return value.getTime();
|
||||||
|
const text = stringifyCell(value).trim();
|
||||||
|
if (!text) return NaN;
|
||||||
|
return Date.parse(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
function compareByOperator(actual: number, expected: number, operator: TypedFilterOperator): boolean {
|
||||||
|
if (operator === "gt" || operator === "after") return actual > expected;
|
||||||
|
if (operator === "gte") return actual >= expected;
|
||||||
|
if (operator === "lt" || operator === "before") return actual < expected;
|
||||||
|
if (operator === "lte") return actual <= expected;
|
||||||
|
return actual === expected;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseTypedFilter(value: string, filterType: DataGridFilterType): { operator: TypedFilterOperator; value: string } {
|
||||||
|
if (!value.includes(":")) return { operator: filterType === "text" ? "contains" : "eq", value };
|
||||||
|
const [operator, ...parts] = value.split(":");
|
||||||
|
const candidate = operator as TypedFilterOperator;
|
||||||
|
if (!["contains", "eq", "gt", "gte", "lt", "lte", "before", "after"].includes(candidate)) {
|
||||||
|
return { operator: filterType === "text" ? "contains" : "eq", value };
|
||||||
|
}
|
||||||
|
return { operator: candidate, value: parts.join(":") };
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatTypedFilter(operator: TypedFilterOperator, value: string): string {
|
||||||
|
return value ? `${operator}:${value}` : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const NUMBER_OPERATORS: { value: TypedFilterOperator; label: string }[] = [
|
||||||
|
{ value: "eq", label: "Equals" },
|
||||||
|
{ value: "gt", label: "Greater than" },
|
||||||
|
{ value: "gte", label: "Greater or equal" },
|
||||||
|
{ value: "lt", label: "Less than" },
|
||||||
|
{ value: "lte", label: "Less or equal" }
|
||||||
|
];
|
||||||
|
|
||||||
|
const DATE_OPERATORS: { value: TypedFilterOperator; label: string }[] = [
|
||||||
|
{ value: "eq", label: "On" },
|
||||||
|
{ value: "before", label: "Before" },
|
||||||
|
{ value: "after", label: "After" }
|
||||||
|
];
|
||||||
|
|
||||||
|
function compareValues(a: unknown, b: unknown): number {
|
||||||
|
if (typeof a === "number" && typeof b === "number") return a - b;
|
||||||
|
const aDate = typeof a === "string" ? Date.parse(a) : NaN;
|
||||||
|
const bDate = typeof b === "string" ? Date.parse(b) : NaN;
|
||||||
|
if (!Number.isNaN(aDate) && !Number.isNaN(bDate)) return aDate - bDate;
|
||||||
|
return stringifyCell(a).localeCompare(stringifyCell(b), undefined, { numeric: true, sensitivity: "base" });
|
||||||
|
}
|
||||||
|
|
||||||
|
function stringifyCell(value: unknown): string {
|
||||||
|
if (value === null || value === undefined) return "";
|
||||||
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return String(value);
|
||||||
|
if (Array.isArray(value)) return value.map(stringifyCell).join(", ");
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function shallowEqualNumberRecords(a: Record<string, number>, b: Record<string, number>): boolean {
|
||||||
|
const aKeys = Object.keys(a);
|
||||||
|
const bKeys = Object.keys(b);
|
||||||
|
if (aKeys.length !== bKeys.length) return false;
|
||||||
|
return aKeys.every((key) => a[key] === b[key]);
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ import Button from "../../components/Button";
|
|||||||
import Card from "../../components/Card";
|
import Card from "../../components/Card";
|
||||||
import PageTitle from "../../components/PageTitle";
|
import PageTitle from "../../components/PageTitle";
|
||||||
import StatusBadge from "../../components/StatusBadge";
|
import StatusBadge from "../../components/StatusBadge";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../components/table/DataGrid";
|
||||||
|
|
||||||
const personalContacts = [
|
const personalContacts = [
|
||||||
{ name: "Ada Lovelace", email: "ada@example.local", source: "Personal", tags: "Used recently" },
|
{ name: "Ada Lovelace", email: "ada@example.local", source: "Personal", tags: "Used recently" },
|
||||||
@@ -18,6 +19,16 @@ const tenantContacts = [
|
|||||||
{ name: "Data Protection", email: "privacy@example.local", source: "Tenant", tags: "Directory" }
|
{ name: "Data Protection", email: "privacy@example.local", source: "Tenant", tags: "Directory" }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function contactColumns(): DataGridColumn<{ name: string; email: string; source: string; tags: string }>[] {
|
||||||
|
return [
|
||||||
|
{ id: "name", header: "Name", width: "minmax(180px, 1fr)", sortable: true, filterable: true, sticky: "start", render: (contact) => <strong>{contact.name}</strong>, value: (contact) => contact.name },
|
||||||
|
{ id: "email", header: "Email", width: 240, sortable: true, filterable: true, value: (contact) => contact.email },
|
||||||
|
{ id: "scope", header: "Scope", width: 140, sortable: true, filterable: true, value: (contact) => contact.source },
|
||||||
|
{ id: "tags", header: "Tags", width: 180, sortable: true, filterable: true, value: (contact) => contact.tags },
|
||||||
|
{ id: "status", header: "Status", width: 130, sortable: true, filterable: true, render: () => <StatusBadge status="mock" />, value: () => "mock" }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
export default function AddressBookPage() {
|
export default function AddressBookPage() {
|
||||||
const allContacts = [...personalContacts, ...groupContacts, ...tenantContacts];
|
const allContacts = [...personalContacts, ...groupContacts, ...tenantContacts];
|
||||||
|
|
||||||
@@ -62,24 +73,14 @@ export default function AddressBookPage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Card title="Contacts" actions={<Button disabled>Manage sources</Button>}>
|
<Card title="Contacts" actions={<Button disabled>Manage sources</Button>}>
|
||||||
<div className="app-table-wrap compact-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table module-table">
|
id="address-book-contacts"
|
||||||
<thead>
|
rows={allContacts}
|
||||||
<tr><th>Name</th><th>Email</th><th>Scope</th><th>Tags</th><th>Status</th></tr>
|
columns={contactColumns()}
|
||||||
</thead>
|
getRowKey={(contact) => `${contact.source}-${contact.email}`}
|
||||||
<tbody>
|
emptyText="No contacts found."
|
||||||
{allContacts.map((contact) => (
|
className="compact-table-wrap module-table"
|
||||||
<tr key={`${contact.source}-${contact.email}`}>
|
/>
|
||||||
<td><strong>{contact.name}</strong></td>
|
|
||||||
<td>{contact.email}</td>
|
|
||||||
<td>{contact.source}</td>
|
|
||||||
<td>{contact.tags}</td>
|
|
||||||
<td><StatusBadge status="mock" /></td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import PageTitle from "../../components/PageTitle";
|
|||||||
import StatusBadge from "../../components/StatusBadge";
|
import StatusBadge from "../../components/StatusBadge";
|
||||||
import ModuleSubnav, { type ModuleSubnavGroup } from "../../layout/ModuleSubnav";
|
import ModuleSubnav, { type ModuleSubnavGroup } from "../../layout/ModuleSubnav";
|
||||||
import AdminPlaceholderTable, { type AdminPlaceholderTableConfig } from "./components/AdminPlaceholderTable";
|
import AdminPlaceholderTable, { type AdminPlaceholderTableConfig } from "./components/AdminPlaceholderTable";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../components/table/DataGrid";
|
||||||
|
|
||||||
type AdminSection = "overview" | "system" | "tenants" | "users" | "groups" | "roles" | "api-keys" | "mail-servers" | "settings" | "audit";
|
type AdminSection = "overview" | "system" | "tenants" | "users" | "groups" | "roles" | "api-keys" | "mail-servers" | "settings" | "audit";
|
||||||
|
|
||||||
@@ -203,16 +204,28 @@ function ApiKeys() {
|
|||||||
return (
|
return (
|
||||||
<Card title="API keys" actions={<Button disabled>Create API key</Button>}>
|
<Card title="API keys" actions={<Button disabled>Create API key</Button>}>
|
||||||
<p className="muted">The backend has API-key support, but a complete key lifecycle UI needs list, revoke and rotate endpoints before this can be safely exposed.</p>
|
<p className="muted">The backend has API-key support, but a complete key lifecycle UI needs list, revoke and rotate endpoints before this can be safely exposed.</p>
|
||||||
<div className="app-table-wrap compact-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table module-table">
|
id="admin-api-keys"
|
||||||
<thead><tr><th>Name</th><th>Scope</th><th>Owner</th><th>Status</th><th>Last used</th></tr></thead>
|
rows={[{ id: "development", name: "Development key", scope: "Automation", owner: "Tenant", status: "dev", lastUsed: "Local only" }]}
|
||||||
<tbody><tr><td>Development key</td><td>Automation</td><td>Tenant</td><td><StatusBadge status="dev" /></td><td>Local only</td></tr></tbody>
|
columns={apiKeyColumns()}
|
||||||
</table>
|
getRowKey={(row) => row.id}
|
||||||
</div>
|
emptyText="No API keys found."
|
||||||
|
className="compact-table-wrap module-table"
|
||||||
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function apiKeyColumns(): DataGridColumn<{ id: string; name: string; scope: string; owner: string; status: string; lastUsed: string }>[] {
|
||||||
|
return [
|
||||||
|
{ id: "name", header: "Name", width: "minmax(180px, 1fr)", sortable: true, filterable: true, sticky: "start", value: (row) => row.name },
|
||||||
|
{ id: "scope", header: "Scope", width: 160, sortable: true, filterable: true, value: (row) => row.scope },
|
||||||
|
{ id: "owner", header: "Owner", width: 140, sortable: true, filterable: true, value: (row) => row.owner },
|
||||||
|
{ id: "status", header: "Status", width: 130, sortable: true, filterable: true, render: (row) => <StatusBadge status={row.status} />, value: (row) => row.status },
|
||||||
|
{ id: "last_used", header: "Last used", width: 160, sortable: true, filterable: true, value: (row) => row.lastUsed }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function MailServers() {
|
function MailServers() {
|
||||||
return <AdminPlaceholderTable {...adminTableConfigs.mailServers} />;
|
return <AdminPlaceholderTable {...adminTableConfigs.mailServers} />;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import Button from "../../../components/Button";
|
import Button from "../../../components/Button";
|
||||||
import Card from "../../../components/Card";
|
import Card from "../../../components/Card";
|
||||||
|
import DismissibleAlert from "../../../components/DismissibleAlert";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../../components/table/DataGrid";
|
||||||
|
|
||||||
export type AdminPlaceholderTableConfig = {
|
export type AdminPlaceholderTableConfig = {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -9,19 +11,43 @@ export type AdminPlaceholderTableConfig = {
|
|||||||
note?: string;
|
note?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type PlaceholderRow = Record<string, string> & { id: string };
|
||||||
|
|
||||||
export default function AdminPlaceholderTable({ title, columns, rows, action, note }: AdminPlaceholderTableConfig) {
|
export default function AdminPlaceholderTable({ title, columns, rows, action, note }: AdminPlaceholderTableConfig) {
|
||||||
|
const normalizedRows = rows.map((row, rowIndex) => {
|
||||||
|
const values = row.split("|");
|
||||||
|
return columns.reduce<PlaceholderRow>((record, column, columnIndex) => {
|
||||||
|
record[column] = values[columnIndex] ?? "";
|
||||||
|
return record;
|
||||||
|
}, { id: `${title}-${rowIndex}` });
|
||||||
|
});
|
||||||
|
const dataColumns: DataGridColumn<PlaceholderRow>[] = columns.map((column, index) => ({
|
||||||
|
id: column,
|
||||||
|
header: column,
|
||||||
|
width: index === 0 ? "minmax(180px, 1fr)" : 180,
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
resizable: true,
|
||||||
|
sticky: index === 0 ? "start" : undefined,
|
||||||
|
value: (row) => row[column] ?? ""
|
||||||
|
}));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card title={title} actions={<Button disabled>{action}</Button>}>
|
<Card title={title} actions={<Button disabled>{action}</Button>}>
|
||||||
<div className="alert info">This view is laid out for production use, but the corresponding backend list/write endpoints still need to be added.</div>
|
<DismissibleAlert tone="info">This view is laid out for production use, but the corresponding backend list/write endpoints still need to be added.</DismissibleAlert>
|
||||||
{note && <p className="muted">{note}</p>}
|
{note && <p className="muted">{note}</p>}
|
||||||
<div className="app-table-wrap compact-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table module-table">
|
id={`admin-${slugify(title)}`}
|
||||||
<thead><tr>{columns.map((column) => <th key={column}>{column}</th>)}</tr></thead>
|
rows={normalizedRows}
|
||||||
<tbody>
|
columns={dataColumns}
|
||||||
{rows.map((row) => <tr key={row}>{row.split("|").map((cell, index) => <td key={`${row}-${index}`}>{cell}</td>)}</tr>)}
|
getRowKey={(row) => row.id}
|
||||||
</tbody>
|
emptyText="No rows configured."
|
||||||
</table>
|
className="compact-table-wrap module-table"
|
||||||
</div>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function slugify(value: string): string {
|
||||||
|
return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,11 +8,13 @@ import LoadingFrame from "../../components/LoadingFrame";
|
|||||||
import LockedVersionNotice from "./components/LockedVersionNotice";
|
import LockedVersionNotice from "./components/LockedVersionNotice";
|
||||||
import VersionLine from "./components/VersionLine";
|
import VersionLine from "./components/VersionLine";
|
||||||
import ToggleSwitch from "../../components/ToggleSwitch";
|
import ToggleSwitch from "../../components/ToggleSwitch";
|
||||||
|
import DismissibleAlert from "../../components/DismissibleAlert";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../components/table/DataGrid";
|
||||||
import { useCampaignWorkspaceData } from "./hooks/useCampaignWorkspaceData";
|
import { useCampaignWorkspaceData } from "./hooks/useCampaignWorkspaceData";
|
||||||
import { useCampaignDraftEditor } from "./hooks/useCampaignDraftEditor";
|
import { useCampaignDraftEditor } from "./hooks/useCampaignDraftEditor";
|
||||||
import { asRecord, isAuditLockedVersion } from "./utils/campaignView";
|
import { asRecord, isAuditLockedVersion } from "./utils/campaignView";
|
||||||
import { updateNested } from "./utils/draftEditor";
|
import { updateNested } from "./utils/draftEditor";
|
||||||
import { AttachmentRulesTable } from "./components/AttachmentRulesOverlay";
|
import { AttachmentRulesDataGrid } from "./components/AttachmentRulesOverlay";
|
||||||
import { countIndividualAttachmentRules, createAttachmentBasePath, createAttachmentRule, ensureAttachmentBasePaths, mockAttachmentPathOptions, normalizeAttachmentBasePaths, normalizeAttachmentRules, summarizeAttachmentRules, type AttachmentBasePath } from "./utils/attachments";
|
import { countIndividualAttachmentRules, createAttachmentBasePath, createAttachmentRule, ensureAttachmentBasePaths, mockAttachmentPathOptions, normalizeAttachmentBasePaths, normalizeAttachmentRules, summarizeAttachmentRules, type AttachmentBasePath } from "./utils/attachments";
|
||||||
|
|
||||||
type PathChooserState = { index: number };
|
type PathChooserState = { index: number };
|
||||||
@@ -84,8 +86,8 @@ export default function AttachmentsDataPage({ settings, campaignId }: { settings
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <div className="alert danger">{error}</div>}
|
{error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>}
|
||||||
{localError && <div className="alert danger">{localError}</div>}
|
{localError && <DismissibleAlert tone="danger" resetKey={localError}>{localError}</DismissibleAlert>}
|
||||||
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Create an editable copy before changing attachments." />}
|
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Create an editable copy before changing attachments." />}
|
||||||
|
|
||||||
<LoadingFrame loading={loading || !draft} label="Loading campaign draft…">
|
<LoadingFrame loading={loading || !draft} label="Loading campaign draft…">
|
||||||
@@ -94,61 +96,26 @@ export default function AttachmentsDataPage({ settings, campaignId }: { settings
|
|||||||
title="Attachment sources"
|
title="Attachment sources"
|
||||||
actions={<Button variant="primary" onClick={addBasePath} disabled={locked}>Add base path</Button>}
|
actions={<Button variant="primary" onClick={addBasePath} disabled={locked}>Add base path</Button>}
|
||||||
>
|
>
|
||||||
<div className="app-table-wrap attachment-sources-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table attachment-sources-table">
|
id={`campaign-${campaignId}-attachment-sources`}
|
||||||
<thead>
|
rows={basePaths}
|
||||||
<tr>
|
columns={attachmentSourceColumns({ locked, basePaths, patchBasePath, removeBasePath, setPathChooser })}
|
||||||
<th>Name</th>
|
getRowKey={(basePath) => basePath.id}
|
||||||
<th>Path</th>
|
emptyText="No attachment sources configured."
|
||||||
<th>Individual attachments</th>
|
className="attachment-sources-table-wrap attachment-sources-table"
|
||||||
<th>Unsent warning</th>
|
|
||||||
<th></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{basePaths.map((basePath, index) => (
|
|
||||||
<tr key={basePath.id}>
|
|
||||||
<td><input value={basePath.name} disabled={locked} placeholder="Campaign files" onChange={(event) => patchBasePath(index, { name: event.target.value })} /></td>
|
|
||||||
<td>
|
|
||||||
<div className="field-with-action">
|
|
||||||
<input
|
|
||||||
className="chooser-display-input"
|
|
||||||
value={basePath.path}
|
|
||||||
disabled={locked}
|
|
||||||
readOnly
|
|
||||||
tabIndex={-1}
|
|
||||||
placeholder="attachments"
|
|
||||||
onClick={() => !locked && setPathChooser({ index })}
|
|
||||||
onKeyDown={(event) => {
|
|
||||||
if (!locked && (event.key === "Enter" || event.key === " ")) {
|
|
||||||
event.preventDefault();
|
|
||||||
setPathChooser({ index });
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<Button onClick={() => setPathChooser({ index })} disabled={locked}>Choose</Button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><ToggleSwitch label="Individual" checked={Boolean(basePath.allow_individual)} disabled={locked} onChange={(checked) => patchBasePath(index, { allow_individual: checked })} /></td>
|
|
||||||
<td><ToggleSwitch label="Unsent" checked={Boolean(basePath.unsent_warning)} disabled={locked} onChange={(checked) => patchBasePath(index, { unsent_warning: checked })} /></td>
|
|
||||||
<td className="table-action-cell"><Button variant="danger" onClick={() => removeBasePath(index)} disabled={locked || basePaths.length <= 1}>Remove</Button></td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
title="Global Attachments"
|
title="Global Attachments"
|
||||||
actions={<Button variant="primary" onClick={addGlobalAttachmentRule} disabled={locked}>Add file</Button>}
|
actions={<Button variant="primary" onClick={addGlobalAttachmentRule} disabled={locked}>Add file</Button>}
|
||||||
>
|
>
|
||||||
<AttachmentRulesTable
|
<AttachmentRulesDataGrid
|
||||||
|
id={`campaign-${campaignId}-global-attachments`}
|
||||||
rules={globalRules}
|
rules={globalRules}
|
||||||
disabled={locked}
|
disabled={locked}
|
||||||
emptyText="No global attachments are configured yet. Add files here only if every message should include them."
|
emptyText="No global attachments are configured yet. Add files here only if every message should include them."
|
||||||
basePaths={basePaths}
|
basePaths={basePaths}
|
||||||
showAddButton={false}
|
|
||||||
onChange={(rules) => patch(["attachments", "global"], rules)}
|
onChange={(rules) => patch(["attachments", "global"], rules)}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
@@ -182,6 +149,52 @@ export default function AttachmentsDataPage({ settings, campaignId }: { settings
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AttachmentSourceColumnContext = {
|
||||||
|
locked: boolean;
|
||||||
|
basePaths: AttachmentBasePath[];
|
||||||
|
patchBasePath: (index: number, patch: Partial<AttachmentBasePath>) => void;
|
||||||
|
removeBasePath: (index: number) => void;
|
||||||
|
setPathChooser: (state: PathChooserState | null) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
function attachmentSourceColumns({ locked, basePaths, patchBasePath, removeBasePath, setPathChooser }: AttachmentSourceColumnContext): DataGridColumn<AttachmentBasePath>[] {
|
||||||
|
return [
|
||||||
|
{ id: "name", header: "Name", width: 220, resizable: true, sortable: true, filterable: true, sticky: "start", render: (basePath, index) => <input value={basePath.name} disabled={locked} placeholder="Campaign files" onChange={(event) => patchBasePath(index, { name: event.target.value })} />, value: (basePath) => basePath.name },
|
||||||
|
{
|
||||||
|
id: "path",
|
||||||
|
header: "Path",
|
||||||
|
width: "minmax(260px, 1fr)",
|
||||||
|
resizable: true,
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
render: (basePath, index) => (
|
||||||
|
<div className="field-with-action">
|
||||||
|
<input
|
||||||
|
className="chooser-display-input"
|
||||||
|
value={basePath.path}
|
||||||
|
disabled={locked}
|
||||||
|
readOnly
|
||||||
|
tabIndex={-1}
|
||||||
|
placeholder="attachments"
|
||||||
|
onClick={() => !locked && setPathChooser({ index })}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
if (!locked && (event.key === "Enter" || event.key === " ")) {
|
||||||
|
event.preventDefault();
|
||||||
|
setPathChooser({ index });
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Button onClick={() => setPathChooser({ index })} disabled={locked}>Choose</Button>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
value: (basePath) => basePath.path
|
||||||
|
},
|
||||||
|
{ id: "individual", header: "Individual attachments", width: 260, sortable: true, filterable: true, render: (basePath, index) => <ToggleSwitch label="Individual" checked={Boolean(basePath.allow_individual)} disabled={locked} onChange={(checked) => patchBasePath(index, { allow_individual: checked })} />, value: (basePath) => basePath.allow_individual ? "individual" : "global only" },
|
||||||
|
{ id: "unsent_warning", header: "Unsent warning", width: 200, sortable: true, filterable: true, render: (basePath, index) => <ToggleSwitch label="Unsent" checked={Boolean(basePath.unsent_warning)} disabled={locked} onChange={(checked) => patchBasePath(index, { unsent_warning: checked })} />, value: (basePath) => basePath.unsent_warning ? "warn" : "off" },
|
||||||
|
{ id: "actions", header: "Actions", width: 120, sticky: "end", render: (_basePath, index) => <Button variant="danger" onClick={() => removeBasePath(index)} disabled={locked || basePaths.length <= 1}>Remove</Button> }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function MockPathChooserOverlay({ onClose, onSelect }: { onClose: () => void; onSelect: (path: Partial<AttachmentBasePath>) => void }) {
|
function MockPathChooserOverlay({ onClose, onSelect }: { onClose: () => void; onSelect: (path: Partial<AttachmentBasePath>) => void }) {
|
||||||
return createPortal(
|
return createPortal(
|
||||||
<div className="overlay-backdrop" role="dialog" aria-modal="true" aria-labelledby="mock-path-chooser-title">
|
<div className="overlay-backdrop" role="dialog" aria-modal="true" aria-labelledby="mock-path-chooser-title">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import type { ApiSettings } from "../../types";
|
import type { ApiSettings } from "../../types";
|
||||||
import Button from "../../components/Button";
|
import Button from "../../components/Button";
|
||||||
import Card from "../../components/Card";
|
import Card from "../../components/Card";
|
||||||
|
import DismissibleAlert from "../../components/DismissibleAlert";
|
||||||
import PageTitle from "../../components/PageTitle";
|
import PageTitle from "../../components/PageTitle";
|
||||||
import VersionLine from "./components/VersionLine";
|
import VersionLine from "./components/VersionLine";
|
||||||
import LoadingFrame from "../../components/LoadingFrame";
|
import LoadingFrame from "../../components/LoadingFrame";
|
||||||
@@ -22,7 +23,7 @@ export default function CampaignAuditPage({ settings, campaignId }: { settings:
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <div className="alert danger">{error}</div>}
|
{error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>}
|
||||||
|
|
||||||
<LoadingFrame loading={loading} label="Loading audit data…">
|
<LoadingFrame loading={loading} label="Loading audit data…">
|
||||||
<Card title="Recent audit events">
|
<Card title="Recent audit events">
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import { useCampaignDraftEditor } from "./hooks/useCampaignDraftEditor";
|
|||||||
import { asRecord, isAuditLockedVersion, isRecord } from "./utils/campaignView";
|
import { asRecord, isAuditLockedVersion, isRecord } from "./utils/campaignView";
|
||||||
import { getBool, getText, updateNested } from "./utils/draftEditor";
|
import { getBool, getText, updateNested } from "./utils/draftEditor";
|
||||||
import FieldValueInput from "./components/FieldValueInput";
|
import FieldValueInput from "./components/FieldValueInput";
|
||||||
|
import DismissibleAlert from "../../components/DismissibleAlert";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../components/table/DataGrid";
|
||||||
import { fieldTypeOptions, humanizeFieldName, normalizeFieldType, type CampaignFieldDefinition } from "./utils/fieldDefinitions";
|
import { fieldTypeOptions, humanizeFieldName, normalizeFieldType, type CampaignFieldDefinition } from "./utils/fieldDefinitions";
|
||||||
|
|
||||||
|
|
||||||
@@ -154,9 +156,9 @@ export default function CampaignFieldsPage({ settings, campaignId }: { settings:
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <div className="alert danger">{error}</div>}
|
{error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>}
|
||||||
{localError && <div className="alert danger">{localError}</div>}
|
{localError && <DismissibleAlert tone="danger" resetKey={localError}>{localError}</DismissibleAlert>}
|
||||||
{fieldNameWarning && <div className="alert warning">{fieldNameWarning}</div>}
|
{fieldNameWarning && <DismissibleAlert tone="warning" resetKey={fieldNameWarning}>{fieldNameWarning}</DismissibleAlert>}
|
||||||
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Create an editable copy before changing fields." />}
|
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Create an editable copy before changing fields." />}
|
||||||
|
|
||||||
<LoadingFrame loading={loading || !draft} label="Loading campaign draft…">
|
<LoadingFrame loading={loading || !draft} label="Loading campaign draft…">
|
||||||
@@ -165,42 +167,14 @@ export default function CampaignFieldsPage({ settings, campaignId }: { settings:
|
|||||||
title="Fields and global values"
|
title="Fields and global values"
|
||||||
actions={<Button variant="primary" onClick={addField} disabled={locked}>Add field</Button>}
|
actions={<Button variant="primary" onClick={addField} disabled={locked}>Add field</Button>}
|
||||||
>
|
>
|
||||||
<div className="app-table-wrap field-editor-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table field-editor-table">
|
id={`campaign-${campaignId}-fields`}
|
||||||
<thead>
|
rows={fields}
|
||||||
<tr>
|
columns={fieldColumns({ locked, globalValues, renameField, setField, setGlobalValue, setOverrideAllowed, deleteField })}
|
||||||
<th>Field ID</th>
|
getRowKey={(_field, index) => `field-row-${index}`}
|
||||||
<th>Label</th>
|
emptyText="No campaign fields configured yet."
|
||||||
<th>Type</th>
|
className="field-editor-table-wrap field-editor-table"
|
||||||
<th>Required</th>
|
/>
|
||||||
<th>Global value</th>
|
|
||||||
<th>Recipient override</th>
|
|
||||||
<th></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{fields.length === 0 ? (
|
|
||||||
<tr>
|
|
||||||
<td colSpan={7} className="empty-table-cell">No campaign fields configured yet.</td>
|
|
||||||
</tr>
|
|
||||||
) : fields.map((field, index) => (
|
|
||||||
<tr key={`field-row-${index}`}>
|
|
||||||
<td><input value={field.name} disabled={locked} placeholder="field_name" onChange={(event) => renameField(index, event.target.value)} /></td>
|
|
||||||
<td><input value={field.label} disabled={locked} placeholder="Display label" onChange={(event) => setField(index, { label: event.target.value })} /></td>
|
|
||||||
<td>
|
|
||||||
<select value={field.type} disabled={locked} onChange={(event) => setField(index, { type: normalizeFieldType(event.target.value) })}>
|
|
||||||
{fieldTypeOptions.map((option) => <option key={option} value={option}>{option}</option>)}
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td><ToggleSwitch label="Required" checked={field.required} disabled={locked} onChange={(checked) => setField(index, { required: checked })} /></td>
|
|
||||||
<td><FieldValueInput fieldType={field.type} value={globalValues[field.name]} disabled={locked || !field.name} placeholder="Optional default" onChange={(value) => setGlobalValue(field.name, value)} /></td>
|
|
||||||
<td><ToggleSwitch label="Can override" checked={field.can_override} disabled={locked || !field.name} onChange={(checked) => setOverrideAllowed(index, checked)} /></td>
|
|
||||||
<td className="table-action-cell"><Button variant="danger" disabled={locked} onClick={() => deleteField(index)}>Remove</Button></td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<div className="button-row page-bottom-actions">
|
<div className="button-row page-bottom-actions">
|
||||||
@@ -212,6 +186,28 @@ export default function CampaignFieldsPage({ settings, campaignId }: { settings:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type FieldColumnContext = {
|
||||||
|
locked: boolean;
|
||||||
|
globalValues: Record<string, unknown>;
|
||||||
|
renameField: (index: number, nextName: string) => void;
|
||||||
|
setField: (index: number, patchValue: Partial<CampaignFieldDefinition>) => void;
|
||||||
|
setGlobalValue: (key: string, value: unknown) => void;
|
||||||
|
setOverrideAllowed: (index: number, allowed: boolean) => void;
|
||||||
|
deleteField: (index: number) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
function fieldColumns({ locked, globalValues, renameField, setField, setGlobalValue, setOverrideAllowed, deleteField }: FieldColumnContext): DataGridColumn<CampaignFieldDefinition>[] {
|
||||||
|
return [
|
||||||
|
{ id: "name", header: "Field ID", width: 190, resizable: true, sortable: true, filterable: true, sticky: "start", render: (field, index) => <input value={field.name} disabled={locked} placeholder="field_name" onChange={(event) => renameField(index, event.target.value)} />, value: (field) => field.name },
|
||||||
|
{ id: "label", header: "Label", width: 210, resizable: true, sortable: true, filterable: true, render: (field, index) => <input value={field.label} disabled={locked} placeholder="Display label" onChange={(event) => setField(index, { label: event.target.value })} />, value: (field) => field.label },
|
||||||
|
{ id: "type", header: "Type", width: 140, sortable: true, filterable: true, render: (field, index) => <select value={field.type} disabled={locked} onChange={(event) => setField(index, { type: normalizeFieldType(event.target.value) })}>{fieldTypeOptions.map((option) => <option key={option} value={option}>{option}</option>)}</select>, value: (field) => field.type },
|
||||||
|
{ id: "required", header: "Required", width: 140, sortable: true, filterable: true, render: (field, index) => <ToggleSwitch label="Required" checked={field.required} disabled={locked} onChange={(checked) => setField(index, { required: checked })} />, value: (field) => field.required ? "required" : "optional" },
|
||||||
|
{ id: "global_value", header: "Global value", width: 220, resizable: true, filterable: true, render: (field) => <FieldValueInput fieldType={field.type} value={globalValues[field.name]} disabled={locked || !field.name} placeholder="Optional default" onChange={(value) => setGlobalValue(field.name, value)} />, value: (field) => String(globalValues[field.name] ?? "") },
|
||||||
|
{ id: "override", header: "Recipient override", width: 170, sortable: true, filterable: true, render: (field, index) => <ToggleSwitch label="Can override" checked={field.can_override} disabled={locked || !field.name} onChange={(checked) => setOverrideAllowed(index, checked)} />, value: (field) => field.can_override ? "can override" : "locked" },
|
||||||
|
{ id: "actions", header: "Actions", width: 120, sticky: "end", render: (_field, index) => <Button variant="danger" disabled={locked} onClick={() => deleteField(index)}>Remove</Button> }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function normalizeFields(value: unknown): CampaignFieldDefinition[] {
|
function normalizeFields(value: unknown): CampaignFieldDefinition[] {
|
||||||
if (!Array.isArray(value)) return [];
|
if (!Array.isArray(value)) return [];
|
||||||
return value.filter(isRecord).map((field) => ({
|
return value.filter(isRecord).map((field) => ({
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import type { ApiSettings } from "../../types";
|
import type { ApiSettings } from "../../types";
|
||||||
import Card from "../../components/Card";
|
import Card from "../../components/Card";
|
||||||
import Button from "../../components/Button";
|
import Button from "../../components/Button";
|
||||||
|
import DismissibleAlert from "../../components/DismissibleAlert";
|
||||||
import PageTitle from "../../components/PageTitle";
|
import PageTitle from "../../components/PageTitle";
|
||||||
import VersionLine from "./components/VersionLine";
|
import VersionLine from "./components/VersionLine";
|
||||||
import LoadingFrame from "../../components/LoadingFrame";
|
import LoadingFrame from "../../components/LoadingFrame";
|
||||||
@@ -27,7 +28,7 @@ export default function CampaignJsonView({ settings, campaignId }: { settings: A
|
|||||||
<Button onClick={() => downloadJson(filename, campaignJson)} disabled={!version}>Download JSON</Button>
|
<Button onClick={() => downloadJson(filename, campaignJson)} disabled={!version}>Download JSON</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert danger">{error}</div>}
|
{error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>}
|
||||||
<LoadingFrame loading={loading} label="Loading JSON…">
|
<LoadingFrame loading={loading} label="Loading JSON…">
|
||||||
<Card>
|
<Card>
|
||||||
{!loading || version ? <pre className="code-panel">{JSON.stringify(campaignJson, null, 2)}</pre> : <pre className="code-panel">{"{}"}</pre>}
|
{!loading || version ? <pre className="code-panel">{JSON.stringify(campaignJson, null, 2)}</pre> : <pre className="code-panel">{"{}"}</pre>}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import Button from "../../components/Button";
|
|||||||
import StatusBadge from "../../components/StatusBadge";
|
import StatusBadge from "../../components/StatusBadge";
|
||||||
import PageTitle from "../../components/PageTitle";
|
import PageTitle from "../../components/PageTitle";
|
||||||
import LoadingFrame from "../../components/LoadingFrame";
|
import LoadingFrame from "../../components/LoadingFrame";
|
||||||
|
import DismissibleAlert from "../../components/DismissibleAlert";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../components/table/DataGrid";
|
||||||
import { createNewCampaign, listCampaigns } from "../../api/campaigns";
|
import { createNewCampaign, listCampaigns } from "../../api/campaigns";
|
||||||
import type { CampaignListItem } from "../../types";
|
import type { CampaignListItem } from "../../types";
|
||||||
|
|
||||||
@@ -51,13 +53,69 @@ export default function CampaignListPage({ settings }: { settings: ApiSettings }
|
|||||||
load();
|
load();
|
||||||
}, [settings.apiBaseUrl, settings.apiKey, settings.accessToken]);
|
}, [settings.apiBaseUrl, settings.apiKey, settings.accessToken]);
|
||||||
|
|
||||||
|
const columns: DataGridColumn<CampaignListItem>[] = [
|
||||||
|
{
|
||||||
|
id: "campaign",
|
||||||
|
header: "Campaign",
|
||||||
|
width: "minmax(260px, 1.8fr)",
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
sticky: "start",
|
||||||
|
render: (campaign) => (
|
||||||
|
<div>
|
||||||
|
<Link className="table-primary-link" to={`/campaigns/${campaign.id}`}>
|
||||||
|
{campaign.name || campaign.external_id || campaign.id}
|
||||||
|
</Link>
|
||||||
|
<div className="table-subline">{campaign.description || campaign.external_id || campaign.id}</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
value: (campaign) => `${campaign.name ?? ""} ${campaign.external_id ?? ""} ${campaign.id}`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "status",
|
||||||
|
header: "Status",
|
||||||
|
width: 150,
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
render: (campaign) => <StatusBadge status={campaign.status || "draft"} />,
|
||||||
|
value: (campaign) => campaign.status || "draft"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "current_version",
|
||||||
|
header: "Current version",
|
||||||
|
width: 170,
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
className: "version-cell mono-small",
|
||||||
|
render: (campaign) => <span title={campaign.current_version_id || undefined}>{campaign.current_version_id ? shortId(campaign.current_version_id) : "—"}</span>,
|
||||||
|
value: (campaign) => campaign.current_version_id ?? ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "updated",
|
||||||
|
header: "Updated",
|
||||||
|
width: 190,
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
className: "updated-cell",
|
||||||
|
render: (campaign) => formatDateTime(campaign.updated_at ?? campaign.updatedAt ?? campaign.created_at),
|
||||||
|
value: (campaign) => campaign.updated_at ?? campaign.updatedAt ?? campaign.created_at ?? ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "actions",
|
||||||
|
header: "Actions",
|
||||||
|
width: 110,
|
||||||
|
sticky: "end",
|
||||||
|
render: (campaign) => <Link to={`/campaigns/${campaign.id}`}><Button variant="primary">Open</Button></Link>
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="content-pad campaigns-page">
|
<div className="content-pad campaigns-page">
|
||||||
{!hasAuth && (
|
{!hasAuth && (
|
||||||
<div className="alert warning">Sign in with your user account or configure an automation API key under Settings to load campaigns.</div>
|
<DismissibleAlert tone="warning">Sign in with your user account or configure an automation API key under Settings to load campaigns.</DismissibleAlert>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{error && <div className="alert danger">{error}</div>}
|
{error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>}
|
||||||
|
|
||||||
<div className="page-heading split workspace-heading">
|
<div className="page-heading split workspace-heading">
|
||||||
<div>
|
<div>
|
||||||
@@ -74,7 +132,7 @@ export default function CampaignListPage({ settings }: { settings: ApiSettings }
|
|||||||
|
|
||||||
<Card>
|
<Card>
|
||||||
<LoadingFrame loading={loading} label="Loading campaigns…">
|
<LoadingFrame loading={loading} label="Loading campaigns…">
|
||||||
{campaigns.length === 0 && (
|
{campaigns.length === 0 ? (
|
||||||
<div className="empty-state">
|
<div className="empty-state">
|
||||||
<h2>No campaigns yet</h2>
|
<h2>No campaigns yet</h2>
|
||||||
<p>Start with a guided campaign draft. The WebUI will create a portable campaign JSON in the background.</p>
|
<p>Start with a guided campaign draft. The WebUI will create a portable campaign JSON in the background.</p>
|
||||||
@@ -82,41 +140,15 @@ export default function CampaignListPage({ settings }: { settings: ApiSettings }
|
|||||||
Create first campaign
|
Create first campaign
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
) : (
|
||||||
{campaigns.length > 0 && (
|
<DataGrid
|
||||||
<div className="app-table-wrap campaign-table-wrap">
|
id="campaigns"
|
||||||
<table className="app-table campaign-table">
|
rows={campaigns}
|
||||||
<thead>
|
columns={columns}
|
||||||
<tr>
|
getRowKey={(campaign) => campaign.id}
|
||||||
<th>Campaign</th>
|
className="campaign-table-wrap"
|
||||||
<th>Status</th>
|
emptyText="No campaigns found."
|
||||||
<th>Current version</th>
|
/>
|
||||||
<th>Updated</th>
|
|
||||||
<th aria-label="Open"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{campaigns.map((campaign) => (
|
|
||||||
<tr key={campaign.id}>
|
|
||||||
<td>
|
|
||||||
<Link className="table-primary-link" to={`/campaigns/${campaign.id}`}>
|
|
||||||
{campaign.name || campaign.external_id || campaign.id}
|
|
||||||
</Link>
|
|
||||||
<div className="table-subline">{campaign.description || campaign.external_id || campaign.id}</div>
|
|
||||||
</td>
|
|
||||||
<td><StatusBadge status={campaign.status || "draft"} /></td>
|
|
||||||
<td className="version-cell mono-small" title={campaign.current_version_id || undefined}>
|
|
||||||
{campaign.current_version_id ? shortId(campaign.current_version_id) : "—"}
|
|
||||||
</td>
|
|
||||||
<td className="updated-cell">{formatDateTime(campaign.updated_at ?? campaign.updatedAt ?? campaign.created_at)}</td>
|
|
||||||
<td>
|
|
||||||
<Link to={`/campaigns/${campaign.id}`}><Button variant="primary">Open</Button></Link>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</LoadingFrame>
|
</LoadingFrame>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import FormField from "../../components/FormField";
|
|||||||
import LoadingFrame from "../../components/LoadingFrame";
|
import LoadingFrame from "../../components/LoadingFrame";
|
||||||
import PageTitle from "../../components/PageTitle";
|
import PageTitle from "../../components/PageTitle";
|
||||||
import StatusBadge from "../../components/StatusBadge";
|
import StatusBadge from "../../components/StatusBadge";
|
||||||
|
import DismissibleAlert from "../../components/DismissibleAlert";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../components/table/DataGrid";
|
||||||
import { publishCampaignVersion, updateCampaignMetadata, type CampaignVersionListItem } from "../../api/campaigns";
|
import { publishCampaignVersion, updateCampaignMetadata, type CampaignVersionListItem } from "../../api/campaigns";
|
||||||
import { useCampaignWorkspaceData } from "./hooks/useCampaignWorkspaceData";
|
import { useCampaignWorkspaceData } from "./hooks/useCampaignWorkspaceData";
|
||||||
import { canUnlockValidationVersion, formatDateTime, isFinalLockedVersion, isUserLockedVersion, isVersionReadyForDelivery, summaryValue } from "./utils/campaignView";
|
import { canUnlockValidationVersion, formatDateTime, isFinalLockedVersion, isUserLockedVersion, isVersionReadyForDelivery, summaryValue } from "./utils/campaignView";
|
||||||
@@ -94,8 +96,8 @@ export default function CampaignOverviewPage({ settings, campaignId }: { setting
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <div className="alert danger">{error}</div>}
|
{error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>}
|
||||||
{message && <div className="alert success">{message}</div>}
|
{message && <DismissibleAlert tone="success" resetKey={message}>{message}</DismissibleAlert>}
|
||||||
|
|
||||||
<LoadingFrame loading={loading} label="Loading campaign overview…">
|
<LoadingFrame loading={loading} label="Loading campaign overview…">
|
||||||
<Card title="Campaign identity">
|
<Card title="Campaign identity">
|
||||||
@@ -118,48 +120,15 @@ export default function CampaignOverviewPage({ settings, campaignId }: { setting
|
|||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title="Version history">
|
<Card title="Version history">
|
||||||
<div className="app-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table version-history-table">
|
id={`campaign-${campaignId}-versions`}
|
||||||
<thead>
|
rows={versions}
|
||||||
<tr>
|
columns={versionColumns(setLockingVersion)}
|
||||||
<th>Version</th>
|
getRowKey={(version) => version.id}
|
||||||
<th>State</th>
|
emptyText="No versions found."
|
||||||
<th>Lock</th>
|
className="version-history-table"
|
||||||
<th>Validation</th>
|
rowClassName={(version) => version.id === data.currentVersion?.id ? "current-version-row" : undefined}
|
||||||
<th>Build</th>
|
/>
|
||||||
<th>Updated</th>
|
|
||||||
<th aria-label="Actions"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{versions.length === 0 && (
|
|
||||||
<tr><td colSpan={7} className="muted">No versions found.</td></tr>
|
|
||||||
)}
|
|
||||||
{versions.map((version) => {
|
|
||||||
const isCurrentVersion = version.id === data.currentVersion?.id;
|
|
||||||
return (
|
|
||||||
<tr key={version.id} className={isCurrentVersion ? "current-version-row" : undefined}>
|
|
||||||
<td>#{version.version_number}</td>
|
|
||||||
<td><StatusBadge status={version.workflow_state ?? "editing"} /></td>
|
|
||||||
<td>{versionLockLabel(version)}</td>
|
|
||||||
<td>{validationLabel(version)}</td>
|
|
||||||
<td>{buildLabel(version)}</td>
|
|
||||||
<td>{formatDateTime(version.updated_at)}</td>
|
|
||||||
<td className="table-action-cell">
|
|
||||||
<div className="button-row compact-actions">
|
|
||||||
<Link to={`review?version=${version.id}`}><Button variant="primary">Open</Button></Link>
|
|
||||||
<Button
|
|
||||||
onClick={() => setLockingVersion(version)}
|
|
||||||
disabled={isUserLockedVersion(version) || isFinalLockedVersion(version) || canUnlockValidationVersion(version)}
|
|
||||||
>Lock</Button>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title="Current version state">
|
<Card title="Current version state">
|
||||||
@@ -186,6 +155,32 @@ export default function CampaignOverviewPage({ settings, campaignId }: { setting
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function versionColumns(setLockingVersion: (version: CampaignVersionListItem) => void): DataGridColumn<CampaignVersionListItem>[] {
|
||||||
|
return [
|
||||||
|
{ id: "version", header: "Version", width: 110, sortable: true, filterable: true, sticky: "start", render: (version) => `#${version.version_number}`, value: (version) => version.version_number ?? 0 },
|
||||||
|
{ id: "state", header: "State", width: 140, sortable: true, filterable: true, render: (version) => <StatusBadge status={version.workflow_state ?? "editing"} />, value: (version) => version.workflow_state ?? "editing" },
|
||||||
|
{ id: "lock", header: "Lock", width: 170, sortable: true, filterable: true, render: versionLockLabel, value: versionLockLabel },
|
||||||
|
{ id: "validation", header: "Validation", width: 170, sortable: true, filterable: true, render: validationLabel, value: validationLabel },
|
||||||
|
{ id: "build", header: "Build", width: 140, sortable: true, filterable: true, render: buildLabel, value: buildLabel },
|
||||||
|
{ id: "updated", header: "Updated", width: 190, sortable: true, filterable: true, render: (version) => formatDateTime(version.updated_at), value: (version) => version.updated_at ?? "" },
|
||||||
|
{
|
||||||
|
id: "actions",
|
||||||
|
header: "Actions",
|
||||||
|
width: 190,
|
||||||
|
sticky: "end",
|
||||||
|
render: (version) => (
|
||||||
|
<div className="button-row compact-actions">
|
||||||
|
<Link to={`send?version=${version.id}`}><Button variant="primary">Open</Button></Link>
|
||||||
|
<Button
|
||||||
|
onClick={() => setLockingVersion(version)}
|
||||||
|
disabled={isUserLockedVersion(version) || isFinalLockedVersion(version) || canUnlockValidationVersion(version)}
|
||||||
|
>Lock</Button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function versionLockLabel(version: CampaignVersionListItem): string {
|
function versionLockLabel(version: CampaignVersionListItem): string {
|
||||||
if (isUserLockedVersion(version)) return "User locked";
|
if (isUserLockedVersion(version)) return "User locked";
|
||||||
if (isFinalLockedVersion(version)) return "Final";
|
if (isFinalLockedVersion(version)) return "Final";
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import type { ApiSettings } from "../../types";
|
import type { ApiSettings } from "../../types";
|
||||||
import Card from "../../components/Card";
|
import Card from "../../components/Card";
|
||||||
import Button from "../../components/Button";
|
import Button from "../../components/Button";
|
||||||
|
import DismissibleAlert from "../../components/DismissibleAlert";
|
||||||
import PageTitle from "../../components/PageTitle";
|
import PageTitle from "../../components/PageTitle";
|
||||||
import VersionLine from "./components/VersionLine";
|
import VersionLine from "./components/VersionLine";
|
||||||
import LoadingFrame from "../../components/LoadingFrame";
|
import LoadingFrame from "../../components/LoadingFrame";
|
||||||
@@ -23,7 +24,7 @@ export default function CampaignReportPage({ settings, campaignId }: { settings:
|
|||||||
<Button onClick={reload} disabled={loading}>Reload</Button>
|
<Button onClick={reload} disabled={loading}>Reload</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{error && <div className="alert danger">{error}</div>}
|
{error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>}
|
||||||
<LoadingFrame loading={loading} label="Loading report data…">
|
<LoadingFrame loading={loading} label="Loading report data…">
|
||||||
<div className="dashboard-grid">
|
<div className="dashboard-grid">
|
||||||
<Card title="Report summary">
|
<Card title="Report summary">
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ function CampaignWorkspaceInner({ settings }: { settings: ApiSettings }) {
|
|||||||
<Route path="mail-settings" element={<MailSettingsPage settings={settings} campaignId={campaignId || ""} />} />
|
<Route path="mail-settings" element={<MailSettingsPage settings={settings} campaignId={campaignId || ""} />} />
|
||||||
<Route path="server-settings" element={<Navigate to="../mail-settings" replace />} />
|
<Route path="server-settings" element={<Navigate to="../mail-settings" replace />} />
|
||||||
<Route path="global-settings" element={<GlobalSettingsPage settings={settings} campaignId={campaignId || ""} />} />
|
<Route path="global-settings" element={<GlobalSettingsPage settings={settings} campaignId={campaignId || ""} />} />
|
||||||
|
<Route path="review" element={<Navigate to="../send" replace />} />
|
||||||
<Route path="send" element={<SendDataPage settings={settings} campaignId={campaignId || ""} />} />
|
<Route path="send" element={<SendDataPage settings={settings} campaignId={campaignId || ""} />} />
|
||||||
<Route path="report" element={<CampaignReportPage settings={settings} campaignId={campaignId || ""} />} />
|
<Route path="report" element={<CampaignReportPage settings={settings} campaignId={campaignId || ""} />} />
|
||||||
<Route path="reports" element={<Navigate to="../report" replace />} />
|
<Route path="reports" element={<Navigate to="../report" replace />} />
|
||||||
@@ -85,6 +86,8 @@ function CampaignWorkspaceInner({ settings }: { settings: ApiSettings }) {
|
|||||||
<Route path="campaign" element={<Navigate to="../data" replace />} />
|
<Route path="campaign" element={<Navigate to="../data" replace />} />
|
||||||
<Route path="mail" element={<Navigate to="../mail-settings" replace />} />
|
<Route path="mail" element={<Navigate to="../mail-settings" replace />} />
|
||||||
<Route path="settings" element={<Navigate to="../global-settings" replace />} />
|
<Route path="settings" element={<Navigate to="../global-settings" replace />} />
|
||||||
|
<Route path="Review" element={<Navigate to="../" replace />} />
|
||||||
|
<Route path="*" element={<Navigate to="../" replace />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
@@ -104,7 +107,7 @@ function sectionFromPath(pathname: string): CampaignWorkspaceSection {
|
|||||||
if (section === "template") return "template";
|
if (section === "template") return "template";
|
||||||
if (section === "files" || section === "attachments") return "files";
|
if (section === "files" || section === "attachments") return "files";
|
||||||
if (section === "mail-settings" || section === "server-settings" || section === "mail") return "mail-settings";
|
if (section === "mail-settings" || section === "server-settings" || section === "mail") return "mail-settings";
|
||||||
if (section === "review") return "review";
|
if (section === "review") return "send";
|
||||||
if (section === "send") return "send";
|
if (section === "send") return "send";
|
||||||
if (section === "report" || section === "reports") return "report";
|
if (section === "report" || section === "reports") return "report";
|
||||||
if (section === "audit") return "audit";
|
if (section === "audit") return "audit";
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import type { ApiSettings } from "../../types";
|
|||||||
import Button from "../../components/Button";
|
import Button from "../../components/Button";
|
||||||
import Card from "../../components/Card";
|
import Card from "../../components/Card";
|
||||||
import FormField from "../../components/FormField";
|
import FormField from "../../components/FormField";
|
||||||
|
import DismissibleAlert from "../../components/DismissibleAlert";
|
||||||
import PageTitle from "../../components/PageTitle";
|
import PageTitle from "../../components/PageTitle";
|
||||||
import LoadingFrame from "../../components/LoadingFrame";
|
import LoadingFrame from "../../components/LoadingFrame";
|
||||||
import LockedVersionNotice from "./components/LockedVersionNotice";
|
import LockedVersionNotice from "./components/LockedVersionNotice";
|
||||||
@@ -67,8 +68,8 @@ export default function GlobalSettingsPage({ settings, campaignId }: { settings:
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <div className="alert danger">{error}</div>}
|
{error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>}
|
||||||
{localError && <div className="alert danger">{localError}</div>}
|
{localError && <DismissibleAlert tone="danger" resetKey={localError}>{localError}</DismissibleAlert>}
|
||||||
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Create an editable copy before changing global settings." />}
|
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Create an editable copy before changing global settings." />}
|
||||||
|
|
||||||
<LoadingFrame loading={loading || !draft} label="Loading campaign draft…">
|
<LoadingFrame loading={loading || !draft} label="Loading campaign draft…">
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import LockedVersionNotice from "./components/LockedVersionNotice";
|
|||||||
import VersionLine from "./components/VersionLine";
|
import VersionLine from "./components/VersionLine";
|
||||||
import MessagePreviewOverlay, { type MessagePreviewAttachment } from "./components/MessagePreviewOverlay";
|
import MessagePreviewOverlay, { type MessagePreviewAttachment } from "./components/MessagePreviewOverlay";
|
||||||
import ToggleSwitch from "../../components/ToggleSwitch";
|
import ToggleSwitch from "../../components/ToggleSwitch";
|
||||||
|
import DismissibleAlert from "../../components/DismissibleAlert";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../components/table/DataGrid";
|
||||||
import { clearMockMailboxMessages, getMockMailboxMessage, listImapFolders, listMockMailboxMessages, testImapSettings, testSmtpSettings, updateMockMailboxFailures, type MailConnectionTestResponse, type MailImapFolderListResponse, type MailSecurity, type MockMailboxMessage } from "../../api/mail";
|
import { clearMockMailboxMessages, getMockMailboxMessage, listImapFolders, listMockMailboxMessages, testImapSettings, testSmtpSettings, updateMockMailboxFailures, type MailConnectionTestResponse, type MailImapFolderListResponse, type MailSecurity, type MockMailboxMessage } from "../../api/mail";
|
||||||
import { useCampaignWorkspaceData } from "./hooks/useCampaignWorkspaceData";
|
import { useCampaignWorkspaceData } from "./hooks/useCampaignWorkspaceData";
|
||||||
import { useCampaignDraftEditor } from "./hooks/useCampaignDraftEditor";
|
import { useCampaignDraftEditor } from "./hooks/useCampaignDraftEditor";
|
||||||
@@ -259,8 +261,8 @@ export default function MailSettingsPage({ settings, campaignId }: { settings: A
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <div className="alert danger">{error}</div>}
|
{error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>}
|
||||||
{localError && <div className="alert danger">{localError}</div>}
|
{localError && <DismissibleAlert tone="danger" resetKey={localError}>{localError}</DismissibleAlert>}
|
||||||
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Create an editable copy before changing server settings." />}
|
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Create an editable copy before changing server settings." />}
|
||||||
|
|
||||||
<LoadingFrame loading={loading || !draft} label="Loading campaign draft…">
|
<LoadingFrame loading={loading || !draft} label="Loading campaign draft…">
|
||||||
@@ -329,36 +331,15 @@ export default function MailSettingsPage({ settings, campaignId }: { settings: A
|
|||||||
<Button variant="danger" onClick={clearMockMailbox} disabled={mailActionState === "mock" || mockMessages.length === 0}>Clear</Button>
|
<Button variant="danger" onClick={clearMockMailbox} disabled={mailActionState === "mock" || mockMessages.length === 0}>Clear</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{mockError && <div className="alert danger">{mockError}</div>}
|
{mockError && <DismissibleAlert tone="danger" resetKey={mockError}>{mockError}</DismissibleAlert>}
|
||||||
<div className="table-wrap">
|
<DataGrid
|
||||||
<table className="data-table">
|
id={`campaign-${campaignId}-server-mock-mailbox`}
|
||||||
<thead>
|
rows={mockMessages}
|
||||||
<tr>
|
columns={mockMailboxColumns(openMockMessage)}
|
||||||
<th>Kind</th>
|
getRowKey={(message) => message.id}
|
||||||
<th>Received</th>
|
emptyText="No mock messages captured yet."
|
||||||
<th>Subject</th>
|
className="data-table compact-table"
|
||||||
<th>Envelope</th>
|
/>
|
||||||
<th>Attachments</th>
|
|
||||||
<th>Actions</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{mockMessages.map((message) => (
|
|
||||||
<tr key={message.id}>
|
|
||||||
<td><span className="status-badge neutral">{message.kind === "imap_append" ? "IMAP" : "SMTP"}</span></td>
|
|
||||||
<td>{formatMockDate(message.created_at)}</td>
|
|
||||||
<td>{message.subject || "—"}</td>
|
|
||||||
<td>{message.envelope_from || message.folder || "—"} → {(message.envelope_recipients || []).join(", ") || message.folder || "—"}</td>
|
|
||||||
<td>{message.attachment_count ?? 0}</td>
|
|
||||||
<td><Button onClick={() => openMockMessage(message.id)}>Open</Button></td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
{mockMessages.length === 0 && (
|
|
||||||
<tr><td colSpan={6}>No mock messages captured yet.</td></tr>
|
|
||||||
)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
@@ -415,6 +396,17 @@ function formatMockDate(value: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function mockMailboxColumns(openMockMessage: (id: string) => Promise<void>): DataGridColumn<MockMailboxMessage>[] {
|
||||||
|
return [
|
||||||
|
{ id: "kind", header: "Kind", width: 110, sortable: true, filterable: true, sticky: "start", render: (message) => <span className="status-badge neutral">{message.kind === "imap_append" ? "IMAP" : "SMTP"}</span>, value: (message) => message.kind === "imap_append" ? "IMAP" : "SMTP" },
|
||||||
|
{ id: "received", header: "Received", width: 180, sortable: true, filterable: true, value: (message) => formatMockDate(message.created_at), sortValue: (message) => message.created_at ?? "" },
|
||||||
|
{ id: "subject", header: "Subject", width: "minmax(240px, 1fr)", sortable: true, filterable: true, value: (message) => message.subject || "—" },
|
||||||
|
{ id: "envelope", header: "Envelope", width: 300, resizable: true, filterable: true, value: (message) => `${message.envelope_from || message.folder || "—"} → ${(message.envelope_recipients || []).join(", ") || message.folder || "—"}` },
|
||||||
|
{ id: "attachments", header: "Attachments", width: 130, sortable: true, filterable: true, value: (message) => String(message.attachment_count ?? 0) },
|
||||||
|
{ id: "actions", header: "Actions", width: 110, sticky: "end", render: (message) => <Button onClick={() => openMockMessage(message.id)}>Open</Button> }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function MailActionResult({ result }: { result: MailConnectionTestResponse | null }) {
|
function MailActionResult({ result }: { result: MailConnectionTestResponse | null }) {
|
||||||
if (!result) return null;
|
if (!result) return null;
|
||||||
const authenticated = result.details?.authenticated;
|
const authenticated = result.details?.authenticated;
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import LockedVersionNotice from "./components/LockedVersionNotice";
|
|||||||
import VersionLine from "./components/VersionLine";
|
import VersionLine from "./components/VersionLine";
|
||||||
import ToggleSwitch from "../../components/ToggleSwitch";
|
import ToggleSwitch from "../../components/ToggleSwitch";
|
||||||
import EmailAddressInput from "../../components/email/EmailAddressInput";
|
import EmailAddressInput from "../../components/email/EmailAddressInput";
|
||||||
|
import DismissibleAlert from "../../components/DismissibleAlert";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../components/table/DataGrid";
|
||||||
import { useCampaignWorkspaceData } from "./hooks/useCampaignWorkspaceData";
|
import { useCampaignWorkspaceData } from "./hooks/useCampaignWorkspaceData";
|
||||||
import { useCampaignDraftEditor } from "./hooks/useCampaignDraftEditor";
|
import { useCampaignDraftEditor } from "./hooks/useCampaignDraftEditor";
|
||||||
import { asArray, asRecord, isAuditLockedVersion } from "./utils/campaignView";
|
import { asArray, asRecord, isAuditLockedVersion } from "./utils/campaignView";
|
||||||
@@ -134,8 +136,8 @@ export default function RecipientDataPage({ settings, campaignId }: { settings:
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <div className="alert danger">{error}</div>}
|
{error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>}
|
||||||
{localError && <div className="alert danger">{localError}</div>}
|
{localError && <DismissibleAlert tone="danger" resetKey={localError}>{localError}</DismissibleAlert>}
|
||||||
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Create an editable copy before changing sender or recipient profiles." />}
|
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Create an editable copy before changing sender or recipient profiles." />}
|
||||||
|
|
||||||
<LoadingFrame loading={loading || !draft} label="Loading campaign draft…">
|
<LoadingFrame loading={loading || !draft} label="Loading campaign draft…">
|
||||||
@@ -224,51 +226,17 @@ export default function RecipientDataPage({ settings, campaignId }: { settings:
|
|||||||
>
|
>
|
||||||
{inlineEntries.length === 0 && !source.type && <p className="muted">No recipient profiles are stored in the current version yet.</p>}
|
{inlineEntries.length === 0 && !source.type && <p className="muted">No recipient profiles are stored in the current version yet.</p>}
|
||||||
{inlineEntries.length === 0 && Boolean(source.type) && (
|
{inlineEntries.length === 0 && Boolean(source.type) && (
|
||||||
<div className="alert info">This campaign references an external recipient source. A parsed preview table will be added when file/source preview support is implemented.</div>
|
<DismissibleAlert tone="info">This campaign references an external recipient source. A parsed preview table will be added when file/source preview support is implemented.</DismissibleAlert>
|
||||||
)}
|
)}
|
||||||
{inlineEntries.length > 0 && (
|
{inlineEntries.length > 0 && (
|
||||||
<div className="app-table-wrap recipient-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table recipient-table recipient-address-table">
|
id={`campaign-${campaignId}-recipient-profiles`}
|
||||||
<thead>
|
rows={inlineEntries.slice(0, 100)}
|
||||||
<tr>
|
columns={recipientProfileColumns({ locked, entryAddressColumns, addressSuggestions, updateEntryAddressList, updateEntry, removeEntry })}
|
||||||
<th>#</th>
|
getRowKey={(entry, index) => String(entry.id || index)}
|
||||||
{entryAddressColumns.map((column) => <th key={column.key}>{column.label}</th>)}
|
emptyText="No recipient profiles are stored in the current version yet."
|
||||||
<th>Active</th>
|
className="recipient-table-wrap recipient-address-table"
|
||||||
<th aria-label="Actions"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{inlineEntries.slice(0, 100).map((entry, index) => (
|
|
||||||
<tr key={String(entry.id || index)}>
|
|
||||||
<td className="mono-small">{index + 1}</td>
|
|
||||||
{entryAddressColumns.map((column) => (
|
|
||||||
<td key={column.key}>
|
|
||||||
<EmailAddressInput
|
|
||||||
value={getEntryAddresses(entry, column.key)}
|
|
||||||
suggestions={addressSuggestions}
|
|
||||||
allowMultiple={column.allowMultiple}
|
|
||||||
compact
|
|
||||||
disabled={locked}
|
|
||||||
addLabel={column.addLabel}
|
|
||||||
emptyText={column.emptyText}
|
|
||||||
onChange={(addresses) => updateEntryAddressList(index, column.key, addresses)}
|
|
||||||
/>
|
/>
|
||||||
</td>
|
|
||||||
))}
|
|
||||||
<td>
|
|
||||||
<ToggleSwitch
|
|
||||||
label="Active"
|
|
||||||
checked={entry.active !== false}
|
|
||||||
disabled={locked}
|
|
||||||
onChange={(checked) => updateEntry(index, (current) => ({ ...current, active: checked }))}
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td className="table-action-cell"><Button variant="danger" onClick={() => removeEntry(index)} disabled={locked}>Remove</Button></td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
@@ -281,6 +249,43 @@ export default function RecipientDataPage({ settings, campaignId }: { settings:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RecipientProfileColumnContext = {
|
||||||
|
locked: boolean;
|
||||||
|
entryAddressColumns: EntryAddressColumn[];
|
||||||
|
addressSuggestions: MailboxAddress[];
|
||||||
|
updateEntryAddressList: (index: number, key: EntryAddressColumn["key"], addresses: MailboxAddress[]) => void;
|
||||||
|
updateEntry: (index: number, updater: (entry: Record<string, unknown>) => Record<string, unknown>) => void;
|
||||||
|
removeEntry: (index: number) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
function recipientProfileColumns({ locked, entryAddressColumns, addressSuggestions, updateEntryAddressList, updateEntry, removeEntry }: RecipientProfileColumnContext): DataGridColumn<Record<string, unknown>>[] {
|
||||||
|
return [
|
||||||
|
{ id: "number", header: "#", width: 70, sortable: true, sticky: "start", render: (_entry, index) => <span className="mono-small">{index + 1}</span>, value: (_entry, index) => index + 1 },
|
||||||
|
...entryAddressColumns.map((column): DataGridColumn<Record<string, unknown>> => ({
|
||||||
|
id: column.key,
|
||||||
|
header: column.label,
|
||||||
|
width: column.key === "to" ? "minmax(260px, 1.2fr)" : 250,
|
||||||
|
resizable: true,
|
||||||
|
filterable: true,
|
||||||
|
render: (entry, index) => (
|
||||||
|
<EmailAddressInput
|
||||||
|
value={getEntryAddresses(entry, column.key)}
|
||||||
|
suggestions={addressSuggestions}
|
||||||
|
allowMultiple={column.allowMultiple}
|
||||||
|
compact
|
||||||
|
disabled={locked}
|
||||||
|
addLabel={column.addLabel}
|
||||||
|
emptyText={column.emptyText}
|
||||||
|
onChange={(addresses) => updateEntryAddressList(index, column.key, addresses)}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
value: (entry) => getEntryAddresses(entry, column.key).map((address) => `${address.name ?? ""} ${address.email ?? ""}`).join(", ")
|
||||||
|
})),
|
||||||
|
{ id: "active", header: "Active", width: 130, sortable: true, filterable: true, render: (entry, index) => <ToggleSwitch label="Active" checked={entry.active !== false} disabled={locked} onChange={(checked) => updateEntry(index, (current) => ({ ...current, active: checked }))} />, value: (entry) => entry.active !== false ? "active" : "inactive" },
|
||||||
|
{ id: "actions", header: "Actions", width: 120, sticky: "end", render: (_entry, index) => <Button variant="danger" onClick={() => removeEntry(index)} disabled={locked}>Remove</Button> }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function getEntryAddresses(entry: Record<string, unknown>, key: EntryAddressColumn["key"]): MailboxAddress[] {
|
function getEntryAddresses(entry: Record<string, unknown>, key: EntryAddressColumn["key"]): MailboxAddress[] {
|
||||||
if (key === "to") {
|
if (key === "to") {
|
||||||
const explicit = addressesFromValue(entry.to);
|
const explicit = addressesFromValue(entry.to);
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import AttachmentRulesOverlay from "./components/AttachmentRulesOverlay";
|
|||||||
import { getDraftFields } from "./utils/fieldDefinitions";
|
import { getDraftFields } from "./utils/fieldDefinitions";
|
||||||
import { getIndividualAttachmentBasePaths, normalizeAttachmentBasePaths, normalizeAttachmentRules, type AttachmentRule } from "./utils/attachments";
|
import { getIndividualAttachmentBasePaths, normalizeAttachmentBasePaths, normalizeAttachmentRules, type AttachmentRule } from "./utils/attachments";
|
||||||
import { addressesFromValue } from "../../utils/emailAddresses";
|
import { addressesFromValue } from "../../utils/emailAddresses";
|
||||||
|
import DismissibleAlert from "../../components/DismissibleAlert";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../components/table/DataGrid";
|
||||||
|
|
||||||
|
|
||||||
export default function RecipientDetailsPage({ settings, campaignId }: { settings: ApiSettings; campaignId: string }) {
|
export default function RecipientDetailsPage({ settings, campaignId }: { settings: ApiSettings; campaignId: string }) {
|
||||||
@@ -79,8 +81,8 @@ export default function RecipientDetailsPage({ settings, campaignId }: { setting
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <div className="alert danger">{error}</div>}
|
{error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>}
|
||||||
{localError && <div className="alert danger">{localError}</div>}
|
{localError && <DismissibleAlert tone="danger" resetKey={localError}>{localError}</DismissibleAlert>}
|
||||||
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Create an editable copy before changing recipient data." />}
|
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Create an editable copy before changing recipient data." />}
|
||||||
|
|
||||||
<LoadingFrame loading={loading || !draft} label="Loading campaign draft…">
|
<LoadingFrame loading={loading || !draft} label="Loading campaign draft…">
|
||||||
@@ -88,59 +90,17 @@ export default function RecipientDetailsPage({ settings, campaignId }: { setting
|
|||||||
<Card title="Recipient field values and attachments">
|
<Card title="Recipient field values and attachments">
|
||||||
{inlineEntries.length === 0 && !source.type && <p className="muted">No recipient profiles are stored in the current version yet. Add recipients first, then maintain their data here.</p>}
|
{inlineEntries.length === 0 && !source.type && <p className="muted">No recipient profiles are stored in the current version yet. Add recipients first, then maintain their data here.</p>}
|
||||||
{inlineEntries.length === 0 && Boolean(source.type) && (
|
{inlineEntries.length === 0 && Boolean(source.type) && (
|
||||||
<div className="alert info">This campaign references an external recipient source. A parsed data preview will be added when file/source preview support is implemented.</div>
|
<DismissibleAlert tone="info">This campaign references an external recipient source. A parsed data preview will be added when file/source preview support is implemented.</DismissibleAlert>
|
||||||
)}
|
)}
|
||||||
{inlineEntries.length > 0 && (
|
{inlineEntries.length > 0 && (
|
||||||
<div className="app-table-wrap recipient-table-wrap recipient-data-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table recipient-table recipient-data-table">
|
id={`campaign-${campaignId}-recipient-data`}
|
||||||
<thead>
|
rows={inlineEntries.slice(0, 100)}
|
||||||
<tr>
|
columns={recipientDataColumns({ locked, fieldDefinitions, individualAttachmentBasePaths, updateEntryAttachments, updateEntryField })}
|
||||||
<th>#</th>
|
getRowKey={(entry, index) => String(entry.id || index)}
|
||||||
<th>Recipient</th>
|
emptyText="No recipient data found."
|
||||||
<th>Attachments</th>
|
className="recipient-table-wrap recipient-data-table-wrap recipient-data-table"
|
||||||
{fieldDefinitions.map((field) => <th key={field.name}>{field.label || field.name}</th>)}
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{inlineEntries.slice(0, 100).map((entry, index) => {
|
|
||||||
const fields = asRecord(entry.fields);
|
|
||||||
const attachments = normalizeAttachmentRules(entry.attachments);
|
|
||||||
return (
|
|
||||||
<tr key={String(entry.id || index)}>
|
|
||||||
<td className="mono-small recipient-index-cell">{index + 1}</td>
|
|
||||||
<td className="recipient-data-identity-cell">
|
|
||||||
<Link className="recipient-data-identity" to="../recipients" title="Open recipient address profile">
|
|
||||||
<span className="recipient-data-address">{firstRecipientEmail(entry) || "No To address"}</span>
|
|
||||||
{extraRecipientCount(entry) > 0 && <span className="recipient-extra-bubble">+{extraRecipientCount(entry)}</span>}
|
|
||||||
</Link>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<AttachmentRulesOverlay
|
|
||||||
title={`Attachments for recipient ${index + 1}`}
|
|
||||||
rules={attachments}
|
|
||||||
disabled={locked}
|
|
||||||
basePaths={individualAttachmentBasePaths}
|
|
||||||
onChange={(rules) => updateEntryAttachments(index, rules)}
|
|
||||||
/>
|
/>
|
||||||
</td>
|
|
||||||
{fieldDefinitions.map((field) => (
|
|
||||||
<td key={field.name}>
|
|
||||||
<FieldValueInput
|
|
||||||
className="recipient-field-input"
|
|
||||||
fieldType={field.type}
|
|
||||||
value={fields[field.name]}
|
|
||||||
disabled={locked || field.can_override === false}
|
|
||||||
placeholder={field.can_override === false ? "Uses global value" : undefined}
|
|
||||||
onChange={(value) => updateEntryField(index, field.name, value)}
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
))}
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
@@ -153,6 +113,77 @@ export default function RecipientDetailsPage({ settings, campaignId }: { setting
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RecipientDataColumnContext = {
|
||||||
|
locked: boolean;
|
||||||
|
fieldDefinitions: ReturnType<typeof getDraftFields>;
|
||||||
|
individualAttachmentBasePaths: ReturnType<typeof getIndividualAttachmentBasePaths>;
|
||||||
|
updateEntryAttachments: (index: number, attachments: AttachmentRule[]) => void;
|
||||||
|
updateEntryField: (index: number, field: string, value: unknown) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
function recipientDataColumns({ locked, fieldDefinitions, individualAttachmentBasePaths, updateEntryAttachments, updateEntryField }: RecipientDataColumnContext): DataGridColumn<Record<string, unknown>>[] {
|
||||||
|
return [
|
||||||
|
{ id: "number", header: "#", width: 70, sortable: true, sticky: "start", render: (_entry, index) => <span className="mono-small recipient-index-cell">{index + 1}</span>, value: (_entry, index) => index + 1 },
|
||||||
|
{
|
||||||
|
id: "recipient",
|
||||||
|
header: "Recipient",
|
||||||
|
width: 260,
|
||||||
|
resizable: true,
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
sticky: "start",
|
||||||
|
render: (entry) => (
|
||||||
|
<Link className="recipient-data-identity" to="../recipients" title="Open recipient address profile">
|
||||||
|
<span className="recipient-data-address">{firstRecipientEmail(entry) || "No To address"}</span>
|
||||||
|
{extraRecipientCount(entry) > 0 && <span className="recipient-extra-bubble">+{extraRecipientCount(entry)}</span>}
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
value: firstRecipientEmail
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "attachments",
|
||||||
|
header: "Attachments",
|
||||||
|
width: 180,
|
||||||
|
filterable: true,
|
||||||
|
render: (entry, index) => {
|
||||||
|
const attachments = normalizeAttachmentRules(entry.attachments);
|
||||||
|
return (
|
||||||
|
<AttachmentRulesOverlay
|
||||||
|
title={`Attachments for recipient ${index + 1}`}
|
||||||
|
rules={attachments}
|
||||||
|
disabled={locked}
|
||||||
|
basePaths={individualAttachmentBasePaths}
|
||||||
|
onChange={(rules) => updateEntryAttachments(index, rules)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
value: (entry) => normalizeAttachmentRules(entry.attachments).map((rule) => `${rule.label ?? ""} ${rule.file_filter ?? ""}`).join(", ")
|
||||||
|
},
|
||||||
|
...fieldDefinitions.map((field): DataGridColumn<Record<string, unknown>> => ({
|
||||||
|
id: `field-${field.name}`,
|
||||||
|
header: field.label || field.name,
|
||||||
|
width: 190,
|
||||||
|
resizable: true,
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
render: (entry, index) => {
|
||||||
|
const fields = asRecord(entry.fields);
|
||||||
|
return (
|
||||||
|
<FieldValueInput
|
||||||
|
className="recipient-field-input"
|
||||||
|
fieldType={field.type}
|
||||||
|
value={fields[field.name]}
|
||||||
|
disabled={locked || field.can_override === false}
|
||||||
|
placeholder={field.can_override === false ? "Uses global value" : undefined}
|
||||||
|
onChange={(value) => updateEntryField(index, field.name, value)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
value: (entry) => String(asRecord(entry.fields)[field.name] ?? "")
|
||||||
|
}))
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function firstRecipientEmail(entry: Record<string, unknown>): string {
|
function firstRecipientEmail(entry: Record<string, unknown>): string {
|
||||||
return (addressesFromValue(entry.to)[0] ?? addressesFromValue(entry.recipient)[0] ?? addressesFromValue(entry)[0])?.email ?? "";
|
return (addressesFromValue(entry.to)[0] ?? addressesFromValue(entry.recipient)[0] ?? addressesFromValue(entry)[0])?.email ?? "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import Card from "../../components/Card";
|
|||||||
import MetricCard from "../../components/MetricCard";
|
import MetricCard from "../../components/MetricCard";
|
||||||
import StatusBadge from "../../components/StatusBadge";
|
import StatusBadge from "../../components/StatusBadge";
|
||||||
import ToggleSwitch from "../../components/ToggleSwitch";
|
import ToggleSwitch from "../../components/ToggleSwitch";
|
||||||
|
import DismissibleAlert from "../../components/DismissibleAlert";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../components/table/DataGrid";
|
||||||
import { mockSendCampaign, sendCampaignNow } from "../../api/campaigns";
|
import { mockSendCampaign, sendCampaignNow } from "../../api/campaigns";
|
||||||
import { getMockMailboxMessage, type MockMailboxMessage } from "../../api/mail";
|
import { getMockMailboxMessage, type MockMailboxMessage } from "../../api/mail";
|
||||||
import { useCampaignWorkspaceData } from "./hooks/useCampaignWorkspaceData";
|
import { useCampaignWorkspaceData } from "./hooks/useCampaignWorkspaceData";
|
||||||
@@ -146,9 +148,9 @@ export default function SendDataPage({ settings, campaignId }: { settings: ApiSe
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <div className="alert danger">{error}</div>}
|
{error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>}
|
||||||
{sendMessage && <div className="alert info">{sendMessage}</div>}
|
{sendMessage && <DismissibleAlert tone="info" resetKey={sendMessage}>{sendMessage}</DismissibleAlert>}
|
||||||
{mockMessage && <div className="alert info">{mockMessage}</div>}
|
{mockMessage && <DismissibleAlert tone="info" resetKey={mockMessage}>{mockMessage}</DismissibleAlert>}
|
||||||
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Send snapshot. Copy to edit." />}
|
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Send snapshot. Copy to edit." />}
|
||||||
|
|
||||||
<LoadingFrame loading={loading || queuedOrSending} label={queuedOrSending ? "Refreshing send state…" : "Loading send data…"}>
|
<LoadingFrame loading={loading || queuedOrSending} label={queuedOrSending ? "Refreshing send state…" : "Loading send data…"}>
|
||||||
@@ -181,89 +183,49 @@ export default function SendDataPage({ settings, campaignId }: { settings: ApiSe
|
|||||||
|
|
||||||
{mockResult && (
|
{mockResult && (
|
||||||
<div className="mock-flow-panel">
|
<div className="mock-flow-panel">
|
||||||
<div className="app-table-wrap data-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table data-table compact-table">
|
id={`campaign-${campaignId}-mock-steps`}
|
||||||
<thead><tr><th>Step</th><th>Status</th><th>Summary</th></tr></thead>
|
rows={mockSteps}
|
||||||
<tbody>
|
columns={mockStepColumns()}
|
||||||
{mockSteps.map((step) => (
|
getRowKey={(step, index) => String(step.key ?? index)}
|
||||||
<tr key={String(step.key)}>
|
emptyText="No mock steps returned."
|
||||||
<td>{String(step.label ?? step.key)}</td>
|
className="data-table-wrap data-table compact-table"
|
||||||
<td><StatusBadge status={String(step.status ?? "info")} /></td>
|
/>
|
||||||
<td>{stringifyPreview(asRecord(step.summary), 240)}</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h3>Built messages</h3>
|
<h3>Built messages</h3>
|
||||||
<div className="app-table-wrap data-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table data-table compact-table">
|
id={`campaign-${campaignId}-mock-built-messages`}
|
||||||
<thead><tr><th>#</th><th>Recipient</th><th>Subject</th><th>Validation</th><th>Attachments</th><th>Issues</th></tr></thead>
|
rows={mockMessages}
|
||||||
<tbody>
|
columns={mockBuiltMessageColumns()}
|
||||||
{mockMessages.map((message) => {
|
getRowKey={(message, index) => String(message.entry_index ?? message.entry_id ?? index)}
|
||||||
const to = asArray(message.to).map(asRecord);
|
emptyText="No messages were built."
|
||||||
const issues = asArray(message.issues).map(asRecord);
|
className="data-table-wrap data-table compact-table"
|
||||||
return (
|
/>
|
||||||
<tr key={String(message.entry_index ?? message.entry_id)}>
|
|
||||||
<td>{String(message.entry_index ?? "—")}</td>
|
|
||||||
<td>{to.map((item) => String(item.email ?? "")).filter(Boolean).join(", ") || "—"}</td>
|
|
||||||
<td>{String(message.subject ?? "—")}</td>
|
|
||||||
<td><StatusBadge status={String(message.validation_status ?? "unknown")} /></td>
|
|
||||||
<td>{String(message.attachment_count ?? 0)}</td>
|
|
||||||
<td>{issues.length === 0 ? "—" : issues.map((issue) => String(issue.message ?? issue.code ?? "issue")).join(" · ")}</td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
{mockMessages.length === 0 && <tr><td colSpan={6}>No messages were built.</td></tr>}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{mockRows.length > 0 && (
|
{mockRows.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<h3>Mock send results</h3>
|
<h3>Mock send results</h3>
|
||||||
<div className="app-table-wrap data-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table data-table compact-table">
|
id={`campaign-${campaignId}-mock-send-results`}
|
||||||
<thead><tr><th>#</th><th>Status</th><th>Recipient</th><th>SMTP</th><th>IMAP</th><th>Message</th></tr></thead>
|
rows={mockRows}
|
||||||
<tbody>
|
columns={mockSendResultColumns()}
|
||||||
{mockRows.map((row, index) => {
|
getRowKey={(_row, index) => `mock-send-${index}`}
|
||||||
const to = asArray(row.to).map(asRecord);
|
emptyText="No mock send results returned."
|
||||||
return (
|
className="data-table-wrap data-table compact-table"
|
||||||
<tr key={index}>
|
/>
|
||||||
<td>{String(row.entry_index ?? index + 1)}</td>
|
|
||||||
<td><StatusBadge status={String(row.status ?? "info")} /></td>
|
|
||||||
<td>{to.map((item) => String(item.email ?? "")).filter(Boolean).join(", ") || "—"}</td>
|
|
||||||
<td>{String(row.smtp_message_id ?? row.status ?? "—")}</td>
|
|
||||||
<td>{String(row.imap_message_id ?? row.imap_status ?? "—")}</td>
|
|
||||||
<td>{String(row.message ?? "—")}</td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<h3>Mock mailbox</h3>
|
<h3>Mock mailbox</h3>
|
||||||
<div className="app-table-wrap data-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table data-table compact-table">
|
id={`campaign-${campaignId}-mock-mailbox`}
|
||||||
<thead><tr><th>Kind</th><th>Subject</th><th>Envelope / folder</th><th>Attachments</th><th>Actions</th></tr></thead>
|
rows={mockMailboxMessages}
|
||||||
<tbody>
|
columns={mockMailboxColumns(openMockMessage)}
|
||||||
{mockMailboxMessages.map((message) => (
|
getRowKey={(message, index) => String(message.id ?? index)}
|
||||||
<tr key={String(message.id)}>
|
emptyText="No mock messages captured in this run."
|
||||||
<td><span className="status-badge neutral">{String(message.kind ?? "mock")}</span></td>
|
className="data-table-wrap data-table compact-table"
|
||||||
<td>{String(message.subject ?? "—")}</td>
|
/>
|
||||||
<td>{String(message.envelope_from ?? message.folder ?? "—")} → {asArray(message.envelope_recipients).join(", ") || String(message.folder ?? "—")}</td>
|
|
||||||
<td>{String(message.attachment_count ?? 0)}</td>
|
|
||||||
<td><Button onClick={() => void openMockMessage(String(message.id))}>Open</Button></td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
{mockMailboxMessages.length === 0 && <tr><td colSpan={5}>No mock messages captured in this run.</td></tr>}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@@ -271,8 +233,8 @@ export default function SendDataPage({ settings, campaignId }: { settings: ApiSe
|
|||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card title="Send campaign" actions={<span className="muted small-note">Requires a validated, locked and built version. Sending makes it final.</span>}>
|
<Card title="Send campaign" actions={<span className="muted small-note">Requires a validated, locked and built version. Sending makes it final.</span>}>
|
||||||
{!readyForDelivery && <div className="alert warning compact-alert">Validate and lock this version in Review before dry-run or sending.</div>}
|
{!readyForDelivery && <DismissibleAlert tone="warning" compact>Validate and lock this version in Review before dry-run or sending.</DismissibleAlert>}
|
||||||
{readyForDelivery && !hasBuild && <div className="alert warning compact-alert">Build the queue in Review before dry-run or sending.</div>}
|
{readyForDelivery && !hasBuild && <DismissibleAlert tone="warning" compact>Build the queue in Review before dry-run or sending.</DismissibleAlert>}
|
||||||
<div className="button-row compact-actions">
|
<div className="button-row compact-actions">
|
||||||
<Button onClick={() => void runSendNow(true)} disabled={!version || loading || sendBusy || !readyForDelivery || !hasBuild}>Dry run</Button>
|
<Button onClick={() => void runSendNow(true)} disabled={!version || loading || sendBusy || !readyForDelivery || !hasBuild}>Dry run</Button>
|
||||||
<Button variant="primary" onClick={() => setSendConfirmOpen(true)} disabled={!version || loading || sendBusy || !readyForDelivery || !hasBuild}>
|
<Button variant="primary" onClick={() => setSendConfirmOpen(true)} disabled={!version || loading || sendBusy || !readyForDelivery || !hasBuild}>
|
||||||
@@ -292,22 +254,14 @@ export default function SendDataPage({ settings, campaignId }: { settings: ApiSe
|
|||||||
Attempted {String(sendResult.attempted_count ?? "—")}, sent {String(sendResult.sent_count ?? "—")}, failed {String(sendResult.failed_count ?? "—")}, skipped {String(sendResult.skipped_count ?? "—")}.
|
Attempted {String(sendResult.attempted_count ?? "—")}, sent {String(sendResult.sent_count ?? "—")}, failed {String(sendResult.failed_count ?? "—")}, skipped {String(sendResult.skipped_count ?? "—")}.
|
||||||
</p>
|
</p>
|
||||||
{resultRows.length > 0 && (
|
{resultRows.length > 0 && (
|
||||||
<div className="app-table-wrap data-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table data-table compact-table">
|
id={`campaign-${campaignId}-send-results`}
|
||||||
<thead>
|
rows={resultRows.slice(0, 10)}
|
||||||
<tr><th>Status</th><th>Job</th><th>Message</th></tr>
|
columns={sendResultColumns()}
|
||||||
</thead>
|
getRowKey={(_row, index) => `send-result-${index}`}
|
||||||
<tbody>
|
emptyText="No send results returned."
|
||||||
{resultRows.slice(0, 10).map((row, index) => (
|
className="data-table-wrap data-table compact-table"
|
||||||
<tr key={index}>
|
/>
|
||||||
<td><StatusBadge status={String(row.status ?? "info")} /></td>
|
|
||||||
<td>{String(row.job_id ?? row.version_id ?? "—")}</td>
|
|
||||||
<td>{String(row.message ?? stringifyPreview(row, 180))}</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -372,6 +326,54 @@ export default function SendDataPage({ settings, campaignId }: { settings: ApiSe
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function mockStepColumns(): DataGridColumn<Record<string, unknown>>[] {
|
||||||
|
return [
|
||||||
|
{ id: "step", header: "Step", width: 190, sortable: true, filterable: true, sticky: "start", value: (step) => String(step.label ?? step.key ?? "") },
|
||||||
|
{ id: "status", header: "Status", width: 140, sortable: true, filterable: true, render: (step) => <StatusBadge status={String(step.status ?? "info")} />, value: (step) => String(step.status ?? "info") },
|
||||||
|
{ id: "summary", header: "Summary", width: "minmax(320px, 1fr)", filterable: true, render: (step) => stringifyPreview(asRecord(step.summary), 240), value: (step) => stringifyPreview(asRecord(step.summary), 240) }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function mockBuiltMessageColumns(): DataGridColumn<Record<string, unknown>>[] {
|
||||||
|
return [
|
||||||
|
{ id: "number", header: "#", width: 80, sortable: true, sticky: "start", value: (message) => String(message.entry_index ?? "—") },
|
||||||
|
{ id: "recipient", header: "Recipient", width: 240, resizable: true, sortable: true, filterable: true, value: (message) => asArray(message.to).map(asRecord).map((item) => String(item.email ?? "")).filter(Boolean).join(", ") || "—" },
|
||||||
|
{ id: "subject", header: "Subject", width: "minmax(260px, 1fr)", resizable: true, sortable: true, filterable: true, value: (message) => String(message.subject ?? "—") },
|
||||||
|
{ id: "validation", header: "Validation", width: 150, sortable: true, filterable: true, render: (message) => <StatusBadge status={String(message.validation_status ?? "unknown")} />, value: (message) => String(message.validation_status ?? "unknown") },
|
||||||
|
{ id: "attachments", header: "Attachments", width: 130, sortable: true, filterable: true, value: (message) => String(message.attachment_count ?? 0) },
|
||||||
|
{ id: "issues", header: "Issues", width: 260, resizable: true, filterable: true, value: (message) => { const issues = asArray(message.issues).map(asRecord); return issues.length === 0 ? "—" : issues.map((issue) => String(issue.message ?? issue.code ?? "issue")).join(" · "); } }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function mockSendResultColumns(): DataGridColumn<Record<string, unknown>>[] {
|
||||||
|
return [
|
||||||
|
{ id: "number", header: "#", width: 80, sortable: true, sticky: "start", value: (row, index) => String(row.entry_index ?? index + 1) },
|
||||||
|
{ id: "status", header: "Status", width: 140, sortable: true, filterable: true, render: (row) => <StatusBadge status={String(row.status ?? "info")} />, value: (row) => String(row.status ?? "info") },
|
||||||
|
{ id: "recipient", header: "Recipient", width: 240, resizable: true, sortable: true, filterable: true, value: (row) => asArray(row.to).map(asRecord).map((item) => String(item.email ?? "")).filter(Boolean).join(", ") || "—" },
|
||||||
|
{ id: "smtp", header: "SMTP", width: 190, sortable: true, filterable: true, value: (row) => String(row.smtp_message_id ?? row.status ?? "—") },
|
||||||
|
{ id: "imap", header: "IMAP", width: 190, sortable: true, filterable: true, value: (row) => String(row.imap_message_id ?? row.imap_status ?? "—") },
|
||||||
|
{ id: "message", header: "Message", width: "minmax(260px, 1fr)", filterable: true, value: (row) => String(row.message ?? "—") }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function mockMailboxColumns(openMockMessage: (id: string) => Promise<void>): DataGridColumn<Record<string, unknown>>[] {
|
||||||
|
return [
|
||||||
|
{ id: "kind", header: "Kind", width: 130, sortable: true, filterable: true, sticky: "start", render: (message) => <span className="status-badge neutral">{String(message.kind ?? "mock")}</span>, value: (message) => String(message.kind ?? "mock") },
|
||||||
|
{ id: "subject", header: "Subject", width: "minmax(240px, 1fr)", sortable: true, filterable: true, value: (message) => String(message.subject ?? "—") },
|
||||||
|
{ id: "envelope", header: "Envelope / folder", width: 300, resizable: true, filterable: true, value: (message) => `${String(message.envelope_from ?? message.folder ?? "—")} → ${asArray(message.envelope_recipients).join(", ") || String(message.folder ?? "—")}` },
|
||||||
|
{ id: "attachments", header: "Attachments", width: 130, sortable: true, filterable: true, value: (message) => String(message.attachment_count ?? 0) },
|
||||||
|
{ id: "actions", header: "Actions", width: 110, sticky: "end", render: (message) => <Button onClick={() => void openMockMessage(String(message.id))}>Open</Button> }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendResultColumns(): DataGridColumn<Record<string, unknown>>[] {
|
||||||
|
return [
|
||||||
|
{ id: "status", header: "Status", width: 140, sortable: true, filterable: true, sticky: "start", render: (row) => <StatusBadge status={String(row.status ?? "info")} />, value: (row) => String(row.status ?? "info") },
|
||||||
|
{ id: "job", header: "Job", width: 180, sortable: true, filterable: true, value: (row) => String(row.job_id ?? row.version_id ?? "—") },
|
||||||
|
{ id: "message", header: "Message", width: "minmax(320px, 1fr)", filterable: true, value: (row) => String(row.message ?? stringifyPreview(row, 180)) }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function mockMessageMetaItems(message: MockMailboxMessage) {
|
function mockMessageMetaItems(message: MockMailboxMessage) {
|
||||||
return [
|
return [
|
||||||
{ label: "From", value: message.from_header || message.envelope_from || "—" },
|
{ label: "From", value: message.from_header || message.envelope_from || "—" },
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import Card from "../../components/Card";
|
|||||||
import FormField from "../../components/FormField";
|
import FormField from "../../components/FormField";
|
||||||
import PageTitle from "../../components/PageTitle";
|
import PageTitle from "../../components/PageTitle";
|
||||||
import LoadingFrame from "../../components/LoadingFrame";
|
import LoadingFrame from "../../components/LoadingFrame";
|
||||||
|
import DismissibleAlert from "../../components/DismissibleAlert";
|
||||||
import LockedVersionNotice from "./components/LockedVersionNotice";
|
import LockedVersionNotice from "./components/LockedVersionNotice";
|
||||||
import VersionLine from "./components/VersionLine";
|
import VersionLine from "./components/VersionLine";
|
||||||
import MessagePreviewOverlay, { type MessagePreviewAttachment } from "./components/MessagePreviewOverlay";
|
import MessagePreviewOverlay, { type MessagePreviewAttachment } from "./components/MessagePreviewOverlay";
|
||||||
@@ -141,8 +142,8 @@ export default function TemplateDataPage({ settings, campaignId }: { settings: A
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{error && <div className="alert danger">{error}</div>}
|
{error && <DismissibleAlert tone="danger" resetKey={error}>{error}</DismissibleAlert>}
|
||||||
{localError && <div className="alert danger">{localError}</div>}
|
{localError && <DismissibleAlert tone="danger" resetKey={localError}>{localError}</DismissibleAlert>}
|
||||||
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Create an editable copy before changing the template." />}
|
{locked && <LockedVersionNotice settings={settings} campaignId={campaignId} version={version} reload={reload} message="Create an editable copy before changing the template." />}
|
||||||
|
|
||||||
<LoadingFrame loading={loading || !draft} label="Loading campaign draft…">
|
<LoadingFrame loading={loading || !draft} label="Loading campaign draft…">
|
||||||
@@ -197,7 +198,7 @@ export default function TemplateDataPage({ settings, campaignId }: { settings: A
|
|||||||
<div className="template-side-stack">
|
<div className="template-side-stack">
|
||||||
<Card title="Fields">
|
<Card title="Fields">
|
||||||
{invalidNamespacePlaceholders.length > 0 && (
|
{invalidNamespacePlaceholders.length > 0 && (
|
||||||
<div className="alert warning">Undefined placeholder namespace detected: {invalidNamespacePlaceholders.map((field) => field.namespace || field.raw).join(", ")}.</div>
|
<DismissibleAlert tone="warning" resetKey={invalidNamespacePlaceholders.map((field) => field.namespace || field.raw).join(",")}>Undefined placeholder namespace detected: {invalidNamespacePlaceholders.map((field) => field.namespace || field.raw).join(", ")}.</DismissibleAlert>
|
||||||
)}
|
)}
|
||||||
{usedPlaceholders.length === 0 && <p className="muted">No template placeholders detected yet.</p>}
|
{usedPlaceholders.length === 0 && <p className="muted">No template placeholders detected yet.</p>}
|
||||||
<p className="muted small-note">Click a field to insert it at the current cursor position as a namespaced placeholder.</p>
|
<p className="muted small-note">Click a field to insert it at the current cursor position as a namespaced placeholder.</p>
|
||||||
@@ -263,7 +264,7 @@ export default function TemplateDataPage({ settings, campaignId }: { settings: A
|
|||||||
</header>
|
</header>
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
<p>The template uses <code>{`{{${undefinedDialog.raw}}}`}</code>, but it cannot be matched to a known field.</p>
|
<p>The template uses <code>{`{{${undefinedDialog.raw}}}`}</code>, but it cannot be matched to a known field.</p>
|
||||||
{undefinedDialog.reason === "invalid-namespace" && <div className="alert warning">Use the namespace <code>global:</code> or <code>local:</code>.</div>}
|
{undefinedDialog.reason === "invalid-namespace" && <DismissibleAlert tone="warning">Use the namespace <code>global:</code> or <code>local:</code>.</DismissibleAlert>}
|
||||||
{undefinedDialog.reason === "missing-field" && <p className="muted">You can add the name <strong>{undefinedDialog.name}</strong> as a campaign field, or remove this placeholder from subject, plain text and HTML.</p>}
|
{undefinedDialog.reason === "missing-field" && <p className="muted">You can add the name <strong>{undefinedDialog.name}</strong> as a campaign field, or remove this placeholder from subject, plain text and HTML.</p>}
|
||||||
</div>
|
</div>
|
||||||
<footer className="modal-footer">
|
<footer className="modal-footer">
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { createPortal } from "react-dom";
|
import { createPortal } from "react-dom";
|
||||||
import Button from "../../../components/Button";
|
import Button from "../../../components/Button";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../../components/table/DataGrid";
|
||||||
import ToggleSwitch from "../../../components/ToggleSwitch";
|
import ToggleSwitch from "../../../components/ToggleSwitch";
|
||||||
import { getBool, getText } from "../utils/draftEditor";
|
import { getBool, getText } from "../utils/draftEditor";
|
||||||
import { createAttachmentRule, mockAttachmentFiles, summarizeAttachmentRules, type AttachmentBasePath, type AttachmentRule } from "../utils/attachments";
|
import { createAttachmentRule, mockAttachmentFiles, summarizeAttachmentRules, type AttachmentBasePath, type AttachmentRule } from "../utils/attachments";
|
||||||
@@ -22,6 +23,7 @@ type AttachmentRulesTableProps = {
|
|||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
emptyText?: string;
|
emptyText?: string;
|
||||||
basePaths?: AttachmentBasePath[];
|
basePaths?: AttachmentBasePath[];
|
||||||
|
id?: string;
|
||||||
showAddButton?: boolean;
|
showAddButton?: boolean;
|
||||||
activeChooserRuleIndex?: number | null;
|
activeChooserRuleIndex?: number | null;
|
||||||
onOpenFileChooser?: (ruleIndex: number) => void;
|
onOpenFileChooser?: (ruleIndex: number) => void;
|
||||||
@@ -124,25 +126,44 @@ export default function AttachmentRulesOverlay({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function AttachmentRulesTable({
|
export function AttachmentRulesTable({
|
||||||
|
showAddButton = true,
|
||||||
|
onChange,
|
||||||
|
...tableProps
|
||||||
|
}: AttachmentRulesTableProps) {
|
||||||
|
function addRule() {
|
||||||
|
onChange([...tableProps.rules, createAttachmentRule(tableProps.basePaths?.[0]?.path ?? "")]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="attachment-rules-editor">
|
||||||
|
<div className="attachment-rules-main">
|
||||||
|
<AttachmentRulesDataGrid {...tableProps} onChange={onChange} />
|
||||||
|
{showAddButton && (
|
||||||
|
<div className="button-row compact-actions attachment-rules-footer-actions">
|
||||||
|
<Button onClick={addRule} disabled={tableProps.disabled}>Add file</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AttachmentRulesDataGrid({
|
||||||
rules,
|
rules,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
emptyText = "No attachment files or matching rules configured yet.",
|
emptyText = "No attachment files or matching rules configured yet.",
|
||||||
basePaths = [],
|
basePaths = [],
|
||||||
showAddButton = true,
|
id = "attachment-rules",
|
||||||
activeChooserRuleIndex = null,
|
activeChooserRuleIndex = null,
|
||||||
onOpenFileChooser,
|
onOpenFileChooser,
|
||||||
onChange
|
onChange
|
||||||
}: AttachmentRulesTableProps) {
|
}: Omit<AttachmentRulesTableProps, "showAddButton">) {
|
||||||
const [fileChooser, setFileChooser] = useState<FileChooserState | null>(null);
|
const [fileChooser, setFileChooser] = useState<FileChooserState | null>(null);
|
||||||
|
|
||||||
function patchRule(index: number, patch: Partial<AttachmentRule>) {
|
function patchRule(index: number, patch: Partial<AttachmentRule>) {
|
||||||
onChange(rules.map((rule, currentIndex) => currentIndex === index ? { ...rule, ...patch } : rule));
|
onChange(rules.map((rule, currentIndex) => currentIndex === index ? { ...rule, ...patch } : rule));
|
||||||
}
|
}
|
||||||
|
|
||||||
function addRule() {
|
|
||||||
onChange([...rules, createAttachmentRule(basePaths[0]?.path ?? "")]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeRule(index: number) {
|
function removeRule(index: number) {
|
||||||
setFileChooser(null);
|
setFileChooser(null);
|
||||||
onChange(rules.filter((_, currentIndex) => currentIndex !== index));
|
onChange(rules.filter((_, currentIndex) => currentIndex !== index));
|
||||||
@@ -169,40 +190,69 @@ export function AttachmentRulesTable({
|
|||||||
: "";
|
: "";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="attachment-rules-editor">
|
<>
|
||||||
<div className="attachment-rules-main">
|
|
||||||
{rules.length === 0 ? (
|
{rules.length === 0 ? (
|
||||||
<p className="muted attachment-rules-empty">{emptyText}</p>
|
<p className="muted attachment-rules-empty">{emptyText}</p>
|
||||||
) : (
|
) : (
|
||||||
<div className="app-table-wrap attachment-rules-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table attachment-rules-table">
|
id={id}
|
||||||
<thead>
|
rows={rules}
|
||||||
<tr>
|
columns={attachmentRuleColumns({ disabled, basePaths, activeChooserRuleIndex: activeChooserRuleIndex ?? fileChooser?.ruleIndex ?? null, patchRule, openFileChooser, removeRule })}
|
||||||
<th>Label</th>
|
getRowKey={(rule, index) => String(rule.id ?? index)}
|
||||||
<th>Base path</th>
|
emptyText={emptyText}
|
||||||
<th>File / pattern</th>
|
className="attachment-rules-table-wrap attachment-rules-table"
|
||||||
<th>Required</th>
|
rowClassName={(_rule, index) => (activeChooserRuleIndex ?? fileChooser?.ruleIndex) === index ? "is-choosing-file" : undefined}
|
||||||
<th>Subdirs</th>
|
/>
|
||||||
<th></th>
|
)}
|
||||||
</tr>
|
{fileChooser && (
|
||||||
</thead>
|
<MockFileChooserOverlay
|
||||||
<tbody>
|
basePath={activeBasePath}
|
||||||
{rules.map((rule, index) => {
|
onSelect={selectFileFilter}
|
||||||
|
onClose={() => setFileChooser(null)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
type AttachmentRuleColumnContext = {
|
||||||
|
disabled: boolean;
|
||||||
|
basePaths: AttachmentBasePath[];
|
||||||
|
activeChooserRuleIndex: number | null;
|
||||||
|
patchRule: (index: number, patch: Partial<AttachmentRule>) => void;
|
||||||
|
openFileChooser: (ruleIndex: number) => void;
|
||||||
|
removeRule: (index: number) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
function attachmentRuleColumns({ disabled, basePaths, activeChooserRuleIndex: _activeChooserRuleIndex, patchRule, openFileChooser, removeRule }: AttachmentRuleColumnContext): DataGridColumn<AttachmentRule>[] {
|
||||||
|
return [
|
||||||
|
{ id: "label", header: "Label", width: 190, resizable: true, sortable: true, filterable: true, sticky: "start", render: (rule, index) => <input value={getText(rule, "label")} disabled={disabled} placeholder="Attachment label" onChange={(event) => patchRule(index, { label: event.target.value })} />, value: (rule) => getText(rule, "label") },
|
||||||
|
{
|
||||||
|
id: "base_path",
|
||||||
|
header: "Base path",
|
||||||
|
width: 250,
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
render: (rule, index) => {
|
||||||
const currentBasePath = getText(rule, "base_dir", basePaths[0]?.path ?? "");
|
const currentBasePath = getText(rule, "base_dir", basePaths[0]?.path ?? "");
|
||||||
const isChoosingFile = (activeChooserRuleIndex ?? fileChooser?.ruleIndex) === index;
|
return basePaths.length > 0 ? (
|
||||||
return (
|
|
||||||
<tr key={String(rule.id ?? index)} className={isChoosingFile ? "is-choosing-file" : undefined}>
|
|
||||||
<td><input value={getText(rule, "label")} disabled={disabled} placeholder="Attachment label" onChange={(event) => patchRule(index, { label: event.target.value })} /></td>
|
|
||||||
<td>
|
|
||||||
{basePaths.length > 0 ? (
|
|
||||||
<select value={currentBasePath} disabled={disabled} onChange={(event) => patchRule(index, { base_dir: event.target.value })}>
|
<select value={currentBasePath} disabled={disabled} onChange={(event) => patchRule(index, { base_dir: event.target.value })}>
|
||||||
{basePaths.map((basePath) => <option key={basePath.id} value={basePath.path}>{basePath.name || basePath.path}</option>)}
|
{basePaths.map((basePath) => <option key={basePath.id} value={basePath.path}>{basePath.name || basePath.path}</option>)}
|
||||||
</select>
|
</select>
|
||||||
) : (
|
) : (
|
||||||
<input value={currentBasePath} disabled={disabled} readOnly placeholder="optional/folder" />
|
<input value={currentBasePath} disabled={disabled} readOnly placeholder="optional/folder" />
|
||||||
)}
|
);
|
||||||
</td>
|
},
|
||||||
<td>
|
value: (rule) => getText(rule, "base_dir", basePaths[0]?.path ?? "")
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "file_filter",
|
||||||
|
header: "File / pattern",
|
||||||
|
width: "minmax(260px, 1fr)",
|
||||||
|
resizable: true,
|
||||||
|
sortable: true,
|
||||||
|
filterable: true,
|
||||||
|
render: (rule, index) => (
|
||||||
<div className="field-with-action">
|
<div className="field-with-action">
|
||||||
<input
|
<input
|
||||||
className="chooser-display-input"
|
className="chooser-display-input"
|
||||||
@@ -221,32 +271,13 @@ export function AttachmentRulesTable({
|
|||||||
/>
|
/>
|
||||||
<Button onClick={() => openFileChooser(index)} disabled={disabled}>Choose</Button>
|
<Button onClick={() => openFileChooser(index)} disabled={disabled}>Choose</Button>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
),
|
||||||
<td><ToggleSwitch label="Required" checked={getBool(rule, "required", true)} disabled={disabled} onChange={(checked) => patchRule(index, { required: checked })} /></td>
|
value: (rule) => getText(rule, "file_filter")
|
||||||
<td><ToggleSwitch label="Subdirs" checked={getBool(rule, "include_subdirs")} disabled={disabled} onChange={(checked) => patchRule(index, { include_subdirs: checked })} /></td>
|
},
|
||||||
<td className="table-action-cell"><Button variant="danger" onClick={() => removeRule(index)} disabled={disabled}>Remove</Button></td>
|
{ id: "required", header: "Required", width: 175, sortable: true, filterable: true, render: (rule, index) => <ToggleSwitch label="Required" checked={getBool(rule, "required", true)} disabled={disabled} onChange={(checked) => patchRule(index, { required: checked })} />, value: (rule) => getBool(rule, "required", true) ? "required" : "optional" },
|
||||||
</tr>
|
{ id: "subdirs", header: "Subdirs", width: 165, sortable: true, filterable: true, render: (rule, index) => <ToggleSwitch label="Subdirs" checked={getBool(rule, "include_subdirs")} disabled={disabled} onChange={(checked) => patchRule(index, { include_subdirs: checked })} />, value: (rule) => getBool(rule, "include_subdirs") ? "subdirs" : "current" },
|
||||||
);
|
{ id: "actions", header: "", width: 120, sticky: "end", render: (_rule, index) => <Button variant="danger" onClick={() => removeRule(index)} disabled={disabled}>Remove</Button> }
|
||||||
})}
|
];
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{showAddButton && (
|
|
||||||
<div className="button-row compact-actions attachment-rules-footer-actions">
|
|
||||||
<Button onClick={addRule} disabled={disabled}>Add file</Button>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
{fileChooser && (
|
|
||||||
<MockFileChooserOverlay
|
|
||||||
basePath={activeBasePath}
|
|
||||||
onSelect={selectFileFilter}
|
|
||||||
onClose={() => setFileChooser(null)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function MockFileChooserOverlay({ basePath, onSelect, onClose }: { basePath: string; onSelect: (fileFilter: string) => void; onClose: () => void }) {
|
function MockFileChooserOverlay({ basePath, onSelect, onClose }: { basePath: string; onSelect: (fileFilter: string) => void; onClose: () => void }) {
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import type { CampaignSummary, CampaignVersionDetail } from "../../../api/campai
|
|||||||
import { buildVersion, validateVersion } from "../../../api/campaigns";
|
import { buildVersion, validateVersion } from "../../../api/campaigns";
|
||||||
import Button from "../../../components/Button";
|
import Button from "../../../components/Button";
|
||||||
import Card from "../../../components/Card";
|
import Card from "../../../components/Card";
|
||||||
|
import DismissibleAlert from "../../../components/DismissibleAlert";
|
||||||
import StatusBadge from "../../../components/StatusBadge";
|
import StatusBadge from "../../../components/StatusBadge";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../../components/table/DataGrid";
|
||||||
import {
|
import {
|
||||||
asArray,
|
asArray,
|
||||||
asRecord,
|
asRecord,
|
||||||
@@ -105,7 +107,7 @@ export default function ReviewWorkflowCards({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{actionMessage && <div className="alert info">{actionMessage}</div>}
|
{actionMessage && <DismissibleAlert tone="info" resetKey={actionMessage}>{actionMessage}</DismissibleAlert>}
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
title="Review actions"
|
title="Review actions"
|
||||||
@@ -262,46 +264,29 @@ export default function ReviewWorkflowCards({
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{issues.length > 0 && (
|
{issues.length > 0 && (
|
||||||
<div className="app-table-wrap data-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table data-table">
|
id={`campaign-${version?.campaign_id ?? "unknown"}-validation-issues`}
|
||||||
<thead>
|
rows={issues}
|
||||||
<tr>
|
columns={validationIssueColumns()}
|
||||||
<th>Severity</th>
|
getRowKey={(issue, index) => String(issue.issueKey ?? index)}
|
||||||
<th>Location</th>
|
emptyText="No validation issues are stored for this version."
|
||||||
<th>Code</th>
|
className="data-table-wrap data-table"
|
||||||
<th>Message</th>
|
/>
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{issues.map((issue, index) => (
|
|
||||||
<tr key={String(issue.issueKey ?? index)}>
|
|
||||||
<td>
|
|
||||||
<StatusBadge status={String(issue.severity || "info")} />
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{String(
|
|
||||||
issue.path ||
|
|
||||||
issue.source ||
|
|
||||||
issue.section ||
|
|
||||||
issue.field ||
|
|
||||||
"—",
|
|
||||||
)}
|
|
||||||
</td>
|
|
||||||
<td>{String(issue.code || "—")}</td>
|
|
||||||
<td>
|
|
||||||
{String(issue.message || stringifyPreview(issue, 220))}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</Card>
|
</Card>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validationIssueColumns(): DataGridColumn<Record<string, unknown>>[] {
|
||||||
|
return [
|
||||||
|
{ id: "severity", header: "Severity", width: 140, sortable: true, filterable: true, sticky: "start", render: (issue) => <StatusBadge status={String(issue.severity || "info")} />, value: (issue) => String(issue.severity || "info") },
|
||||||
|
{ id: "location", header: "Location", width: 220, resizable: true, sortable: true, filterable: true, render: (issue) => String(issue.path || issue.source || issue.section || issue.field || "—"), value: (issue) => String(issue.path || issue.source || issue.section || issue.field || "") },
|
||||||
|
{ id: "code", header: "Code", width: 180, resizable: true, sortable: true, filterable: true, render: (issue) => String(issue.code || "—"), value: (issue) => String(issue.code || "") },
|
||||||
|
{ id: "message", header: "Message", width: "minmax(320px, 1fr)", resizable: true, sortable: true, filterable: true, render: (issue) => String(issue.message || stringifyPreview(issue, 220)), value: (issue) => String(issue.message || stringifyPreview(issue, 220)) }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function SummaryTile({
|
function SummaryTile({
|
||||||
label,
|
label,
|
||||||
value,
|
value,
|
||||||
|
|||||||
@@ -58,7 +58,16 @@ export function isUserLockedVersion(version: CampaignVersionDetail | CampaignVer
|
|||||||
|
|
||||||
export function isFinalLockedVersion(version: CampaignVersionDetail | CampaignVersionListItem | null): boolean {
|
export function isFinalLockedVersion(version: CampaignVersionDetail | CampaignVersionListItem | null): boolean {
|
||||||
if (!version) return false;
|
if (!version) return false;
|
||||||
return ["queued", "sending", "completed", "archived", "cancelled"].includes(version.workflow_state ?? "");
|
return [
|
||||||
|
"queued",
|
||||||
|
"sending",
|
||||||
|
"sent",
|
||||||
|
"completed",
|
||||||
|
"failed_partial",
|
||||||
|
"partially_sent",
|
||||||
|
"archived",
|
||||||
|
"cancelled"
|
||||||
|
].includes((version.workflow_state ?? "").toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isVersionReadyForDelivery(version: CampaignVersionDetail | CampaignVersionListItem | null): boolean {
|
export function isVersionReadyForDelivery(version: CampaignVersionDetail | CampaignVersionListItem | null): boolean {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type { ApiSettings, WizardStep } from "../../../types";
|
|||||||
import Stepper from "../../../components/Stepper";
|
import Stepper from "../../../components/Stepper";
|
||||||
import Card from "../../../components/Card";
|
import Card from "../../../components/Card";
|
||||||
import Button from "../../../components/Button";
|
import Button from "../../../components/Button";
|
||||||
|
import DismissibleAlert from "../../../components/DismissibleAlert";
|
||||||
import PageTitle from "../../../components/PageTitle";
|
import PageTitle from "../../../components/PageTitle";
|
||||||
import LockedVersionNotice from "../components/LockedVersionNotice";
|
import LockedVersionNotice from "../components/LockedVersionNotice";
|
||||||
import { validatePartial } from "../../../api/campaigns";
|
import { validatePartial } from "../../../api/campaigns";
|
||||||
@@ -116,8 +117,8 @@ export default function CreateWizard({ settings, campaignId }: { settings: ApiSe
|
|||||||
</div>
|
</div>
|
||||||
<div className="save-state">{saveState}</div>
|
<div className="save-state">{saveState}</div>
|
||||||
</div>
|
</div>
|
||||||
{localError && <div className="alert danger">{localError}</div>}
|
{localError && <DismissibleAlert tone="danger" resetKey={localError}>{localError}</DismissibleAlert>}
|
||||||
{validationMessage && <div className="alert info">{validationMessage}</div>}
|
{validationMessage && <DismissibleAlert tone="info" resetKey={validationMessage}>{validationMessage}</DismissibleAlert>}
|
||||||
<Card>
|
<Card>
|
||||||
{draft && activeStep === "basics" && <BasicsStep draft={draft} patch={patch} />}
|
{draft && activeStep === "basics" && <BasicsStep draft={draft} patch={patch} />}
|
||||||
{draft && activeStep === "sender" && <SenderStep draft={draft} patch={patch} />}
|
{draft && activeStep === "sender" && <SenderStep draft={draft} patch={patch} />}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Card from "../../components/Card";
|
|||||||
import PageTitle from "../../components/PageTitle";
|
import PageTitle from "../../components/PageTitle";
|
||||||
import StatusBadge from "../../components/StatusBadge";
|
import StatusBadge from "../../components/StatusBadge";
|
||||||
import ModuleSubnav, { type ModuleSubnavGroup } from "../../layout/ModuleSubnav";
|
import ModuleSubnav, { type ModuleSubnavGroup } from "../../layout/ModuleSubnav";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../components/table/DataGrid";
|
||||||
|
|
||||||
type StorageRecord = {
|
type StorageRecord = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -82,6 +83,30 @@ const demoFiles = [
|
|||||||
{ name: "global_notice.pdf", path: "/shared/global_notice.pdf", size: "81 KB", updatedAt: "2026-06-06 09:44", status: "ready" }
|
{ name: "global_notice.pdf", path: "/shared/global_notice.pdf", size: "81 KB", updatedAt: "2026-06-06 09:44", status: "ready" }
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function storageColumns(openStorage: (storageId: string) => void): DataGridColumn<StorageRecord>[] {
|
||||||
|
return [
|
||||||
|
{ id: "storage", header: "Storage", width: "minmax(240px, 1.4fr)", sortable: true, filterable: true, sticky: "start", render: (storage) => <div className="module-title-cell"><strong>{storage.name}</strong><span>{storage.description}</span></div>, value: (storage) => `${storage.name} ${storage.description}` },
|
||||||
|
{ id: "type", header: "Type", width: 220, sortable: true, filterable: true, value: (storage) => storage.type },
|
||||||
|
{ id: "scope", header: "Scope", width: 160, sortable: true, filterable: true, value: (storage) => storage.scope },
|
||||||
|
{ id: "files", header: "Files", width: 110, sortable: true, filterable: true, value: (storage) => storage.files },
|
||||||
|
{ id: "used", header: "Used", width: 120, sortable: true, filterable: true, value: (storage) => storage.used },
|
||||||
|
{ id: "retention", header: "Retention", width: 190, sortable: true, filterable: true, value: (storage) => storage.retention },
|
||||||
|
{ id: "updated", header: "Updated", width: 170, sortable: true, filterable: true, render: (storage) => <span className="muted small-text">{storage.updatedAt}</span>, value: (storage) => storage.updatedAt },
|
||||||
|
{ id: "actions", header: "Actions", width: 110, sticky: "end", render: (storage) => <Button onClick={() => openStorage(storage.id)}>Open</Button> }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function fileColumns(): DataGridColumn<(typeof demoFiles)[number]>[] {
|
||||||
|
return [
|
||||||
|
{ id: "name", header: "Name", width: "minmax(180px, 1fr)", sortable: true, filterable: true, sticky: "start", value: (file) => file.name },
|
||||||
|
{ id: "path", header: "Path", width: 260, sortable: true, filterable: true, resizable: true, render: (file) => <code>{file.path}</code>, value: (file) => file.path },
|
||||||
|
{ id: "size", header: "Size", width: 100, sortable: true, filterable: true, value: (file) => file.size },
|
||||||
|
{ id: "updated", header: "Updated", width: 170, sortable: true, filterable: true, render: (file) => <span className="muted small-text">{file.updatedAt}</span>, value: (file) => file.updatedAt },
|
||||||
|
{ id: "status", header: "Status", width: 130, sortable: true, filterable: true, render: (file) => <StatusBadge status={file.status} />, value: (file) => file.status },
|
||||||
|
{ id: "actions", header: "Actions", width: 120, sticky: "end", render: () => <Button disabled>Download</Button> }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
export default function FilesPage() {
|
export default function FilesPage() {
|
||||||
const [selectedStorageId, setSelectedStorageId] = useState<string | null>(null);
|
const [selectedStorageId, setSelectedStorageId] = useState<string | null>(null);
|
||||||
const [active, setActive] = useState<StorageSection>("browse");
|
const [active, setActive] = useState<StorageSection>("browse");
|
||||||
@@ -146,41 +171,14 @@ export default function FilesPage() {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div className="app-table-wrap compact-table-wrap module-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table module-table module-entry-table">
|
id="file-storages"
|
||||||
<thead>
|
rows={storages}
|
||||||
<tr>
|
columns={storageColumns(openStorage)}
|
||||||
<th>Storage</th>
|
getRowKey={(storage) => storage.id}
|
||||||
<th>Type</th>
|
emptyText="No file storages configured."
|
||||||
<th>Scope</th>
|
className="compact-table-wrap module-table-wrap module-entry-table"
|
||||||
<th>Files</th>
|
/>
|
||||||
<th>Used</th>
|
|
||||||
<th>Retention</th>
|
|
||||||
<th>Updated</th>
|
|
||||||
<th aria-label="Actions" />
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{storages.map((storage) => (
|
|
||||||
<tr key={storage.id}>
|
|
||||||
<td>
|
|
||||||
<div className="module-title-cell">
|
|
||||||
<strong>{storage.name}</strong>
|
|
||||||
<span>{storage.description}</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>{storage.type}</td>
|
|
||||||
<td>{storage.scope}</td>
|
|
||||||
<td>{storage.files}</td>
|
|
||||||
<td>{storage.used}</td>
|
|
||||||
<td>{storage.retention}</td>
|
|
||||||
<td><span className="muted small-text">{storage.updatedAt}</span></td>
|
|
||||||
<td className="table-action-cell"><Button onClick={() => openStorage(storage.id)}>Open</Button></td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -192,24 +190,14 @@ function StorageBrowse({ storage }: { storage: StorageRecord }) {
|
|||||||
title="Browse content"
|
title="Browse content"
|
||||||
actions={<div className="button-row compact-actions"><Button disabled>Upload</Button><Button disabled>Download selected</Button><Button variant="danger" disabled>Delete selected</Button></div>}
|
actions={<div className="button-row compact-actions"><Button disabled>Upload</Button><Button disabled>Download selected</Button><Button variant="danger" disabled>Delete selected</Button></div>}
|
||||||
>
|
>
|
||||||
<div className="app-table-wrap compact-table-wrap module-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table module-table">
|
id={`files-${storage.id}`}
|
||||||
<thead><tr><th>Name</th><th>Path</th><th>Size</th><th>Updated</th><th>Status</th><th></th></tr></thead>
|
rows={storage.id === "campaign-files" ? demoFiles : []}
|
||||||
<tbody>
|
columns={fileColumns()}
|
||||||
{(storage.id === "campaign-files" ? demoFiles : []).map((file) => (
|
getRowKey={(file) => file.path}
|
||||||
<tr key={file.path}>
|
emptyText="Files will appear here when this storage is connected."
|
||||||
<td>{file.name}</td>
|
className="compact-table-wrap module-table-wrap module-table"
|
||||||
<td><code>{file.path}</code></td>
|
/>
|
||||||
<td>{file.size}</td>
|
|
||||||
<td><span className="muted small-text">{file.updatedAt}</span></td>
|
|
||||||
<td><StatusBadge status={file.status} /></td>
|
|
||||||
<td className="table-action-cell"><Button disabled>Download</Button></td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
{storage.id !== "campaign-files" && <tr><td colSpan={6} className="muted">Files will appear here when this storage is connected.</td></tr>}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import PageTitle from "../../components/PageTitle";
|
|||||||
import FieldLabel from "../../components/help/FieldLabel";
|
import FieldLabel from "../../components/help/FieldLabel";
|
||||||
import StatusBadge from "../../components/StatusBadge";
|
import StatusBadge from "../../components/StatusBadge";
|
||||||
import ModuleSubnav, { type ModuleSubnavGroup } from "../../layout/ModuleSubnav";
|
import ModuleSubnav, { type ModuleSubnavGroup } from "../../layout/ModuleSubnav";
|
||||||
|
import DataGrid, { type DataGridColumn } from "../../components/table/DataGrid";
|
||||||
|
|
||||||
type TemplateRecord = {
|
type TemplateRecord = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -81,6 +82,26 @@ const templateSubnav = (onBack: () => void): ModuleSubnavGroup<TemplateDetailSec
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function templateLibraryColumns(openTemplate: (templateId: string) => void): DataGridColumn<TemplateRecord>[] {
|
||||||
|
return [
|
||||||
|
{ id: "template", header: "Template", width: "minmax(240px, 1.4fr)", sortable: true, filterable: true, sticky: "start", render: (template) => <div className="module-title-cell"><strong>{template.name}</strong><span>{template.description}</span></div>, value: (template) => `${template.name} ${template.description}` },
|
||||||
|
{ id: "type", header: "Type", width: 150, sortable: true, filterable: true, value: (template) => template.type },
|
||||||
|
{ id: "fields", header: "Fields", width: 240, filterable: true, render: (template) => <div className="chip-row compact-chip-row">{template.fields.slice(0, 3).map((field) => <span key={field} className="field-chip">{field}</span>)}</div>, value: (template) => template.fields.join(", ") },
|
||||||
|
{ id: "updated", header: "Updated", width: 170, sortable: true, filterable: true, render: (template) => <span className="muted small-text">{template.updatedAt}</span>, value: (template) => template.updatedAt },
|
||||||
|
{ id: "status", header: "Status", width: 130, sortable: true, filterable: true, render: (template) => <StatusBadge status={template.status} />, value: (template) => template.status },
|
||||||
|
{ id: "actions", header: "Actions", width: 110, sticky: "end", render: (template) => <Button onClick={() => openTemplate(template.id)}>Open</Button> }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function templateFieldColumns(): DataGridColumn<{ id: string; field: string; source: string; required: string }>[] {
|
||||||
|
return [
|
||||||
|
{ id: "field", header: "Field", width: "minmax(180px, 1fr)", sortable: true, filterable: true, sticky: "start", render: (row) => <code>{row.field}</code>, value: (row) => row.field },
|
||||||
|
{ id: "source", header: "Source", width: 190, sortable: true, filterable: true, value: (row) => row.source },
|
||||||
|
{ id: "required", header: "Required", width: 120, sortable: true, filterable: true, value: (row) => row.required },
|
||||||
|
{ id: "actions", header: "Actions", width: 130, sticky: "end", render: () => <Button disabled>Configure</Button> }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
export default function TemplatesPage() {
|
export default function TemplatesPage() {
|
||||||
const [selectedId, setSelectedId] = useState<string | null>(null);
|
const [selectedId, setSelectedId] = useState<string | null>(null);
|
||||||
const [active, setActive] = useState<TemplateDetailSection>("overview");
|
const [active, setActive] = useState<TemplateDetailSection>("overview");
|
||||||
@@ -145,41 +166,14 @@ export default function TemplatesPage() {
|
|||||||
}
|
}
|
||||||
actions={<Button disabled>Refresh</Button>}
|
actions={<Button disabled>Refresh</Button>}
|
||||||
>
|
>
|
||||||
<div className="app-table-wrap compact-table-wrap module-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table module-table module-entry-table">
|
id="template-library"
|
||||||
<thead>
|
rows={templateRecords}
|
||||||
<tr>
|
columns={templateLibraryColumns(openTemplate)}
|
||||||
<th>Template</th>
|
getRowKey={(template) => template.id}
|
||||||
<th>Type</th>
|
emptyText="No templates found."
|
||||||
<th>Fields</th>
|
className="compact-table-wrap module-table-wrap module-entry-table"
|
||||||
<th>Updated</th>
|
/>
|
||||||
<th>Status</th>
|
|
||||||
<th aria-label="Actions" />
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{templateRecords.map((template) => (
|
|
||||||
<tr key={template.id}>
|
|
||||||
<td>
|
|
||||||
<div className="module-title-cell">
|
|
||||||
<strong>{template.name}</strong>
|
|
||||||
<span>{template.description}</span>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>{template.type}</td>
|
|
||||||
<td>
|
|
||||||
<div className="chip-row compact-chip-row">
|
|
||||||
{template.fields.slice(0, 3).map((field) => <span key={field} className="field-chip">{field}</span>)}
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td><span className="muted small-text">{template.updatedAt}</span></td>
|
|
||||||
<td><StatusBadge status={template.status} /></td>
|
|
||||||
<td className="table-action-cell"><Button onClick={() => openTemplate(template.id)}>Open</Button></td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</Card>
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -222,16 +216,14 @@ function TemplateContent({ template }: { template: TemplateRecord }) {
|
|||||||
function TemplateFields({ template }: { template: TemplateRecord }) {
|
function TemplateFields({ template }: { template: TemplateRecord }) {
|
||||||
return (
|
return (
|
||||||
<Card title="Template fields" actions={<Button disabled>Add field hint</Button>}>
|
<Card title="Template fields" actions={<Button disabled>Add field hint</Button>}>
|
||||||
<div className="app-table-wrap compact-table-wrap module-table-wrap">
|
<DataGrid
|
||||||
<table className="app-table module-table">
|
id={`template-${template.id}-fields`}
|
||||||
<thead><tr><th>Field</th><th>Source</th><th>Required</th><th></th></tr></thead>
|
rows={template.fields.map((field) => ({ id: field, field, source: "Detected placeholder", required: "Yes" }))}
|
||||||
<tbody>
|
columns={templateFieldColumns()}
|
||||||
{template.fields.map((field) => (
|
getRowKey={(field) => field.id}
|
||||||
<tr key={field}><td><code>{field}</code></td><td>Detected placeholder</td><td>Yes</td><td><Button disabled>Configure</Button></td></tr>
|
emptyText="No fields detected."
|
||||||
))}
|
className="compact-table-wrap module-table-wrap module-table"
|
||||||
</tbody>
|
/>
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -607,3 +607,335 @@
|
|||||||
transition: none;
|
transition: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reusable dismissible page alerts */
|
||||||
|
.alert-dismissible {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
position: sticky;
|
||||||
|
top: 10px;
|
||||||
|
z-index: 30;
|
||||||
|
box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-dismissible .alert-message {
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-dismiss {
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
|
color: currentColor;
|
||||||
|
opacity: 0.78;
|
||||||
|
cursor: pointer;
|
||||||
|
line-height: 1;
|
||||||
|
padding: 2px;
|
||||||
|
border-radius: 999px;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.alert-dismiss:hover,
|
||||||
|
.alert-dismiss:focus-visible {
|
||||||
|
opacity: 1;
|
||||||
|
background: rgba(255, 255, 255, 0.45);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reusable data grid */
|
||||||
|
.data-grid-shell {
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
overflow: auto;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
background: var(--surface);
|
||||||
|
scrollbar-gutter: stable;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-body > .data-grid-shell:only-child {
|
||||||
|
margin: -22px -24px;
|
||||||
|
width: calc(100% + 48px);
|
||||||
|
border-left: 0;
|
||||||
|
border-right: 0;
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-container {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid {
|
||||||
|
display: grid;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-has-flex {
|
||||||
|
width: 100%;
|
||||||
|
min-width: max-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-fixed-only {
|
||||||
|
width: 100%;
|
||||||
|
min-width: max-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-container .data-grid {
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-cell {
|
||||||
|
min-width: 0;
|
||||||
|
padding: 11px 12px;
|
||||||
|
border-right: 1px solid rgba(189, 184, 176, 0.32);
|
||||||
|
border-bottom: 1px solid var(--border-soft, var(--line));
|
||||||
|
background: var(--surface);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-cell:last-child {
|
||||||
|
border-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-header-cell {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 4;
|
||||||
|
background: var(--bar);
|
||||||
|
border-bottom: 1px solid var(--line-dark);
|
||||||
|
color: #625f5a;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 800;
|
||||||
|
letter-spacing: .04em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-body-cell {
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-body-cell.data-grid-row-odd {
|
||||||
|
background: #fbfaf8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-body-cell.data-grid-row-even {
|
||||||
|
background: var(--surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-body-cell.align-center,
|
||||||
|
.data-grid-header-cell.align-center {
|
||||||
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-body-cell.align-right,
|
||||||
|
.data-grid-header-cell.align-right {
|
||||||
|
justify-content: flex-end;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-header-button {
|
||||||
|
all: unset;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 7px;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
color: inherit;
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-header-button span {
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-header-cell.is-sortable .data-grid-header-button {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-header-cell.is-sorted .data-grid-header-button {
|
||||||
|
color: var(--text-strong);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-resize-handle,
|
||||||
|
.data-grid-filter-trigger {
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
|
color: rgba(98, 95, 90, .68);
|
||||||
|
padding: 0;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
border-radius: 999px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-resize-handle {
|
||||||
|
cursor: col-resize;
|
||||||
|
width: 16px;
|
||||||
|
align-self: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-trigger {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-trigger:hover,
|
||||||
|
.data-grid-filter-trigger:focus-visible,
|
||||||
|
.data-grid-filter-trigger.is-open {
|
||||||
|
color: var(--text-strong);
|
||||||
|
background: rgba(255, 255, 255, .45);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-trigger.has-filter {
|
||||||
|
color: var(--text-strong);
|
||||||
|
background: rgba(255, 255, 255, .62);
|
||||||
|
box-shadow: inset 0 0 0 1px rgba(98, 95, 90, .24);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-popover {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 12000;
|
||||||
|
border: 1px solid var(--line-dark);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
background: var(--surface);
|
||||||
|
box-shadow: var(--shadow-menu);
|
||||||
|
padding: 12px;
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-popover-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
color: var(--text-strong);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-popover-header strong {
|
||||||
|
min-width: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-popover-header button,
|
||||||
|
.data-grid-filter-input-wrap button {
|
||||||
|
border: 0;
|
||||||
|
background: transparent;
|
||||||
|
color: var(--muted);
|
||||||
|
cursor: pointer;
|
||||||
|
border-radius: 999px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-popover-header button:hover,
|
||||||
|
.data-grid-filter-input-wrap button:hover,
|
||||||
|
.data-grid-filter-popover-header button:focus-visible,
|
||||||
|
.data-grid-filter-input-wrap button:focus-visible {
|
||||||
|
color: var(--text-strong);
|
||||||
|
background: var(--panel-soft);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-stack {
|
||||||
|
display: grid;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-field {
|
||||||
|
display: grid;
|
||||||
|
gap: 5px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--muted);
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-field input,
|
||||||
|
.data-grid-filter-field select {
|
||||||
|
width: 100%;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
background: #fff;
|
||||||
|
color: var(--text);
|
||||||
|
font: inherit;
|
||||||
|
font-weight: 500;
|
||||||
|
padding: 8px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-field input:focus,
|
||||||
|
.data-grid-filter-field select:focus {
|
||||||
|
outline: none;
|
||||||
|
box-shadow: var(--focus-ring);
|
||||||
|
border-color: var(--blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-input-wrap {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-input-wrap input {
|
||||||
|
padding-right: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-filter-input-wrap button {
|
||||||
|
position: absolute;
|
||||||
|
right: 6px;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-empty {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
padding: 20px;
|
||||||
|
color: var(--muted);
|
||||||
|
background: var(--surface);
|
||||||
|
border-bottom: 1px solid var(--line);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-cell.is-sticky-start,
|
||||||
|
.data-grid-cell.is-sticky-end {
|
||||||
|
position: sticky;
|
||||||
|
z-index: 2;
|
||||||
|
background-clip: padding-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-cell.is-sticky-start {
|
||||||
|
border-right: 1px solid var(--line-dark);
|
||||||
|
box-shadow: 8px 0 14px -14px rgba(45, 43, 40, .6);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-cell.is-sticky-end {
|
||||||
|
border-left: 1px solid var(--line-dark);
|
||||||
|
box-shadow: -8px 0 14px -14px rgba(45, 43, 40, .6);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-header-cell.is-sticky-start,
|
||||||
|
.data-grid-header-cell.is-sticky-end {
|
||||||
|
z-index: 5;
|
||||||
|
border-bottom: 1px solid var(--line-dark);
|
||||||
|
background: var(--bar);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-grid-body-cell.current-version-row,
|
||||||
|
.data-grid-body-cell.current-recipient-row,
|
||||||
|
.data-grid-body-cell.current-row {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user