Skip to content

Commit

Permalink
[general] Customize favicon (#337)
Browse files Browse the repository at this point in the history
## Describe your changes
This PR allows users to customize favicons with a custom url or
predefined colors (green, orange, pink, purple, red, yellow)

## Issue ticket number and link
#197

## 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
- [x] 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)

<img width="901" alt="image"
src="https://github.com/tprouvot/Salesforce-Inspector-reloaded/assets/35368290/1bbd9cc8-2425-4e79-8a92-a4e954f3d369">
  • Loading branch information
tprouvot authored Mar 6, 2024
1 parent 2bfcbdc commit 49b7ef8
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Version 1.23

- Customize extension's favicon [feature 197](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/197)
- Save default batch size and thread for data import [feature 329](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/329) (feature request by [ritterblau](https://github.com/ritterblau))
- Load recently viewed records on popup [feature 321](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/321)
- Open documentation when installing the extension [feature 322](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/322)
Expand Down
Binary file added addon/images/favicons/green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added addon/images/favicons/orange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added addon/images/favicons/pink.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added addon/images/favicons/purple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added addon/images/favicons/red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added addon/images/favicons/yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions addon/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export let sfConn = {
localStorage.setItem(sfHost + "_orgInstance", res.records[0].InstanceName);
});
}
setFavicon(sfHost);
},

async rest(url, {logErrors = true, method = "GET", api = "normal", body = undefined, bodyType = "json", responseType = "json", headers = {}, progressHandler = null} = {}) {
Expand Down Expand Up @@ -317,3 +318,21 @@ function showExpiredTokenLink() {
const mainContainer = document.getElementById("mainTabs");
if (mainContainer) { mainContainer.classList.add("mask"); }
}

function setFavicon(sfHost){
let fav = localStorage.getItem(sfHost + "_customFavicon");
if (fav){
let link = document.querySelector("link[rel~='icon']");
if (!link) {
link = document.createElement("link");
link.rel = "icon";
document.head.appendChild(link);
}
//check if custom favicon from the extension or web
if (fav.indexOf("http") == -1){
fav = "./images/favicons/" + fav + ".png";
}
link.href = fav;
}

}
4 changes: 3 additions & 1 deletion addon/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class OptionsTabSelector extends React.Component {
constructor(props) {
super(props);
this.model = props.model;
this.sfHost = this.model.sfHost;
this.state = {
selectedTabId: 1
};
Expand All @@ -78,7 +79,8 @@ class OptionsTabSelector extends React.Component {
{option: Option, props: {type: "toggle", title: "Always open links in a new tab", key: "openLinksInNewTab"}},
{option: Option, props: {type: "toggle", title: "Open Permission Set / Permission Set Group summary from shortcuts", key: "enablePermSetSummary"}},
{option: Option, props: {type: "toggle", title: "Search metadata from Shortcut tab", key: "metadataShortcutSearch"}},
{option: Option, props: {type: "toggle", title: "Disable query input autofocus", key: "disableQueryInputAutoFocus"}}
{option: Option, props: {type: "toggle", title: "Disable query input autofocus", key: "disableQueryInputAutoFocus"}},
{option: Option, props: {type: "text", title: "Custom favicon (org specific)", key: this.sfHost + "_customFavicon", placeholder: "Available values : green, orange, pink, purple, red, yellow"}},
]
},
{
Expand Down
15 changes: 13 additions & 2 deletions docs/how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,16 @@ You can update the debug level (configuration is per organization) and duration
## Display query performance in Data Export

To enable performance metrics for queries on the data export page, open the Options screen and select the Data Export tab,
then set "Display Query Execution Time" to enabled. Total time for the query to process and, when applicable, batch stats (Total Number of Batches, Min/Max/Avg Batch Time)
are displayed.
then set "Display Query Execution Time" to enabled. Total time for the query to process and, when applicable, batch stats (Total Number of Batches, Min/Max/Avg Batch Time)
are displayed.

## Customize extension's favicon

From the option page, you can customize the default favicon by:

- a predefined color among those values (green, orange, pink, purple, red, yellow)
- a custom favicon url (ie "https://stackoverflow.com/favicon.ico")

The customization is linked to the org, it means you can have different colors for DEV and UAT env for example.

<img width="901" alt="image" src="https://github.com/tprouvot/Salesforce-Inspector-reloaded/assets/35368290/1bbd9cc8-2425-4e79-8a92-a4e954f3d369">

0 comments on commit 49b7ef8

Please sign in to comment.