Skip to content

Commit

Permalink
Add VDBE endpoint view
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffxy committed Jan 23, 2025
1 parent 8eec87a commit 98fabad
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
36 changes: 36 additions & 0 deletions ui/src/components/VdbeView.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { useState } from "react";
import DbCylinder from "./DbCylinder";
import TableView from "./TableView";
import ExpandableTableSet from "./ExpandableTableSet";
import IconButton from "@mui/material/IconButton";
import Tooltip from "@mui/material/Tooltip";
import EditRoundedIcon from "@mui/icons-material/EditRounded";
import DeleteRoundedIcon from "@mui/icons-material/DeleteRounded";
import LinkRoundedIcon from "@mui/icons-material/LinkRounded";
import Snackbar from "@mui/material/Snackbar";
import "./styles/VdbeView.css";
import {
highlightTableViewClass,
Expand Down Expand Up @@ -75,8 +78,24 @@ function EditControls({ onEditClick, onDeleteClick }) {
);
}

function VdbeEndpoint({ endpoint, setShowSnackbar }) {
const handleCopy = () => {
navigator.clipboard.writeText(endpoint);
setShowSnackbar(true);
};
return (
<div class="vdbe-endpoint" onClick={handleCopy}>
<LinkRoundedIcon style={{ marginRight: "8px" }} />
<Tooltip title="Click to copy endpoint" placement="right">
<span>{endpoint}</span>
</Tooltip>
</div>
);
}

function VdbeView({
vdbe,
endpoint,
highlight,
onTableHoverEnter,
onTableHoverExit,
Expand All @@ -88,6 +107,14 @@ function VdbeView({
const peakLatency = formatMilliseconds(vdbe.p90_latency_slo_ms);
const dialect = formatDialect(vdbe.interface);
const sortedTables = sortTablesToHoist(highlight, vengName, true, tables);
const [showSnackbar, setShowSnackbar] = useState(false);

const handleClose = (event, reason) => {
if (reason === "clickaway") {
return;
}
setShowSnackbar(false);
};

return (
<div
Expand All @@ -99,6 +126,9 @@ function VdbeView({
<EditControls onEditClick={() => {}} onDeleteClick={() => {}} />
)}
</div>
{endpoint && (
<VdbeEndpoint endpoint={endpoint} setShowSnackbar={setShowSnackbar} />
)}
<div class="vdbe-view-props">
<ul>
<li>🌿: {freshness != null ? freshness : "-----"}</li>
Expand Down Expand Up @@ -131,6 +161,12 @@ function VdbeView({
/>
))}
</ExpandableTableSet>
<Snackbar
open={showSnackbar}
autoHideDuration={3000}
message="Endpoint copied to clipboard"
onClose={handleClose}
/>
</div>
);
}
Expand Down
19 changes: 19 additions & 0 deletions ui/src/components/styles/VdbeView.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,22 @@
.vdbe-view:hover .vdbe-edit-controls {
opacity: 1;
}

.vdbe-endpoint {
display: flex;
flex-direction: row;
align-items: center;
font-size: 1em;
margin: 0 0 15px 0;
cursor: pointer;
color: #1d8033;
transition: all 0.2s ease-in-out;

background-color: #f6fdf7;
border-radius: 20px;
padding: 3px 8px;
}

.vdbe-endpoint:hover {
color: #51a965;
}

0 comments on commit 98fabad

Please sign in to comment.