Skip to content
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
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,11 @@
"connectionString"
]
}
},
"mdb.showOverviewPageAfterInstall": {
"type": "boolean",
"default": true,
"description": "Specify whether to show the overview page immediately after installing the extension."
}
}
},
Expand Down
33 changes: 22 additions & 11 deletions src/mdbExtensionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1018,24 +1018,35 @@ export default class MDBExtensionController implements vscode.Disposable {
}

showOverviewPageIfRecentlyInstalled(): void {
const showOverviewFromSettings = vscode.workspace
.getConfiguration('mdb')
.get<boolean>('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<void> {
Expand Down
26 changes: 26 additions & 0 deletions src/test/suite/mdbExtensionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
});

Expand Down
Loading