Skip to content

Commit 74dd970

Browse files
authored
chore(webview): remove old form VSCODE-491 (#636)
1 parent 6f2017f commit 74dd970

File tree

103 files changed

+314
-9123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+314
-9123
lines changed

.depcheckrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ ignores:
55
- "@types/jest"
66
- "buffer"
77
- "eslint-config-mongodb-js"
8-
- "electron"
98
- "mocha-junit-reporter"
109
- "mocha-multi"
1110
- "mongodb-client-encryption"

.github/workflows/actions/test-and-build/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ runs:
7676

7777
- name: Build .vsix
7878
env:
79-
NODE_OPTIONS: "--require ./scripts/no-npm-list-fail.js --max_old_space_size=4096"
79+
NODE_OPTIONS: "--require ./scripts/no-npm-list-fail.js"
8080
# NOTE: --githubBranch is "The GitHub branch used to infer relative links in README.md."
8181
run: |
8282
npx vsce package --githubBranch main

package-lock.json

Lines changed: 228 additions & 1906 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,13 +1036,9 @@
10361036
"dependencies": {
10371037
"@babel/parser": "^7.22.6",
10381038
"@babel/traverse": "^7.23.2",
1039-
"@fortawesome/fontawesome-svg-core": "^6.4.0",
1040-
"@fortawesome/free-solid-svg-icons": "^6.4.0",
1041-
"@fortawesome/react-fontawesome": "^0.2.0",
1042-
"@iconify-icons/codicon": "^1.2.25",
1043-
"@iconify/react": "^1.1.4",
10441039
"@mongodb-js/compass-components": "^1.20.0",
10451040
"@mongodb-js/connection-form": "^1.20.4",
1041+
"@mongodb-js/connection-info": "^0.1.1",
10461042
"@mongodb-js/mongodb-constants": "^0.7.1",
10471043
"@mongosh/browser-runtime-electron": "^2.0.2",
10481044
"@mongosh/i18n": "^2.0.2",
@@ -1051,7 +1047,6 @@
10511047
"@segment/analytics-node": "^1.1.4",
10521048
"bson": "^6.1.0",
10531049
"bson-transpilers": "^2.0.4",
1054-
"classnames": "^2.3.2",
10551050
"debug": "^4.3.4",
10561051
"dotenv": "^16.3.1",
10571052
"lodash": "^4.17.21",
@@ -1060,16 +1055,13 @@
10601055
"mongodb-build-info": "^1.6.2",
10611056
"mongodb-cloud-info": "^2.1.0",
10621057
"mongodb-connection-string-url": "^2.6.0",
1063-
"mongodb-data-service": "^22.17.1",
1064-
"mongodb-data-service-legacy": "npm:[email protected]",
1058+
"mongodb-data-service": "^22.17.0",
10651059
"mongodb-log-writer": "^1.4.0",
10661060
"mongodb-query-parser": "^3.1.3",
10671061
"mongodb-schema": "^11.2.2",
10681062
"numeral": "^2.0.6",
10691063
"react": "^17.0.2",
10701064
"react-dom": "^17.0.2",
1071-
"react-redux": "^8.1.1",
1072-
"redux": "^4.2.1",
10731065
"resolve-mongodb-srv": "^1.1.2",
10741066
"ts-log": "^2.2.5",
10751067
"uuid": "^8.3.2",
@@ -1088,7 +1080,6 @@
10881080
"@types/babel__traverse": "^7.20.1",
10891081
"@types/chai": "^4.3.5",
10901082
"@types/debug": "^4.1.8",
1091-
"@types/enzyme": "^3.10.13",
10921083
"@types/glob": "^7.2.0",
10931084
"@types/jest": "^26.0.24",
10941085
"@types/micromatch": "^4.0.2",
@@ -1114,7 +1105,6 @@
11141105
"css-loader": "^6.8.1",
11151106
"depcheck": "^1.4.3",
11161107
"duplicate-package-checker-webpack-plugin": "^3.0.0",
1117-
"electron": "^23.3.9",
11181108
"enzyme": "^3.11.0",
11191109
"eslint": "^8.44.0",
11201110
"eslint-config-mongodb-js": "^5.0.3",
@@ -1154,11 +1144,6 @@
11541144
"webpack-merge": "^5.9.0",
11551145
"xvfb-maybe": "^0.2.1"
11561146
},
1157-
"overrides": {
1158-
"mongodb-connection-model": {
1159-
"@mongodb-js/compass-utils": "0.3.4"
1160-
}
1161-
},
11621147
"precommit": [
11631148
"check"
11641149
]

scripts/check-vsix-size.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const vsixFileName = path.resolve(
1212
);
1313
const size = fs.statSync(vsixFileName).size;
1414

15-
const maxSize = 8_500_000; // 8.5 MB
15+
const maxSize = 8_000_000;
1616

1717
if (size >= maxSize) {
1818
throw new Error(

src/connectionController.ts

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,20 @@ import { connect, createConnectionAttempt } from 'mongodb-data-service';
33
import type {
44
DataService,
55
ConnectionAttempt,
6-
ConnectionOptions as ConnectionOptionsFromCurrentDS,
6+
ConnectionOptions,
77
} from 'mongodb-data-service';
88
import ConnectionString from 'mongodb-connection-string-url';
99
import { EventEmitter } from 'events';
1010
import type { MongoClientOptions } from 'mongodb';
1111
import { v4 as uuidv4 } from 'uuid';
1212
import { cloneDeep, merge } from 'lodash';
1313
import { mongoLogId } from 'mongodb-log-writer';
14-
import type {
15-
ConnectionInfo as ConnectionInfoFromLegacyDS,
16-
ConnectionOptions as ConnectionOptionsFromLegacyDS,
17-
} from 'mongodb-data-service-legacy';
18-
import {
19-
extractSecrets,
20-
convertConnectionModelToInfo,
21-
} from 'mongodb-data-service-legacy';
14+
import { extractSecrets } from '@mongodb-js/connection-info';
2215
import { adjustConnectionOptionsBeforeConnect } from '@mongodb-js/connection-form';
2316

2417
import { CONNECTION_STATUS } from './views/webview-app/extension-app-message-constants';
2518
import { createLogger } from './logging';
2619
import formatError from './utils/formatError';
27-
import type LegacyConnectionModel from './views/webview-app/legacy/connection-model/legacy-connection-model';
2820
import type { StorageController } from './storage';
2921
import type { StatusView } from './views';
3022
import type TelemetryService from './telemetry/telemetryService';
@@ -75,13 +67,6 @@ type RecursivePartial<T> = {
7567
: T[P];
7668
};
7769

78-
export function launderConnectionOptionTypeFromLegacyToCurrent(
79-
opts: ConnectionOptionsFromLegacyDS
80-
): ConnectionOptionsFromCurrentDS {
81-
// Ensure that, at most, the types for OIDC mismatch here.
82-
return opts as Omit<typeof opts, 'oidc'>;
83-
}
84-
8570
export default class ConnectionController {
8671
// This is a map of connection ids to their configurations.
8772
// These connections can be saved on the session (runtime),
@@ -244,25 +229,19 @@ export default class ConnectionController {
244229
);
245230
}
246231

247-
parseNewConnection(
248-
rawConnectionModel: LegacyConnectionModel
249-
): ConnectionInfoFromLegacyDS {
250-
return convertConnectionModelToInfo({
251-
...rawConnectionModel,
252-
appname: `${packageJSON.name} ${packageJSON.version}`, // Override the default connection appname.
253-
});
254-
}
255-
256232
async saveNewConnectionAndConnect(
257-
originalConnectionInfo: ConnectionInfoFromLegacyDS,
233+
connection: {
234+
connectionOptions: ConnectionOptions;
235+
id: string;
236+
},
258237
connectionType: ConnectionTypes
259238
): Promise<ConnectionAttemptResult> {
260239
const savedConnectionWithoutSecrets =
261-
await this._connectionStorage.saveNewConnection(originalConnectionInfo);
240+
await this._connectionStorage.saveNewConnection(connection);
262241

263242
this._connections[savedConnectionWithoutSecrets.id] = {
264243
...savedConnectionWithoutSecrets,
265-
connectionOptions: originalConnectionInfo.connectionOptions, // The connection options with secrets.
244+
connectionOptions: connection.connectionOptions, // The connection options with secrets.
266245
};
267246

268247
log.info(
@@ -326,9 +305,7 @@ export default class ConnectionController {
326305
let dataService;
327306
try {
328307
const connectionOptions = adjustConnectionOptionsBeforeConnect({
329-
connectionOptions: launderConnectionOptionTypeFromLegacyToCurrent(
330-
connectionInfo.connectionOptions
331-
),
308+
connectionOptions: connectionInfo.connectionOptions,
332309
defaultAppName: packageJSON.name,
333310
notifyDeviceFlow: undefined,
334311
preferences: {

src/storage/connectionStorage.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import * as vscode from 'vscode';
2-
import type {
3-
ConnectionInfo as ConnectionInfoFromLegacyDS,
4-
ConnectionOptions as ConnectionOptionsFromLegacyDS,
5-
} from 'mongodb-data-service-legacy';
62
import {
73
getConnectionTitle,
84
extractSecrets,
95
mergeSecrets,
10-
} from 'mongodb-data-service-legacy';
6+
} from '@mongodb-js/connection-info';
7+
import type { ConnectionOptions } from 'mongodb-data-service';
118

129
import { createLogger } from '../logging';
1310
import type StorageController from './storageController';
@@ -26,7 +23,7 @@ export interface StoreConnectionInfo {
2623
name: string; // Possibly user given name, not unique.
2724
storageLocation: StorageLocation;
2825
secretStorageLocation?: SecretStorageLocationType;
29-
connectionOptions?: ConnectionOptionsFromLegacyDS;
26+
connectionOptions?: ConnectionOptions;
3027
}
3128

3229
type StoreConnectionInfoWithConnectionOptions = StoreConnectionInfo &
@@ -46,16 +43,19 @@ export class ConnectionStorage {
4643
}
4744

4845
// Returns the saved connection (without secrets).
49-
async saveNewConnection(originalConnectionInfo: ConnectionInfoFromLegacyDS) {
50-
const name = getConnectionTitle(originalConnectionInfo);
46+
async saveNewConnection(connection: {
47+
connectionOptions: ConnectionOptions;
48+
id: string;
49+
}): Promise<LoadedConnection> {
50+
const name = getConnectionTitle(connection);
5151
const newConnectionInfo = {
52-
id: originalConnectionInfo.id,
52+
id: connection.id,
5353
name,
5454
// To begin we just store it on the session, the storage controller
5555
// handles changing this based on user preference.
5656
storageLocation: StorageLocation.NONE,
5757
secretStorageLocation: SecretStorageLocation.SecretStorage,
58-
connectionOptions: originalConnectionInfo.connectionOptions,
58+
connectionOptions: connection.connectionOptions,
5959
};
6060

6161
return await this.saveConnectionWithSecrets(newConnectionInfo);
@@ -147,7 +147,7 @@ export class ConnectionStorage {
147147
): Promise<LoadedConnection> {
148148
// We don't want to store secrets to disc.
149149
const { connectionInfo: safeConnectionInfo, secrets } = extractSecrets(
150-
newStoreConnectionInfoWithSecrets as ConnectionInfoFromLegacyDS
150+
newStoreConnectionInfoWithSecrets
151151
);
152152
const savedConnectionInfo = await this.saveConnection({
153153
...newStoreConnectionInfoWithSecrets,

src/test/suite/connectionController.test.ts

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ import { afterEach, beforeEach } from 'mocha';
66
import assert from 'assert';
77
import * as mongodbDataService from 'mongodb-data-service';
88

9-
import AUTH_STRATEGY_VALUES from '../../views/webview-app/legacy/connection-model/constants/auth-strategies';
109
import ConnectionController, {
1110
DataServiceEventTypes,
12-
launderConnectionOptionTypeFromLegacyToCurrent,
1311
} from '../../connectionController';
1412
import formatError from '../../utils/formatError';
1513
import { StorageController, StorageVariables } from '../../storage';
@@ -18,9 +16,6 @@ import {
1816
DefaultSavingLocations,
1917
SecretStorageLocation,
2018
} from '../../storage/storageController';
21-
import READ_PREFERENCES from '../../views/webview-app/legacy/connection-model/constants/read-preferences';
22-
import SSH_TUNNEL_TYPES from '../../views/webview-app/legacy/connection-model/constants/ssh-tunnel-types';
23-
import SSL_METHODS from '../../views/webview-app/legacy/connection-model/constants/ssl-methods';
2419
import { StatusView } from '../../views';
2520
import TelemetryService from '../../telemetry/telemetryService';
2621
import { ExtensionContextStub } from './stubs';
@@ -762,9 +757,7 @@ suite('Connection Controller Test Suite', function () {
762757
await sleep(50);
763758

764759
return mongodbDataService.connect({
765-
connectionOptions: launderConnectionOptionTypeFromLegacyToCurrent(
766-
connectionOptions.connectionOptions
767-
),
760+
connectionOptions: connectionOptions.connectionOptions,
768761
});
769762
}
770763
);
@@ -868,39 +861,6 @@ suite('Connection Controller Test Suite', function () {
868861
);
869862
});
870863

871-
test('parseNewConnection converts a connection model to a connection info and overrides a default appname', () => {
872-
const connectionInfo = testConnectionController.parseNewConnection({
873-
_id: 'c4871b21-92c4-40e2-a2c2-fdd551cff114',
874-
isFavorite: false,
875-
name: 'Local',
876-
isSrvRecord: true,
877-
hostname: 'host.u88dd.test.test',
878-
port: 27017,
879-
hosts: [
880-
{ host: 'host-shard-00-00.u88dd.test.test', port: 27017 },
881-
{ host: 'host-shard-00-01.u88dd.test.test', port: 27017 },
882-
{ host: 'host-shard-00-02.u88dd.test.test', port: 27017 },
883-
],
884-
extraOptions: {},
885-
readPreference: READ_PREFERENCES.PRIMARY,
886-
authStrategy: AUTH_STRATEGY_VALUES.MONGODB,
887-
kerberosCanonicalizeHostname: false,
888-
sslMethod: SSL_METHODS.SYSTEMCA,
889-
sshTunnel: SSH_TUNNEL_TYPES.NONE,
890-
sshTunnelPort: 22,
891-
mongodbUsername: 'username',
892-
mongodbPassword: 'somepassword',
893-
mongodbDatabaseName: 'admin',
894-
});
895-
896-
assert.deepStrictEqual(connectionInfo, {
897-
id: 'c4871b21-92c4-40e2-a2c2-fdd551cff114',
898-
connectionOptions: {
899-
connectionString: `mongodb+srv://username:[email protected]/?authSource=admin&readPreference=primary&appname=mongodb-vscode+${version}&ssl=true`,
900-
},
901-
});
902-
});
903-
904864
test('getMongoClientConnectionOptions returns url and options properties', async () => {
905865
await testConnectionController.addNewConnectionStringAndConnect(
906866
TEST_DATABASE_URI

src/test/suite/language/mongoDBService.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import MongoDBService, {
2121
} from '../../../language/mongoDBService';
2222
import { mdbTestExtension } from '../stubbableMdbExtension';
2323
import { StreamStub } from '../stubs';
24-
import READ_PREFERENCES from '../../../views/webview-app/legacy/connection-model/constants/read-preferences';
2524
import DIAGNOSTIC_CODES from '../../../language/diagnosticCodes';
2625
import { ServerCommands } from '../../../language/serverCommands';
2726
import LINKS from '../../../utils/links';
@@ -35,7 +34,6 @@ suite('MongoDBService Test Suite', () => {
3534
connectionId: 'pineapple',
3635
connectionString: 'mongodb://localhost:27088',
3736
connectionOptions: {
38-
readPreference: READ_PREFERENCES.PRIMARY,
3937
productDocsLink: LINKS.extensionDocs(),
4038
productName: 'MongoDB for VS Code',
4139
},
@@ -2565,7 +2563,7 @@ suite('MongoDBService Test Suite', () => {
25652563
this.timeout(INCREASED_TEST_TIMEOUT);
25662564

25672565
const mongoClient = new MongoClient(params.connectionString, {
2568-
readPreference: params.connectionOptions.readPreference,
2566+
readPreference: 'primary',
25692567
});
25702568
const up = new StreamStub();
25712569
const down = new StreamStub();

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@ import * as vscode from 'vscode';
33
import { afterEach, beforeEach } from 'mocha';
44
import { expect } from 'chai';
55

6-
import AUTH_STRATEGY_VALUES from '../../../views/webview-app/legacy/connection-model/constants/auth-strategies';
76
import { StorageController, StorageVariables } from '../../../storage';
87
import {
98
StorageLocation,
109
DefaultSavingLocations,
1110
SecretStorageLocation,
1211
} from '../../../storage/storageController';
13-
import READ_PREFERENCES from '../../../views/webview-app/legacy/connection-model/constants/read-preferences';
14-
import SSH_TUNNEL_TYPES from '../../../views/webview-app/legacy/connection-model/constants/ssh-tunnel-types';
15-
import SSL_METHODS from '../../../views/webview-app/legacy/connection-model/constants/ssl-methods';
1612
import { ExtensionContextStub } from '../stubs';
1713
import {
1814
TEST_DATABASE_URI,
@@ -260,11 +256,11 @@ suite('Connection Storage Test Suite', function () {
260256
hosts: [{ host: 'localhost', port: 27017 }],
261257
extraOptions: {},
262258
connectionType: 'NODE_DRIVER',
263-
authStrategy: AUTH_STRATEGY_VALUES.NONE,
264-
readPreference: READ_PREFERENCES.PRIMARY,
259+
authStrategy: 'NONE',
260+
readPreference: 'primary',
265261
kerberosCanonicalizeHostname: false,
266-
sslMethod: SSL_METHODS.NONE,
267-
sshTunnel: SSH_TUNNEL_TYPES.NONE,
262+
sslMethod: 'NONE',
263+
sshTunnel: 'NONE',
268264
sshTunnelPort: 22,
269265
},
270266
};

src/test/suite/views/webview-app/jest-setup.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ const { TextEncoder, TextDecoder } = require('util');
99
chai.use(require('sinon-chai'));
1010
Enzyme.configure({ adapter: new Adapter() });
1111

12-
// eslint-disable-next-line no-undef
13-
jest.mock('@iconify-icons/codicon/book', () => {});
14-
1512
// Note applied with js dom so we do manually. (Required by node_modules/mongodb-connection-string-url/node_modules/whatwg-url/lib/encoding.js)
1613
Object.assign(global, { TextDecoder, TextEncoder });
1714

0 commit comments

Comments
 (0)