Updated the URL used to obtain the SPA session and hid the Manage Time icon for SALES_REP users

This commit is contained in:
2026-10-31 03:27:04 -03:00
parent d689807a50
commit 0d0a7cfe14
14 changed files with 80 additions and 31 deletions

View File

@@ -16,7 +16,7 @@ function createBackgroundContracts() {
const OPPTY_PRODUCTS_MAX_PAGES = 250;
const OPPTY_PRODUCTS_CONCURRENCY = 4;
const CUSTOMER_TOKEN_SERVICE_URL = "https://spa.oracle.com/oalcrm/web/api/g2m-consumer-application/consumerTokenService";
const CUSTOMER_TOKEN_SESSION_URL = "https://spa.oracle.com/";
const CUSTOMER_TOKEN_SESSION_URL = "https://spa.oracle.com/oalcrm/web/api/g2m-consumer-application/ui/index.html?ojr=whitespace";
const CUSTOMER_TOKEN_MAX_ATTEMPTS = 5;
const CUSTOMER_TOKEN_RETRY_BASE_DELAY_MS = 750;
const CUSTOMER_TOKEN_RETRY_MAX_DELAY_MS = 4000;

View File

@@ -169,9 +169,14 @@ function createContentApplication(overrides = {}) {
environment
});
const svgPaths = createSvgPaths({ environment });
const manageTime = createManageTime({ MODAL_ID: contracts.MODAL_ID, environment, tableSorting, searchableSelect, dates: createTimeDates(),
async function ensureManageTimeAccess() {
await currentUser.ensure();
if (!currentUser.allowsCrmActivities()) throw new Error("Manage Time is unavailable for this profile.");
}
const manageTime = createManageTime({ allowsManageTime: () => currentUser.allowsCrmActivities(), MODAL_ID: contracts.MODAL_ID, environment, tableSorting, searchableSelect, dates: createTimeDates(),
notify: (...args) => opportunitiesLinks.showCopyConfirmation(...args),
async requestDelete(id) {
await ensureManageTimeAccess();
await srSessionPreparation.ensure();
const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestTimeEntriesDelete, id });
debugContentLog.appendBackgroundRequestLog(result?.debugRequests || []);
@@ -179,6 +184,7 @@ function createContentApplication(overrides = {}) {
return result.result;
},
async requestSave(method, items) {
await ensureManageTimeAccess();
await srSessionPreparation.ensure();
await currentUser.ensure();
const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestTimeEntriesSave, method, items, emailAddress: currentUser.getUserId() });
@@ -187,6 +193,7 @@ function createContentApplication(overrides = {}) {
return result.result;
},
async requestEntries(weekId) {
await ensureManageTimeAccess();
await srSessionPreparation.ensure();
await currentUser.ensure();
const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestTimeEntries, weekId, emailAddress: currentUser.getUserId() });
@@ -195,18 +202,21 @@ function createContentApplication(overrides = {}) {
return result.items;
},
async requestTaskTypes() {
await ensureManageTimeAccess();
const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestLookupTaskType });
debugContentLog.appendBackgroundRequestLog(result?.debugRequests || []);
if (!result?.ok) throw new Error(result?.error || "Unable to load Task Types.");
return result.items;
},
async requestExpand(srNumbers) {
await ensureManageTimeAccess();
const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestServiceRequestExpand, srNumbers });
debugContentLog.appendBackgroundRequestLog(result?.debugRequests || []);
if (!result?.ok) throw new Error(result?.error || "Unable to load activities.");
return result.items;
},
async requestServices(weekId) {
await ensureManageTimeAccess();
await srSessionPreparation.ensure();
await currentUser.ensure();
const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestActiveServiceRequests, weekId, emailAddress: currentUser.getUserId() });
@@ -215,6 +225,7 @@ function createContentApplication(overrides = {}) {
return result.items;
},
async requestWeek(dateReference) {
await ensureManageTimeAccess();
const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestWeekDetails, dateReference });
debugContentLog.appendBackgroundRequestLog(result?.debugRequests || []);
if (!result?.ok) throw new Error(result?.error || "Unable to load week details.");

View File

@@ -3,7 +3,7 @@
.oe-time-modal { grid-template-columns: minmax(0, 1fr); }
.oe-time-dialog, .oe-time-body { min-width: 0; }
.oe-time-dialog * { box-sizing: border-box; }
.oe-time-dialog [hidden] { display: none !important; }
.oe-time-dialog [hidden], .oe-time-launcher[hidden] { display: none !important; }
.oe-time-header { flex-shrink: 0; }
.oe-time-body { padding: 18px; overflow: auto; min-height: 0; }
.oe-time-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }

View File

@@ -1,4 +1,4 @@
function createManageTime({ MODAL_ID, environment, tableSorting, searchableSelect, dates, requestWeek, requestSave, requestDelete, notify = () => {}, requestEntries = async () => [], requestServices = async () => [], requestExpand = async () => [], requestTaskTypes = async () => [] }) {
function createManageTime({ allowsManageTime = () => true, MODAL_ID, environment, tableSorting, searchableSelect, dates, requestWeek, requestSave, requestDelete, notify = () => {}, requestEntries = async () => [], requestServices = async () => [], requestExpand = async () => [], requestTaskTypes = async () => [] }) {
const { document } = environment;
let active = null;
let ready = false;
@@ -19,8 +19,8 @@ function createManageTime({ MODAL_ID, environment, tableSorting, searchableSelec
catch { /* Keep the selection for this page even if persistence is blocked. */ }
}
function setReady(value) {
ready = !!value;
if (launcher) { launcher.disabled = !ready; launcher.title = ready ? "Manage Time" : "Waiting for SR session ready"; }
ready = !!value && allowsManageTime();
if (launcher) { launcher.hidden = !allowsManageTime(); launcher.disabled = !ready; launcher.title = ready ? "Manage Time" : "Waiting for SR session ready"; }
}
function node(tag, className = "", text) {
const el = document.createElement(tag);
@@ -63,7 +63,7 @@ function createManageTime({ MODAL_ID, environment, tableSorting, searchableSelec
}
function createButton() {
const trigger = button("Manage Time", "clock", () => open(trigger));
trigger.className = "opportunities-extension-icon-button";
trigger.className = "opportunities-extension-icon-button oe-time-launcher";
launcher = trigger; setReady(ready);
return trigger;
}
@@ -77,7 +77,7 @@ function createManageTime({ MODAL_ID, environment, tableSorting, searchableSelec
}
function open(trigger) {
if (active?.saving) return;
if (!ready) return;
if (!ready || !allowsManageTime()) return;
const host = document.getElementById(MODAL_ID);
if (!host || host.hidden) return;
close(false);