Skip to content

Commit 611338b

Browse files
authored
refine welcome view for getting started experiment (#700)
* not show first view by default Signed-off-by: Yan Zhang <[email protected]> * present first view once in control group Signed-off-by: Yan Zhang <[email protected]> * Exp treatment group: feature tour redirects to walkthrough Signed-off-by: Yan Zhang <[email protected]>
1 parent c666cb4 commit 611338b

File tree

5 files changed

+35
-20
lines changed

5 files changed

+35
-20
lines changed

src/exp/TreatmentVariables.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
export class TreatmentVariables {
55
public static readonly VSCodeConfig = 'vscode';
66
public static readonly PresentWelcomePageByDefault = 'presentWelcomePageByDefault';
7+
public static readonly JavaWalkthroughEnabled = "vscode.gettingStarted.overrideCategory.vscjava.vscode-java-pack.javaWelcome.when"
78
}

src/extension.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { initialize as initUtils } from "./utils";
77
import { initialize as initCommands } from "./commands";
88
import { initialize as initRecommendations } from "./recommendation";
99
import { showReleaseNotesOnStart, HelpViewType } from "./misc";
10-
import { initialize as initExp } from "./exp";
10+
import { getExpService, initialize as initExp } from "./exp";
1111
import { OverviewViewSerializer } from "./overview";
1212
import { JavaRuntimeViewSerializer, validateJavaRuntime } from "./java-runtime";
1313
import { scheduleAction } from "./utils/scheduler";
@@ -18,7 +18,8 @@ import { ClassPathConfigurationViewSerializer } from "./classpath/classpathConfi
1818
import { initFormatterSettingsEditorProvider } from "./formatter-settings";
1919
import { initRemoteProfileProvider } from "./formatter-settings/RemoteProfileProvider";
2020
import { CodeActionProvider } from "./providers/CodeActionProvider";
21-
import { KEY_SHOW_WHEN_USING_JAVA } from "./utils/globalState";
21+
import { KEY_IS_WELCOME_PAGE_VIEWED, KEY_SHOW_WHEN_USING_JAVA } from "./utils/globalState";
22+
import { TreatmentVariables } from "./exp/TreatmentVariables";
2223

2324
export async function activate(context: vscode.ExtensionContext) {
2425
syncState(context);
@@ -47,17 +48,17 @@ async function initializeExtension(_operationId: string, context: vscode.Extensi
4748

4849
const config = vscode.workspace.getConfiguration("java.help");
4950

50-
if (config.get("firstView") !== HelpViewType.None) {
51-
let showWhenUsingJava = context.globalState.get(KEY_SHOW_WHEN_USING_JAVA);
52-
if (showWhenUsingJava === undefined) {
53-
showWhenUsingJava = vscode.env.uiKind === vscode.UIKind.Desktop;
54-
}
51+
// for control group where walkthrough is not enabled, present first view for once.
52+
const walkthroughEnabled = getExpService().getTreatmentVariable<boolean>(TreatmentVariables.VSCodeConfig, TreatmentVariables.JavaWalkthroughEnabled);
53+
if (walkthroughEnabled === false && !context.globalState.get(KEY_IS_WELCOME_PAGE_VIEWED)) {
54+
presentFirstView(context);
55+
context.globalState.update(KEY_IS_WELCOME_PAGE_VIEWED, true)
56+
}
5557

56-
if (showWhenUsingJava) {
57-
scheduleAction("showFirstView", true).then(() => {
58-
presentFirstView(context);
59-
});
60-
}
58+
if (config.get("firstView") !== HelpViewType.None && context.globalState.get(KEY_SHOW_WHEN_USING_JAVA)) {
59+
scheduleAction("showFirstView", true).then(() => {
60+
presentFirstView(context);
61+
});
6162
}
6263

6364
if (config.get("showReleaseNotes")) {

src/welcome/assets/components/GetStartedPage.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import TourPage from "./TourPage";
1212

1313
export class GetStartedPage extends React.Component<{
1414
showWhenUsingJava: boolean,
15-
firstTimeRun: boolean
15+
firstTimeRun: boolean,
16+
walkthrough?: boolean
1617
}> {
1718

1819
render() {
@@ -25,7 +26,7 @@ export class GetStartedPage extends React.Component<{
2526
}
2627

2728
renderWelcomePage() {
28-
const {showWhenUsingJava} = this.props;
29+
const {showWhenUsingJava, walkthrough} = this.props;
2930
return (
3031
<Container fluid className="root">
3132
<Row className="mb-4">
@@ -35,7 +36,7 @@ export class GetStartedPage extends React.Component<{
3536
</Row>
3637
<Row className="mb-4">
3738
<Col>
38-
<QuickActionPanel />
39+
<QuickActionPanel walkthrough={walkthrough}/>
3940
</Col>
4041
</Row>
4142
<Row className="mb-4">

src/welcome/assets/components/QuickActionPanel.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { ListGroup } from "react-bootstrap";
66
import { encodeCommandUriWithTelemetry, supportedByNavigator } from "../../../utils/webview";
77
import { WEBVIEW_ID } from "../utils";
88

9-
export default class QuickActionPanel extends React.Component {
9+
export default class QuickActionPanel extends React.Component<{
10+
walkthrough?: boolean
11+
}, {}> {
1012
render() {
1113
const newProjectElement = <span>
1214
{"Create a "}
@@ -20,13 +22,17 @@ export default class QuickActionPanel extends React.Component {
2022
{"Take a "}
2123
<span className="highlight">{"Tour"}</span>
2224
</span>;
23-
const actions = [
25+
const actions: any[] = [
2426
{ name: "Create a New Project", command: "java.project.create", element: newProjectElement },
2527
{ name: "Open an Existing Project", command: "workbench.action.files.openFolder", os: "win", element: existingProjectElement },
2628
{ name: "Open an Existing Project", command: "workbench.action.files.openFolder", os: "linux", element: existingProjectElement },
2729
{ name: "Open an Existing Project", command: "workbench.action.files.openFileFolder", os: "mac", element: existingProjectElement },
28-
{ name: "Take a Tour", command: "java.welcome", args: [{ firstTimeRun: true }], element: tourElement }
2930
];
31+
// EXP: walkthrough v.s. previous feature tour
32+
actions.push(this.props.walkthrough ?
33+
{ name: "Take a Tour", command: "workbench.action.openWalkthrough", args: ["vscjava.vscode-java-pack#javaWelcome"], element: tourElement } :
34+
{ name: "Take a Tour", command: "java.welcome", args: [{ firstTimeRun: true }], element: tourElement }
35+
);
3036
const actionItems = actions.filter(action => !action.os || supportedByNavigator(action.os)).map(action => (
3137
<ListGroup.Item
3238
action

src/welcome/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import * as path from "path";
66
import { getExtensionContext, loadTextFromFile } from "../utils";
77
import { instrumentSimpleOperation, sendInfo } from "vscode-extension-telemetry-wrapper";
88
import { KEY_SHOW_WHEN_USING_JAVA, KEY_IS_WELCOME_PAGE_VIEWED } from "../utils/globalState";
9+
import { getExpService } from "../exp";
10+
import { TreatmentVariables } from "../exp/TreatmentVariables";
911

1012
let welcomeView: vscode.WebviewPanel | undefined;
1113

@@ -86,22 +88,26 @@ const setFirstTimeRun = (context: vscode.ExtensionContext, firstTimeRun: boolean
8688
};
8789

8890
const fetchInitProps = (context: vscode.ExtensionContext) => {
91+
const walkthrough = getExpService().getTreatmentVariable<boolean>(TreatmentVariables.VSCodeConfig, TreatmentVariables.JavaWalkthroughEnabled);
8992
welcomeView?.webview.postMessage({
9093
command: "onDidFetchInitProps",
9194
props: {
9295
showWhenUsingJava: context.globalState.get(KEY_SHOW_WHEN_USING_JAVA),
93-
firstTimeRun: context.globalState.get(KEY_IS_WELCOME_PAGE_VIEWED) !== true
96+
firstTimeRun: context.globalState.get(KEY_IS_WELCOME_PAGE_VIEWED) !== true,
97+
walkthrough
9498
}
9599
});
96100
setFirstTimeRun(context, false);
97101
};
98102

99103
const showTourPage = (context: vscode.ExtensionContext) => {
104+
const walkthrough = getExpService().getTreatmentVariable<boolean>(TreatmentVariables.VSCodeConfig, TreatmentVariables.JavaWalkthroughEnabled);
100105
welcomeView?.webview.postMessage({
101106
command: "onDidFetchInitProps",
102107
props: {
103108
showWhenUsingJava: context.globalState.get(KEY_SHOW_WHEN_USING_JAVA),
104-
firstTimeRun: true
109+
firstTimeRun: true,
110+
walkthrough
105111
}
106112
});
107113
setFirstTimeRun(context, false);

0 commit comments

Comments
 (0)