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

[data-export] Add download button #436

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
15 changes: 8 additions & 7 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

## Version 1.24

- Add `Download CSV` button in data export page ([feature 101](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/101) requested by [Mickael Gudin](https://github.com/mickaelgudin))
- Customize extension's pages shortcuts in [chrome://extensions/shortcut](chrome://extensions/shortcut) ([feature 171](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/171) by [asanaEAzimzhanov](https://github.com/asanaEAzimzhanov))
- Add option to exclude formula fields from data export autocomplete [feature 415](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/415)
- Removes whitespace from both ends in user search [feature 410](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/410) (contribution by [César Blanco](https://github.com/cesarblancg))
- Add setup menu items 'Trusted URLs' and 'Trusted URL and Browser Policy Violations' to shortcut links
- Add setup menu items `Trusted URLs` and `Trusted URL and Browser Policy Violations` to shortcut links
- Ability to quit popup with escape button [feature 378](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/378) (contribution by [Gerald Gramier](https://github.com/gramier))
- Add option to customize org favicon [feature 180](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/180)
- Add tooltip to options [feature 399](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/399) (contribution by [Nathan Shulman](https://github.com/nshulman))
Expand All @@ -16,11 +17,11 @@

- Add new [setup pages](https://help.salesforce.com/s/articleView?id=release-notes.rn_general_setup_domain_prepare.htm&release=246&type=5) domain [feature 389](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/389) (by [akalatksy](https://github.com/akalatksy))
- Add "View summary" link on User tab [feature 386](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/386)
- Add option to hide 'Delete Records' button from Data Export page
- Add option to hide `Delete Records` button from Data Export page
- Fix popup not closing in inspect page [issue 159](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/159) (contribution by [Luca Bassani](https://github.com/baslu93))
- On inspect page, when double clicking on a picklist field, iterate through available values [feature 366](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/366)
- Integrate Experience Cloud builder link to shortcut search in popup [feature 365](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/365)
- Add 'Flow Versions' button in popup when recordId is a flow [feature 362](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/362)
- Add `Flow Versions` button in popup when recordId is a flow [feature 362](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/362)
- Format relations as expected in import process [feature 26](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/26) (contribution by [Olivier Dufour](https://github.com/dufoli))
- Ability to choose header theme [feature 294](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/294)
- Add query template customization in Option page [feature 349](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/349)
Expand Down Expand Up @@ -83,8 +84,8 @@
## Version 1.20

- Move popup arrow icon in Flow Builder because of Winter 24 UI changes [feature 200](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/200)
- Add 'Login As' button for Experience users [feature 190](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/190)
- Add 'Delete Records' button from data export page [feature 134](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/134) (contribution by [Oscar Gomez Balaguer](https://github.com/ogomezba))
- Add `Login As` button for Experience users [feature 190](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/190)
- Add `Delete Records` button from data export page [feature 134](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/134) (contribution by [Oscar Gomez Balaguer](https://github.com/ogomezba))
- Update popup title to show "Salesforce Inspector Reloaded" [feature 188](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/188) (idea by [Nicolas Vuillamy](https://github.com/nvuillam))
- Add "Query Record" link from data-export page [feature 111](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/111) (contribution by [Antoine Leleu](https://github.com/AntoineLeleu-Salesforce))
- Fix "Edit page layout link" for from show all data and use "openLinksInNewTab" property for those links [issue 181](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/181)
Expand All @@ -101,10 +102,10 @@
- Add missing Date Literals [feature 155](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/155)
- Allow navigation to the extension tabs (Object, Users, Shortcuts) using keyboard [feature 135](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/135) (feature by [Sarath Addanki](https://github.com/asknet))
- Update query on EntityDefinition to avoid missing objects for large orgs [issue 138](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/138) (issue by [AjitRajendran](https://github.com/AjitRajendran))
- Add 'LIMIT 200' when selecting 'FIELDS(' in autocomplete [feature 146](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/146) )
- Add `LIMIT 200` when selecting `FIELDS(` in autocomplete [feature 146](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/146) )
- Change method to get extension id to be compatible with firefox [issue 137](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/137) (issue by [kkorynta](https://github.com/kkorynta))
- Fix hardcoded browser in Generate Token url [issue 137](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/137) (issue by [kkorynta](https://github.com/kkorynta))
- Add "Create New Flow", "Create New Custom Object", "Create New Permission Set", "Create New Custom Permission" and "Recycle Bin" shortcuts
- Add `Create New Flow`, `Create New Custom Object`, `Create New Permission Set`, `Create New Custom Permission` and `Recycle Bin` shortcuts
- Update pop-up release note link to github pages
- Detect SObject on list view page [feature 121](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/121) (idea by [Mehdi Cherfaoui](https://github.com/mehdisfdc))
- Automate test setup manual step of contact to multiple accounts [Aidan Majewski](https://github.com/aimaj)
Expand Down
17 changes: 14 additions & 3 deletions addon/data-export.css
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ input:disabled:hover {
color: #dddbda;
}

button:disabled > svg.button-icon{
fill: #dddbda;
}

.highlighted {
background-color: rgb(0, 112, 210);
border-color: rgb(0, 112, 210);
Expand Down Expand Up @@ -447,9 +451,6 @@ button[hidden],
margin-right: 0
}

/* div.button-group:not(:only-of-type) {
margin-left: 10px;
} */
.button-group> :first-child,
.button-group>[hidden]+* {
border-top-left-radius: 0.25rem;
Expand Down Expand Up @@ -522,6 +523,16 @@ button.toggle .button-icon {
-webkit-mask-image: url('chrome-extension://__MSG_@@extension_id__/images/light_bulb.svg');
}

svg.button-icon {
-webkit-mask-repeat: no-repeat;
-webkit-mask-size: 1rem;
display: inline-block;
width: 16px;
height: 16px;
fill: #0070d2;
vertical-align: sub;
}

.autocomplete-header {
display: flex;
align-items: flex-end;
Expand Down
27 changes: 22 additions & 5 deletions addon/data-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class Model {
"SELECT Id FROM WHERE LIKE",
"SELECT Id FROM WHERE ORDER BY"
];
this.separator = getSeparator();

this.spinFor(sfConn.soap(sfConn.wsdl(apiVersion, "Partner"), "getUserInfo", {}).then(res => {
this.userInfo = res.userFullName + " / " + res.userName + " / " + res.organizationName;
Expand Down Expand Up @@ -278,15 +279,20 @@ class Model {
copyToClipboard(this.exportedData.csvSerialize("\t"));
}
copyAsCsv() {
let separator = getSeparator();
copyToClipboard(this.exportedData.csvSerialize(separator));
copyToClipboard(this.exportedData.csvSerialize(this.separator));
}
copyAsJson() {
copyToClipboard(JSON.stringify(this.exportedData.records, null, " "));
}
downloadAsCsv(){
const blob = new Blob([this.exportedData.csvSerialize(this.separator)], { type: "data:text/csv;charset=utf-8," });
const downloadAnchor = document.createElement("a");
downloadAnchor.download = `${this.autocompleteResults.sobjectName}-${new Date().toLocaleDateString()}.csv`;
downloadAnchor.href = window.URL.createObjectURL(blob);
downloadAnchor.click();
}
deleteRecords(e) {
let separator = getSeparator();
let data = this.exportedData.csvSerialize(separator);
let data = this.exportedData.csvSerialize(this.separator);
let encodedData = btoa(data);

let args = new URLSearchParams();
Expand Down Expand Up @@ -1065,6 +1071,7 @@ class App extends React.Component {
this.onQueryPlan = this.onQueryPlan.bind(this);
this.onCopyAsExcel = this.onCopyAsExcel.bind(this);
this.onCopyAsCsv = this.onCopyAsCsv.bind(this);
this.onDownloadAsCsv = this.onDownloadAsCsv.bind(this);
this.onCopyAsJson = this.onCopyAsJson.bind(this);
this.onDeleteRecords = this.onDeleteRecords.bind(this);
this.onResultsFilterInput = this.onResultsFilterInput.bind(this);
Expand Down Expand Up @@ -1189,6 +1196,11 @@ class App extends React.Component {
model.copyAsCsv();
model.didUpdate();
}
onDownloadAsCsv(){
let {model} = this.props;
model.downloadAsCsv();
model.didUpdate();
}
onCopyAsJson() {
let {model} = this.props;
model.copyAsJson();
Expand Down Expand Up @@ -1382,9 +1394,14 @@ class App extends React.Component {
h("div", {className: "result-bar"},
h("h1", {}, "Export Result"),
h("div", {className: "button-group"},
h("button", {disabled: !model.canCopy(), onClick: this.onCopyAsExcel, title: "Copy exported data to clipboard for pasting into Excel or similar"}, "Copy (Excel format)"),
h("button", {disabled: !model.canCopy(), onClick: this.onCopyAsExcel, title: "Copy exported data to clipboard for pasting into Excel or similar"}, "Copy (Excel)"),
h("button", {disabled: !model.canCopy(), onClick: this.onCopyAsCsv, title: "Copy exported data to clipboard for saving as a CSV file"}, "Copy (CSV)"),
h("button", {disabled: !model.canCopy(), onClick: this.onCopyAsJson, title: "Copy raw API output to clipboard"}, "Copy (JSON)"),
h("button", {disabled: !model.canCopy(), onClick: this.onDownloadAsCsv, title: "Download as a CSV file"},
h("svg", {className: "button-icon"},
h("use", {xlinkHref: "symbols.svg#download"})
)
),
localStorage.getItem("showDeleteRecordsButton") !== "false"
? h("button", {disabled: !model.canDelete(), onClick: this.onDeleteRecords, title: "Open the 'Data Import' page with preloaded records to delete (< 20k records). 'Id' field needs to be queried", className: "delete-btn"}, "Delete Records") : null,
),
Expand Down
Loading