Add back removing panels via menu

Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
Julius Volz 2024-03-07 16:59:47 +01:00
parent 1e523b204d
commit 124f36e670
2 changed files with 7 additions and 0 deletions

View file

@ -58,6 +58,7 @@ import {
IconTerminal, IconTerminal,
IconTrash, IconTrash,
} from "@tabler/icons-react"; } from "@tabler/icons-react";
import { removePanel } from "../../state/queryPageSlice";
const promqlExtension = new PromQLExtension(); const promqlExtension = new PromQLExtension();
@ -106,11 +107,13 @@ export class HistoryCompleteStrategy implements CompleteStrategy {
interface ExpressionInputProps { interface ExpressionInputProps {
initialExpr: string; initialExpr: string;
executeQuery: (expr: string) => void; executeQuery: (expr: string) => void;
removePanel: () => void;
} }
const ExpressionInput: FC<ExpressionInputProps> = ({ const ExpressionInput: FC<ExpressionInputProps> = ({
initialExpr, initialExpr,
executeQuery, executeQuery,
removePanel,
}) => { }) => {
const theme = useComputedColorScheme(); const theme = useComputedColorScheme();
const [expr, setExpr] = useState(initialExpr); const [expr, setExpr] = useState(initialExpr);
@ -183,6 +186,7 @@ const ExpressionInput: FC<ExpressionInputProps> = ({
leftSection={ leftSection={
<IconTrash style={{ width: rem(14), height: rem(14) }} /> <IconTrash style={{ width: rem(14), height: rem(14) }} />
} }
onClick={removePanel}
> >
Remove query Remove query
</Menu.Item> </Menu.Item>

View file

@ -52,6 +52,9 @@ const QueryPanel: FC<PanelProps> = ({ idx }) => {
setRetriggerIdx((idx) => idx + 1); setRetriggerIdx((idx) => idx + 1);
dispatch(setExpr({ idx, expr })); dispatch(setExpr({ idx, expr }));
}} }}
removePanel={() => {
dispatch(removePanel(idx));
}}
/> />
<Tabs defaultValue="table" keepMounted={false}> <Tabs defaultValue="table" keepMounted={false}>
<Tabs.List> <Tabs.List>