Skip to content

Commit

Permalink
Prevent welcome view flashes (#1399)
Browse files Browse the repository at this point in the history
## Changes
Right now if you switch to the Databricks panel (after the extension is
already logged in), you will still see "Create a new Databricks Project"
welcome view for half a second.

This is because our main view takes this long to load all the relevant
information (sync component make API request to the workspace). This PR
prevents UI flashed by adding "Loading configuration" welcome view based
on the isBundleProject flag.

## Tests
Manual and existing tests
  • Loading branch information
ilia-db authored Oct 21, 2024
1 parent c1c4a43 commit 261e06c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/databricks-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@
]
},
"viewsWelcome": [
{
"view": "configurationView",
"contents": "Initializing...",
"when": "workspaceFolderCount > 0 && !databricks.context.initialized"
},
{
"view": "configurationView",
"contents": "There are multiple Databricks projects in the folder:\n[Open existing Databricks Project](command:databricks.bundle.openSubProject)",
Expand All @@ -398,12 +403,12 @@
{
"view": "configurationView",
"contents": "[Create a new Databricks Project](command:databricks.bundle.initNewProject)",
"when": "workspaceFolderCount > 0 && databricks.context.initialized"
"when": "workspaceFolderCount > 0 && databricks.context.initialized && !databricks.context.isBundleProject"
},
{
"view": "configurationView",
"contents": "Initializing...",
"when": "workspaceFolderCount > 0 && !databricks.context.initialized"
"contents": "Loading configuration",
"when": "workspaceFolderCount > 0 && databricks.context.initialized && databricks.context.isBundleProject"
},
{
"view": "configurationView",
Expand Down Expand Up @@ -923,7 +928,7 @@
"package:copy-webview-toolkit": "cp ./node_modules/@vscode/webview-ui-toolkit/dist/toolkit.js ./out/toolkit.js",
"esbuild:base": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node --sourcemap --target=es2019",
"build": "yarn run package:wrappers:write && yarn run package:jupyter-init-script:write && tsc --build --force",
"watch": "yarn run package:wrappers:write && yarn run package:jupyter-init-script:write && yarn run package:copy-webview-toolkit && tsc --build --watch --force",
"watch": "yarn run package:wrappers:write && yarn run package:jupyter-init-script:write && yarn run package:copy-webview-toolkit && tsc --build --watch --force --verbose",
"fix": "eslint src --ext ts --fix && prettier . --write",
"test:lint": "eslint src --ext ts && prettier . -c",
"test:unit": "yarn run build && node ./out/test/runTest.js",
Expand Down
2 changes: 2 additions & 0 deletions packages/databricks-vscode/src/bundle/BundleProjectManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,13 @@ export class BundleProjectManager {
this.logger.debug(
"Detected an existing bundle project, initializing project services"
);
this.customWhenContext.setIsBundleProject(true);
return this.initProjectServices();
} else {
this.logger.debug(
"No bundle config detected, disposing project services"
);
this.customWhenContext.setIsBundleProject(false);
await this.disposeProjectServices();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ export class CustomWhenContext {
);
}

setIsBundleProject(value: boolean) {
commands.executeCommand(
"setContext",
"databricks.context.isBundleProject",
value
);
}

setSubProjectsAvailable(value: boolean) {
commands.executeCommand(
"setContext",
Expand Down

0 comments on commit 261e06c

Please sign in to comment.