Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi buffer support in editor #65

Draft
wants to merge 72 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
c96693a
Multi-buffer editor PoC
insmac Sep 30, 2022
f1cb613
pass-through prop
insmac Sep 30, 2022
606db6b
Add file rename
insmac Sep 30, 2022
737af34
simplify editor tabs code
insmac Sep 30, 2022
e1507e7
Cleanup renaming
insmac Oct 1, 2022
90c125b
Merge branch 'web-console/multi-buffer' of https://github.com/questdb…
insmac Oct 1, 2022
98c1f9f
Cleanup
insmac Oct 1, 2022
e8fc587
Update value on rename
insmac Oct 1, 2022
88fe488
Merge branch 'main' into web-console/multi-buffer
argshook Oct 6, 2022
af41142
add uuid
argshook Oct 6, 2022
615c02c
rename `file` -> `buffer` and use id instead of label
argshook Oct 6, 2022
196bf4b
extract label to component
argshook Oct 10, 2022
65e0038
set value to buffers
argshook Oct 10, 2022
772b3fa
add dexie and dexie-react-hooks
argshook Oct 10, 2022
f7f3534
use dexie for buffers storage
argshook Oct 10, 2022
3dcd6f6
fix everything
argshook Oct 10, 2022
05094fe
remove uuid and @types/uuid
argshook Oct 10, 2022
094330c
save activeBufferId to db
argshook Oct 11, 2022
346ec50
set active buffer after deleting one
argshook Oct 11, 2022
772fa7a
populate buffer from local storage
argshook Oct 11, 2022
f7663f9
remove query_text after popoulating indexedDB
argshook Oct 11, 2022
44d2e32
refactor editor provider
argshook Oct 12, 2022
769cd84
remove getValue
argshook Oct 12, 2022
8fd0890
refactor Monaco file
argshook Oct 12, 2022
e4a4e2b
extract language addons to file
argshook Oct 12, 2022
c238fd3
extract legacy event bus action to dedicated file
argshook Oct 12, 2022
b58a0e0
save editorViewState to indexedDB
argshook Oct 12, 2022
5bbf93d
remove localStorage preferences
argshook Oct 12, 2022
18ef1ca
fix default editorViewState
argshook Oct 12, 2022
f962535
preserve viewState when switching tabs
argshook Oct 12, 2022
b4aa8bc
add hack to restoreViewState on initial load
argshook Oct 13, 2022
625dcb3
wrap EditorProvider right in Editor component
argshook Oct 13, 2022
5f795d7
refactor restoreViewState hack
argshook Oct 13, 2022
143176c
fix buffer deleting and state save
argshook Oct 13, 2022
d264f09
fix types and rename editorReadyHook -> editorReadyTrigger
argshook Oct 13, 2022
5c917ed
fix tab renaming
argshook Oct 13, 2022
582a965
add new buffer when `?query` is used
argshook Oct 13, 2022
f9592cd
fix `executeQuery` for `addBuffer`
argshook Oct 13, 2022
cd6b652
use `addBuffer` for example quries
argshook Oct 13, 2022
4a84c2a
done check for `buffer.value`
argshook Oct 13, 2022
3d04f1b
fix `add` button in schema
argshook Oct 14, 2022
18a40ed
Merge branch 'main' into web-console/multi-buffer
argshook Oct 17, 2022
cdc5b0f
Merge branch 'main' into web-console/multi-buffer
argshook Oct 24, 2022
966ef6a
add keyboard shortcuts
argshook Oct 24, 2022
5ab9325
add getAll to buffers store API
argshook Oct 26, 2022
4a2817b
make sure at least one buffer is available
argshook Oct 26, 2022
c9dab7f
prevent closing tab with alt+w when only one in total
argshook Oct 26, 2022
a4b138a
fix buffer deletion and state save
argshook Oct 26, 2022
9063116
show `close` context menu entry only when buffers.length > 1
argshook Oct 26, 2022
25c0616
disallow renaming tab to empty string
argshook Oct 26, 2022
c1ff7ee
fix browser-tests to work with multi buffers
argshook Oct 26, 2022
78d5033
for QueryPicker add new buffer if current non empty
argshook Oct 26, 2022
7770082
upgrade cypress to v10
argshook Nov 7, 2022
41e49f9
migrate cypress config to v10
argshook Nov 7, 2022
c9b0e9a
add few browser tests for tabs
argshook Nov 7, 2022
0f9c5bc
add another test
argshook Nov 7, 2022
8601d48
Merge branch 'main' into web-console/multi-buffer
argshook Nov 7, 2022
3534e97
fix keyboard shortcut test
argshook Nov 7, 2022
c4c4bfe
do not set activebuffer for already active buffer
argshook Nov 7, 2022
b27eda6
remove `double click to rename` feature
argshook Nov 7, 2022
ac321d5
fix bug found by tabs test
argshook Nov 8, 2022
35130c7
fix active tab highlight when removing all with keyboard shortcut
argshook Nov 8, 2022
de32874
add license banner
argshook Nov 8, 2022
4188e1d
wip tab UI and scrolling
argshook Nov 9, 2022
ee6b6b6
scroll into view active tab
argshook Nov 9, 2022
7451e98
keep focus on editor after closing tab
argshook Nov 9, 2022
891c442
keep editor focus when clicking active tab
argshook Nov 9, 2022
a627d96
adjust tab style
argshook Nov 9, 2022
7760ed0
ensure tab text is not trimmed vertically
argshook Nov 9, 2022
9cb44fa
add tab open/close shortcuts info
argshook Nov 14, 2022
bb3d046
Merge branch 'main' into web-console/multi-buffer
argshook Feb 15, 2023
929560f
Merge branch 'main' into web-console/multi-buffer
bluestreak01 Feb 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
64 changes: 48 additions & 16 deletions packages/browser-tests/cypress/integration/console/editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ describe("appendQuery", () => {
consoleConfiguration
).as("getConsoleConfiguration");

indexedDB.deleteDatabase("web-console");
cy.visit(baseUrl);
cy.getEditor().should("be.visible");
});

