diff --git a/package.json b/package.json index b238ac577..a78053c7e 100644 --- a/package.json +++ b/package.json @@ -1277,6 +1277,11 @@ "connectionString" ] } + }, + "mdb.showOverviewPageAfterInstall": { + "type": "boolean", + "default": true, + "description": "Specify whether to show the overview page immediately after installing the extension." } } }, diff --git a/src/mdbExtensionController.ts b/src/mdbExtensionController.ts index 363b5d2a7..cebcce663 100644 --- a/src/mdbExtensionController.ts +++ b/src/mdbExtensionController.ts @@ -1018,24 +1018,35 @@ export default class MDBExtensionController implements vscode.Disposable { } showOverviewPageIfRecentlyInstalled(): void { + const showOverviewFromSettings = vscode.workspace + .getConfiguration('mdb') + .get('showOverviewPageAfterInstall'); + + if (!showOverviewFromSettings) { + // Users may opt out of showing the overview page in the settings. + return; + } + const hasBeenShownViewAlready = !!this._storageController.get( StorageVariables.GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW, ); - // Show the overview page when it hasn't been show to the - // user yet, and they have no saved connections. - if (!hasBeenShownViewAlready) { - if (!this._connectionStorage.hasSavedConnections()) { - void vscode.commands.executeCommand( - EXTENSION_COMMANDS.MDB_OPEN_OVERVIEW_PAGE, - ); - } + if (hasBeenShownViewAlready) { + // Don't show the overview page if it has already been shown. + return; + } - void this._storageController.update( - StorageVariables.GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW, - true, + if (!this._connectionStorage.hasSavedConnections()) { + // Only show the overview page if there are no saved connections. + void vscode.commands.executeCommand( + EXTENSION_COMMANDS.MDB_OPEN_OVERVIEW_PAGE, ); } + + void this._storageController.update( + StorageVariables.GLOBAL_HAS_BEEN_SHOWN_INITIAL_VIEW, + true, + ); } async dispose(): Promise { diff --git a/src/test/suite/mdbExtensionController.test.ts b/src/test/suite/mdbExtensionController.test.ts index c3b33d1ef..bfdf2449e 100644 --- a/src/test/suite/mdbExtensionController.test.ts +++ b/src/test/suite/mdbExtensionController.test.ts @@ -1716,6 +1716,32 @@ suite('MDBExtensionController Test Suite', function () { assert(!executeCommandStub.called); }); }); + + suite('when a user has opted out of the overview page', () => { + beforeEach(async () => { + await vscode.workspace + .getConfiguration('mdb') + .update('showOverviewPageAfterInstall', false); + + sandbox.replace( + mdbTestExtension.testExtensionController._storageController, + 'get', + sandbox.fake.returns(false), + ); + + void mdbTestExtension.testExtensionController.showOverviewPageIfRecentlyInstalled(); + }); + + afterEach(async () => { + await vscode.workspace + .getConfiguration('mdb') + .update('showOverviewPageAfterInstall', undefined); + }); + + test('they are not shown the overview page', () => { + assert(!executeCommandStub.called); + }); + }); }); });