import { Checkbox, Dropdown, Icon, IconButton, IDropdownOption, ITextFieldStyles, Label, Link, Stack, Text, TextField, TooltipHost, } from "@fluentui/react"; import React from "react"; import { userContext } from "UserContext"; export const PostgresConnectTab: React.FC = (): JSX.Element => { const { adminLogin, nodes, enablePublicIpAccess } = userContext.postgresConnectionStrParams; const [usePgBouncerPort, setUsePgBouncerPort] = React.useState(false); const [selectedNode, setSelectedNode] = React.useState(nodes?.[0]?.value); const portNumber = usePgBouncerPort ? "6432" : "5432"; const onCopyBtnClicked = (selector: string): void => { const textfield: HTMLInputElement = document.querySelector(selector); textfield.select(); document.execCommand("copy"); }; const textfieldStyles: Partial = { root: { width: "100%" }, field: { backgroundColor: "rgb(230, 230, 230)" }, fieldGroup: { borderColor: "rgb(138, 136, 134)" }, subComponentStyles: { label: { fontWeight: 400 } }, description: { fontWeight: 400 }, }; const nodesDropdownOptions: IDropdownOption[] = nodes.map((node) => ({ key: node.value, text: node.text, })); const postgresSQLConnectionURL = `postgres://${adminLogin}:{your_password}@${selectedNode}:${portNumber}/citus?sslmode=require`; const psql = `psql "host=${selectedNode} port=${portNumber} dbname=citus user=${adminLogin} password={your_password} sslmode=require"`; const jdbc = `jdbc:postgresql://${selectedNode}:${portNumber}/citus?user=${adminLogin}&password={your_password}&sslmode=require`; const libpq = `host=${selectedNode} port=${portNumber} dbname=citus user=${adminLogin} password={your_password} sslmode=require`; const adoDotNet = `Server=${selectedNode};Database=citus;Port=${portNumber};User Id=${adminLogin};Password={your_password};Ssl Mode=Require;`; return (
{ const selectedNode = option.key as string; setSelectedNode(selectedNode); if (!selectedNode.startsWith("c.")) { setUsePgBouncerPort(false); } }} style={{ width: 200 }} /> setUsePgBouncerPort(checked)} disabled={!selectedNode?.startsWith("c.")} /> onCopyBtnClicked("#postgresSQLConnectionURL")} /> onCopyBtnClicked("#psql")} /> onCopyBtnClicked("#JDBC")} /> onCopyBtnClicked("#libpq")} /> onCopyBtnClicked("#adoDotNet")} /> Only secure connections are supported. For production use cases, we recommend using the 'verify-full' mode to enforce TLS certificate verification. You will need to download the Hyperscale (Citus) certificate, and provide it when connecting to the database.{" "} Learn more Refer to our{" "} guide {" "} to help you connect via pgAdmin.
); };