Lançamento da versão 1.0.10
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
WORKLIST_SAASUI_PATHNAME,
|
||||
IDS,
|
||||
cleanString,
|
||||
isJwtExpired,
|
||||
hcmTileTemplate,
|
||||
onOpenArchPanel,
|
||||
writeCachedWorklistToken,
|
||||
@@ -12,12 +13,9 @@
|
||||
let lastPersistedWorklistIframeUrl = "";
|
||||
|
||||
function syncHcmTile() {
|
||||
const appsGroup = document.getElementById(HCM_MY_INFORMATION_APPS_GROUP_ID);
|
||||
const addTile = appsGroup?.querySelector(
|
||||
".flat-grid-cell.flat-grid-cell-addicon"
|
||||
);
|
||||
const insertion = resolveHcmTileInsertion();
|
||||
|
||||
if (!addTile?.parentElement) {
|
||||
if (!insertion?.container) {
|
||||
document.getElementById(IDS.hcmTile)?.remove();
|
||||
return;
|
||||
}
|
||||
@@ -25,21 +23,47 @@
|
||||
const tile = document.getElementById(IDS.hcmTile) || createHcmTile();
|
||||
|
||||
if (
|
||||
tile.parentElement !== addTile.parentElement ||
|
||||
tile.nextElementSibling !== addTile
|
||||
tile.parentElement !== insertion.container ||
|
||||
tile.nextElementSibling !== insertion.before
|
||||
) {
|
||||
addTile.parentElement.insertBefore(tile, addTile);
|
||||
insertion.container.insertBefore(tile, insertion.before || null);
|
||||
}
|
||||
}
|
||||
|
||||
function resolveHcmTileInsertion() {
|
||||
const appsGroup = document.getElementById(HCM_MY_INFORMATION_APPS_GROUP_ID);
|
||||
|
||||
if (!appsGroup) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const addTile = appsGroup.querySelector(
|
||||
".flat-grid-cell.flat-grid-cell-addicon"
|
||||
);
|
||||
|
||||
if (addTile?.parentElement && appsGroup.contains(addTile.parentElement)) {
|
||||
return {
|
||||
container: addTile.parentElement,
|
||||
before: addTile,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
container: appsGroup,
|
||||
before: null,
|
||||
};
|
||||
}
|
||||
|
||||
function syncWorklistIframeToken(options = {}) {
|
||||
for (const frame of document.querySelectorAll("iframe")) {
|
||||
const tokenPayload = extractWorklistIframeToken(frame);
|
||||
|
||||
if (tokenPayload?.token) {
|
||||
persistWorklistIframeToken(tokenPayload, options);
|
||||
return tokenPayload;
|
||||
if (!tokenPayload?.token || isWorklistTokenExpired(tokenPayload.token)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
persistWorklistIframeToken(tokenPayload, options);
|
||||
return tokenPayload;
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -73,6 +97,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
function isWorklistTokenExpired(token) {
|
||||
return typeof isJwtExpired === "function" && isJwtExpired(token, 120);
|
||||
}
|
||||
|
||||
function persistWorklistIframeToken(tokenPayload, options = {}) {
|
||||
if (!options.force && tokenPayload.url === lastPersistedWorklistIframeUrl) {
|
||||
return;
|
||||
|
||||
@@ -44,7 +44,8 @@
|
||||
appState.errorMessage = "";
|
||||
updateLoadingProgress("Requesting current user", 4);
|
||||
|
||||
const user = await fetchCurrentUser();
|
||||
let user = await fetchCurrentUser();
|
||||
user = await preserveCachedUserAvatar(user);
|
||||
|
||||
updateLoadingProgress("Loading current resource user", 8);
|
||||
|
||||
@@ -206,6 +207,48 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function preserveCachedUserAvatar(user) {
|
||||
if (cleanString(user?.avatar)) {
|
||||
return user;
|
||||
}
|
||||
|
||||
const currentDatasetAvatar =
|
||||
getCachedUserAvatar(user, appState.dataset?.user) ||
|
||||
getCachedUserAvatar(user, appState.dataset?.exportPayload?.user);
|
||||
|
||||
if (currentDatasetAvatar) {
|
||||
return {
|
||||
...user,
|
||||
avatar: currentDatasetAvatar,
|
||||
};
|
||||
}
|
||||
|
||||
const cachedPayload = await readCachedDataset().catch(() => null);
|
||||
const persistedAvatar = getCachedUserAvatar(user, cachedPayload?.user);
|
||||
|
||||
return persistedAvatar
|
||||
? {
|
||||
...user,
|
||||
avatar: persistedAvatar,
|
||||
}
|
||||
: user;
|
||||
}
|
||||
|
||||
function getCachedUserAvatar(user, cachedUser) {
|
||||
if (!cachedUser) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const userEmail = normalizeString(user?.userEmail);
|
||||
const cachedUserEmail = normalizeString(cachedUser?.userEmail);
|
||||
|
||||
if (!userEmail || userEmail !== cachedUserEmail) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return cleanString(cachedUser?.avatar || cachedUser?.imageUrl);
|
||||
}
|
||||
|
||||
function updateLoadingProgress(message, progress) {
|
||||
appState.loadingMessage = message;
|
||||
appState.loadingProgress = Math.max(
|
||||
@@ -312,21 +355,49 @@
|
||||
|
||||
const worklistToken = currentFrameToken || (await readCachedWorklistToken());
|
||||
|
||||
if (!worklistToken) {
|
||||
throw new Error(
|
||||
"Unable to resolve Worklist token. Reload the FuseWelcome page so the Worklist iframe token can be captured before refreshing data."
|
||||
);
|
||||
appState.sessionAuthHeaders = {};
|
||||
|
||||
if (worklistToken) {
|
||||
try {
|
||||
const user = await workbenchRepository.fetchWorklistCurrentUser(
|
||||
worklistToken
|
||||
);
|
||||
|
||||
appState.sessionAuthHeaders = {};
|
||||
|
||||
return user;
|
||||
} catch (error) {
|
||||
appState.sessionAuthHeaders = {};
|
||||
|
||||
if (!isWorklistAuthError(error)) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
appState.sessionAuthHeaders = {};
|
||||
try {
|
||||
const user = await workbenchRepository.fetchSpaCurrentUser();
|
||||
|
||||
const user = await workbenchRepository.fetchWorklistCurrentUser(
|
||||
worklistToken
|
||||
);
|
||||
appState.sessionAuthHeaders = {};
|
||||
|
||||
appState.sessionAuthHeaders = {};
|
||||
return user;
|
||||
} catch (error) {
|
||||
appState.sessionAuthHeaders = {};
|
||||
|
||||
return user;
|
||||
throw new Error(
|
||||
worklistToken
|
||||
? `Unable to refresh current user. The Worklist token was rejected and the Workload Workbench current-user fallback also failed: ${getErrorMessage(
|
||||
error
|
||||
)}. Reload the FuseWelcome page and try Refresh data again.`
|
||||
: `Unable to resolve the current user. Reload the FuseWelcome page and try Refresh data again. ${getErrorMessage(
|
||||
error
|
||||
)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function isWorklistAuthError(error) {
|
||||
return /\b(401|403)\b/.test(getErrorMessage(error));
|
||||
}
|
||||
|
||||
function findWorkloadById(workloadId) {
|
||||
|
||||
Reference in New Issue
Block a user