-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from hudec117/dev
0.2.0
- Loading branch information
Showing
37 changed files
with
2,574 additions
and
900 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
window.onload = function () { | ||
const isInPopupIFrame = document.location.pathname.includes('emptyHtmlDoc.html'); | ||
if (isInPopupIFrame) { | ||
return; | ||
} | ||
|
||
const pageTypeElements = document.getElementsByClassName('pageType'); | ||
if (pageTypeElements.length === 0) { | ||
return; | ||
} | ||
|
||
const isOnUserDetailPage = pageTypeElements[0].innerText === 'User'; | ||
const isOnUserListPage = pageTypeElements[0].innerText === 'All Users'; | ||
if (isOnUserDetailPage) { | ||
injectEditPublicGroupMembershipsButton(); | ||
injectEditQueueMembershipsButton(); | ||
// injectCloneUserButton(); | ||
} else if (isOnUserListPage) { | ||
// injectFreezeUsersButton(); | ||
} | ||
|
||
function injectEditPublicGroupMembershipsButton() { | ||
const editMembershipButton = document.createElement('input'); | ||
editMembershipButton.id = 'sf-niknax-edit-public-group-memberships-button'; | ||
editMembershipButton.value = 'Edit Memberships'; | ||
editMembershipButton.title = `Salesforce Niknax: ${editMembershipButton.value}`; | ||
editMembershipButton.className = 'btn'; | ||
editMembershipButton.type = 'button'; | ||
editMembershipButton.style = 'margin-left: 5px; border: 1px solid #2574a9;'; | ||
|
||
// Setup event listeners, we also need to handle the pop-up panel for the links at the top of the page. | ||
const rlPanelFrame = document.getElementById('RLPanelFrame'); | ||
rlPanelFrame.contentDocument.addEventListener('click', onClick); | ||
document.addEventListener('click', onClick); | ||
|
||
function onClick(event) { | ||
if (event.target.id === editMembershipButton.id) { | ||
chrome.runtime.sendMessage({ operation: 'open-sf-niknax', page: 'edit-public-group-memberships' }); | ||
} | ||
} | ||
|
||
// Find and inject | ||
const publicGroupMembershipSection = getElementByStaticID('_RelatedPublicGroupMemberList'); | ||
if (!publicGroupMembershipSection) { | ||
console.error('sf-niknax: failed to find *_RelatedPublicGroupMemberList element.'); | ||
return; | ||
} | ||
|
||
const buttonRow = publicGroupMembershipSection.querySelector('div.listRelatedObject.groupBlock > div > div.pbHeader > table > tbody > tr > td.pbButton'); | ||
buttonRow.appendChild(editMembershipButton); | ||
} | ||
|
||
function injectEditQueueMembershipsButton() { | ||
const editMembershipButton = document.createElement('input'); | ||
editMembershipButton.id = 'sf-niknax-edit-queue-memberships-button'; | ||
editMembershipButton.value = 'Edit Memberships'; | ||
editMembershipButton.title = `Salesforce Niknax: ${editMembershipButton.value}`; | ||
editMembershipButton.className = 'btn'; | ||
editMembershipButton.type = 'button'; | ||
editMembershipButton.style = 'margin-left: 5px; border: 1px solid #2574a9;'; | ||
|
||
const rlPanelFrame = document.getElementById('RLPanelFrame'); | ||
rlPanelFrame.contentDocument.addEventListener('click', onClick); | ||
document.addEventListener('click', onClick); | ||
|
||
function onClick(event) { | ||
if (event.target.id === editMembershipButton.id) { | ||
chrome.runtime.sendMessage({ operation: 'open-sf-niknax', page: 'edit-queue-memberships' }); | ||
} | ||
} | ||
|
||
// Find and inject | ||
const queueMembershipSection = getElementByStaticID('_RelatedQueueMemberList'); | ||
if (!queueMembershipSection) { | ||
console.error('sf-niknax: failed to find *_RelatedQueueMemberList element.'); | ||
return; | ||
} | ||
|
||
const buttonRow = queueMembershipSection.querySelector('div.listRelatedObject.setupBlock > div > div.pbHeader > table > tbody > tr > td.pbButton'); | ||
buttonRow.appendChild(editMembershipButton); | ||
} | ||
|
||
// function injectCloneUserButton() { | ||
// const cloneUserButton = document.createElement('input'); | ||
// cloneUserButton.value = 'Clone'; | ||
// cloneUserButton.title = `Salesforce Niknax: ${cloneUserButton.value}`; | ||
// cloneUserButton.className = 'btn'; | ||
// cloneUserButton.type = 'button'; | ||
// cloneUserButton.style = 'margin-left: 5px; border: 1px solid #2574a9;'; | ||
// cloneUserButton.addEventListener('click', () => { | ||
// chrome.runtime.sendMessage({ operation: 'open-sf-niknax', page: 'clone-user' }); | ||
// }); | ||
|
||
// const topButtonRow = document.getElementById('topButtonRow'); | ||
// topButtonRow.appendChild(cloneUserButton); | ||
// } | ||
|
||
// function injectFreezeUsersButton() { | ||
// const freezeUsersButton = document.createElement('input'); | ||
// freezeUsersButton.value = 'Bulk Freeze/Unfreeze'; | ||
// freezeUsersButton.title = `Salesforce Niknax: ${freezeUsersButton.value}`; | ||
// freezeUsersButton.className = 'btn'; | ||
// freezeUsersButton.type = 'button'; | ||
// freezeUsersButton.style = 'margin-left: 5px; border: 1px solid #2574a9;'; | ||
// freezeUsersButton.addEventListener('click', () => { | ||
// chrome.runtime.sendMessage({ operation: 'open-sf-niknax', page: 'bulk-freeze-users' }); | ||
// }); | ||
|
||
// const topButtonRow = document.querySelector('td.pbBottomButtons'); | ||
// topButtonRow.appendChild(freezeUsersButton); | ||
// } | ||
|
||
function getElementByStaticID(staticString) { | ||
const divElements = document.querySelectorAll('div'); | ||
|
||
for (const element of divElements) { | ||
if (element.id && element.id.includes(staticString)) { | ||
return element; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
window.onload = function () { | ||
const QUICK_CREATE_USER_GLOBAL_ACTION_HTML = ` | ||
<div class="oneHelpAndTrainingExperience"> | ||
<button id="sf-niknax-quick-create-user-button" type="button" class="slds-button slds-button slds-button_icon slds-button_icon slds-button_icon-container slds-button_icon-small slds-global-actions__item-action forceHeaderButton" title="Salesforce Niknax: Quick Create User"> | ||
<lightning-icon icon-name="utility:adduser" class="slds-icon-utility-adduser slds-global-header__icon slds-button__icon slds-icon_container forceIcon"> | ||
<span part="boundary"> | ||
<lightning-primitive-icon> | ||
<svg class="slds-icon slds-icon_xx-small" focusable="false" viewBox="0 0 52 52" part="icon"> | ||
<g> | ||
<path d="M21.9,37c0-2.7,0.9-5.8,2.3-8.2c1.7-3,3.6-4.2,5.1-6.4c2.5-3.7,3-9,1.4-13c-1.6-4.1-5.4-6.5-9.8-6.4 | ||
s-8,2.8-9.4,6.9c-1.6,4.5-0.9,9.9,2.7,13.3c1.5,1.4,2.9,3.6,2.1,5.7c-0.7,2-3.1,2.9-4.8,3.7c-3.9,1.7-8.6,4.1-9.4,8.7 | ||
C1.3,45.1,3.9,49,8,49h17c0.8,0,1.3-1,0.8-1.6C23.3,44.5,21.9,40.8,21.9,37z"/> | ||
<path d="M37.9,25c-6.6,0-12,5.4-12,12s5.4,12,12,12s12-5.4,12-12S44.5,25,37.9,25z M44,38c0,0.6-0.5,1-1.1,1H40v3 | ||
c0,0.6-0.5,1-1.1,1h-2c-0.6,0-0.9-0.4-0.9-1v-3h-3.1c-0.6,0-0.9-0.4-0.9-1v-2c0-0.6,0.3-1,0.9-1H36v-3c0-0.6,0.3-1,0.9-1h2 | ||
c0.6,0,1.1,0.4,1.1,1v3h2.9c0.6,0,1.1,0.4,1.1,1V38z"/> | ||
</g> | ||
</svg> | ||
</lightning-primitive-icon> | ||
</span> | ||
</lightning-icon> | ||
</button> | ||
</div> | ||
`; | ||
|
||
// The inject is unreliable due to LX's long loading and so different pages (e.g. normal vs setup) | ||
// would load differently requiring an interval timer to wait to find the right element to inject next to. | ||
// We wait for up to a minute to allow for super slow loading times. | ||
const MAX_TRIES = 240; | ||
const INTERVAL = 250; | ||
let tries = 0; | ||
let intervalTimer; | ||
|
||
intervalTimer = setInterval(() => { | ||
const helpListItemDiv = document.querySelector('li.slds-global-actions__item div.oneHelpAndTrainingExperience'); | ||
if (helpListItemDiv) { | ||
clearInterval(intervalTimer); | ||
injectQuickCreateUserButton(helpListItemDiv); | ||
} else { | ||
tries++; | ||
if (tries >= MAX_TRIES) { | ||
clearInterval(intervalTimer); | ||
console.warn('sf-niknax: failed to inject quick create user button.'); | ||
} | ||
} | ||
}, INTERVAL); | ||
|
||
function injectQuickCreateUserButton(helpListItemDiv) { | ||
const quickCreateUserListItem = document.createElement('li'); | ||
quickCreateUserListItem.className = 'slds-global-actions__item slds-dropdown-trigger slds-dropdown-trigger--click'; | ||
quickCreateUserListItem.innerHTML = QUICK_CREATE_USER_GLOBAL_ACTION_HTML; | ||
|
||
// Go up to the "li" and insert ours after it. | ||
helpListItemDiv.parentNode.after(quickCreateUserListItem); | ||
|
||
const quickCreateUserButton = document.getElementById('sf-niknax-quick-create-user-button'); | ||
quickCreateUserButton.addEventListener('click', function() { | ||
chrome.runtime.sendMessage({ operation: 'open-sf-niknax', page: 'quick-create-user' }); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.