Skip to content

Commit d5b69e4

Browse files
Show t&c popup for private preview (#1128)
## Changes <!-- Summary of your changes that are easy to understand --> ## Tests <!-- How is this tested? -->
1 parent f3354a7 commit d5b69e4

File tree

6 files changed

+54
-7
lines changed

6 files changed

+54
-7
lines changed

packages/databricks-vscode/src/extension.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
extensions,
66
window,
77
workspace,
8+
env,
9+
Uri,
810
} from "vscode";
911
import {CliWrapper} from "./cli/CliWrapper";
1012
import {ConnectionCommands} from "./configuration/ConnectionCommands";
@@ -60,6 +62,7 @@ import {BundleProjectManager} from "./bundle/BundleProjectManager";
6062
import {TreeItemDecorationProvider} from "./ui/bundle-resource-explorer/DecorationProvider";
6163
import {BundleInitWizard} from "./bundle/BundleInitWizard";
6264
import {DatabricksDebugConfigurationProvider} from "./run/DatabricksDebugConfigurationProvider";
65+
import {isIntegrationTest} from "./utils/developmentUtils";
6366

6467
const customWhenContext = new CustomWhenContext();
6568

@@ -69,6 +72,43 @@ export async function activate(
6972
customWhenContext.setActivated(false);
7073
customWhenContext.setDeploymentState("idle");
7174

75+
const stateStorage = new StateStorage(context);
76+
77+
if (
78+
!stateStorage.get("databricks.preview-tnc.accepted") &&
79+
!isIntegrationTest()
80+
) {
81+
const acceptTnc = await window.showInformationMessage(
82+
`Please note that you should only be using this functionality if you are part of our private preview and have accepted our terms and conditions regarding this preview.`,
83+
{
84+
modal: true,
85+
detail: `In order to enroll in the private preview please contact us and we will get you added`,
86+
},
87+
"Contact us",
88+
"Continue if you are already enrolled"
89+
);
90+
switch (acceptTnc) {
91+
case "Contact us":
92+
env.openExternal(
93+
Uri.parse(
94+
"mailto:[email protected]?subject=Databricks+Extension+v2+Private+Preview+Enrollment+Request"
95+
)
96+
);
97+
window.showErrorMessage(
98+
"Databricks Extension is not activated"
99+
);
100+
return;
101+
case "Continue if you are already enrolled":
102+
stateStorage.set("databricks.preview-tnc.accepted", true);
103+
break;
104+
default:
105+
window.showErrorMessage(
106+
"Databricks Extension is not activated"
107+
);
108+
return;
109+
}
110+
}
111+
72112
if (extensions.getExtension("databricks.databricks-vscode") !== undefined) {
73113
await commands.executeCommand(
74114
"workbench.extensions.uninstallExtension",
@@ -126,7 +166,6 @@ export async function activate(
126166
}
127167

128168
const workspaceUri = workspace.workspaceFolders[0].uri;
129-
const stateStorage = new StateStorage(context);
130169

131170
// Add the databricks binary to the PATH environment variable in terminals
132171
context.environmentVariableCollection.clear();

packages/databricks-vscode/src/telemetry/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe(__filename, () => {
4040
});
4141

4242
it("sets context metadata with prod env type", async () => {
43-
delete process.env["TEST_DEFAULT_CLUSTER_ID"];
43+
delete process.env["DATABRICKS_VSCODE_INTEGRATION_TEST"];
4444
telemetry.setMetadata(Metadata.CONTEXT, getContextMetadata());
4545
telemetry.recordEvent(Events.COMMAND_EXECUTION, {
4646
command: "testCommand",
@@ -58,7 +58,7 @@ describe(__filename, () => {
5858
});
5959

6060
it("sets context metadata with tests env type", async () => {
61-
process.env["TEST_DEFAULT_CLUSTER_ID"] = "123";
61+
process.env["DATABRICKS_VSCODE_INTEGRATION_TEST"] = "true";
6262
telemetry.setMetadata(Metadata.CONTEXT, getContextMetadata());
6363
telemetry.recordEvent(Events.COMMAND_EXECUTION, {
6464
command: "testCommand",

packages/databricks-vscode/src/telemetry/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import TelemetryReporter from "@vscode/extension-telemetry";
22
import {DatabricksWorkspace} from "../configuration/DatabricksWorkspace";
3-
import {isDevExtension} from "../utils/developmentUtils";
3+
import {isDevExtension, isIntegrationTest} from "../utils/developmentUtils";
44
import {
55
DEV_APP_INSIGHTS_CONFIGURATION_KEY,
66
EventProperties,
@@ -82,9 +82,7 @@ export async function toUserMetadata(
8282

8383
export function getContextMetadata(): ExtraMetadata[Metadata.CONTEXT] {
8484
return {
85-
environmentType: process.env["TEST_DEFAULT_CLUSTER_ID"]
86-
? "tests"
87-
: "prod",
85+
environmentType: isIntegrationTest() ? "tests" : "prod",
8886
};
8987
}
9088

packages/databricks-vscode/src/test/e2e/wdio.conf.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ export const config: Options.Testrunner = {
279279
process.env.WORKSPACE_PATH = WORKSPACE_PATH;
280280
process.env.TEST_REPO_PATH = repoPath;
281281
process.env.TEST_WORKSPACE_FOLDER_PATH = workspaceFolderPath;
282+
process.env.DATABRICKS_VSCODE_INTEGRATION_TEST = "true";
282283
} catch (e) {
283284
console.error(e);
284285
process.exit(1);

packages/databricks-vscode/src/utils/developmentUtils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ export const EXTENSION_DEVELOPMENT = "EXTENSION_DEVELOPMENT";
33
export function isDevExtension(): boolean {
44
return process.env.EXTENSION_DEVELOPMENT === "true";
55
}
6+
7+
export function isIntegrationTest(): boolean {
8+
return process.env.DATABRICKS_VSCODE_INTEGRATION_TEST === "true";
9+
}

packages/databricks-vscode/src/vscode-objs/StateStorage.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ const StorageConfigurations = {
8383
location: "global",
8484
defaultValue: "0.0.0",
8585
}),
86+
87+
"databricks.preview-tnc.accepted": withType<boolean>()({
88+
location: "global",
89+
defaultValue: false,
90+
}),
8691
};
8792

8893
type Keys = keyof typeof StorageConfigurations;

0 commit comments

Comments
 (0)