Skip to content

Commit

Permalink
VSCODE-222: Edit documents from playground results (#232)
Browse files Browse the repository at this point in the history
* feat: edit documents from playground results (VSCODE-222)

* test: add tests for document controller and edit code lenses provider

* refactor: check content type instead of the whole result object

* refactor: use the same playground result file instead of reopen it

* feat: show and write mongodb documents using a FileSystemProvider (VSCODE-223)

* test: fix some long-running tests

* refactor: do not refresh playground results after saving document

* refactor: errors clean up

* refactor: reset memory file system provider

* refactor: remove repeated code

* test: update names to be more specific

* refactor: set language not extension for playground results

* refactor: update code lenses position in code lenses provider

* refactor: update comments in code

* refactor: use document controller only accesing database

* refactor: rename document controller to service

* refactor: return lost function parameter
  • Loading branch information
alenakhineika authored Jan 11, 2021
1 parent 2c8414b commit 7eede49
Show file tree
Hide file tree
Showing 30 changed files with 1,809 additions and 1,442 deletions.
151 changes: 130 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"onCommand:mdb.disconnect",
"onCommand:mdb.removeConnection",
"onCommand:mdb.openMongoDBShell",
"onCommand:mdb.saveDocumentToMongoDB",
"onCommand:mdb.saveMongoDBDocument",
"onView:mongoDB",
"onView:mongoDBConnectionExplorer",
"onView:mongoDBPlaygroundsExplorer",
Expand Down Expand Up @@ -220,7 +220,7 @@
"title": "MongoDB: Run Selected Lines From Playground"
},
{
"command": "mdb.saveDocumentToMongoDB",
"command": "mdb.saveMongoDBDocument",
"title": "MongoDB: Save Document To MongoDB"
},
{
Expand Down Expand Up @@ -539,7 +539,7 @@
],
"commandPalette": [
{
"command": "mdb.saveDocumentToMongoDB",
"command": "mdb.saveMongoDBDocument",
"when": "editorLangId == json"
},
{
Expand Down Expand Up @@ -690,7 +690,7 @@
"when": "editorLangId == mongodb"
},
{
"command": "mdb.saveDocumentToMongoDB",
"command": "mdb.saveMongoDBDocument",
"key": "ctrl+s",
"mac": "cmd+s",
"when": "editorLangId == json"
Expand Down Expand Up @@ -884,8 +884,8 @@
"@types/sinon": "^9.0.1",
"@types/vscode": "^1.49.0",
"@types/ws": "^7.2.4",
"@typescript-eslint/eslint-plugin": "^2.19.2",
"@typescript-eslint/parser": "^2.19.2",
"@typescript-eslint/eslint-plugin": "^4.12.0",
"@typescript-eslint/parser": "^4.12.0",
"autoprefixer": "^9.7.5",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
Expand Down
5 changes: 3 additions & 2 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ enum EXTENSION_COMMANDS {
MDB_RUN_ALL_PLAYGROUND_BLOCKS = 'mdb.runAllPlaygroundBlocks',
MDB_RUN_ALL_OR_SELECTED_PLAYGROUND_BLOCKS = 'mdb.runPlayground',

MDB_SAVE_DOCUMENT_TO_MONGODB = 'mdb.saveDocumentToMongoDB',
MDB_OPEN_MONGODB_DOCUMENT_FROM_PLAYGROUND = 'mdb.openMongoDBDocumentFromPlayground',
MDB_OPEN_MONGODB_DOCUMENT_FROM_TREE = 'mdb.openMongoDBDocumentFromTree',
MDB_SAVE_MONGODB_DOCUMENT = 'mdb.saveMongoDBDocument',

MDB_CHANGE_ACTIVE_CONNECTION = 'mdb.changeActiveConnection',
MDB_REFRESH_PLAYGROUNDS = 'mdb.refreshPlaygrounds',
Expand Down Expand Up @@ -43,7 +45,6 @@ enum EXTENSION_COMMANDS {
MDB_ADD_COLLECTION = 'mdb.addCollection',
MDB_COPY_COLLECTION_NAME = 'mdb.copyCollectionName',
MDB_DROP_COLLECTION = 'mdb.dropCollection',
MDB_VIEW_DOCUMENT = 'mdb.viewDocument',
MDB_VIEW_COLLECTION_DOCUMENTS = 'mdb.viewCollectionDocuments',
MDB_REFRESH_COLLECTION = 'mdb.refreshCollection',
MDB_REFRESH_DOCUMENT_LIST = 'mdb.refreshDocumentList',
Expand Down
16 changes: 8 additions & 8 deletions src/editors/activeConnectionCodeLensProvider.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import * as vscode from 'vscode';
import EXTENSION_COMMANDS from '../commands';
import ConnectionController from '../connectionController';

export default class ActiveConnectionCodeLensProvider
implements vscode.CodeLensProvider {
private _connectionController: any;
private _onDidChangeCodeLenses: vscode.EventEmitter<
void
> = new vscode.EventEmitter<void>();
public readonly onDidChangeCodeLenses: vscode.Event<void> = this
_connectionController: ConnectionController;
_onDidChangeCodeLenses: vscode.EventEmitter<void> = new vscode.EventEmitter<void>();

readonly onDidChangeCodeLenses: vscode.Event<void> = this
._onDidChangeCodeLenses.event;

constructor(connectionController?: any) {
constructor(connectionController: ConnectionController) {
this._connectionController = connectionController;

vscode.workspace.onDidChangeConfiguration(() => {
this._onDidChangeCodeLenses.fire();
});
}

public refresh(): void {
refresh(): void {
this._onDidChangeCodeLenses.fire();
}

public provideCodeLenses(): vscode.CodeLens[] {
provideCodeLenses(): vscode.CodeLens[] {
const codeLens = new vscode.CodeLens(new vscode.Range(0, 0, 0, 0));
let message = '';

Expand Down
1 change: 0 additions & 1 deletion src/editors/collectionDocumentsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import CollectionDocumentsOperationsStore from './collectionDocumentsOperationsS
import ConnectionController from '../connectionController';
import { StatusView } from '../views';

export const DOCUMENT_LOCATION_URI_IDENTIFIER = 'documentLocation';
export const NAMESPACE_URI_IDENTIFIER = 'namespace';
export const OPERATION_ID_URI_IDENTIFIER = 'operationId';
export const CONNECTION_ID_URI_IDENTIFIER = 'connectionId';
Expand Down
Loading

0 comments on commit 7eede49

Please sign in to comment.