Skip to content

Commit d2d58e6

Browse files
committed
feat(tree-explorer): add reactivity, sample value and remove configuration suffix
1 parent 06b1e90 commit d2d58e6

File tree

6 files changed

+35
-10
lines changed

6 files changed

+35
-10
lines changed

.vscode/settings.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
},
1818
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
1919
"typescript.tsc.autoDetect": "off",
20-
"mdb.presetSavedConnections": [
20+
"mdb.presetSavedConnections":[
2121
{
22-
"name": "Local Test",
23-
"connectionString": "mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000"
22+
"name": "Local Test Connection",
23+
"connectionString": "mongodb://localhost:27017"
2424
}
25+
],
26+
"conventionalCommits.scopes": [
27+
"tree-explorer"
2528
]
2629
}

package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,8 +1190,22 @@
11901190
"scope": "window",
11911191
"type": "array",
11921192
"description": "Defines preset saved connections.",
1193+
"examples": [
1194+
[
1195+
{
1196+
"name": "Local Test Connection",
1197+
"connectionString": "mongodb://localhost:27017"
1198+
}
1199+
]
1200+
],
11931201
"items": {
11941202
"type": "object",
1203+
"examples": [
1204+
{
1205+
"name": "Local Test Connection",
1206+
"connectionString": "mongodb://localhost:27017"
1207+
}
1208+
],
11951209
"properties": {
11961210
"name": {
11971211
"type": "string",

src/connectionController.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ export default class ConnectionController {
162162
}
163163

164164
async loadSavedConnections(): Promise<void> {
165+
this._connections = Object.create(null);
166+
165167
const loadedConnections = await this._connectionStorage.loadConnections();
166168

167169
for (const connection of loadedConnections) {

src/mdbExtensionController.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ export default class MDBExtensionController implements vscode.Disposable {
160160
this._editorsController.registerProviders();
161161
}
162162

163+
subscribeToConfigurationChanges(): void {
164+
const subscription = vscode.workspace.onDidChangeConfiguration((event) => {
165+
if (event.affectsConfiguration('mdb.presetSavedConnections')) {
166+
void this._connectionController.loadSavedConnections();
167+
}
168+
});
169+
this._context.subscriptions.push(subscription);
170+
}
171+
163172
async activate(): Promise<void> {
164173
this._explorerController.activateConnectionsTreeView();
165174
this._helpExplorer.activateHelpTreeView(this._telemetryService);
@@ -172,6 +181,7 @@ export default class MDBExtensionController implements vscode.Disposable {
172181

173182
this.registerCommands();
174183
this.showOverviewPageIfRecentlyInstalled();
184+
this.subscribeToConfigurationChanges();
175185

176186
const copilot = vscode.extensions.getExtension(COPILOT_EXTENSION_ID);
177187
void vscode.commands.executeCommand(

src/storage/connectionStorage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export class ConnectionStorage {
185185

186186
return presetSavedConnections.map((presetConnection) => ({
187187
id: uuidv4(),
188-
name: `${presetConnection.name} (From Configuration)`,
188+
name: presetConnection.name,
189189
connectionOptions: {
190190
connectionString: presetConnection.connectionString,
191191
},

src/test/suite/storage/connectionStorage.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,7 @@ suite('Connection Storage Test Suite', function () {
368368
for (let i = 0; i < connections.length; i++) {
369369
const connection = connections[i];
370370
const presetConnection = presetConnections[i];
371-
expect(connection.name).equals(
372-
`${presetConnection.name} (From Configuration)`
373-
);
371+
expect(connection.name).equals(presetConnection.name);
374372
expect(connection.connectionOptions.connectionString).equals(
375373
presetConnection.connectionString
376374
);
@@ -401,9 +399,7 @@ suite('Connection Storage Test Suite', function () {
401399
for (let i = 0; i < presetConnections.length; i++) {
402400
const connection = loadedConnections[i];
403401
const presetConnection = presetConnections[i];
404-
expect(connection.name).equals(
405-
`${presetConnection.name} (From Configuration)`
406-
);
402+
expect(connection.name).equals(presetConnection.name);
407403
expect(connection.connectionOptions.connectionString).equals(
408404
presetConnection.connectionString
409405
);

0 commit comments

Comments
 (0)