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

[fix] link custom setting #82

Merged
merged 8 commits into from
May 2, 2023
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ General
* Restore focus on suggested fields when pressing tab key in query editor ([issue 66](https://github.com/tprouvot/Salesforce-Inspector-reloaded/issues/66) created by [Enrique Muñoz](https://github.com/emunoz-at-wiris))
* Update shortcut indication for mac users
* Fix links for custom object [PR80](https://github.com/tprouvot/Salesforce-Inspector-reloaded/pull/80) (by [Mouloud Habchi](https://github.com/MD931) )
* Fix links for custom setting [PR82](https://github.com/tprouvot/Salesforce-Inspector-reloaded/pull/82) (by [Mouloud Habchi](https://github.com/MD931) )

Version 1.16
===========
Expand Down
28 changes: 19 additions & 9 deletions addon/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class AllDataBox extends React.PureComponent {
loadSobjects() {
let entityMap = new Map();

function addEntity({ name, label, keyPrefix, durableId }, api) {
function addEntity({ name, label, keyPrefix, durableId, isCustomSetting }, api) {
label = label || ""; // Avoid null exceptions if the object does not have a label (some don't). All objects have a name. Not needed for keyPrefix since we only do equality comparisons on those.
let entity = entityMap.get(name);
if (entity) {
Expand All @@ -299,6 +299,7 @@ class AllDataBox extends React.PureComponent {
label,
keyPrefix,
durableId,
isCustomSetting,
availableKeyPrefix: null,
};
entityMap.set(name, entity);
Expand All @@ -322,14 +323,15 @@ class AllDataBox extends React.PureComponent {
}

function getEntityDefinitions(bucket) {
let query = "select QualifiedApiName, Label, KeyPrefix, DurableId from EntityDefinition" + bucket;
let query = "select QualifiedApiName, Label, KeyPrefix, DurableId, IsCustomSetting from EntityDefinition" + bucket;
return sfConn.rest("/services/data/v" + apiVersion + "/tooling/query?q=" + encodeURIComponent(query)).then(res => {
for (let record of res.records) {
addEntity({
name: record.QualifiedApiName,
label: record.Label,
keyPrefix: record.KeyPrefix,
durableId: record.DurableId
durableId: record.DurableId,
isCustomSetting: record.IsCustomSetting
}, null);
}
}).catch(err => {
Expand Down Expand Up @@ -986,9 +988,11 @@ class AllDataSelection extends React.PureComponent {
/**
* Optimistically generate lightning setup uri for the provided object api name.
*/
getObjectSetupLink(sobjectName, durableId) {
getObjectSetupLink(sobjectName, durableId, isCustomSetting) {
if (sobjectName.endsWith("__mdt")) {
return this.getCustomMetadataLink(durableId);
} else if (isCustomSetting) {
return "https://" + this.props.sfHost + "/lightning/setup/CustomSettings/page?address=%2F" + durableId + "?setupid=CustomSettings";
} else if (sobjectName.endsWith("__c")) {
return "https://" + this.props.sfHost + "/lightning/setup/ObjectManager/" + durableId + "/Details/view";
} else {
Expand All @@ -998,18 +1002,24 @@ class AllDataSelection extends React.PureComponent {
getCustomMetadataLink(durableId) {
return "https://" + this.props.sfHost + "/lightning/setup/CustomMetadata/page?address=%2F" + durableId + "%3Fsetupid%3DCustomMetadata";
}
getObjectFieldsSetupLink(sobjectName, durableId) {
getObjectFieldsSetupLink(sobjectName, durableId, isCustomSetting) {
if (sobjectName.endsWith("__mdt")) {
return this.getCustomMetadataLink(durableId);
} else if (isCustomSetting) {
return "https://" + this.props.sfHost + "/lightning/setup/CustomSettings/page?address=%2F" + durableId + "?setupid=CustomSettings";

} else if (sobjectName.endsWith("__c")) {
return "https://" + this.props.sfHost + "/lightning/setup/ObjectManager/" + durableId + "/FieldsAndRelationships/view";
} else {
return "https://" + this.props.sfHost + "/lightning/setup/ObjectManager/" + sobjectName + "/FieldsAndRelationships/view";
}
}
getObjectListLink(sobjectName, keyPrefix) {
getObjectListLink(sobjectName, keyPrefix, isCustomSetting) {
if (sobjectName.endsWith("__mdt")) {
return "https://" + this.props.sfHost + "/lightning/setup/CustomMetadata/page?address=%2F" + keyPrefix;
} else if (isCustomSetting) {
return "https://" + this.props.sfHost + "/lightning/setup/CustomSettings/page?address=%2Fsetup%2Fui%2FlistCustomSettingsData.apexp?id=" + keyPrefix;

} else {
return "https://" + this.props.sfHost + "/lightning/o/" + sobjectName + "/list";
}
Expand Down Expand Up @@ -1038,15 +1048,15 @@ class AllDataSelection extends React.PureComponent {
h("tr", {},
h("th", {}, "Name:"),
h("td", {},
h("a", { href: this.getObjectSetupLink(selectedValue.sobject.name, selectedValue.sobject.durableId), target: linkTarget }, selectedValue.sobject.name)
h("a", { href: this.getObjectSetupLink(selectedValue.sobject.name, selectedValue.sobject.durableId, selectedValue.sobject.isCustomSetting), target: linkTarget }, selectedValue.sobject.name)
)
),
h("tr", {},
h("th", {}, "Links:"),
h("td", {},
h("a", { href: this.getObjectFieldsSetupLink(selectedValue.sobject.name, selectedValue.sobject.durableId), target: linkTarget }, "Fields / "),
h("a", { href: this.getObjectFieldsSetupLink(selectedValue.sobject.name, selectedValue.sobject.durableId, selectedValue.sobject.isCustomSetting), target: linkTarget }, "Fields / "),
h("a", { href: this.getRecordTypesLink(sfHost, selectedValue.sobject.name, selectedValue.sobject.durableId), target: linkTarget }, "Record Types / "),
h("a", { href: this.getObjectListLink(selectedValue.sobject.name, selectedValue.sobject.keyPrefix), target: linkTarget }, "Object List")
h("a", { href: this.getObjectListLink(selectedValue.sobject.name, selectedValue.sobject.keyPrefix, selectedValue.sobject.isCustomSetting), target: linkTarget }, "Object List")
),
),
h("tr", {},
Expand Down