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 | 6966x 6966x 6966x 6966x 6966x 6966x 6966x 248x | import {
PropertyInfoRead,
useCoreExpressionListQuery,
useCorePropertyinfoPartialUpdateMutation,
} from "../../../../../api/apiStore.gen";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
} from "../../../../../ahuora-design-system/ui/dropdown-menu";
import { useProjectId } from "../../../../../hooks/project";
import { CircleDot } from "lucide-react";
import { MSSDot } from "../../../multi-steady-state/MSSDot";
import { ToolTipCover } from "@/ahuora-design-system/ui/tooltip";
// Multi-steady-state connection popover
function MSSConnection(props: { property: PropertyInfoRead }) {
const id = useProjectId();
const expressions = useCoreExpressionListQuery({ flowsheet: id })?.data;
const [updateProperty] = useCorePropertyinfoPartialUpdateMutation();
const selectedExpression = props.property.expression + "";
const isSelected = selectedExpression != "null";
// TODO: Implement logic to update the propertyInfo when this changes.
const onChange = (value: string) => {
updateProperty({
id: props.property.id,
patchedPropertyInfo: {
expression: parseInt(value),
},
});
};
return (
<DropdownMenu>
<DropdownMenuTrigger>
<ToolTipCover content="Select data source" delay={0} asChild>
<div>
{" "}
{/** Do not remove this div. This div allows the tooltip to appear. */}
<MSSDot isSelected={isSelected} />
</div>
</ToolTipCover>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuRadioGroup
value={selectedExpression}
onValueChange={onChange}
>
<DropdownMenuLabel>Choose data source</DropdownMenuLabel>
<DropdownMenuSeparator />
{expressions?.map((expression) => {
return (
<DropdownMenuRadioItem
key={expression.id}
value={expression.id + ""}
disabled={expression.property?.expression || false}
>
{expression.name}
</DropdownMenuRadioItem>
);
})}
{isSelected && (
<>
<DropdownMenuSeparator />
<DropdownMenuRadioItem value="null">
Disconnect
</DropdownMenuRadioItem>
</>
)}
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
);
}
export default MSSConnection;
|