Skip to content

Commit

Permalink
Merge branch 'main' into web-console/fix-run-position
Browse files Browse the repository at this point in the history
  • Loading branch information
insmac authored Dec 28, 2023
2 parents 799523d + e462e26 commit 3c85a63
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 14 deletions.
38 changes: 28 additions & 10 deletions packages/browser-tests/cypress/integration/console/editor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,36 +194,54 @@ describe("autocomplete", () => {
.should("not.be.visible")
.clearEditor();

cy.typeQuery('create table "my_secrets" ("secret" string)')
.runLine()
.clearEditor();

cy.typeQuery("select * from my_")
.getAutocomplete()
.should("contain", "my_secrets");

cy.matchImageSnapshot();
cy.clearEditor().typeQuery('drop table "my_secrets"').runLine();
});

it("should work when tables list is not empty", () => {
cy.typeQuery('create table "my_secrets" ("secret" string);')
.clickRun()
.clearEditor();

// We're creating another table with the same column name.
// The autocomplete should merge the column completions into one
// and respond with something like `secret (my_secrets, my_secrets2)`
cy.typeQuery('create table "my_secrets2" ("secret" string);')
.clickRun()
.clearEditor();

cy.typeQuery('create table "my_publics" ("public" string);')
.clickRun()
.clearEditor();

cy.visit(baseUrl);
cy.typeQuery("\nselect * from ");
cy.typeQuery("\nselect ");
cy.getAutocomplete()
// Tables
.should("not.contain", "telemetry")
.should("contain", "my_secrets")
.should("contain", "my_publics")
// Columns
.should("contain", "secret")
.should("contain", "public")
// Tables list for the `secret` column
// list the tables containing `secret` column
.should("contain", "my_secrets, my_secrets2")
.clearEditor();

cy.typeQuery("select * from my_secrets where ");
cy.getAutocomplete()
.should("contain", "secret")
.should("not.contain", "public")
.clearEditor();

cy.typeQuery("select * from my_secrets join my_publics on ");
cy.getAutocomplete()
.should("contain", "my_publics.public")
.should("contain", "my_secrets.secret")
.clearEditor();

cy.typeQuery('drop table "my_secrets"').runLine().clearEditor();
cy.typeQuery('drop table "my_secrets2"').runLine().clearEditor();
cy.typeQuery('drop table "my_publics"').runLine().clearEditor();
});
});
Expand Down
3 changes: 2 additions & 1 deletion packages/web-console/src/components/ToggleButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ const baseStyles = css<Props>`
color: ${({ selected, theme }) =>
theme.color[selected ? "foreground" : "offWhite"]};
svg + span {
svg + span,
img + span {
margin-left: 1rem;
}
`
Expand Down
21 changes: 21 additions & 0 deletions packages/web-console/src/components/icons/import.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from "react"

export const Import = ({ size }: { size: string }) => (
<svg
width={size}
height={size}
viewBox="0 0 26 26"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M25 22.3704H1V24.1481H25V22.3704Z" fill="currentColor" />
<path
d="M1 19.2593V21.037H25V19.7037L21.8889 13.4815H16.1111V16.5926H9.88889V13.4815H4.11111L1 19.2593Z"
fill="currentColor"
/>
<path
d="M13 1.92593L6.33337 8.59259H11.2223V14.8148H14.3334V8.59259H19.6667L13 1.92593Z"
fill="currentColor"
/>
</svg>
)
3 changes: 2 additions & 1 deletion packages/web-console/src/scenes/Console/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { PrimaryToggleButton } from "../../components"
import { Import } from "./import"
import { BottomPanel } from "../../store/Console/types"
import { Allotment, AllotmentHandle } from "allotment"
import { Import as ImportIcon } from "../../components/icons/import"

const Root = styled.div`
display: flex;
Expand Down Expand Up @@ -218,7 +219,7 @@ const Console = () => {
selected={activeBottomPanel === "import"}
data-hook="import-panel-button"
>
<Upload2 size={BUTTON_ICON_SIZE} />
<ImportIcon size={BUTTON_ICON_SIZE} />
</PrimaryToggleButton>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export const createSchemaCompletionProvider = (
)

const fromMatch = queryAtCursor.query.match(/(?<=FROM\s)([^ )]+)/gim)
const joinMatch = queryAtCursor.query.match(/(JOIN)\s+([^ ]+)/)
const joinMatch = queryAtCursor.query.match(/(JOIN)\s+([^ ]+)/i)
const alterTableMatch = queryAtCursor.query.match(
/(ALTER TABLE)\s+([^ ]+)/,
/(ALTER TABLE)\s+([^ ]+)/i,
)
if (fromMatch) {
tableContext = uniq(fromMatch)
Expand Down

0 comments on commit 3c85a63

Please sign in to comment.