Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
import { useApplicationStore } from '../../../hooks/useApplicationStore';
import {
clearAppMode,
isAppModeHintFresh,
readAppModeHint,
readAppModeSession,
resolveEffectiveAppMode,
resolveInitialAppMode,
Expand Down Expand Up @@ -162,16 +164,27 @@
const appDefault = translateWireMode(appConfig?.defaultAppMode ?? null);
setAppDefaultMode(appDefault);

// If this tab already has a session tuple (a manual toggle earlier in
// this tab, or a reload of one) leave it alone. `useResolvedAppMode`
// is the authoritative source and treats the tuple as the highest-
// priority signal once persona information is available — writing
// here would clobber a valid in-tab choice with the boot-time best-
// effort resolve (which cannot yet see persona) and break "toggle to
// AI, then reload" for users who did not tick "remember".
// Skip the boot-time write when this tab already has a signal that
// `useResolvedAppMode` will resolve authoritatively — the resolver is
// the single source of truth once it has persona + registry
// information, and writing to the session tuple here poisons the
// subsequent resolve. Two signals count:
//
// 1. A session tuple this tab already owns (returning tab, or a
// manual toggle earlier in this tab).
// 2. A fresh cross-tab `omAppModeHint` — the mechanism by which a
// sibling tab's active mode carries into a newly-opened tab.
// Once we write `DEFAULT_APP_MODE` here, the resolver's session-
// tuple check is satisfied by our write and it never consults
// the hint, so a cmd+click from an AI tab silently boots the new
// tab into Classic.
if (readAppModeSession()?.mode) {
return;
}
const hint = readAppModeHint();
if (isAppModeHintFresh(hint) && hint?.mode) {
return;
}

const userPref =
derivePreferencesFromList(prefsRes.preferences).appMode ?? null;
Expand Down Expand Up @@ -246,7 +259,7 @@

const clientType = authConfig?.clientType ?? ClientType.Public;

const onLoginHandler = () => {

Check warning on line 262 in openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

The 'onLoginHandler' function makes the dependencies of useMemo Hook (at line 900) change on every render. Move it inside the useMemo callback. Alternatively, wrap the definition of 'onLoginHandler' in its own useCallback() Hook
setApplicationLoading(true);

let attempts = 0;
Expand Down Expand Up @@ -323,7 +336,7 @@

// Upon logout, redirect to the login page
navigate(ROUTES.SIGNIN);
}, [timeoutId]);

Check warning on line 339 in openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useCallback has missing dependencies: 'navigate', 'setApplicationLoading', 'setCurrentUser', and 'setIsAuthenticated'. Either include them or remove the dependency array

const handledVerifiedUser = () => {
if (!applicationRoutesClass.isProtectedRoute(location.pathname)) {
Expand Down Expand Up @@ -381,7 +394,7 @@
});
}, []);

const resetUserDetails = (forceLogout = false) => {

Check warning on line 397 in openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

The 'resetUserDetails' function makes the dependencies of useMemo Hook (at line 900) change on every render. To fix this, wrap the definition of 'resetUserDetails' in its own useCallback() Hook
setCurrentUser({} as User);
clearOidcToken();
setIsAuthenticated(false);
Expand Down Expand Up @@ -463,7 +476,7 @@
// After every refresh success, start timer again
tokenService.current.updateRefreshSuccessCallback(startTokenExpiryTimer);
}
}, [authenticatorRef.current?.renewIdToken]);

Check warning on line 479 in openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useEffect has a missing dependency: 'startTokenExpiryTimer'. Either include it or remove the dependency array

// When the tab becomes visible after being backgrounded, browsers may have
// throttled or suspended the proactive renewal timer. Check token freshness
Expand Down Expand Up @@ -506,7 +519,7 @@
return () => {
document.removeEventListener('visibilitychange', handleVisibilityChange);
};
}, []);

Check warning on line 522 in openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useEffect has a missing dependency: 'startTokenExpiryTimer'. Either include it or remove the dependency array

/**
* Performs cleanup around timers
Expand All @@ -516,7 +529,7 @@
clearTimeout(timeoutId);
}, [timeoutId]);

const handleFailedLogin = () => {

Check warning on line 532 in openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

The 'handleFailedLogin' function makes the dependencies of useMemo Hook (at line 900) change on every render. Move it inside the useMemo callback. Alternatively, wrap the definition of 'handleFailedLogin' in its own useCallback() Hook
setIsSigningUp(false);
setIsAuthenticated(false);
setApplicationLoading(false);
Expand Down Expand Up @@ -574,7 +587,7 @@
setApplicationLoading(false);
}
},
[

Check warning on line 590 in openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

React Hook useCallback has missing dependencies: 'authConfig?.provider', 'handledVerifiedUser', 'navigate', 'resetUserDetails', and 'startTokenExpiryTimer'. Either include them or remove the dependency array
authConfig?.enableSelfSignup,
clientType,
authorizerConfig?.principalDomain,
Expand Down Expand Up @@ -619,7 +632,7 @@
* Initialize Axios interceptors to intercept every request and response
* to handle appropriately. This should be called only when security is enabled.
*/
const initializeAxiosInterceptors = async () => {

Check warning on line 635 in openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

The 'initializeAxiosInterceptors' function makes the dependencies of useMemo Hook (at line 900) change on every render. To fix this, wrap the definition of 'initializeAxiosInterceptors' in its own useCallback() Hook
// Axios Request interceptor to add Bearer tokens in Header
if (requestInterceptor != null) {
axiosClient.interceptors.request.eject(requestInterceptor);
Expand Down Expand Up @@ -687,26 +700,26 @@
}
isRefreshDriverActive = true;

const drainPendingRequests = (hasNewToken: boolean) => {

Check warning on line 703 in openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

Refactor this code to not nest functions more than 4 levels deep
const queued = pendingRequests;
pendingRequests = [];
isRefreshDriverActive = false;
if (hasNewToken) {
queued.forEach(
({ resolve: onResolve, reject: onReject, config }) =>

Check failure on line 709 in openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx

View check run for this annotation

SonarQubeCloud / [open-metadata-ui] SonarCloud Code Analysis

Refactor this code to not nest functions more than 5 levels deep.

See more on https://sonarcloud.io/project/issues?id=open-metadata-ui&issues=AZ_wZpFnxzD3XMBcnMrc&open=AZ_wZpFnxzD3XMBcnMrc&pullRequest=31335
axiosClient
.request(config)
.then(onResolve)
.catch(onReject)
);
} else {
queued.forEach(({ reject: onReject }) => onReject(error));

Check failure on line 716 in openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx

View check run for this annotation

SonarQubeCloud / [open-metadata-ui] SonarCloud Code Analysis

Refactor this code to not nest functions more than 5 levels deep.

See more on https://sonarcloud.io/project/issues?id=open-metadata-ui&issues=AZ_wZpFnxzD3XMBcnMrd&open=AZ_wZpFnxzD3XMBcnMrd&pullRequest=31335
}
};

tokenService.current
.refreshToken()
.then(async (token) => {

Check warning on line 722 in openmetadata-ui/src/main/resources/ui/src/components/Auth/AuthProviders/AuthProvider.tsx

View workflow job for this annotation

GitHub Actions / checkstyle

Refactor this code to not nest functions more than 4 levels deep
if (token) {
await initializeAxiosInterceptors();
drainPendingRequests(true);
Expand Down
Loading