Added the ability to bookmark the extension, along with some visual adjustments
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
function createContentModal({
|
||||
openBookmarkPicker,
|
||||
getShortcutBookmarkStatus,
|
||||
ACCOUNT_PLANS_MODAL_ID,
|
||||
AUTH_STATUS,
|
||||
CUSTOMER_FILTER_BUTTON_ID,
|
||||
@@ -72,6 +74,27 @@ function createContentModal({
|
||||
}) {
|
||||
const { document, window, setTimeout, clearTimeout, matchMedia } = environment;
|
||||
let authCompletion = null;
|
||||
let bookmarkHintTimer = null;
|
||||
let bookmarkHintVersion = 0;
|
||||
function hideBookmarkHint() {
|
||||
bookmarkHintVersion++;
|
||||
if (bookmarkHintTimer !== null) clearTimeout(bookmarkHintTimer);
|
||||
bookmarkHintTimer = null;
|
||||
const hint = document.getElementById("opportunities-extension-bookmark-hint");
|
||||
if (hint) hint.hidden = true;
|
||||
}
|
||||
async function refreshBookmarkHint() {
|
||||
hideBookmarkHint();
|
||||
const version = bookmarkHintVersion;
|
||||
try {
|
||||
const result = await getShortcutBookmarkStatus?.();
|
||||
const modal = document.getElementById(MODAL_ID);
|
||||
const hint = document.getElementById("opportunities-extension-bookmark-hint");
|
||||
if (version !== bookmarkHintVersion || !modal || modal.hidden || !hint || !result?.ok || result.bookmarked) return;
|
||||
hint.hidden = false;
|
||||
bookmarkHintTimer = setTimeout(hideBookmarkHint, 20000);
|
||||
} catch { /* A failed bookmarks check must not interrupt opportunities. */ }
|
||||
}
|
||||
function resetAuthCompletion() {
|
||||
if (!authCompletion) return;
|
||||
clearTimeout(authCompletion.waitTimer);
|
||||
@@ -89,6 +112,7 @@ function createContentModal({
|
||||
|
||||
if (existingModal) {
|
||||
existingModal.hidden = false;
|
||||
refreshBookmarkHint();
|
||||
prepareSrSession?.();
|
||||
existingModal.querySelector("select").focus();
|
||||
document.documentElement.classList.add("opportunities-extension-scroll-lock");
|
||||
@@ -148,7 +172,13 @@ function createContentModal({
|
||||
productsCacheTimestamp.className = "opportunities-extension-products-cache-timestamp";
|
||||
productsCacheTimestamp.setAttribute("role", "status");
|
||||
productsCacheTimestamp.hidden = true;
|
||||
subtitleRow.append(authBadge, productsProgressBadge, productsCacheTimestamp);
|
||||
const bookmarkHint = document.createElement("span");
|
||||
bookmarkHint.id = "opportunities-extension-bookmark-hint";
|
||||
bookmarkHint.className = "opportunities-extension-products-cache-timestamp";
|
||||
bookmarkHint.setAttribute("role", "status");
|
||||
bookmarkHint.textContent = "Save to favorites: Ctrl+Shift+F";
|
||||
bookmarkHint.hidden = true;
|
||||
subtitleRow.append(productsCacheTimestamp, bookmarkHint, authBadge, productsProgressBadge);
|
||||
|
||||
const titleBlock = document.createElement("div");
|
||||
titleBlock.className = "opportunities-extension-title-row";
|
||||
@@ -420,6 +450,7 @@ function createContentModal({
|
||||
shell.append(header, body);
|
||||
overlay.append(shell);
|
||||
document.body.append(overlay);
|
||||
refreshBookmarkHint();
|
||||
document.documentElement.classList.add("opportunities-extension-scroll-lock");
|
||||
ensureEscapeKeyHandler();
|
||||
renderStageFilterButtons();
|
||||
@@ -472,6 +503,7 @@ function createContentModal({
|
||||
|
||||
function closeOpportunitiesModal() {
|
||||
if (closeOrganizationChart()) return;
|
||||
hideBookmarkHint();
|
||||
resetAuthCompletion();
|
||||
closeCrmSrPopover();
|
||||
const modal = document.getElementById(MODAL_ID);
|
||||
@@ -502,10 +534,14 @@ function createContentModal({
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.ctrlKey && event.key.toLowerCase() === "d") {
|
||||
const shortcutKey = event.key.toLowerCase();
|
||||
if (event.ctrlKey && event.shiftKey && !event.altKey && !event.metaKey &&
|
||||
(shortcutKey === "d" || shortcutKey === "f")) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
toggleDebugPanel();
|
||||
if (event.repeat) return;
|
||||
if (shortcutKey === "d") toggleDebugPanel();
|
||||
else openBookmarkPicker();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -580,5 +616,5 @@ function createContentModal({
|
||||
});
|
||||
}
|
||||
|
||||
return { openOpportunitiesModal, updateAuthBadge, closeOpportunitiesModal, ensureEscapeKeyHandler };
|
||||
return { openOpportunitiesModal, updateAuthBadge, closeOpportunitiesModal, ensureEscapeKeyHandler, hideBookmarkHint, refreshBookmarkHint };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user