it("should append and select query", () => {
Expand All @@ -46,59 +48,87 @@ describe("appendQuery", () => {
cy.getEditor().should("have.value", expected).snapshot();
});

it("should correctly append and select query after multiple inserts", () => {
cy.selectQuery(1);
cy.selectQuery(2);
cy.typeQuery(`{ctrl}g2{enter}`); // go to line 2
it("should open new tab for each new query", () => {
cy.selectQuery(0);
cy.selectQuery(1);
const expected = `${queries[1]}\n\n${queries[1]}\n\n${queries[2]}\n`;
cy.getEditor().should("have.value", expected).snapshot();
cy.getTab(0).click();
cy.getEditor().should(
"have.value",
`${consoleConfiguration.savedQueries[0].value}\n`
);

cy.getTab(1).click();
cy.getEditor().should(
"have.value",
consoleConfiguration.savedQueries[1].value
);
});

it("should correctly append and select query when position is first line which is empty", () => {
// this test is trying to assert `appendQuery` through `QueryPicker`.
// `QueryPicker` adds new tab for each query
// @TODO: move `appendQuery` test to `@questdb/web-console` unit tests
it.skip("should correctly append and select query when position is first line which is empty", () => {
cy.typeQuery(`{enter}--b{upArrow}`);
cy.selectQuery(0);
cy.selectQuery(1);
const expected = `${queries[0]}\n\n${queries[1]}\n\n--b`;
cy.getEditor().should("have.value", expected).snapshot();
});

it("should correctly append and select query when position is first line which is not empty", () => {
// this test is trying to assert `appendQuery` through `QueryPicker`.
// `QueryPicker` adds new tab for each query
// @TODO: move `appendQuery` test to `@questdb/web-console` unit tests
it.skip("should correctly append and select query when position is first line which is not empty", () => {
cy.typeQuery(`--a`);
cy.selectQuery(0);
const expected = `--a\n\n${queries[0]}\n`;
cy.getEditor().should("have.value", expected).snapshot();
});

it("should correctly append and select query when position is first line which is not empty and there's more content after", () => {
// this test is trying to assert `appendQuery` through `QueryPicker`.
// `QueryPicker` adds new tab for each query
// @TODO: move `appendQuery` test to `@questdb/web-console` unit tests
it.skip("should correctly append and select query when position is first line which is not empty and there's more content after", () => {
cy.typeQuery(`--a{enter}{enter}--b{upArrow}{upArrow}`);
cy.selectQuery(0);
const expected = `--a\n\n${queries[0]}\n\n--b`;
cy.getEditor().should("have.value", expected).snapshot();
});

it("should correctly append and add surrounding new lines when position is middle line which is empty", () => {
// this test is trying to assert `appendQuery` through `QueryPicker`.
// `QueryPicker` adds new tab for each query
// @TODO: move `appendQuery` test to `@questdb/web-console` unit tests
it.skip("should correctly append and add surrounding new lines when position is middle line which is empty", () => {
cy.typeQuery(`--a{enter}{enter}--b{upArrow}`);
cy.selectQuery(0);
const expected = `--a\n\n${queries[0]}\n\n--b`;
cy.getEditor().should("have.value", expected).snapshot();
});

it("should correctly append and add surrounding new lines when position is last line which is empty", () => {
// this test is trying to assert `appendQuery` through `QueryPicker`.
// `QueryPicker` adds new tab for each query
// @TODO: move `appendQuery` test to `@questdb/web-console` unit tests
it.skip("should correctly append and add surrounding new lines when position is last line which is empty", () => {
cy.typeQuery(`--a{enter}--b`);
cy.selectQuery(0);
const expected = `--a\n--b\n\n${queries[0]}\n`;
cy.getEditor().should("have.value", expected).snapshot();
});

it("should correctly append and add surrounding new lines when there are two lines and position is last line which is empty", () => {
// this test is trying to assert `appendQuery` through `QueryPicker`.
// `QueryPicker` adds new tab for each query
// @TODO: move `appendQuery` test to `@questdb/web-console` unit tests
it.skip("should correctly append and add surrounding new lines when there are two lines and position is last line which is empty", () => {
cy.typeQuery(`--a{enter}`);
cy.selectQuery(0);
const expected = `--a\n\n${queries[0]}\n`;
cy.getEditor().should("have.value", expected).snapshot();
});

it("should correctly append and add surrounding new lines when position is middle of non empty line and next line is empty", () => {
// this test is trying to assert `appendQuery` through `QueryPicker`.
// `QueryPicker` adds new tab for each query
// @TODO: move `appendQuery` test to `@questdb/web-console` unit tests
it.skip("should correctly append and add surrounding new lines when position is middle of non empty line and next line is empty", () => {
cy.typeQuery(`--a{enter}--b{enter}{enter}--c`);
cy.typeQuery(`{ctrl}g2{enter}{rightArrow}`); // go to line 2
cy.selectQuery(0);
Expand Down Expand Up @@ -149,17 +179,20 @@ describe("&query URL param", () => {

describe("autocomplete", () => {
beforeEach(() => {
indexedDB.deleteDatabase("web-console");
Cypress.on("uncaught:exception", (err) => {
// this error can be safely ignored
if (err.message.includes("ResizeObserver loop limit exceeded")) {
return false;
}
});

cy.visit(baseUrl);
cy.getEditor().should("be.visible");
});

it("should work when tables list is empty", () => {
cy.visit(baseUrl);
cy.typeQuery("select * from tel");
cy.typeQuery("select * from teleme");
cy.getAutocomplete().should("not.be.visible");
cy.clearEditor();
cy.runQuery('create table "my_secrets" ("secret" string)');
Expand All @@ -170,7 +203,6 @@ describe("autocomplete", () => {
});

it("should work when tables list is not empty", () => {
cy.visit(baseUrl);
cy.runQuery('create table "my_secrets" ("secret" string)');
cy.runQuery('create table "my_publics" ("public" string)');
cy.reload();
Expand Down
9 changes: 8 additions & 1 deletion packages/browser-tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Cypress.Commands.add("runQuery", (query) => {
return cy.typeQuery(query).type("{ctrl}{enter}").wait("@exec");
});

Cypress.Commands.add("clearEditor", () => cy.typeQuery("{ctrl}a{backspace}"));
Cypress.Commands.add("clearEditor", () => {
cy.typeQuery("{ctrl}a{backspace}");
});

Cypress.Commands.add("selectQuery", (n) =>
cy
Expand All @@ -41,5 +43,10 @@ Cypress.Commands.add("getErrorMarker", () => cy.get(".squiggly-error"));
Cypress.Commands.add("F9", () =>
cy.getEditor().trigger("keydown", {
keyCode: 120,
force: true,
})
);

Cypress.Commands.add("getTab", (nth = 0) =>
cy.get("[data-hook^=tab-]").eq(nth)
);
10 changes: 5 additions & 5 deletions packages/browser-tests/snapshots.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion packages/web-console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
"compare-versions": "^5.0.1",
"core-js": "^3.22.8",
"date-fns": "2.14.0",
"dexie": "^3.2.2",
"dexie-react-hooks": "^1.1.1",
"docsearch.js": "2.6.3",
"dotenv": "^10.0.0",
"echarts": "^5.2.2",
Expand All @@ -53,7 +55,8 @@
"sql-formatter": "^4.0.2",
"styled-components": "5.1.1",
"styled-icons": "10.2.1",
"throttle-debounce": "2.2.1"
"throttle-debounce": "2.2.1",
"usehooks-ts": "^2.7.1"
},
"devDependencies": {
"@babel/cli": "^7.17.10",
Expand Down
Loading