Skip to content

Commit 55a0d9b

Browse files
1 parent e9a2fa8 commit 55a0d9b

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

packages/databricks-vscode/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,13 @@
203203
"viewsWelcome": [
204204
{
205205
"view": "configurationView",
206-
"contents": "In order to connect to a cluster you first have to configure your Databricks workspace:\n[Configure Databricks](command:databricks.connection.configureProject)\nTo learn more about how to use Databricks with VS Code [read our docs](https://github.com/databricks/databricks-vscode)."
206+
"contents": "In order to connect to a cluster you first have to configure your Databricks workspace:\n[Configure Databricks](command:databricks.connection.configureProject)\nTo learn more about how to use Databricks with VS Code [read our docs](https://github.com/databricks/databricks-vscode).",
207+
"when": "workspaceFolderCount > 0"
208+
},
209+
{
210+
"view": "configurationView",
211+
"contents": "Please open a folder to start using Databricks on VSCode.\n[Open Folder](command:vscode.openFolder)",
212+
"when": "workspaceFolderCount == 0"
207213
}
208214
],
209215
"menus": {

packages/databricks-vscode/src/extension.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,22 @@ import {
3030
import {format, loggers, transports} from "winston";
3131
import {UtilsCommands} from "./utils/UtilsCommands";
3232

33-
export function activate(context: ExtensionContext): PublicApi {
33+
export function activate(context: ExtensionContext): PublicApi | undefined {
34+
const a = workspace.workspaceFolders;
35+
if (
36+
workspace.workspaceFolders === undefined ||
37+
workspace.workspaceFolders?.length === 0
38+
) {
39+
window.showErrorMessage("Open a folder to use Databricks extension");
40+
/*
41+
We force the user to open a folder from the databricks sidebar view. Returning
42+
here blocks all other commands from running.
43+
Since the workspace is reloaded when a folder is opened, the activation function
44+
is called again. Therefore this won't block the activation of the extension on a
45+
valid workspace.
46+
*/
47+
return undefined;
48+
}
3449
NamedLogger.getOrCreate(
3550
ExposedLoggers.SDK,
3651
{

0 commit comments

Comments
 (0)