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

@@ -362,7 +362,7 @@ function createBackgroundContracts() {
const OPPTY_PRODUCTS_MAX_PAGES = 250; const OPPTY_PRODUCTS_MAX_PAGES = 250;
const OPPTY_PRODUCTS_CONCURRENCY = 4; const OPPTY_PRODUCTS_CONCURRENCY = 4;
const CUSTOMER_TOKEN_SERVICE_URL = "https://spa.oracle.com/oalcrm/web/api/g2m-consumer-application/consumerTokenService"; 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_MAX_ATTEMPTS = 5;
const CUSTOMER_TOKEN_RETRY_BASE_DELAY_MS = 750; const CUSTOMER_TOKEN_RETRY_BASE_DELAY_MS = 750;
const CUSTOMER_TOKEN_RETRY_MAX_DELAY_MS = 4000; const CUSTOMER_TOKEN_RETRY_MAX_DELAY_MS = 4000;

File diff suppressed because one or more lines are too long

View File

@@ -362,7 +362,7 @@ function createBackgroundContracts() {
const OPPTY_PRODUCTS_MAX_PAGES = 250; const OPPTY_PRODUCTS_MAX_PAGES = 250;
const OPPTY_PRODUCTS_CONCURRENCY = 4; const OPPTY_PRODUCTS_CONCURRENCY = 4;
const CUSTOMER_TOKEN_SERVICE_URL = "https://spa.oracle.com/oalcrm/web/api/g2m-consumer-application/consumerTokenService"; 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_MAX_ATTEMPTS = 5;
const CUSTOMER_TOKEN_RETRY_BASE_DELAY_MS = 750; const CUSTOMER_TOKEN_RETRY_BASE_DELAY_MS = 750;
const CUSTOMER_TOKEN_RETRY_MAX_DELAY_MS = 4000; const CUSTOMER_TOKEN_RETRY_MAX_DELAY_MS = 4000;

File diff suppressed because one or more lines are too long

View File

@@ -16,7 +16,7 @@ function createBackgroundContracts() {
const OPPTY_PRODUCTS_MAX_PAGES = 250; const OPPTY_PRODUCTS_MAX_PAGES = 250;
const OPPTY_PRODUCTS_CONCURRENCY = 4; const OPPTY_PRODUCTS_CONCURRENCY = 4;
const CUSTOMER_TOKEN_SERVICE_URL = "https://spa.oracle.com/oalcrm/web/api/g2m-consumer-application/consumerTokenService"; 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_MAX_ATTEMPTS = 5;
const CUSTOMER_TOKEN_RETRY_BASE_DELAY_MS = 750; const CUSTOMER_TOKEN_RETRY_BASE_DELAY_MS = 750;
const CUSTOMER_TOKEN_RETRY_MAX_DELAY_MS = 4000; const CUSTOMER_TOKEN_RETRY_MAX_DELAY_MS = 4000;

View File

@@ -169,9 +169,14 @@ function createContentApplication(overrides = {}) {
environment environment
}); });
const svgPaths = createSvgPaths({ 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), notify: (...args) => opportunitiesLinks.showCopyConfirmation(...args),
async requestDelete(id) { async requestDelete(id) {
await ensureManageTimeAccess();
await srSessionPreparation.ensure(); await srSessionPreparation.ensure();
const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestTimeEntriesDelete, id }); const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestTimeEntriesDelete, id });
debugContentLog.appendBackgroundRequestLog(result?.debugRequests || []); debugContentLog.appendBackgroundRequestLog(result?.debugRequests || []);
@@ -179,6 +184,7 @@ function createContentApplication(overrides = {}) {
return result.result; return result.result;
}, },
async requestSave(method, items) { async requestSave(method, items) {
await ensureManageTimeAccess();
await srSessionPreparation.ensure(); await srSessionPreparation.ensure();
await currentUser.ensure(); await currentUser.ensure();
const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestTimeEntriesSave, method, items, emailAddress: currentUser.getUserId() }); const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestTimeEntriesSave, method, items, emailAddress: currentUser.getUserId() });
@@ -187,6 +193,7 @@ function createContentApplication(overrides = {}) {
return result.result; return result.result;
}, },
async requestEntries(weekId) { async requestEntries(weekId) {
await ensureManageTimeAccess();
await srSessionPreparation.ensure(); await srSessionPreparation.ensure();
await currentUser.ensure(); await currentUser.ensure();
const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestTimeEntries, weekId, emailAddress: currentUser.getUserId() }); const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestTimeEntries, weekId, emailAddress: currentUser.getUserId() });
@@ -195,18 +202,21 @@ function createContentApplication(overrides = {}) {
return result.items; return result.items;
}, },
async requestTaskTypes() { async requestTaskTypes() {
await ensureManageTimeAccess();
const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestLookupTaskType }); const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestLookupTaskType });
debugContentLog.appendBackgroundRequestLog(result?.debugRequests || []); debugContentLog.appendBackgroundRequestLog(result?.debugRequests || []);
if (!result?.ok) throw new Error(result?.error || "Unable to load Task Types."); if (!result?.ok) throw new Error(result?.error || "Unable to load Task Types.");
return result.items; return result.items;
}, },
async requestExpand(srNumbers) { async requestExpand(srNumbers) {
await ensureManageTimeAccess();
const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestServiceRequestExpand, srNumbers }); const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestServiceRequestExpand, srNumbers });
debugContentLog.appendBackgroundRequestLog(result?.debugRequests || []); debugContentLog.appendBackgroundRequestLog(result?.debugRequests || []);
if (!result?.ok) throw new Error(result?.error || "Unable to load activities."); if (!result?.ok) throw new Error(result?.error || "Unable to load activities.");
return result.items; return result.items;
}, },
async requestServices(weekId) { async requestServices(weekId) {
await ensureManageTimeAccess();
await srSessionPreparation.ensure(); await srSessionPreparation.ensure();
await currentUser.ensure(); await currentUser.ensure();
const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestActiveServiceRequests, weekId, emailAddress: currentUser.getUserId() }); const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestActiveServiceRequests, weekId, emailAddress: currentUser.getUserId() });
@@ -215,6 +225,7 @@ function createContentApplication(overrides = {}) {
return result.items; return result.items;
}, },
async requestWeek(dateReference) { async requestWeek(dateReference) {
await ensureManageTimeAccess();
const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestWeekDetails, dateReference }); const result = await platformContentMessages.sendRuntimeMessage({ type: messageTypes.requestWeekDetails, dateReference });
debugContentLog.appendBackgroundRequestLog(result?.debugRequests || []); debugContentLog.appendBackgroundRequestLog(result?.debugRequests || []);
if (!result?.ok) throw new Error(result?.error || "Unable to load week details."); 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-modal { grid-template-columns: minmax(0, 1fr); }
.oe-time-dialog, .oe-time-body { min-width: 0; } .oe-time-dialog, .oe-time-body { min-width: 0; }
.oe-time-dialog * { box-sizing: border-box; } .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-header { flex-shrink: 0; }
.oe-time-body { padding: 18px; overflow: auto; min-height: 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; } .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; const { document } = environment;
let active = null; let active = null;
let ready = false; 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. */ } catch { /* Keep the selection for this page even if persistence is blocked. */ }
} }
function setReady(value) { function setReady(value) {
ready = !!value; ready = !!value && allowsManageTime();
if (launcher) { launcher.disabled = !ready; launcher.title = ready ? "Manage Time" : "Waiting for SR session ready"; } if (launcher) { launcher.hidden = !allowsManageTime(); launcher.disabled = !ready; launcher.title = ready ? "Manage Time" : "Waiting for SR session ready"; }
} }
function node(tag, className = "", text) { function node(tag, className = "", text) {
const el = document.createElement(tag); const el = document.createElement(tag);
@@ -63,7 +63,7 @@ function createManageTime({ MODAL_ID, environment, tableSorting, searchableSelec
} }
function createButton() { function createButton() {
const trigger = button("Manage Time", "clock", () => open(trigger)); 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); launcher = trigger; setReady(ready);
return trigger; return trigger;
} }
@@ -77,7 +77,7 @@ function createManageTime({ MODAL_ID, environment, tableSorting, searchableSelec
} }
function open(trigger) { function open(trigger) {
if (active?.saving) return; if (active?.saving) return;
if (!ready) return; if (!ready || !allowsManageTime()) return;
const host = document.getElementById(MODAL_ID); const host = document.getElementById(MODAL_ID);
if (!host || host.hidden) return; if (!host || host.hidden) return;
close(false); close(false);

View File

@@ -26,7 +26,7 @@ for (const family of ["chrome", "firefox"]) {
assert.equal(h.tabs[0].active, false); assert.equal(h.tabs[0].active, false);
assert.equal(h.tabs[0].windowId, 3); assert.equal(h.tabs[0].windowId, 3);
assert.equal(h.tabs[0].cookieStoreId, family === "firefox" ? "test-store" : undefined); assert.equal(h.tabs[0].cookieStoreId, family === "firefox" ? "test-store" : undefined);
assert.equal(h.tabs[0].url, "https://spa.oracle.com/"); assert.equal(h.tabs[0].url, "https://spa.oracle.com/oalcrm/web/api/g2m-consumer-application/ui/index.html?ojr=whitespace");
assert.deepEqual(h.removedTabs, [91]); assert.deepEqual(h.removedTabs, [91]);
assert.equal(result.debugRequests[0].httpStatus, status); assert.equal(result.debugRequests[0].httpStatus, status);
assert.match(result.debugRequests[0].metadata.retryReason, /SPA session recovery/); assert.match(result.debugRequests[0].metadata.retryReason, /SPA session recovery/);

View File

@@ -109,7 +109,7 @@ async function run() {
assert.equal(createdTabs[0].active, false); assert.equal(createdTabs[0].active, false);
assert.equal( assert.equal(
createdTabs[0].url, createdTabs[0].url,
"https://spa.oracle.com/" "https://spa.oracle.com/oalcrm/web/api/g2m-consumer-application/ui/index.html?ojr=whitespace"
); );
assert.deepEqual(removedTabs, [27]); assert.deepEqual(removedTabs, [27]);
assert.equal(response.debugRequests.length, 2); assert.equal(response.debugRequests.length, 2);

View File

@@ -86,7 +86,7 @@ for (const family of ["chrome", "firefox"]) {
assert.deepEqual(first, second); assert.deepEqual(first, second);
assert.equal(attempts, 3); assert.equal(attempts, 3);
assert.deepEqual(app.tabs, [{ assert.deepEqual(app.tabs, [{
url: "https://spa.oracle.com/", url: "https://spa.oracle.com/oalcrm/web/api/g2m-consumer-application/ui/index.html?ojr=whitespace",
active: false, windowId: 3, ...(family === "firefox" ? { cookieStoreId: "test-store" } : {}) active: false, windowId: 3, ...(family === "firefox" ? { cookieStoreId: "test-store" } : {})
}]); }]);
assert.deepEqual(app.removedTabs, [91]); assert.deepEqual(app.removedTabs, [91]);

View File

@@ -591,3 +591,19 @@ for (const family of ["chrome", "firefox"]) test(`${family}: resource response i
assert.equal(calls[1].options.headers.Authorization, "Session"); assert.equal(calls[1].options.headers.Authorization, "Session");
await restarted.dispatch({ ...message, emailAddress: "other@example.invalid" }); assert.equal(calls.length, 3); await restarted.dispatch({ ...message, emailAddress: "other@example.invalid" }); assert.equal(calls.length, 3);
}); });
test("restricted profile cannot display or open Manage Time even if session is ready", () => {
const source = fs.readFileSync("src/features/manage-time/view.js", "utf8");
const factory = vm.runInNewContext(source + "\ncreateManageTime");
const element = () => ({ setAttribute() {}, append() {}, addEventListener() {} });
const app = factory({ allowsManageTime: () => false, environment: { document: {
createElement: element, createElementNS: element,
getElementById() { assert.fail("restricted profile must not open a modal"); }
} }, requestWeek() { assert.fail("restricted profile must not request weeks"); } });
const button = app.createButton();
app.setReady(true);
assert.equal(button.hidden, true);
assert.equal(button.disabled, true);
app.open();
});

View File

@@ -24,7 +24,7 @@ for (const family of ["chrome", "firefox"]) {
calls++; calls++;
if (calls === 1) return html(); if (calls === 1) return html();
if (calls === 2) { navigation(app); return html(); } if (calls === 2) { navigation(app); return html(); }
assert.deepEqual(app.updatedTabs, [{ id: 91, details: { url: "https://spa.oracle.com/", active: false } }]); assert.deepEqual(app.updatedTabs, [{ id: 91, details: { url: "https://spa.oracle.com/oalcrm/web/api/g2m-consumer-application/ui/index.html?ojr=whitespace", active: false } }]);
return response(type === currentUser ? identity : tokens); return response(type === currentUser ? identity : tokens);
} }); } });
const result = await app.dispatch({ type }); const result = await app.dispatch({ type });
@@ -78,7 +78,7 @@ test("a successful SPA navigation clears an earlier failure before it can be res
if (++calls === 1) return html(); if (++calls === 1) return html();
if (calls === 2) { if (calls === 2) {
navigation(app); navigation(app);
navigation(app, { url: "https://spa.oracle.com/", statusCode: 200 }); navigation(app, { url: "https://spa.oracle.com/oalcrm/web/api/g2m-consumer-application/ui/index.html?ojr=whitespace", statusCode: 200 });
assert.equal(app.updatedTabs.length, 0); assert.equal(app.updatedTabs.length, 0);
} }
return response(identity); return response(identity);

View File

@@ -72,7 +72,7 @@ function harness({ validAfter = 0 } = {}) {
await flush(); await flush();
} }
function navigation(overrides = {}) { function navigation(overrides = {}) {
headers.emit({ tabId: 91, type: "main_frame", statusCode: 200, url: "https://spa.oracle.com/", ...overrides }); headers.emit({ tabId: 91, type: "main_frame", statusCode: 200, url: "https://spa.oracle.com/oalcrm/web/api/g2m-consumer-application/ui/index.html?ojr=whitespace", ...overrides });
} }
function cookie() { function cookie() {
cookies.emit({ removed: false, cookie: { name: "synthetic-session", value: "never-log-this-cookie", domain: "spa.oracle.com", cookies.emit({ removed: false, cookie: { name: "synthetic-session", value: "never-log-this-cookie", domain: "spa.oracle.com",
@@ -119,7 +119,7 @@ test("callback 401 restarts only the owned SPA home; another HTTP 200 error page
h.navigation({ statusCode: 401, url: "https://spa.oracle.com/cloudgate/v1/oauth2/callback?code=never-replay" }); h.navigation({ statusCode: 401, url: "https://spa.oracle.com/cloudgate/v1/oauth2/callback?code=never-replay" });
await h.advance(1000); await h.advance(1000);
assert.equal(h.updates.length, 1); assert.equal(h.updates.length, 1);
assert.equal(h.updates[0].details.url, "https://spa.oracle.com/"); assert.equal(h.updates[0].details.url, "https://spa.oracle.com/oalcrm/web/api/g2m-consumer-application/ui/index.html?ojr=whitespace");
assert.equal(h.updates[0].details.active, false); assert.equal(h.updates[0].details.active, false);
h.navigation(); h.navigation();
await h.advance(10000); await h.advance(10000);