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
Show file tree
Hide file tree
Changes from 32 commits
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
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
"description": "Enable the new query panel in dbt.",
"default": true
},
"dbt.enableQueryPanelV2": {
"type": "boolean",
"description": "Enable the new query panel in dbt.",
"default": false
},
"dbt.lineage.showSelectEdges": {
"type": "boolean",
"description": "Show select edges in lineage panel.",
Expand Down Expand Up @@ -149,6 +154,20 @@
"default": 500,
"minimum": 1
},
"dbt.perspectiveTheme": {
"type": "string",
"description": "Theme for perspective viewer in query results panel",
"default": "Vintage",
"enum": [
"Vintage",
"Pro Light",
"Pro Dark",
"Vaporwave",
"Solarized",
"Solarized Dark",
"Monokai"
]
},
"dbt.conversationsPollingInterval": {
"type": "integer",
"description": "Polling interval to fetch latest conversations (in seconds)",
Expand Down
23 changes: 22 additions & 1 deletion query_panel/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"Welcome 🚀" }}
</vscode-panel-tab>
<vscode-panel-tab id="tab-4" v-show="hasData" @click="togglePerspective"
>{{ isPerspective ? "Show legacy UI" : "Show new UI"
>{{ isPerspective ? "Switch to legacy UI" : "Switch to new UI"
}}</vscode-panel-tab
>
<vscode-panel-tab id="tab-5" @click="onFeedback"
Expand Down Expand Up @@ -134,6 +134,21 @@
>Download as CSV</vscode-button
>
</div>
<br />
<div class="new-ux-alert">
<span
>This legacy query results UI will be deprecated soon. The new
UI includes this functionality plus additional features.
Please contact us via
<a href="https://getdbt.slack.com/archives/C05KPDGRMDW"
>Slack</a
>
if needed.</span
>
<vscode-button class="btn-new-ux" @click="toggleV2"
>Switch to new UI
</vscode-button>
</div>
<div id="query-results" :style="getTableStyles()"></div>
</div>
</div>
Expand Down Expand Up @@ -199,6 +214,12 @@ <h2>Query Explanation</h2>
</div>

<div class="help-body">
<div class="new-ux-alert">
We are launching new and improved query results panel.
<vscode-button class="btn-new-ux" @click="toggleV2"
>Switch to new UI
</vscode-button>
</div>
<h2>Previewing Query</h2>
<p>
Press Cmd+Enter (Mac) or Control+Enter (Windows/Linux) to run a
Expand Down
11 changes: 10 additions & 1 deletion query_panel/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,12 @@ const app = createApp({
methods: {
togglePerspective() {
this.isPerspective = !this.isPerspective;
updateConfig({ enableNewQueryPanel: this.isPerspective });
// If user is in legacy view v0, and switches to new ui, take to v2
// if user is in v1, switches to legacy v0, take to v0
updateConfig({
enableNewQueryPanel: this.isPerspective,
enableQueryPanelV2: this.isPerspective,
});
this.updateTable(this.data);
setTimeout(() => {
document.querySelector("#panel-manager").activeid = "tab-1";
Expand Down Expand Up @@ -363,6 +368,9 @@ const app = createApp({
compiledSql: this.compiledCode,
});
},
toggleV2() {
updateConfig({ enableQueryPanelV2: true });
},
onFeedback() {
const prevTab = document.querySelector("#panel-manager").activeid;
executeCommand("openUrl", {
Expand Down Expand Up @@ -515,6 +523,7 @@ const app = createApp({
}
});
window.addEventListener("resize", this.handleResize);
executeCommand("webview:ready", {});
},
unmounted() {
window.removeEventListener("resize", this.handleResize);
Expand Down
16 changes: 16 additions & 0 deletions query_panel/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,19 @@ th {
regular-table::-webkit-scrollbar-thumb {
border-width: 2px;
}

.new-ux-alert {
border-radius: 4px;
background: rgba(255, 206, 115, 0.1);
color: var(--Stroke-Orange, #e38e00);
padding: 10px;
line-height: 2;
font-size: 14px;
display: flex;
justify-content: space-between;
margin-bottom: 1rem;
}
.btn-new-ux {
background: #e38e00;
vertical-align: middle;
}
4 changes: 2 additions & 2 deletions src/dbt_client/dbtCoreIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,13 @@ export class DBTCoreProjectIntegration
const queryThread = this.executionInfrastructure.createPythonBridge(
this.projectRoot.fsPath,
);
await this.createPythonDbtProject(queryThread);
await queryThread.ex`project.init_project()`;
return new QueryExecution(
async () => {
queryThread.kill(2);
},
async () => {
await this.createPythonDbtProject(queryThread);
await queryThread.ex`project.init_project()`;
Copy link
Collaborator

@AdiGajbhiye AdiGajbhiye May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure about this change. will the project be in usable state if we kill thread during init_project

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't matter as this is not affecting main thread.

// compile query
const compiledQuery = await this.unsafeCompileQuery(limitQuery);
// execute query
Expand Down
4 changes: 2 additions & 2 deletions src/inversify.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { DBTProjectLogFactory } from "./manifest/modules/dbtProjectLog";
import { SourceFileWatchersFactory } from "./manifest/modules/sourceFileWatchers";
import { TargetWatchersFactory } from "./manifest/modules/targetWatchers";
import { PythonEnvironment } from "./manifest/pythonEnvironment";
import { QueryResultPanel } from "./webview_provider/queryResultPanel";
import { TelemetryService } from "./telemetry";
import {
DBTCoreProjectDetection,
Expand All @@ -39,6 +38,7 @@ import { CommandProcessExecutionFactory } from "./commandProcessExecution";
import { AltimateRequest } from "./altimate";
import { ValidationProvider } from "./validation_provider";
import { DeferToProdService } from "./services/deferToProdService";
import { SharedStateService } from "./services/sharedStateService";

export const container = new Container();
container.load(buildProviderModule());
Expand Down Expand Up @@ -159,7 +159,7 @@ container
container.get(TargetWatchersFactory),
container.get(DBTCommandFactory),
container.get(DBTTerminal),
container.get(QueryResultPanel),
container.get(SharedStateService),
container.get(TelemetryService),
container.get("Factory<DBTCoreProjectIntegration>"),
container.get("Factory<DBTCloudProjectIntegration>"),
Expand Down
17 changes: 10 additions & 7 deletions src/manifest/dbtProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
extendErrorWithSupportLinks,
setupWatcherHandler,
} from "../utils";
import { QueryResultPanel } from "../webview_provider/queryResultPanel";
import {
ManifestCacheChangedEvent,
RebuildManifestStatusChange,
Expand Down Expand Up @@ -58,6 +57,7 @@ import { ValidationProvider } from "../validation_provider";
import { ModelNode } from "../altimate";
import { ColumnMetaData } from "../domain";
import { AltimateConfigProps } from "../webview_provider/insightsPanel";
import { SharedStateService } from "../services/sharedStateService";

interface FileNameTemplateMap {
[key: string]: string;
Expand Down Expand Up @@ -104,7 +104,7 @@ export class DBTProject implements Disposable {
private targetWatchersFactory: TargetWatchersFactory,
private dbtCommandFactory: DBTCommandFactory,
private terminal: DBTTerminal,
private queryResultPanel: QueryResultPanel,
private eventEmitterService: SharedStateService,
private telemetry: TelemetryService,
private dbtCoreIntegrationFactory: (
path: Uri,
Expand Down Expand Up @@ -889,11 +889,14 @@ select * from renamed
adapter: this.getAdapterType(),
limit: limit.toString(),
});
// TODO: this should generate an event instead of directly going to the panel
this.queryResultPanel.executeQuery(
query,
this.dbtProjectIntegration.executeSQL(query, limit),
);

this.eventEmitterService.fire({
command: "executeQuery",
payload: {
query,
fn: this.dbtProjectIntegration.executeSQL(query, limit),
},
});
}

async dispose() {
Expand Down
33 changes: 20 additions & 13 deletions src/webview_provider/altimateWebviewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export interface SharedStateEventEmitterProps {
payload: Record<string, unknown>;
}

interface SendMessageProps extends Record<string, unknown> {
export interface SendMessageProps extends Record<string, unknown> {
command: string;
syncRequestId?: string;
error?: string;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -426,17 +432,17 @@ export class AltimateWebviewProvider implements WebviewViewProvider {
),
),
);
// const insightsCss = webview.asWebviewUri(
// Uri.file(
// path.join(
// extensionUri.fsPath,
// "webview_panels",
// "dist",
// "assets",
// "Insights.css",
// ),
// ),
// );
const SpinnerUrl = webview.asWebviewUri(
Uri.file(
path.join(
extensionUri.fsPath,
"webview_panels",
"dist",
"assets",
"spinner.gif",
),
),
);
const codiconsUri = webview.asWebviewUri(
Uri.joinPath(
extensionUri,
Expand All @@ -460,7 +466,7 @@ export class AltimateWebviewProvider implements WebviewViewProvider {
and only allow scripts that have a specific nonce.
Added unsafe-inline for css due to csp issue: https://github.com/JedWatson/react-select/issues/4631
-->
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; font-src ${webview.cspSource}; style-src 'unsafe-inline' ${webview.cspSource}; img-src ${webview.cspSource} https: data:; script-src 'nonce-${nonce}' https://*.vscode-resource.vscode-cdn.net; connect-src https://*.s3.amazonaws.com">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; worker-src blob:; font-src ${webview.cspSource}; style-src 'unsafe-inline' ${webview.cspSource}; img-src ${webview.cspSource} https: data:; script-src 'unsafe-eval' 'nonce-${nonce}' https://*.vscode-resource.vscode-cdn.net; connect-src https://*.s3.amazonaws.com">
<title>VSCode DBT Power user extension</title>
<link rel="stylesheet" type="text/css" href="${indexCss}">
<link rel="stylesheet" type="text/css" href="${codiconsUri}">
Expand All @@ -471,6 +477,7 @@ export class AltimateWebviewProvider implements WebviewViewProvider {
<div id="sidebar"></div>
<script nonce="${nonce}" >
window.viewPath = "${this.viewPath}";
var spinnerUrl = "${SpinnerUrl}"
</script>

<script nonce="${nonce}" type="module" src="${indexJs}"></script>
Expand Down
Loading
Loading