Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Add privacy modals to external links #62

Merged
merged 10 commits into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions locales/en/out/constants.i18n.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"dialogResponses.acceptPrivacy": "Got it",
"dialogResponses.dontShowAgain": "Don't Show Again",
"dialogResponses.exampleCode": "Example Code on GitHub",
"dialogResponses.help": "I need help",
Expand All @@ -18,7 +19,10 @@
"info.firstTimeWebview": "To reopen the simulator click on the \"Open Simulator\" button on the upper right corner of the text editor, or select the command \"Open Simulator\" from command palette.",
"error.invalidFileExtensionDebug":"The file you tried to run isn\\'t a Python file.",
"info.newProject": "New to Python or Circuit Playground Express project? We are here to help!",
"info.redirect": "You are being redirected.",
"info.runningCode": "Running user code",
"info.privacyStatement": "Privacy Statement",
"info.thirdPartyWebsite": "You will be redirect to adafruit.com, a website outside Microsoft. Read the privacy statement on Adafruit:",
"info.welcomeOutputTab": "Welcome to the Adafruit Simulator output tab !\n\n",
"label.webviewPanel": "Adafruit CPX",
"name": "Pacifica Simulator"
Expand Down
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ export const CONSTANTS = {
"info.newProject",
"New to Python or Circuit Playground Express project? We are here to help!"
),
REDIRECT: localize("info.redirect", "You are being redirected."),
RUNNING_CODE: localize("info.runningCode", "Running user code"),
THIRD_PARTY_WEBSITE: localize("info.thirdPartyWebsite", "You will be redirect to adafruit.com, a website outside Microsoft. Read the privacy statement on Adafruit:"),
WELCOME_OUTPUT_TAB: localize(
"info.welcomeOutputTab",
"Welcome to the Adafruit Simulator output tab !\n\n"
Expand All @@ -98,6 +100,7 @@ export const CONSTANTS = {
"https://github.com/adafruit/Adafruit_CircuitPython_CircuitPlayground/tree/master/examples",
HELP:
"https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart",
PRIVACY: "https://www.adafruit.com/privacy",
TUTORIALS:
"https://learn.adafruit.com/circuitpython-made-easy-on-circuit-playground-express/circuit-playground-express-library"
},
Expand Down Expand Up @@ -154,6 +157,7 @@ export namespace DialogResponses {
export const DONT_SHOW: MessageItem = {
title: localize("dialogResponses.dontShowAgain", "Don't Show Again")
};
export const PRIVACY_STATEMENT: MessageItem = { title: localize("info.privacyStatement", "Privacy Statement") };
export const TUTORIALS: MessageItem = {
title: localize("dialogResponses.tutorials", "Tutorials on Adafruit")
};
Expand Down
22 changes: 14 additions & 8 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,13 @@ export function activate(context: vscode.ExtensionContext) {
TelemetryEventName.CLICK_DIALOG_EXAMPLE_CODE
);
} else if (selection === DialogResponses.TUTORIALS) {
open(CONSTANTS.LINKS.TUTORIALS);
telemetryAI.trackFeatureUsage(
TelemetryEventName.CLICK_DIALOG_TUTORIALS
);
const okAction = () => {
open(CONSTANTS.LINKS.TUTORIALS);
telemetryAI.trackFeatureUsage(
TelemetryEventName.CLICK_DIALOG_TUTORIALS
);
}
utils.showPrivacyModal(okAction);
}
});
}
Expand Down Expand Up @@ -400,10 +403,13 @@ export function activate(context: vscode.ExtensionContext) {
)
.then((selection: vscode.MessageItem | undefined) => {
if (selection === DialogResponses.HELP) {
telemetryAI.trackFeatureUsage(
TelemetryEventName.CLICK_DIALOG_HELP_DEPLOY_TO_DEVICE
);
open(CONSTANTS.LINKS.HELP);
const okAction = () => {
open(CONSTANTS.LINKS.HELP);
telemetryAI.trackFeatureUsage(
TelemetryEventName.CLICK_DIALOG_HELP_DEPLOY_TO_DEVICE
);
}
utils.showPrivacyModal(okAction);
}
});
break;
Expand Down
16 changes: 14 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { ExtensionContext, Uri } from "vscode";
import { ExtensionContext, MessageItem, Uri, window } from "vscode";
import * as path from "path";
import { USER_CODE_NAMES } from "./constants";
import { CONSTANTS, DialogResponses, USER_CODE_NAMES } from "./constants";

// tslint:disable-next-line: export-name
export const getPathToScript = (
Expand All @@ -24,3 +24,15 @@ export const validCodeFileName = (filePath: string) => {
filePath.endsWith(USER_CODE_NAMES.MAIN_PY)
);
};

export const showPrivacyModal = (okAction: () => void) => {
window.showInformationMessage(
`${CONSTANTS.INFO.THIRD_PARTY_WEBSITE} ${CONSTANTS.LINKS.PRIVACY}`,
DialogResponses.MESSAGE_UNDERSTOOD
)
.then((privacySelection: MessageItem | undefined) => {
if (privacySelection === DialogResponses.MESSAGE_UNDERSTOOD) {
okAction();
}
})
}