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

add copy-reponse-body [#300] #317

Merged
merged 4 commits into from
Jan 27, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"onCommand:rest-client.clear-history",
"onCommand:rest-client.save-response",
"onCommand:rest-client.save-response-body",
"onCommand:rest-client.copy-response-body",
"onCommand:rest-client.switch-environment",
"onCommand:rest-client.clear-aad-token-cache",
"onLanguage:http"
Expand Down Expand Up @@ -130,6 +131,15 @@
},
"category": "Rest Client"
},
{
"command": "rest-client.copy-response-body",
"title": "Copy Response Body",
"icon": {
"light": "./images/copy.svg",
"dark": "./images/copy-inverse.svg"
},
"category": "Rest Client"
},
{
"command": "rest-client.generate-codesnippet",
"title": "Generate Code Snippet",
Expand Down Expand Up @@ -183,6 +193,10 @@
"command": "rest-client.save-response-body",
"when": "httpResponsePreviewFocus"
},
{
"command": "rest-client.copy-response-body",
"when": "httpResponsePreviewFocus"
},
{
"command": "rest-client.copy-codesnippet",
"when": "httpResponsePreviewFocus"
Expand All @@ -199,6 +213,11 @@
"command": "rest-client.save-response-body",
"group": "navigation"
},
{
"when": "httpResponsePreviewFocus",
"command": "rest-client.copy-response-body",
"group": "navigation"
},
{
"when": "httpResponsePreviewFocus",
"command": "rest-client.fold-response",
Expand Down
8 changes: 8 additions & 0 deletions src/controllers/responseController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ export class ResponseController {
}
}

@trace('Response-Copy-Body')
public async copyBody() {
const response = HttpResponseWebview.activePreviewResponse;
if (response) {
await this.clipboard.writeText(response.body);
}
}

@trace('Response-Save-Body')
public async saveBody() {
const response = HttpResponseWebview.activePreviewResponse;
Expand Down
1 change: 1 addition & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export async function activate(context: ExtensionContext) {
context.subscriptions.push(commands.registerCommand('rest-client.clear-history', () => historyController.clear()));
context.subscriptions.push(commands.registerCommand('rest-client.save-response', () => responseController.save()));
context.subscriptions.push(commands.registerCommand('rest-client.save-response-body', () => responseController.saveBody()));
context.subscriptions.push(commands.registerCommand('rest-client.copy-response-body', () => responseController.copyBody()));
context.subscriptions.push(commands.registerCommand('rest-client.generate-codesnippet', () => codeSnippetController.run()));
context.subscriptions.push(commands.registerCommand('rest-client.copy-codesnippet', () => codeSnippetController.copy()));
context.subscriptions.push(commands.registerCommand('rest-client.copy-request-as-curl', () => codeSnippetController.copyAsCurl()));
Expand Down