Badge indicator showing whether an opportunity has an associated Workload Workbench Action
This commit is contained in:
29
src/services/spa/workload-actions.js
Normal file
29
src/services/spa/workload-actions.js
Normal file
@@ -0,0 +1,29 @@
|
||||
function createSpaWorkloadActions({ fetchJson }) {
|
||||
async function requestWlActions(message) {
|
||||
const debugRequests = [];
|
||||
try {
|
||||
const revnId = String(message.revnId ?? "").trim();
|
||||
const token = message.authorization?.value;
|
||||
if (!/^\d+$/.test(revnId)) throw new Error("A numeric RevnId is required.");
|
||||
if (typeof token !== "string" || !token.trim()) throw new Error("WWB-TS uiaasHeader.value is unavailable.");
|
||||
const url = `https://spa.oracle.com/oalcrm/web/api/provider-proxy/wwb-provider/service/workbench-proxy/wwb/mgmt/actions?parentType=WORKLOAD&parentId=${encodeURIComponent(revnId)}`;
|
||||
const result = await fetchJson(url, {
|
||||
method: "GET", credentials: "include",
|
||||
headers: { Accept: "application/json", "Wwb-Provider-Authorization": token.trim() }
|
||||
}, "requestWlActions", debugRequests);
|
||||
if (!result || !Array.isArray(result.actions) || typeof result.hasNext !== "boolean"
|
||||
|| result.actions.some(item => !item || typeof item !== "object" || Array.isArray(item))) {
|
||||
throw new Error("requestWlActions returned an invalid collection.");
|
||||
}
|
||||
return { ok: true, actions: result.actions, hasNext: result.hasNext, debugRequests };
|
||||
} catch (error) {
|
||||
error.debugRequests = debugRequests;
|
||||
throw error;
|
||||
} finally {
|
||||
for (const entry of debugRequests) {
|
||||
if (entry.requestHeaders?.["Wwb-Provider-Authorization"]) entry.requestHeaders["Wwb-Provider-Authorization"] = "(present)";
|
||||
}
|
||||
}
|
||||
}
|
||||
return { requestWlActions };
|
||||
}
|
||||
Reference in New Issue
Block a user