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

query panel migration revamp #1093

Merged
merged 43 commits into from
May 31, 2024
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
70f5889
feat: query panel migration
saravmajestic Apr 22, 2024
89e4f06
feat: add query panel default view
saravmajestic Apr 23, 2024
99eae35
fix: query panel components
saravmajestic Apr 23, 2024
8e7ebcc
fix: front end changes
saravmajestic Apr 23, 2024
8bcc5be
fix: perspective in vscode
saravmajestic Apr 26, 2024
0df9103
fix: ui styling
saravmajestic Apr 26, 2024
15908c9
fix: query cancel delay
saravmajestic Apr 29, 2024
5591b1d
fix: loading icon
saravmajestic Apr 29, 2024
c3d4087
fix: hint logic
saravmajestic Apr 29, 2024
5525f9d
Merge branch 'master' into feat/query-panel-migration
saravmajestic Apr 30, 2024
b421dea
fix: show loading when triggered before webview ready
saravmajestic Apr 30, 2024
6313bfc
fix: perspective ui fixes
saravmajestic Apr 30, 2024
66a92a7
fix: query panel fixes
saravmajestic Apr 30, 2024
711a84d
chore: remove table scale for perspective
saravmajestic Apr 30, 2024
10bf1c6
fix: query limit fixes
saravmajestic Apr 30, 2024
e9fe67d
Merge branch 'master' into feat/query-panel-migration
saravmajestic Apr 30, 2024
0f7009c
fix: code cleanup
saravmajestic Apr 30, 2024
b3cca03
fix: query panel perspective themes
saravmajestic May 1, 2024
4fba6c0
fix: toggle v2 buttons
saravmajestic May 1, 2024
1af29d8
Merge branch 'master' into feat/query-panel-migration
saravmajestic May 1, 2024
315f27a
chore: text changes as per comments
saravmajestic May 2, 2024
3539a9b
fix: query cancel issue
saravmajestic May 2, 2024
d4b48ca
Merge branch 'master' into feat/query-panel-migration
saravmajestic May 3, 2024
4210278
Merge branch 'master' into feat/query-panel-migration
anandgupta42 May 6, 2024
c92be50
Merge branch 'master' into feat/query-panel-migration
saravmajestic May 6, 2024
e96a930
Merge branch 'master' into feat/query-panel-migration
saravmajestic May 7, 2024
ff3cb76
fix: add storybook update
saravmajestic May 7, 2024
4a1fb9f
Merge branch 'master' into feat/query-panel-migration
saravmajestic May 8, 2024
bb2ad77
Merge branch 'master' into feat/query-panel-migration
saravmajestic May 9, 2024
36eacea
fix: query panel sql ui issues
saravmajestic May 9, 2024
c5779ab
Merge branch 'master' into feat/query-panel-migration
saravmajestic May 10, 2024
29d1861
Merge branch 'master' into feat/query-panel-migration
saravmajestic May 13, 2024
320378d
fix: add title for testing
saravmajestic May 14, 2024
45e2455
Merge branch 'master' into feat/query-panel-migration
saravmajestic May 16, 2024
e790c55
Merge branch 'master' into feat/query-panel-migration
saravmajestic May 17, 2024
293a053
Merge branch 'master' into feat/query-panel-migration
saravmajestic May 21, 2024
2f3737c
Merge branch 'master' into feat/query-panel-migration
saravmajestic May 29, 2024
bdddd1a
Merge branch 'master' into feat/query-panel-migration
anandgupta42 May 29, 2024
0590f6f
fix: ignore v1
saravmajestic May 30, 2024
03fd016
fix: use right config variable
saravmajestic May 30, 2024
5f38d7c
Merge branch 'master' into feat/query-panel-migration
saravmajestic May 30, 2024
365bc81
Merge branch 'master' into feat/query-panel-migration
saravmajestic May 30, 2024
d2ea9eb
Merge branch 'master' into feat/query-panel-migration
anandgupta42 May 31, 2024
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
Prev Previous commit
Next Next commit
fix: front end changes
saravmajestic committed Apr 23, 2024
commit 8e7ebcc95d653db5f36b40fc8ad51eb3d39f95a7
6 changes: 6 additions & 0 deletions src/webview_provider/altimateWebviewProvider.ts
Original file line number Diff line number Diff line change
@@ -296,6 +296,12 @@ export class AltimateWebviewProvider implements WebviewViewProvider {
params.properties as { [key: string]: string },
);
break;
case "setContext":
this.dbtProjectContainer.setToGlobalState(
params.key as string,
params.value,
);
break;
case "updateConfig":
if (!this.isUpdateConfigProps(params)) {
return;
61 changes: 60 additions & 1 deletion webview_panels/src/modules/queryPanel/QueryPanel.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Meta } from "@storybook/react";
import QueryPanelProvider from "./QueryPanelProvider";
import { Button, Stack } from "@uicore";

