Skip to content

Commit

Permalink
chore(ui): handle and display error received while scrolling the grid (
Browse files Browse the repository at this point in the history
…#348)

* chore(ui): handle and display error received while scrolling the grid

* test

* improved test

* merge

* update submodule

* update submodule

* update submodule

* update submodule

---------

Co-authored-by: Vlad Ilyushchenko <[email protected]>
  • Loading branch information
glasstiger and bluestreak01 authored Nov 6, 2024
1 parent a752692 commit 46af9fb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
13 changes: 13 additions & 0 deletions packages/browser-tests/cypress/integration/console/grid.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ describe("questdb grid", () => {
cy.getGridViewport().scrollTo("bottom");
});

it("multiple scrolls till the bottom with error", () => {
const rows = 1200;
cy.typeQuery(`select simulate_crash('P') from long_sequence(${rows})`);
cy.runLine();

cy.getGridViewport().scrollTo(0, 999 * rowHeight);
cy.getCollapsedNotifications().should("contain", "1,200 rows in");

cy.getGridViewport().scrollTo("bottom");
cy.wait(100);
cy.getCollapsedNotifications().should("contain", "HTTP 400 (Bad request)");
});

it("copy cell into the clipboard", () => {
cy.typeQuery("select x from long_sequence(10)");
cy.runLine();
Expand Down
34 changes: 24 additions & 10 deletions packages/web-console/src/scenes/Result/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import $ from "jquery"
import React, { useContext, useEffect, useRef, useState } from "react"
import { useSelector } from "react-redux"
import { useDispatch, useSelector } from "react-redux"
import styled from "styled-components"
import { Download2, Refresh } from "@styled-icons/remix-line"
import { Reset } from "@styled-icons/boxicons-regular"
Expand All @@ -40,15 +40,17 @@ import {
Text,
Tooltip,
} from "../../components"
import { selectors } from "../../store"
import { color, QueryRawResult } from "../../utils"
import { actions, selectors } from "../../store"
import {color, ErrorResult, QueryRawResult} from "../../utils"
import * as QuestDB from "../../utils/questdb"
import { ResultViewMode } from "scenes/Console/types"
import { Button } from "@questdb/react-components"
import type { IQuestDBGrid } from "../../js/console/grid.js"
import { eventBus } from "../../modules/EventBus"
import { EventType } from "../../modules/EventBus/types"
import { QuestContext } from "../../providers"
import {QueryInNotification} from "../Editor/Monaco/query-in-notification";
import {NotificationType} from "../../store/Query/types";

const Root = styled.div`
display: flex;
Expand Down Expand Up @@ -98,17 +100,29 @@ const Result = ({ viewMode }: { viewMode: ResultViewMode }) => {
const activeSidebar = useSelector(selectors.console.getActiveSidebar)
const gridRef = useRef<IQuestDBGrid | undefined>()
const [gridFreezeLeftState, setGridFreezeLeftState] = useState<number>(0)

const dispatch = useDispatch()

useEffect(() => {
const _grid = grid(
document.getElementById("grid"),
async function (sql, lo, hi, rendererFn: (data: QueryRawResult) => void) {
const result = await quest.queryRaw(sql, {
limit: `${lo},${hi}`,
nm: true,
})
if (result.type === QuestDB.Type.DQL) {
rendererFn(result)
try {
const result = await quest.queryRaw(sql, {
limit: `${lo},${hi}`,
nm: true,
})
if (result.type === QuestDB.Type.DQL) {
rendererFn(result)
}
} catch (err) {
dispatch(actions.query.stopRunning())
dispatch(
actions.query.addNotification({
content: <Text color="red">{(err as ErrorResult).error}</Text>,
sideContent: <QueryInNotification query={sql} />,
type: NotificationType.ERROR,
}),
)
}
},
)
Expand Down

0 comments on commit 46af9fb

Please sign in to comment.