From a563e2a439750f38f170e013d590940d3d53857c Mon Sep 17 00:00:00 2001 From: Thomas Prouvot <35368290+tprouvot@users.noreply.github.com> Date: Wed, 20 Nov 2024 14:39:39 +0100 Subject: [PATCH] [data-export] Add custom shortcuts (#654) ## Describe your changes Add custom shortcuts for loading fields and execute query. ## Issue ticket number and link #653 ## Checklist before requesting a review - [x] I have read and understand the [Contributions section](https://github.com/tprouvot/Salesforce-Inspector-reloaded#contributions) - [x] Target branch is releaseCandidate and not master - [x] I have performed a self-review of my code - [ ] I ran the [unit tests](https://github.com/tprouvot/Salesforce-Inspector-reloaded#unit-tests) and my PR does not break any tests - [x] I documented the changes I've made on the [CHANGES.md](https://github.com/tprouvot/Salesforce-Inspector-reloaded/blob/master/CHANGES.md) and followed actual conventions - [x] I added a new section on [how-to.md](https://github.com/tprouvot/Salesforce-Inspector-reloaded/blob/master/docs/how-to.md) (optional) --- .github/ISSUE_TEMPLATE/bug_report.md | 3 ++- CHANGES.md | 1 + addon/background.js | 4 ++-- addon/data-export.js | 10 ++++++++++ addon/manifest-template.json | 6 ++++++ addon/manifest.json | 6 ++++++ addon/popup.js | 6 +++++- docs/how-to.md | 8 +++++++- 8 files changed, 39 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index eb081d39..f4920286 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -9,6 +9,7 @@ assignees: tprouvot **Make sure to read the troubleshooting section before creating an issue** - [ ] I've read the [common issues](https://tprouvot.github.io/Salesforce-Inspector-reloaded/troubleshooting/) and the one I'm about to create is not one of those documented. +- [ ] I've searched in the [existing issues](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues?q=is%3Aissue) and the one I'm about to create is not one of those created. - [ ] I've read the [release note](https://github.com/tprouvot/Salesforce-Inspector-reloaded/blob/releaseCandidate/CHANGES.md) and the one I'm about to create is not already fixed. **Describe the bug** @@ -30,7 +31,7 @@ If applicable, add screenshots to help explain your problem. **Desktop (please complete the following information):** - OS: [e.g. iOS] - Browser [e.g. chrome, firefox, edge] - - Version [e.g. 1.20] + - Salesforce Inspector Reloaded Version [e.g. 1.25] **Additional context** Add any other context about the problem here. diff --git a/CHANGES.md b/CHANGES.md index f74458bb..1b06eae9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ ## Version 1.26 +- Customize Data Export shortcuts (execute query and insert all fields name in query) [feature 653](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/653) in `chrome://extensions/shortcuts` - Add [clientId](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/headers_calloptions.htm) header param to identify the extension in EventLogFile [feature 504](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/504) - Add Apex Classes metadata search in Shortcut tab and new option configuration for the search [feature 591](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/591) request by [mpekacki](https://github.com/mpekacki) - Add `My Personal Information` shortcuts [feature 627](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/627) request by [Alfredo Chissotti](https://github.com/Astisme) diff --git a/addon/background.js b/addon/background.js index 67e3478c..a2e4a267 100644 --- a/addon/background.js +++ b/addon/background.js @@ -60,13 +60,13 @@ chrome.action.onClicked.addListener(() => { }); }); chrome.commands?.onCommand.addListener((command) => { - if (command !== "open-popup"){ + if (!command.startsWith("open-")){ chrome.tabs.create({ url: `chrome-extension://${chrome.i18n.getMessage("@@extension_id")}/${command}.html?host=${sfHost}` }); } else { chrome.runtime.sendMessage({ - msg: "shortcut_pressed", sfHost + msg: "shortcut_pressed", command, sfHost }); } }); diff --git a/addon/data-export.js b/addon/data-export.js index da60b33c..ef45388f 100644 --- a/addon/data-export.js +++ b/addon/data-export.js @@ -1313,6 +1313,15 @@ class App extends React.Component { model.didUpdate(); } }); + addEventListener("message", e => { + if (e.data.command === "open-export-autocomplete") { + model.queryAutocompleteHandler({ctrlSpace: true}); + model.didUpdate(); + } else if (e.data.command === "open-export-execute"){ + model.doExport(); + model.didUpdate(); + } + }); addEventListener("keydown", e => { if ((e.ctrlKey && e.key == "Enter") || e.key == "F5") { e.preventDefault(); @@ -1453,6 +1462,7 @@ class App extends React.Component { " query in the box above and press Export."), h("p", {}, "Press Ctrl+Space to insert all field name autosuggestions or to load suggestions for field values."), h("p", {}, "Press Ctrl+Enter or F5 to execute the export."), + h("p", {}, "Those shortcuts can be customized in chrome://extensions/shortcuts"), h("p", {}, "Supports the full SOQL language. The columns in the CSV output depend on the returned data. Using subqueries may cause the output to grow rapidly. Bulk API is not supported. Large data volumes may freeze or crash your browser.") ) ), diff --git a/addon/manifest-template.json b/addon/manifest-template.json index 501c6b0b..f5d2109d 100644 --- a/addon/manifest-template.json +++ b/addon/manifest-template.json @@ -92,6 +92,12 @@ "open-popup": { "description": "Open popup" }, + "open-export-autocomplete": { + "description": "Fields suggestion in Data Export" + }, + "open-export-execute": { + "description": "Run Query in Data Export" + }, "data-export": { "description": "Data Export" }, diff --git a/addon/manifest.json b/addon/manifest.json index 3cfbc066..a9cc712b 100644 --- a/addon/manifest.json +++ b/addon/manifest.json @@ -94,6 +94,12 @@ "open-popup": { "description": "Open popup" }, + "open-export-autocomplete": { + "description": "Fields suggestion in Data Export" + }, + "open-export-execute": { + "description": "Run Query in Data Export" + }, "data-export": { "description": "Data Export" }, diff --git a/addon/popup.js b/addon/popup.js index e00e67be..be1a940f 100644 --- a/addon/popup.js +++ b/addon/popup.js @@ -25,7 +25,11 @@ if (typeof browser === "undefined") { }); chrome.runtime.onMessage.addListener((request) => { if (request.msg === "shortcut_pressed") { - parent.postMessage({insextOpenPopup: true}, "*"); + if (request.command === "open-popup"){ + parent.postMessage({insextOpenPopup: true}, "*"); + } else { + parent.postMessage({command: request.command}, "*"); + } } } ); diff --git a/docs/how-to.md b/docs/how-to.md index f5594869..84b47cff 100644 --- a/docs/how-to.md +++ b/docs/how-to.md @@ -275,11 +275,17 @@ From the option page, enable "Use favicon color on sandbox banner" ## Select all fields in a query This functionality already exists in the legacy version but since many users don't know about it, I would like to document it. -When on the export page, put the cursor between `SaELECT` and `FROM` and press `Ctrl + space` for inserting all fields (if you don't have the rights for a particular field, it wont' be added). +When on the export page, put the cursor between `SELECT` and `FROM` and press `Ctrl + space` for inserting all fields (if you don't have the rights for a particular field, it wont' be added). If you want to insert only custom fields, enter `__c` between `SELECT` and `FROM`. ![2024-04-16_08-53-32 (1)](https://github.com/tprouvot/Salesforce-Inspector-reloaded/assets/35368290/ef7ba7a0-c9c4-4573-9aaa-b72e64430f64) +## Customize Select all fields in a query shortcut + +If the default `Ctrl + space` shortcut is already used by another extension or app, you can customize it in `chrome://extensions/shortcuts` and choose the one you prefer. + +Customize Select all fields in a query shortcut + ## Exclude formula fields from data export autocomplete You can exclude formula fields to be included in the autocomplete by disable the toogle