const meta = {
title: "Query Panel",
@@ -14,8 +15,66 @@ const meta = {

export default meta;

const ActionButton = ({
data,
title,
}: {
data: { command: string } & Record<string, unknown>;
title: string;
}) => {
const handleAction = () => {
window.postMessage({
command: data.command,
args: data,
});
};
return <Button onClick={handleAction}>{title}</Button>;
};

export const DefaultQueryPanelView = {
render: (): JSX.Element => {
return <QueryPanelProvider />;
return (
<div>
<Stack className="mb-4">
<ActionButton
data={{ command: "renderLoading" }}
title="Start loading"
/>
<ActionButton
data={{
command: "renderQuery",
raw_sql: "select * from {{ref'users'}}",
compiled_sql: "select * from users",
rows: [{ x: 0, y: false }],
columnNames: [],
}}
title="Render query results"
/>
<ActionButton
data={{
command: "renderError",
raw_sql: "select * from {{ref'users'}}",
compiled_sql: "select * from users",
errorTitle: "Error title",
errorMessage: "Error message here",
errorDataMarkup: "Error data markup here",
}}
title="Render Error"
/>
<ActionButton data={{ command: "resetState" }} title="Reset state" />
</Stack>
<QueryPanelProvider />
</div>
);
},
parameters: {
vscode: {
func: (request: Record<string, unknown>): unknown => {
if (request.command === "getQueryPanelContext") {
return { lastHintTimestamp: 0 };
}
},
timer: 500,
},
},
};
4 changes: 2 additions & 2 deletions webview_panels/src/modules/queryPanel/QueryPanel.tsx
Original file line number Diff line number Diff line change
@@ -2,14 +2,14 @@ import FeedbackButton from "@modules/commonActionButtons/FeedbackButton";
import { Stack } from "@uicore";
import HelpButton from "./components/help/HelpButton";
import ClearResultsButton from "./components/clearResultsButton/ClearResultsButton";
import useListeners from "./useListeners";
import useQueryPanelListeners from "./useQueryPanelListeners";
import QueryPanelTitle from "./components/QueryPanelContents/QueryPanelTitle";
import QueryPanelContent from "./components/QueryPanelContents/QueryPanelContent";
import { useState } from "react";

const QueryPanel = (): JSX.Element => {
const [showCompiledCode, setShowCompiledCode] = useState(false);
useListeners();
useQueryPanelListeners();
return (
<div>
<Stack className="mb-2 justify-content-between">
Original file line number Diff line number Diff line change
@@ -5,14 +5,23 @@ const QueryPanelTitle = ({
}: {
setShowCompiledCode: (show: boolean) => void;
}): JSX.Element => {
const { loading, hasData, hasError, queryExecutionInfo, compiledCodeMarkup } =
useQueryPanelState();
const {
loading,
hasData,
hasError,
queryExecutionInfo,
compiledCodeMarkup,
queryResultsRowCount,
} = useQueryPanelState();

if (loading || hasData || hasError) {
return (
<div>
<span onClick={() => setShowCompiledCode(false)}>
Preview <span>{queryExecutionInfo}</span>
Preview{" "}
<span>
{queryResultsRowCount} rows in {queryExecutionInfo?.elapsedTime}s
</span>
</span>
{compiledCodeMarkup ? (
<span onClick={() => setShowCompiledCode(true)}>SQL</span>
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import { useQueryPanelDispatch } from "@modules/queryPanel/QueryPanelProvider";
import { resetData } from "@modules/queryPanel/context/queryPanelSlice";
import useQueryPanelState from "@modules/queryPanel/useQueryPanelState";
import { Button } from "@uicore";

const ClearResultsButton = (): JSX.Element | null => {
const { queryResults } = useQueryPanelState();
const dispatch = useQueryPanelDispatch();
const handleClear = () => {
dispatch(resetData());
};
if (!queryResults) {
return null;
}
return <Button outline>Clear results</Button>;
return (
<Button outline onClick={handleClear}>
Clear results
</Button>
);
};

export default ClearResultsButton;
2 changes: 2 additions & 0 deletions webview_panels/src/modules/queryPanel/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const HINT_VISIBILITY_DELAY = 1 * 60 * 60 * 1000; // 1 hr

export const HINTS = [
{
message: "Generate models from SQL or source",
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ export const initialState = {
queryResultsError: undefined,
compiledCodeMarkup: undefined,
hintIndex: -1,
lastHintTimestamp: 0,
} as QueryPanelStateProps;

const queryPanelSlice = createSlice({
@@ -29,6 +30,12 @@ const queryPanelSlice = createSlice({
) => {
state.compiledCodeMarkup = action.payload;
},
setLastHintTimestamp: (
state,
action: PayloadAction<QueryPanelStateProps["lastHintTimestamp"]>,
) => {
state.lastHintTimestamp = action.payload;
},
setQueryResultsError: (
state,
action: PayloadAction<QueryPanelStateProps["queryResultsError"]>,
@@ -64,6 +71,7 @@ export const {
setQueryResultsError,
setQueryExecutionInfo,
setQueryResults,
setLastHintTimestamp,
} = queryPanelSlice.actions;

export default queryPanelSlice;
3 changes: 2 additions & 1 deletion webview_panels/src/modules/queryPanel/context/types.ts
Original file line number Diff line number Diff line change
@@ -3,12 +3,13 @@ import { TableData } from "@finos/perspective";
export interface QueryPanelStateProps {
loading: boolean;
queryResults?: TableData;
queryExecutionInfo?: string;
queryExecutionInfo?: { elapsedTime: number };
queryResultsError?: {
errorTitle: string;
errorMessage: string;
errorDataMarkup: string;
};
compiledCodeMarkup?: string;
hintIndex: number;
lastHintTimestamp: number;
}
60 changes: 0 additions & 60 deletions webview_panels/src/modules/queryPanel/useListeners.ts

This file was deleted.

Loading