Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: identify a namespace to place in generated query VSCODE-579 #778

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
34 changes: 32 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@
"id": "mongodb.participant",
"name": "MongoDB",
"description": "Ask anything about MongoDB, from writing queries to questions about your cluster.",
"isSticky": true,
"commands": [
{
"name": "query",
"isSticky": true,
"description": "Ask how to write MongoDB queries or pipelines. For example, you can ask: \"Show me all the documents where the address contains the word street\"."
}
]
Expand Down Expand Up @@ -161,13 +163,25 @@
}
],
"commands": [
{
"command": "mdb.selectDatabaseWithParticipant",
"title": "MongoDB: Select Database with Participant"
},
{
"command": "mdb.selectCollectionWithParticipant",
"title": "MongoDB: Select Collection with Participant"
},
{
"command": "mdb.connectWithParticipant",
"title": "MongoDB: Change Active Connection with Participant"
},
{
"command": "mdb.runParticipantQuery",
"title": "Run Content Generated by the Chat Participant"
"title": "Run Content Generated by Participant"
},
{
"command": "mdb.openParticipantQueryInPlayground",
"title": "Open Generated by the Chat Participant Content In Playground"
"title": "Open Generated by Participant Content In Playground"
},
{
"command": "mdb.connect",
Expand Down Expand Up @@ -719,6 +733,22 @@
}
],
"commandPalette": [
{
"command": "mdb.selectDatabaseWithParticipant",
"when": "false"
},
{
"command": "mdb.selectCollectionWithParticipant",
"when": "false"
},
{
"command": "mdb.connectWithParticipant",
"when": "false"
},
{
"command": "mdb.runParticipantQuery",
"when": "false"
},
{
"command": "mdb.openParticipantQueryInPlayground",
"when": "false"
Expand Down
3 changes: 3 additions & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ enum EXTENSION_COMMANDS {
// Chat participant.
OPEN_PARTICIPANT_QUERY_IN_PLAYGROUND = 'mdb.openParticipantQueryInPlayground',
RUN_PARTICIPANT_QUERY = 'mdb.runParticipantQuery',
CONNECT_WITH_PARTICIPANT = 'mdb.connectWithParticipant',
SELECT_DATABASE_WITH_PARTICIPANT = 'mdb.selectDatabaseWithParticipant',
SELECT_COLLECTION_WITH_PARTICIPANT = 'mdb.selectCollectionWithParticipant',
}

export default EXTENSION_COMMANDS;
19 changes: 16 additions & 3 deletions src/connectionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,14 @@ export default class ConnectionController {
}

log.info('Successfully connected', { connectionId });
void vscode.window.showInformationMessage('MongoDB connection successful.');

const message = 'MongoDB connection successful.';
this._statusView.showMessage(message);
setTimeout(() => {
if (this._statusView._statusBarItem.text === message) {
this._statusView.hideMessage();
}
}, 5000);

dataService.addReauthenticationHandler(
this._reauthenticationHandler.bind(this)
Expand Down Expand Up @@ -603,10 +610,16 @@ export default class ConnectionController {
'mdb.isAtlasStreams',
false
);
void vscode.window.showInformationMessage('MongoDB disconnected.');

this._disconnecting = false;
this._statusView.hideMessage();

const message = 'MongoDB disconnected.';
this._statusView.showMessage(message);
setTimeout(() => {
if (this._statusView._statusBarItem.text === message) {
this._statusView.hideMessage();
}
}, 5000);

return true;
}
Expand Down
12 changes: 4 additions & 8 deletions src/editors/mongoDBDocumentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,11 @@ export default class MongoDBDocumentService {
returnDocument: 'after',
}
);

this._statusView.hideMessage();
this._telemetryService.trackDocumentUpdated(source, true);
} catch (error) {
this._statusView.hideMessage();

return this._saveDocumentFailed(formatError(error).message);
} finally {
this._statusView.hideMessage();
}
}

Expand Down Expand Up @@ -141,17 +139,15 @@ export default class MongoDBDocumentService {
{ limit: 1 }
);

this._statusView.hideMessage();

if (!documents || documents.length === 0) {
return;
}

return getEJSON(documents[0]);
} catch (error) {
this._statusView.hideMessage();

return this._fetchDocumentFailed(formatError(error).message);
} finally {
this._statusView.hideMessage();
}
}
}
20 changes: 18 additions & 2 deletions src/mdbExtensionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ export default class MDBExtensionController implements vscode.Disposable {
() => {
return this._playgroundController.createPlaygroundFromParticipantQuery({
text:
this._participantController._chatResult.metadata.queryContent || '',
this._participantController._chatResult?.metadata
?.responseContent || '',
});
}
);
Expand All @@ -301,10 +302,25 @@ export default class MDBExtensionController implements vscode.Disposable {
() => {
return this._playgroundController.evaluateParticipantQuery({
text:
this._participantController._chatResult.metadata.queryContent || '',
this._participantController._chatResult?.metadata
?.responseContent || '',
});
}
);
this.registerCommand(
EXTENSION_COMMANDS.CONNECT_WITH_PARTICIPANT,
(id: string) => this._participantController.connectWithParticipant(id)
);
this.registerCommand(
EXTENSION_COMMANDS.SELECT_DATABASE_WITH_PARTICIPANT,
(name: string) =>
this._participantController.selectDatabaseWithParticipant(name)
);
this.registerCommand(
EXTENSION_COMMANDS.SELECT_COLLECTION_WITH_PARTICIPANT,
(name: string) =>
this._participantController.selectCollectionWithParticipant(name)
);
};

registerParticipantCommand = (
Expand Down
Loading
Loading