Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | 21400x 21400x 21400x 21400x 21x 219x 226x 21018x 228x 228x 228x 228x 228x 300x 228x 2x 292x 228x 300x 302x 36x 372x 226x 680x 876x 32x 324x 660x 34x 34x 34x 34x 34x 88x 34x 2x 70x 88x 88x 27x 142x 88x 18x 88x 88x | import { X } from "lucide-react";
import {
PropertyValueRead,
useCoreControlvaluesDestroyMutation,
} from "@/api/apiStore.gen";
import { useSearchParam } from "@/hooks/searchParams";
import { ToolTipCover } from "../../../../../../../ahuora-design-system/ui/tooltip";
import { ReverseReplace } from "../../../../../../../assets/ReverseReplace";
type ReplaceInfoProps = {
value: PropertyValueRead;
displayName: string;
onChangeDof?: () => void;
canMutate?: boolean;
};
export function ReplaceInfo({
value,
displayName,
onChangeDof,
canMutate = true,
}: ReplaceInfoProps) {
const isControlManipulated = value.controlManipulated;
const isControlSetPoint = value.controlSetPoint;
if (isControlManipulated) {
return (
<ReplacedByInfo
value={value}
displayName={displayName}
canMutate={canMutate}
/>
);
} else if (isControlSetPoint) {
return (
<ReplacingInfo
value={value}
displayName={displayName}
onChangeDof={onChangeDof}
canMutate={canMutate}
/>
);
} else {
return null;
}
}
// When this property is replacing another property
function ReplacingInfo({
value,
displayName,
onChangeDof,
canMutate,
}: ReplaceInfoProps) {
const [objectIdParam, setObjectId] = useSearchParam("object");
const [deleteControl] = useCoreControlvaluesDestroyMutation();
const objectId = +(objectIdParam || 0);
const handleControlSetPointObjectClick = () => {
setObjectId(String(value.controlSetPointId));
};
const handleRemoveControl = () => {
deleteControl({
id: value.controlSetPoint!,
});
};
return (
<div className="flex flex-row text-success">
<div className="flex flex-row gap-2 pt-1 flex-grow text-success">
<ReverseReplace size={14} fill="hsl(var(--muted-foreground))" />
<small className="font-light">
Replacing {value.controlSetPointName}
{value.controlSetPointId != objectId && <small> at:</small>}
</small>
{value.controlSetPointId != objectId && (
<small
onClick={handleControlSetPointObjectClick}
style={{ cursor: "pointer", textDecoration: "underline" }}
>
{value.controlSetPointObject}
</small>
)}
{canMutate && (
<small
className="cursor-pointer bold underline"
onClick={onChangeDof}
>
Change
</small>
)}
</div>
{canMutate && (
<ToolTipCover content="Click to remove parameter replacement.">
<X
color="hsl(var(--muted-foreground))"
onClick={handleRemoveControl}
aria-label={`setpoint-${displayName}`}
></X>
</ToolTipCover>
)}
</div>
);
}
// When this property is replaced by another property
function ReplacedByInfo({ value, displayName, canMutate }: ReplaceInfoProps) {
const [objectIdParam, setObjectId] = useSearchParam("object");
const [deleteControl] = useCoreControlvaluesDestroyMutation();
const objectId = +(objectIdParam || 0);
const handleControlManipulatedObjectClick = () => {
setObjectId(String(value.controlManipulatedId));
};
const handleRemoveControl = () => {
deleteControl({
id: value.controlManipulated!,
});
};
return (
<div className="flex flex-row text-success">
<div className="flex flex-row gap-2 flex-grow text-success">
<small className="font-light">
{" "}
Replaced by {value.controlManipulatedName}
{value.controlManipulatedId != objectId && <small> at:</small>}
</small>
{value.controlManipulatedId != objectId && (
<small
onClick={handleControlManipulatedObjectClick}
style={{ cursor: "pointer", textDecoration: "underline" }}
>
{value.controlManipulatedObject}
</small>
)}
</div>
{canMutate && (
<ToolTipCover content="Click to remove replacement.">
<X
color="hsl(var(--muted-foreground))"
onClick={handleRemoveControl}
aria-label={`controlled-${displayName}`}
></X>
</ToolTipCover>
)}
</div>
);
}
|