Skip to content

Commit cb3fde1

Browse files
authored
chore: allow opting out of the welcome screen VSCODE-697 (#1053)
1 parent f26234a commit cb3fde1

File tree

3 files changed

+53
-11
lines changed

3 files changed

+53
-11
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,11 @@
12771277
"connectionString"
12781278
]
12791279
}
1280+
},
1281+
"mdb.showOverviewPageAfterInstall": {
1282+
"type": "boolean",
1283+
"default": true,
1284+
"description": "Specify whether to show the overview page immediately after installing the extension."
12801285
}
12811286
}
12821287
},

src/mdbExtensionController.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,24 +1018,35 @@ export default class MDBExtensionController implements vscode.Disposable {
10181018
}
10191019

10201020
showOverviewPageIfRecentlyInstalled(): void {
1021+
const showOverviewFromSettings = vscode.workspace
1022+
.getConfiguration('mdb')
1023+
.get<boolean>('showOverviewPageAfterInstall');
1024+
1025+
if (!showOverviewFromSettings) {
1026+
// Users may opt out of showing the overview page in the settings.
1027+
return;
1028+
}
1029+
10211030
const hasBeenShownViewAlready = !!this._storageController.get(
10221031
StorageVariables.GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW,
10231032
);
10241033

1025-
// Show the overview page when it hasn't been show to the
1026-
// user yet, and they have no saved connections.
1027-
if (!hasBeenShownViewAlready) {
1028-
if (!this._connectionStorage.hasSavedConnections()) {
1029-
void vscode.commands.executeCommand(
1030-
EXTENSION_COMMANDS.MDB_OPEN_OVERVIEW_PAGE,
1031-
);
1032-
}
1034+
if (hasBeenShownViewAlready) {
1035+
// Don't show the overview page if it has already been shown.
1036+
return;
1037+
}
10331038

1034-
void this._storageController.update(
1035-
StorageVariables.GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW,
1036-
true,
1039+
if (!this._connectionStorage.hasSavedConnections()) {
1040+
// Only show the overview page if there are no saved connections.
1041+
void vscode.commands.executeCommand(
1042+
EXTENSION_COMMANDS.MDB_OPEN_OVERVIEW_PAGE,
10371043
);
10381044
}
1045+
1046+
void this._storageController.update(
1047+
StorageVariables.GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW,
1048+
true,
1049+
);
10391050
}
10401051

10411052
async dispose(): Promise<void> {

src/test/suite/mdbExtensionController.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,6 +1716,32 @@ suite('MDBExtensionController Test Suite', function () {
17161716
assert(!executeCommandStub.called);
17171717
});
17181718
});
1719+
1720+
suite('when a user has opted out of the overview page', () => {
1721+
beforeEach(async () => {
1722+
await vscode.workspace
1723+
.getConfiguration('mdb')
1724+
.update('showOverviewPageAfterInstall', false);
1725+
1726+
sandbox.replace(
1727+
mdbTestExtension.testExtensionController._storageController,
1728+
'get',
1729+
sandbox.fake.returns(false),
1730+
);
1731+
1732+
void mdbTestExtension.testExtensionController.showOverviewPageIfRecentlyInstalled();
1733+
});
1734+
1735+
afterEach(async () => {
1736+
await vscode.workspace
1737+
.getConfiguration('mdb')
1738+
.update('showOverviewPageAfterInstall', undefined);
1739+
});
1740+
1741+
test('they are not shown the overview page', () => {
1742+
assert(!executeCommandStub.called);
1743+
});
1744+
});
17191745
});
17201746
});
17211747

0 commit comments

Comments
 (0)