This is an automated email from the ASF dual-hosted git repository.

tiagobento pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools.git


The following commit(s) were added to refs/heads/main by this push:
     new 9d418dfc675 kie-issues#3136: Ability to renew AuthSessions in KIE 
Sandbox (#3150)
9d418dfc675 is described below

commit 9d418dfc675581a448c220fe0abe509a2618eed5
Author: Kusuma04-dev <[email protected]>
AuthorDate: Sat May 31 03:30:38 2025 +0530

    kie-issues#3136: Ability to renew AuthSessions in KIE Sandbox (#3150)
    
    Co-authored-by: chinnamatli kusumalatha 
<[email protected]>
---
 .../online-editor/src/accounts/AccountsContext.tsx |  16 ++++
 .../src/accounts/git/ConnectToGitSection.tsx       |  27 ++++--
 .../kubernetes/ConnectToKubernetesSection.tsx      |   4 +
 .../kubernetes/ConnectToKubernetesSimple.tsx       |  14 ++-
 .../ConnectToLocalKubernetesClusterWizard.tsx      |  14 ++-
 .../accounts/openshift/ConnecToOpenShiftSimple.tsx |  16 +++-
 ...tToDeveloperSandboxForRedHatOpenShiftWizard.tsx |  16 +++-
 .../openshift/ConnectToOpenShiftSection.tsx        |   5 +-
 .../src/authProviders/AuthProvidersApi.ts          |  13 +++
 .../src/authSessions/AuthSessionSelect.tsx         |   9 +-
 .../src/authSessions/AuthSessionsContext.tsx       |  39 +++++++-
 .../src/authSessions/AuthSessionsList.tsx          |  96 +++++++++++--------
 .../src/authSessions/ReAuthenticateHelper.tsx      | 102 +++++++++++++++++++++
 .../GitIntegrationContextProvider.tsx              |  40 ++++++--
 .../GitIntegration/LoadOrganizationsSelect.tsx     |   4 +-
 .../src/editor/Toolbar/Share/GitDropdownGroup.tsx  |   4 +-
 16 files changed, 343 insertions(+), 76 deletions(-)

diff --git a/packages/online-editor/src/accounts/AccountsContext.tsx 
b/packages/online-editor/src/accounts/AccountsContext.tsx
index 57ba3b132b5..f3360c7f46c 100644
--- a/packages/online-editor/src/accounts/AccountsContext.tsx
+++ b/packages/online-editor/src/accounts/AccountsContext.tsx
@@ -55,36 +55,42 @@ export type AccountsState =
       backActionKind: AccountsDispatchActionKind.GO_HOME;
       onNewAuthSession?: (newAuthSession: AuthSession) => any;
       authProviderGroup?: AuthProviderGroup;
+      selectedAuthSession?: AuthSession;
     }
   | {
       section: AccountsSection.CONNECT_TO_GITHUB;
       selectedAuthProvider: GitAuthProvider;
       backActionKind: AccountsDispatchActionKind.SELECT_AUTH_PROVIDER | 
AccountsDispatchActionKind.GO_HOME;
       onNewAuthSession?: (newAuthSession: AuthSession) => any;
+      selectedAuthSession?: AuthSession;
     }
   | {
       section: AccountsSection.CONNECT_TO_BITBUCKET;
       selectedAuthProvider: GitAuthProvider;
       backActionKind: AccountsDispatchActionKind.SELECT_AUTH_PROVIDER | 
AccountsDispatchActionKind.GO_HOME;
       onNewAuthSession?: (newAuthSession: AuthSession) => any;
+      selectedAuthSession?: AuthSession;
     }
   | {
       section: AccountsSection.CONNECT_TO_GITLAB;
       selectedAuthProvider: GitAuthProvider;
       backActionKind: AccountsDispatchActionKind.SELECT_AUTH_PROVIDER | 
AccountsDispatchActionKind.GO_HOME;
       onNewAuthSession?: (newAuthSession: AuthSession) => any;
+      selectedAuthSession?: AuthSession;
     }
   | {
       section: AccountsSection.CONNECT_TO_OPENSHIFT;
       selectedAuthProvider: OpenShiftAuthProvider;
       backActionKind: AccountsDispatchActionKind.SELECT_AUTH_PROVIDER | 
AccountsDispatchActionKind.GO_HOME;
       onNewAuthSession?: (newAuthSession: AuthSession) => any;
+      selectedAuthSession?: AuthSession;
     }
   | {
       section: AccountsSection.CONNECT_TO_KUBERNETES;
       selectedAuthProvider: KubernetesAuthProvider;
       backActionKind: AccountsDispatchActionKind.SELECT_AUTH_PROVIDER | 
AccountsDispatchActionKind.GO_HOME;
       onNewAuthSession?: (newAuthSession: AuthSession) => any;
+      selectedAuthSession?: AuthSession;
     };
 
 // Reducer
@@ -117,30 +123,35 @@ export type AccountsDispatchAction =
       selectedAuthProvider: GitAuthProvider;
       backActionKind: AccountsDispatchActionKind.SELECT_AUTH_PROVIDER | 
AccountsDispatchActionKind.GO_HOME;
       onNewAuthSession?: (newAuthSession: AuthSession) => any;
+      selectedAuthSession?: AuthSession;
     }
   | {
       kind: AccountsDispatchActionKind.SETUP_BITBUCKET_AUTH;
       selectedAuthProvider: GitAuthProvider;
       backActionKind: AccountsDispatchActionKind.SELECT_AUTH_PROVIDER | 
AccountsDispatchActionKind.GO_HOME;
       onNewAuthSession?: (newAuthSession: AuthSession) => any;
+      selectedAuthSession?: AuthSession;
     }
   | {
       kind: AccountsDispatchActionKind.SETUP_GITLAB_AUTH;
       selectedAuthProvider: GitAuthProvider;
       backActionKind: AccountsDispatchActionKind.SELECT_AUTH_PROVIDER | 
AccountsDispatchActionKind.GO_HOME;
       onNewAuthSession?: (newAuthSession: AuthSession) => any;
+      selectedAuthSession?: AuthSession;
     }
   | {
       kind: AccountsDispatchActionKind.SETUP_OPENSHIFT_AUTH;
       selectedAuthProvider: OpenShiftAuthProvider;
       backActionKind: AccountsDispatchActionKind.SELECT_AUTH_PROVIDER | 
AccountsDispatchActionKind.GO_HOME;
       onNewAuthSession?: (newAuthSession: AuthSession) => any;
+      selectedAuthSession?: AuthSession;
     }
   | {
       kind: AccountsDispatchActionKind.SETUP_KUBERNETES_AUTH;
       selectedAuthProvider: KubernetesAuthProvider;
       backActionKind: AccountsDispatchActionKind.SELECT_AUTH_PROVIDER | 
AccountsDispatchActionKind.GO_HOME;
       onNewAuthSession?: (newAuthSession: AuthSession) => any;
+      selectedAuthSession?: AuthSession;
     };
 
 export const AccountsContext = React.createContext<AccountsState>({} as any);
@@ -180,6 +191,7 @@ export function AccountsContextProvider(props: 
React.PropsWithChildren<{}>) {
             selectedAuthProvider: action.selectedAuthProvider,
             onNewAuthSession: action.onNewAuthSession,
             backActionKind: action.backActionKind,
+            selectedAuthSession: action.selectedAuthSession,
           };
         case AccountsDispatchActionKind.SETUP_BITBUCKET_AUTH:
           return {
@@ -187,6 +199,7 @@ export function AccountsContextProvider(props: 
React.PropsWithChildren<{}>) {
             selectedAuthProvider: action.selectedAuthProvider,
             onNewAuthSession: action.onNewAuthSession,
             backActionKind: action.backActionKind,
+            selectedAuthSession: action.selectedAuthSession,
           };
         case AccountsDispatchActionKind.SETUP_GITLAB_AUTH:
           return {
@@ -194,6 +207,7 @@ export function AccountsContextProvider(props: 
React.PropsWithChildren<{}>) {
             selectedAuthProvider: action.selectedAuthProvider,
             onNewAuthSession: action.onNewAuthSession,
             backActionKind: action.backActionKind,
+            selectedAuthSession: action.selectedAuthSession,
           };
         case AccountsDispatchActionKind.SETUP_OPENSHIFT_AUTH:
           return {
@@ -201,6 +215,7 @@ export function AccountsContextProvider(props: 
React.PropsWithChildren<{}>) {
             selectedAuthProvider: action.selectedAuthProvider,
             onNewAuthSession: action.onNewAuthSession,
             backActionKind: action.backActionKind,
+            selectedAuthSession: action.selectedAuthSession,
           };
         case AccountsDispatchActionKind.SETUP_KUBERNETES_AUTH:
           return {
@@ -208,6 +223,7 @@ export function AccountsContextProvider(props: 
React.PropsWithChildren<{}>) {
             selectedAuthProvider: action.selectedAuthProvider,
             onNewAuthSession: action.onNewAuthSession,
             backActionKind: action.backActionKind,
+            selectedAuthSession: action.selectedAuthSession,
           };
         default:
           assertUnreachable(kind);
diff --git a/packages/online-editor/src/accounts/git/ConnectToGitSection.tsx 
b/packages/online-editor/src/accounts/git/ConnectToGitSection.tsx
index d7749b6dfec..4e1f8a19482 100644
--- a/packages/online-editor/src/accounts/git/ConnectToGitSection.tsx
+++ b/packages/online-editor/src/accounts/git/ConnectToGitSection.tsx
@@ -35,7 +35,7 @@ import { useCancelableEffect } from 
"@kie-tools-core/react-hooks/dist/useCancela
 import { AccountsDispatchActionKind, AccountsSection, useAccounts, 
useAccountsDispatch } from "../AccountsContext";
 import { useAuthSessions, useAuthSessionsDispatch } from 
"../../authSessions/AuthSessionsContext";
 import { AuthSessionDescriptionList } from 
"../../authSessions/AuthSessionsList";
-import { AUTH_SESSION_VERSION_NUMBER, GitAuthSession } from 
"../../authSessions/AuthSessionApi";
+import { AUTH_SESSION_VERSION_NUMBER, GitAuthSession, isGitAuthSession } from 
"../../authSessions/AuthSessionApi";
 import { PromiseStateStatus, usePromiseState } from 
"@kie-tools-core/react-hooks/dist/PromiseState";
 import {
   GitAuthProvider,
@@ -89,6 +89,17 @@ export function ConnectToGitSection(props: { authProvider: 
GitAuthProvider }) {
   const [tokenInput, setTokenInput] = useState("");
   const [success, setSuccess] = useState(false);
   const [newAuthSession, setNewAuthSession] = 
usePromiseState<GitAuthSession>();
+  const isGitSection =
+    accounts.section === AccountsSection.CONNECT_TO_GITHUB ||
+    accounts.section === AccountsSection.CONNECT_TO_BITBUCKET ||
+    accounts.section === AccountsSection.CONNECT_TO_GITLAB;
+  const selectedGitSession = isGitSection ? accounts.selectedAuthSession : 
undefined;
+
+  useEffect(() => {
+    if (selectedGitSession && isGitAuthSession(selectedGitSession)) {
+      setUsernameInput(selectedGitSession.login);
+    }
+  }, [selectedGitSession]);
 
   useCancelableEffect(
     useCallback(
@@ -163,7 +174,7 @@ export function ConnectToGitSection(props: { authProvider: 
GitAuthProvider }) {
             }
 
             const newAuthSession: GitAuthSession = {
-              id: uuid(),
+              id: selectedGitSession?.id ?? uuid(),
               version: AUTH_SESSION_VERSION_NUMBER,
               token: tokenInput,
               type: "git",
@@ -175,12 +186,15 @@ export function ConnectToGitSection(props: { 
authProvider: GitAuthProvider }) {
               createdAtDateISO: new Date().toISOString(),
             };
 
+            setNewAuthSession({ data: newAuthSession });
+            setSuccess(true);
+
             // batch updates
-            setTimeout(() => {
+            if (selectedGitSession) {
+              authSessionsDispatch.update(newAuthSession);
+            } else {
               authSessionsDispatch.add(newAuthSession);
-              setNewAuthSession({ data: newAuthSession });
-              setSuccess(true);
-            }, 0);
+            }
           })
           .catch((e) => {
             if (canceled.get()) {
@@ -205,6 +219,7 @@ export function ConnectToGitSection(props: { authProvider: 
GitAuthProvider }) {
         env.KIE_SANDBOX_CORS_PROXY_URL,
         usernameInput,
         authSessionsDispatch,
+        selectedGitSession,
       ]
     )
   );
diff --git 
a/packages/online-editor/src/accounts/kubernetes/ConnectToKubernetesSection.tsx 
b/packages/online-editor/src/accounts/kubernetes/ConnectToKubernetesSection.tsx
index 5f05f3726c4..4db1cb58087 100644
--- 
a/packages/online-editor/src/accounts/kubernetes/ConnectToKubernetesSection.tsx
+++ 
b/packages/online-editor/src/accounts/kubernetes/ConnectToKubernetesSection.tsx
@@ -46,6 +46,8 @@ export function ConnectToKubernetesSection() {
   const [connection, setConnection] = useState(EMPTY_KUBERNETES_CONNECTION);
   const [kieSandboxKubernetesService, setKieSandboxKubernetesService] = 
useState<KieSandboxKubernetesService>();
   const [isLoadingService, setIsLoadingService] = useState(false);
+  const selectedKubernetesSession =
+    accounts.section === AccountsSection.CONNECT_TO_KUBERNETES ? 
accounts.selectedAuthSession : undefined;
 
   useCancelableEffect(
     useCallback(
@@ -145,6 +147,7 @@ export function ConnectToKubernetesSection() {
               setNewAuthSession={setNewAuthSession}
               kieSandboxKubernetesService={kieSandboxKubernetesService}
               isLoadingService={isLoadingService}
+              selectedAuthSession={selectedKubernetesSession}
             />
           )}
           {mode === KubernetesSettingsTabMode.WIZARD && (
@@ -157,6 +160,7 @@ export function ConnectToKubernetesSection() {
               setNewAuthSession={setNewAuthSession}
               kieSandboxKubernetesService={kieSandboxKubernetesService}
               isLoadingService={isLoadingService}
+              selectedAuthSession={selectedKubernetesSession}
             />
           )}
         </>
diff --git 
a/packages/online-editor/src/accounts/kubernetes/ConnectToKubernetesSimple.tsx 
b/packages/online-editor/src/accounts/kubernetes/ConnectToKubernetesSimple.tsx
index 9e884edfeb1..580290fc3cb 100644
--- 
a/packages/online-editor/src/accounts/kubernetes/ConnectToKubernetesSimple.tsx
+++ 
b/packages/online-editor/src/accounts/kubernetes/ConnectToKubernetesSimple.tsx
@@ -27,10 +27,11 @@ import { TextInput } from 
"@patternfly/react-core/dist/js/components/TextInput";
 import HelpIcon from "@patternfly/react-icons/dist/js/icons/help-icon";
 import { TimesIcon } from "@patternfly/react-icons/dist/js/icons/times-icon";
 import { useOnlineI18n } from "../../i18n";
-import { useAuthSessionsDispatch } from 
"../../authSessions/AuthSessionsContext";
+import { useAuthSessionsDispatch, useSyncCloudAuthSession } from 
"../../authSessions/AuthSessionsContext";
 import { v4 as uuid } from "uuid";
 import {
   AUTH_SESSION_VERSION_NUMBER,
+  AuthSession,
   CloudAuthSessionType,
   KubernetesAuthSession,
 } from "../../authSessions/AuthSessionApi";
@@ -62,12 +63,15 @@ export function ConnectToKubernetesSimple(props: {
   setMode: React.Dispatch<React.SetStateAction<KubernetesSettingsTabMode>>;
   setNewAuthSession: 
React.Dispatch<React.SetStateAction<KubernetesAuthSession>>;
   isLoadingService: boolean;
+  selectedAuthSession?: AuthSession;
 }) {
   const { i18n } = useOnlineI18n();
   const [isConnectionValidated, setConnectionValidated] = 
useState(FormValiationOptions.INITIAL);
   const [isConnecting, setConnecting] = useState(false);
   const authSessionsDispatch = useAuthSessionsDispatch();
 
+  useSyncCloudAuthSession(props.selectedAuthSession, props.setConnection);
+
   const onConnect = useCallback(async () => {
     if (isConnecting) {
       return;
@@ -87,14 +91,18 @@ export function ConnectToKubernetesSimple(props: {
       const newAuthSession: KubernetesAuthSession = {
         type: CloudAuthSessionType.Kubernetes,
         version: AUTH_SESSION_VERSION_NUMBER,
-        id: uuid(),
+        id: props.selectedAuthSession?.id ?? uuid(),
         ...props.connection,
         authProviderId: "kubernetes",
         createdAtDateISO: new Date().toISOString(),
         k8sApiServerEndpointsByResourceKind: 
props.kieSandboxKubernetesService.args.k8sApiServerEndpointsByResourceKind,
       };
       props.setStatus(KubernetesInstanceStatus.CONNECTED);
-      authSessionsDispatch.add(newAuthSession);
+      if (props.selectedAuthSession) {
+        authSessionsDispatch.update(newAuthSession);
+      } else {
+        authSessionsDispatch.add(newAuthSession);
+      }
       props.setNewAuthSession(newAuthSession);
     } else if (isConnectionEstablished === 
KubernetesConnectionStatus.MISSING_PERMISSIONS) {
       setConnectionValidated(FormValiationOptions.MISSING_PERMISSIONS);
diff --git 
a/packages/online-editor/src/accounts/kubernetes/ConnectToLocalKubernetesClusterWizard.tsx
 
b/packages/online-editor/src/accounts/kubernetes/ConnectToLocalKubernetesClusterWizard.tsx
index 561bf8f4f07..b5f8fd0da85 100644
--- 
a/packages/online-editor/src/accounts/kubernetes/ConnectToLocalKubernetesClusterWizard.tsx
+++ 
b/packages/online-editor/src/accounts/kubernetes/ConnectToLocalKubernetesClusterWizard.tsx
@@ -32,9 +32,10 @@ import { useOnlineI18n } from "../../i18n";
 import { KubernetesSettingsTabMode } from "./ConnectToKubernetesSection";
 import { KubernetesInstanceStatus } from "./KubernetesInstanceStatus";
 import { v4 as uuid } from "uuid";
-import { useAuthSessionsDispatch } from 
"../../authSessions/AuthSessionsContext";
+import { useAuthSessionsDispatch, useSyncCloudAuthSession } from 
"../../authSessions/AuthSessionsContext";
 import {
   AUTH_SESSION_VERSION_NUMBER,
+  AuthSession,
   CloudAuthSessionType,
   KubernetesAuthSession,
 } from "../../authSessions/AuthSessionApi";
@@ -119,6 +120,7 @@ export function 
ConnectToLocalKubernetesClusterWizard(props: {
   setStatus: React.Dispatch<React.SetStateAction<KubernetesInstanceStatus>>;
   setNewAuthSession: 
React.Dispatch<React.SetStateAction<KubernetesAuthSession>>;
   isLoadingService: boolean;
+  selectedAuthSession?: AuthSession;
 }) {
   const { i18n } = useOnlineI18n();
   const routes = useRoutes();
@@ -189,6 +191,8 @@ export function 
ConnectToLocalKubernetesClusterWizard(props: {
     return isTokenValid(props.connection.token);
   }, [props.connection.token]);
 
+  useSyncCloudAuthSession(props.selectedAuthSession, props.setConnection);
+
   useEffect(() => {
     setConnectionValidated(isKubernetesConnectionValid(props.connection));
   }, [props.connection]);
@@ -259,7 +263,7 @@ export function 
ConnectToLocalKubernetesClusterWizard(props: {
       const newAuthSession: KubernetesAuthSession = {
         type: CloudAuthSessionType.Kubernetes,
         version: AUTH_SESSION_VERSION_NUMBER,
-        id: uuid(),
+        id: props.selectedAuthSession?.id ?? uuid(),
         ...props.connection,
         authProviderId: "kubernetes",
         createdAtDateISO: new Date().toISOString(),
@@ -267,8 +271,12 @@ export function 
ConnectToLocalKubernetesClusterWizard(props: {
       };
       setConnectionValidated(true);
       props.setStatus(KubernetesInstanceStatus.CONNECTED);
-      authSessionsDispatch.add(newAuthSession);
       props.setNewAuthSession(newAuthSession);
+      if (props.selectedAuthSession) {
+        authSessionsDispatch.update(newAuthSession);
+      } else {
+        authSessionsDispatch.add(newAuthSession);
+      }
     } else {
       setConnectionValidated(false);
       return;
diff --git 
a/packages/online-editor/src/accounts/openshift/ConnecToOpenShiftSimple.tsx 
b/packages/online-editor/src/accounts/openshift/ConnecToOpenShiftSimple.tsx
index 2fe84592a87..09ac550589f 100644
--- a/packages/online-editor/src/accounts/openshift/ConnecToOpenShiftSimple.tsx
+++ b/packages/online-editor/src/accounts/openshift/ConnecToOpenShiftSimple.tsx
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-import React, { useCallback, useState } from "react";
+import React, { useCallback, useEffect, useState } from "react";
 import { Alert } from "@patternfly/react-core/dist/js/components/Alert";
 import { Button } from "@patternfly/react-core/dist/js/components/Button";
 import { ActionGroup, Form, FormAlert, FormGroup } from 
"@patternfly/react-core/dist/js/components/Form";
@@ -32,11 +32,13 @@ import { useOnlineI18n } from "../../i18n";
 import { OpenShiftInstanceStatus } from "./OpenShiftInstanceStatus";
 import { OpenShiftSettingsTabMode } from "./ConnectToOpenShiftSection";
 import { KieSandboxOpenShiftService } from 
"../../devDeployments/services/openshift/KieSandboxOpenShiftService";
-import { useAuthSessionsDispatch } from 
"../../authSessions/AuthSessionsContext";
+import { useAuthSessionsDispatch, useSyncCloudAuthSession } from 
"../../authSessions/AuthSessionsContext";
 import { v4 as uuid } from "uuid";
 import {
   AUTH_SESSION_VERSION_NUMBER,
+  AuthSession,
   CloudAuthSessionType,
+  isCloudAuthSession,
   OpenShiftAuthSession,
 } from "../../authSessions/AuthSessionApi";
 import {
@@ -62,11 +64,13 @@ export function ConnecToOpenShiftSimple(props: {
   setStatus: React.Dispatch<React.SetStateAction<OpenShiftInstanceStatus>>;
   setNewAuthSession: 
React.Dispatch<React.SetStateAction<OpenShiftAuthSession>>;
   isLoadingService: boolean;
+  selectedAuthSession?: AuthSession;
 }) {
   const { i18n } = useOnlineI18n();
   const [isConnectionValidated, setConnectionValidated] = 
useState(FormValiationOptions.INITIAL);
   const [isConnecting, setConnecting] = useState(false);
   const authSessionsDispatch = useAuthSessionsDispatch();
+  useSyncCloudAuthSession(props.selectedAuthSession, props.setConnection);
 
   const onConnect = useCallback(async () => {
     if (isConnecting) {
@@ -87,15 +91,19 @@ export function ConnecToOpenShiftSimple(props: {
       const newAuthSession: OpenShiftAuthSession = {
         type: CloudAuthSessionType.OpenShift,
         version: AUTH_SESSION_VERSION_NUMBER,
-        id: uuid(),
+        id: props.selectedAuthSession?.id ?? uuid(),
         ...props.connection,
         authProviderId: "openshift",
         createdAtDateISO: new Date().toISOString(),
         k8sApiServerEndpointsByResourceKind: 
props.kieSandboxOpenShiftService.args.k8sApiServerEndpointsByResourceKind,
       };
       props.setStatus(OpenShiftInstanceStatus.CONNECTED);
-      authSessionsDispatch.add(newAuthSession);
       props.setNewAuthSession(newAuthSession);
+      if (props.selectedAuthSession) {
+        authSessionsDispatch.update(newAuthSession);
+      } else {
+        authSessionsDispatch.add(newAuthSession);
+      }
     } else {
       setConnectionValidated(FormValiationOptions.CONNECTION_ERROR);
       return;
diff --git 
a/packages/online-editor/src/accounts/openshift/ConnectToDeveloperSandboxForRedHatOpenShiftWizard.tsx
 
b/packages/online-editor/src/accounts/openshift/ConnectToDeveloperSandboxForRedHatOpenShiftWizard.tsx
index 7c2b133d48d..10e31ef55ab 100644
--- 
a/packages/online-editor/src/accounts/openshift/ConnectToDeveloperSandboxForRedHatOpenShiftWizard.tsx
+++ 
b/packages/online-editor/src/accounts/openshift/ConnectToDeveloperSandboxForRedHatOpenShiftWizard.tsx
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-import React, { useCallback, useEffect, useMemo, useState } from "react";
+import React, { useCallback, useMemo, useState } from "react";
 import { I18nHtml } from "@kie-tools-core/i18n/dist/react-components";
 import { Alert } from "@patternfly/react-core/dist/js/components/Alert";
 import { Button, ButtonVariant } from 
"@patternfly/react-core/dist/js/components/Button";
@@ -35,9 +35,10 @@ import { OpenShiftSettingsTabMode } from 
"./ConnectToOpenShiftSection";
 import { OpenShiftInstanceStatus } from "./OpenShiftInstanceStatus";
 import { KieSandboxOpenShiftService } from 
"../../devDeployments/services/openshift/KieSandboxOpenShiftService";
 import { v4 as uuid } from "uuid";
-import { useAuthSessionsDispatch } from 
"../../authSessions/AuthSessionsContext";
+import { useAuthSessionsDispatch, useSyncCloudAuthSession } from 
"../../authSessions/AuthSessionsContext";
 import {
   AUTH_SESSION_VERSION_NUMBER,
+  AuthSession,
   CloudAuthSessionType,
   OpenShiftAuthSession,
 } from "../../authSessions/AuthSessionApi";
@@ -70,6 +71,7 @@ export function 
ConnectToDeveloperSandboxForRedHatOpenShiftWizard(props: {
   setStatus: React.Dispatch<React.SetStateAction<OpenShiftInstanceStatus>>;
   setNewAuthSession: 
React.Dispatch<React.SetStateAction<OpenShiftAuthSession>>;
   isLoadingService: boolean;
+  selectedAuthSession?: AuthSession;
 }) {
   const { i18n } = useOnlineI18n();
   const [isConnectionValidated, setConnectionValidated] = useState(false);
@@ -93,6 +95,8 @@ export function 
ConnectToDeveloperSandboxForRedHatOpenShiftWizard(props: {
     return isTokenValid(props.connection.token);
   }, [props.connection.token]);
 
+  useSyncCloudAuthSession(props.selectedAuthSession, props.setConnection);
+
   useCancelableEffect(
     useCallback(
       ({ canceled }) => {
@@ -166,7 +170,7 @@ export function 
ConnectToDeveloperSandboxForRedHatOpenShiftWizard(props: {
       const newAuthSession: OpenShiftAuthSession = {
         type: CloudAuthSessionType.OpenShift,
         version: AUTH_SESSION_VERSION_NUMBER,
-        id: uuid(),
+        id: props.selectedAuthSession?.id ?? uuid(),
         ...props.connection,
         authProviderId: "openshift",
         createdAtDateISO: new Date().toISOString(),
@@ -174,8 +178,12 @@ export function 
ConnectToDeveloperSandboxForRedHatOpenShiftWizard(props: {
       };
       setConnectionValidated(true);
       props.setStatus(OpenShiftInstanceStatus.CONNECTED);
-      authSessionsDispatch.add(newAuthSession);
       props.setNewAuthSession(newAuthSession);
+      if (props.selectedAuthSession) {
+        authSessionsDispatch.update(newAuthSession);
+      } else {
+        authSessionsDispatch.add(newAuthSession);
+      }
     } else {
       setConnectionValidated(false);
       return;
diff --git 
a/packages/online-editor/src/accounts/openshift/ConnectToOpenShiftSection.tsx 
b/packages/online-editor/src/accounts/openshift/ConnectToOpenShiftSection.tsx
index 02ea7cf4638..616132cdd80 100644
--- 
a/packages/online-editor/src/accounts/openshift/ConnectToOpenShiftSection.tsx
+++ 
b/packages/online-editor/src/accounts/openshift/ConnectToOpenShiftSection.tsx
@@ -46,7 +46,8 @@ export function ConnectToOpenShiftSection() {
   const [newAuthSession, setNewAuthSession] = useState<OpenShiftAuthSession>();
   const [status, setStatus] = useState(OpenShiftInstanceStatus.DISCONNECTED);
   const [connection, setConnection] = useState(EMPTY_KUBERNETES_CONNECTION);
-
+  const selectedOpenShiftSession =
+    accounts.section === AccountsSection.CONNECT_TO_OPENSHIFT ? 
accounts.selectedAuthSession : undefined;
   const [kieSandboxOpenShiftService, setKieSandboxOpenShiftService] = 
useState<KieSandboxOpenShiftService>();
   const [isLoadingService, setIsLoadingService] = useState(false);
 
@@ -133,6 +134,7 @@ export function ConnectToOpenShiftSection() {
               setNewAuthSession={setNewAuthSession}
               kieSandboxOpenShiftService={kieSandboxOpenShiftService}
               isLoadingService={isLoadingService}
+              selectedAuthSession={selectedOpenShiftSession}
             />
           )}
           {mode === OpenShiftSettingsTabMode.WIZARD && (
@@ -145,6 +147,7 @@ export function ConnectToOpenShiftSection() {
               setNewAuthSession={setNewAuthSession}
               kieSandboxOpenShiftService={kieSandboxOpenShiftService}
               isLoadingService={isLoadingService}
+              selectedAuthSession={selectedOpenShiftSession}
             />
           )}
         </>
diff --git a/packages/online-editor/src/authProviders/AuthProvidersApi.ts 
b/packages/online-editor/src/authProviders/AuthProvidersApi.ts
index 072991507f5..3afd17fe1cb 100644
--- a/packages/online-editor/src/authProviders/AuthProvidersApi.ts
+++ b/packages/online-editor/src/authProviders/AuthProvidersApi.ts
@@ -47,6 +47,19 @@ export const isGitAuthProvider = (
 ): maybeGitAuthProvider is GitAuthProvider => {
   return gitAuthProviderKeys.some((k) => k === maybeGitAuthProvider?.type);
 };
+export const isOpenShiftAuthProvider = (
+  maybeOpenShiftAuthProvider: AuthProvider | undefined
+): maybeOpenShiftAuthProvider is OpenShiftAuthProvider => {
+  const openShiftAuthProviderKeys = ["openshift"];
+  return openShiftAuthProviderKeys.some((k) => k === 
maybeOpenShiftAuthProvider?.type);
+};
+
+export const isKubernetesAuthProvider = (
+  maybeKubernetesAuthProvider: AuthProvider | undefined
+): maybeKubernetesAuthProvider is KubernetesAuthProvider => {
+  const kubernetesAuthProviderKeys = ["kubernetes"];
+  return kubernetesAuthProviderKeys.some((k) => k === 
maybeKubernetesAuthProvider?.type);
+};
 
 export type OpenShiftAuthProviderType = AuthProviderType.openshift;
 export type KubernetesAuthProviderType = AuthProviderType.kubernetes;
diff --git a/packages/online-editor/src/authSessions/AuthSessionSelect.tsx 
b/packages/online-editor/src/authSessions/AuthSessionSelect.tsx
index eb26c8c5610..0179aa35c8f 100644
--- a/packages/online-editor/src/authSessions/AuthSessionSelect.tsx
+++ b/packages/online-editor/src/authSessions/AuthSessionSelect.tsx
@@ -42,6 +42,7 @@ import { Text, TextContent, TextVariants } from 
"@patternfly/react-core/dist/js/
 import { AuthSession, AuthSessionStatus, AUTH_SESSION_NONE } from 
"./AuthSessionApi";
 import { v4 as uuid } from "uuid";
 import { useAuthProviders } from "../authProviders/AuthProvidersContext";
+import { ReAuthenticateButton } from "./ReAuthenticateHelper";
 
 export type AuthSessionSelectItem = {
   groupLabel: string;
@@ -238,7 +239,7 @@ export function AuthSessionSelect(props: {
                 ) {
                   return [];
                 }
-
+                const isInvalidSession = authSessionStatus.get(authSession.id) 
=== AuthSessionStatus.INVALID;
                 if (authSession.type === "none") {
                   return [
                     <SelectOption key={AUTH_SESSION_NONE.id} 
value={AUTH_SESSION_NONE.id} description={<i>{}</i>}>
@@ -265,6 +266,9 @@ export function AuthSessionSelect(props: {
                         )}
                       </Flex>
                     </SelectOption>,
+                    ...(isInvalidSession
+                      ? [<ReAuthenticateButton 
key={`reauth-${authSession.id}`} authSession={authSession} />]
+                      : []),
                   ];
                 }
 
@@ -284,6 +288,9 @@ export function AuthSessionSelect(props: {
                         )}
                       </Flex>
                     </SelectOption>,
+                    ...(isInvalidSession
+                      ? [<ReAuthenticateButton 
key={`reauth-${authSession.id}`} authSession={authSession} />]
+                      : []),
                   ];
                 }
 
diff --git a/packages/online-editor/src/authSessions/AuthSessionsContext.tsx 
b/packages/online-editor/src/authSessions/AuthSessionsContext.tsx
index c6c137f688d..7bfeda96597 100644
--- a/packages/online-editor/src/authSessions/AuthSessionsContext.tsx
+++ b/packages/online-editor/src/authSessions/AuthSessionsContext.tsx
@@ -39,6 +39,7 @@ import {
   AUTH_SESSIONS_FS_NAME_WITH_VERSION,
   mapSerializer,
   authSessionBroadcastChannel,
+  isCloudAuthSession,
 } from "./AuthSessionApi";
 import { KieSandboxOpenShiftService } from 
"../devDeployments/services/openshift/KieSandboxOpenShiftService";
 import { isGitAuthProvider, isSupportedGitAuthProviderType } from 
"../authProviders/AuthProvidersApi";
@@ -57,6 +58,7 @@ export type AuthSessionsDispatchContextType = {
   recalculateAuthSessionStatus: () => void;
   add: (authSession: AuthSession) => void;
   remove: (authSession: AuthSession) => void;
+  update: (authSession: AuthSession) => void;
 };
 
 const AuthSessionsContext = createContext<AuthSessionsContextType>({} as any);
@@ -130,6 +132,18 @@ export function AuthSessionsContextProvider(props: 
PropsWithChildren<{}>) {
     [authSessions, persistAuthSessions]
   );
 
+  const update = useCallback(
+    (authSession: AuthSession) => {
+      const n = new Map(authSessions?.entries() ?? []);
+      if (!n.has(authSession.id)) {
+        return;
+      }
+      n.set(authSession.id, authSession);
+      persistAuthSessions(n);
+    },
+    [authSessions, persistAuthSessions]
+  );
+
   // Update after persisted
   useEffect(() => {
     authSessionBroadcastChannel.onmessage = refresh;
@@ -250,8 +264,8 @@ export function AuthSessionsContextProvider(props: 
PropsWithChildren<{}>) {
   useCancelableEffect(recalculateAuthSessionStatus);
 
   const dispatch = useMemo(() => {
-    return { add, remove, recalculateAuthSessionStatus };
-  }, [add, remove, recalculateAuthSessionStatus]);
+    return { add, remove, recalculateAuthSessionStatus, update };
+  }, [add, remove, recalculateAuthSessionStatus, update]);
 
   const value = useMemo(() => {
     return { authSessions, authSessionStatus };
@@ -279,6 +293,27 @@ export interface GitConfig {
   email: string;
 }
 
+export function useSyncCloudAuthSession(
+  selectedAuthSession: AuthSession | undefined,
+  setConnection: (connection: {
+    host: string;
+    namespace: string;
+    token: string;
+    insecurelyDisableTlsCertificateValidation: boolean;
+  }) => void
+) {
+  useEffect(() => {
+    if (selectedAuthSession && isCloudAuthSession(selectedAuthSession)) {
+      setConnection({
+        host: selectedAuthSession.host,
+        namespace: selectedAuthSession.namespace,
+        token: "",
+        insecurelyDisableTlsCertificateValidation: 
selectedAuthSession.insecurelyDisableTlsCertificateValidation,
+      });
+    }
+  }, [selectedAuthSession, setConnection]);
+}
+
 export function useAuthSession(authSessionId: string | undefined): {
   authSession: AuthSession | undefined;
   authInfo: AuthInfo | undefined;
diff --git a/packages/online-editor/src/authSessions/AuthSessionsList.tsx 
b/packages/online-editor/src/authSessions/AuthSessionsList.tsx
index 62906047b22..6afb3a4030d 100644
--- a/packages/online-editor/src/authSessions/AuthSessionsList.tsx
+++ b/packages/online-editor/src/authSessions/AuthSessionsList.tsx
@@ -42,6 +42,8 @@ import { useWorkspaceDescriptorsPromise } from 
"@kie-tools-core/workspaces-git-f
 import { useDevDeployments } from "../devDeployments/DevDeploymentsContext";
 import { useCancelableEffect } from 
"@kie-tools-core/react-hooks/dist/useCancelableEffect";
 import { KieSandboxDeployment } from "../devDeployments/services/types";
+import { ReAuthenticateButton } from "./ReAuthenticateHelper";
+import { Flex, FlexItem } from "@patternfly/react-core/dist/js/layouts/Flex";
 
 export function AuthSessionsList(props: {}) {
   const { authSessions, authSessionStatus } = useAuthSessions();
@@ -130,45 +132,63 @@ function AuthSessionCard(props: {
 
   return (
     <Card key={props.authSession.id} isCompact={true} isExpanded={isExpanded}>
-      <CardHeader
-        actions={{
-          actions: (
-            <>
-              {authSessionStatus.get(props.authSession.id) === 
AuthSessionStatus.INVALID && (
-                <Tooltip
-                  content={"Could not authenticate using this session. Its 
Token was probably revoked, or expired."}
-                >
-                  <>
-                    <ExclamationCircleIcon style={{ color: 
"var(--pf-v5-global--palette--red-100)" }} />
-                  </>
-                </Tooltip>
+      <CardHeader onExpand={() => setExpanded((prev) => !prev)}>
+        <Flex
+          flexWrap={{ default: "nowrap" }}
+          justifyContent={{ default: "justifyContentSpaceBetween" }}
+          alignItems={{ default: "alignItemsCenter" }}
+          style={{ width: "100%" }}
+        >
+          <FlexItem>
+            <Flex
+              flexWrap={{ default: "nowrap" }}
+              alignItems={{ default: "alignItemsCenter" }}
+              spaceItems={{ default: "spaceItemsMd" }}
+            >
+              <FlexItem>
+                <AuthSessionLabel authSession={props.authSession} />
+              </FlexItem>
+
+              {(props.authSession.type === "git" ||
+                props.authSession.type === "openshift" ||
+                props.authSession.type === "kubernetes") && (
+                <>
+                  <FlexItem>
+                    <Label>
+                      &nbsp;
+                      {props.usages ? (props.usages.length === 1 ? "1 usage" : 
`${props.usages.length} usages`) : "-"}
+                      &nbsp;
+                    </Label>
+                  </FlexItem>
+                  &nbsp; &nbsp; &nbsp;
+                  {authSessionStatus.get(props.authSession.id) === 
AuthSessionStatus.INVALID && (
+                    <>
+                      <FlexItem>
+                        <Tooltip
+                          content={
+                            "Could not authenticate using this session. Its 
Token was probably revoked, or expired."
+                          }
+                        >
+                          <>
+                            <ExclamationCircleIcon style={{ color: 
"var(--pf-v5-global--palette--red-100)" }} />
+                          </>
+                        </Tooltip>
+                      </FlexItem>
+                      <FlexItem>
+                        <ReAuthenticateButton 
key={`reauth-${props.authSession.id}`} authSession={props.authSession} />
+                      </FlexItem>
+                    </>
+                  )}
+                </>
               )}
-              <Button variant={ButtonVariant.link} onClick={() => 
authSessionsDispatch.remove(props.authSession)}>
-                Remove
-              </Button>
-            </>
-          ),
-          hasNoOffset: false,
-          className: undefined,
-        }}
-        onExpand={() => setExpanded((prev) => !prev)}
-      >
-        {
-          <>
-            <AuthSessionLabel authSession={props.authSession} />
-            {(props.authSession.type === "git" ||
-              props.authSession.type === "openshift" ||
-              props.authSession.type === "kubernetes") && (
-              <>
-                &nbsp; &nbsp; &nbsp;
-                <Label>
-                  &nbsp;{props.usages ? (props.usages.length === 1 ? "1 usage" 
: `${props.usages.length} usages`) : "-"}
-                  &nbsp;
-                </Label>
-              </>
-            )}
-          </>
-        }
+            </Flex>
+          </FlexItem>
+          <FlexItem>
+            <Button variant={ButtonVariant.link} onClick={() => 
authSessionsDispatch.remove(props.authSession)}>
+              Remove
+            </Button>
+          </FlexItem>
+        </Flex>
       </CardHeader>
       <CardExpandableContent>
         <CardBody>
diff --git a/packages/online-editor/src/authSessions/ReAuthenticateHelper.tsx 
b/packages/online-editor/src/authSessions/ReAuthenticateHelper.tsx
new file mode 100644
index 00000000000..1e9fe064ecc
--- /dev/null
+++ b/packages/online-editor/src/authSessions/ReAuthenticateHelper.tsx
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as React from "react";
+import { useCallback } from "react";
+import { AccountsDispatchActionKind, useAccountsDispatch } from 
"../accounts/AccountsContext";
+import { AuthProviderType, isKubernetesAuthProvider } from 
"../authProviders/AuthProvidersApi";
+import { AuthSession, isCloudAuthSession, isGitAuthSession } from 
"./AuthSessionApi";
+import { useAuthProviders } from "../authProviders/AuthProvidersContext";
+import { Button, ButtonVariant } from 
"@patternfly/react-core/dist/js/components/Button";
+
+export function ReAuthenticateButton({ authSession }: { authSession: 
AuthSession }) {
+  const authProviders = useAuthProviders();
+  const accountsDispatch = useAccountsDispatch();
+
+  const handleReAuthenticate = useCallback(() => {
+    if (authSession.id === "none") {
+      console.warn("Unauthenticated session can't be reauthenticated.");
+      return;
+    }
+
+    const matchedProvider =
+      (isGitAuthSession(authSession) || isCloudAuthSession(authSession)) &&
+      authProviders.find((p) => p.id === authSession.authProviderId);
+
+    if (!matchedProvider) {
+      return;
+    }
+
+    switch (matchedProvider.type) {
+      case AuthProviderType.github:
+        accountsDispatch({
+          kind: AccountsDispatchActionKind.SETUP_GITHUB_AUTH,
+          selectedAuthProvider: matchedProvider,
+          selectedAuthSession: authSession,
+          backActionKind: AccountsDispatchActionKind.GO_HOME,
+        });
+        break;
+
+      case AuthProviderType.bitbucket:
+        accountsDispatch({
+          kind: AccountsDispatchActionKind.SETUP_BITBUCKET_AUTH,
+          selectedAuthProvider: matchedProvider,
+          selectedAuthSession: authSession,
+          backActionKind: AccountsDispatchActionKind.GO_HOME,
+        });
+        break;
+
+      case AuthProviderType.gitlab:
+        accountsDispatch({
+          kind: AccountsDispatchActionKind.SETUP_GITLAB_AUTH,
+          selectedAuthProvider: matchedProvider,
+          selectedAuthSession: authSession,
+          backActionKind: AccountsDispatchActionKind.GO_HOME,
+        });
+        break;
+
+      case AuthProviderType.openshift:
+        accountsDispatch({
+          kind: AccountsDispatchActionKind.SETUP_OPENSHIFT_AUTH,
+          selectedAuthProvider: matchedProvider,
+          selectedAuthSession: authSession,
+          backActionKind: AccountsDispatchActionKind.GO_HOME,
+        });
+        break;
+
+      case AuthProviderType.kubernetes:
+        accountsDispatch({
+          kind: AccountsDispatchActionKind.SETUP_KUBERNETES_AUTH,
+          selectedAuthProvider: matchedProvider,
+          selectedAuthSession: authSession,
+          backActionKind: AccountsDispatchActionKind.GO_HOME,
+        });
+        break;
+
+      default:
+        console.warn("Unsupported provider type for selected session");
+    }
+  }, [authSession, accountsDispatch, authProviders]);
+
+  return (
+    <Button variant={ButtonVariant.link} onClick={handleReAuthenticate}>
+      Re-authenticate
+    </Button>
+  );
+}
diff --git 
a/packages/online-editor/src/editor/Toolbar/GitIntegration/GitIntegrationContextProvider.tsx
 
b/packages/online-editor/src/editor/Toolbar/GitIntegration/GitIntegrationContextProvider.tsx
index ca4541e529a..d494e922880 100644
--- 
a/packages/online-editor/src/editor/Toolbar/GitIntegration/GitIntegrationContextProvider.tsx
+++ 
b/packages/online-editor/src/editor/Toolbar/GitIntegration/GitIntegrationContextProvider.tsx
@@ -30,7 +30,7 @@ import React, {
 import { useWorkspaces } from 
"@kie-tools-core/workspaces-git-fs/dist/context/WorkspacesContext";
 import { AuthSessionSelectFilter } from 
"../../../authSessions/AuthSessionSelect";
 import { ActiveWorkspace } from 
"@kie-tools-core/workspaces-git-fs/dist/model/ActiveWorkspace";
-import { useAuthSession } from "../../../authSessions/AuthSessionsContext";
+import { useAuthSession, useAuthSessions } from 
"../../../authSessions/AuthSessionsContext";
 import { useAuthProvider } from "../../../authProviders/AuthProvidersContext";
 import { useGitHubClient } from "../../../github/Hooks";
 import { useBitbucketClient } from "../../../bitbucket/Hooks";
@@ -56,6 +56,7 @@ import { useGitIntegrationAlerts } from 
"./GitIntegrationAlerts";
 import { AuthProviderGroup, isGistEnabledAuthProviderType } from 
"../../../authProviders/AuthProvidersApi";
 import { useEditorToolbarDispatchContext } from 
"../EditorToolbarContextProvider";
 import { useGitlabClient } from "../../../gitlab/useGitlabClient";
+import { AuthSession, AuthSessionStatus } from 
"../../../authSessions/AuthSessionApi";
 
 export type GitIntegrationContextType = {
   workspaceImportableUrl: ImportableUrl;
@@ -258,12 +259,29 @@ export function GitIntegrationContextProvider(props: 
GitIntegrationContextProvid
     () => props.workspace.files.filter((f) => f.relativePath !== 
f.name).length !== 0,
     [props.workspace]
   );
+  const { authSessionStatus } = useAuthSessions();
+  const isValidAuthSession = useCallback((): boolean => {
+    if (!authSession?.id) {
+      return false;
+    }
+    const status = authSessionStatus.get(authSession.id);
+    return status === AuthSessionStatus.VALID;
+  }, [authSession?.id, authSessionStatus]);
 
-  const canCreateGitHubRepository = useMemo(() => authProvider?.type === 
"github", [authProvider?.type]);
+  const canCreateGitHubRepository = useMemo(
+    () => authProvider?.type === "github" && isValidAuthSession(),
+    [authProvider?.type, isValidAuthSession]
+  );
 
-  const canCreateBitbucketRepository = useMemo(() => authProvider?.type === 
"bitbucket", [authProvider?.type]);
+  const canCreateBitbucketRepository = useMemo(
+    () => authProvider?.type === "bitbucket" && isValidAuthSession(),
+    [authProvider?.type, isValidAuthSession]
+  );
 
-  const canCreateGitlabRepository = useMemo(() => authProvider?.type === 
"gitlab", [authProvider?.type]);
+  const canCreateGitlabRepository = useMemo(
+    () => authProvider?.type === "gitlab" && isValidAuthSession(),
+    [authProvider?.type, isValidAuthSession]
+  );
 
   const canCreateGitRepository = useMemo(
     () => canCreateGitHubRepository || canCreateBitbucketRepository || 
canCreateGitlabRepository,
@@ -271,8 +289,8 @@ export function GitIntegrationContextProvider(props: 
GitIntegrationContextProvid
   );
 
   const canPushToGitRepository = useMemo(
-    () => authSession?.type === "git" && !!authProvider,
-    [authProvider, authSession?.type]
+    () => authSession?.type === "git" && !!authProvider && 
isValidAuthSession(),
+    [authProvider, authSession?.type, isValidAuthSession]
   );
 
   const isGitHubGistOwner = useMemo(() => {
@@ -295,9 +313,10 @@ export function GitIntegrationContextProvider(props: 
GitIntegrationContextProvid
         authProvider &&
           isGistEnabledAuthProviderType(authProvider?.type) &&
           props.workspace.descriptor.origin.kind === WorkspaceKind.LOCAL &&
-          !workspaceHasNestedDirectories
+          !workspaceHasNestedDirectories &&
+          isValidAuthSession()
       ),
-    [authProvider, props.workspace.descriptor.origin.kind, 
workspaceHasNestedDirectories]
+    [authProvider, isValidAuthSession, props.workspace.descriptor.origin.kind, 
workspaceHasNestedDirectories]
   );
 
   const canUpdateGistOrSnippet = useMemo(
@@ -308,9 +327,10 @@ export function GitIntegrationContextProvider(props: 
GitIntegrationContextProvid
           !!isGistOrSnippetOwner &&
           props.workspace &&
           isGistLikeWorkspaceKind(props.workspace.descriptor.origin.kind) &&
-          !workspaceHasNestedDirectories
+          !workspaceHasNestedDirectories &&
+          isValidAuthSession()
       ),
-    [authProvider, isGistOrSnippetOwner, props.workspace, 
workspaceHasNestedDirectories]
+    [authProvider, isGistOrSnippetOwner, isValidAuthSession, props.workspace, 
workspaceHasNestedDirectories]
   );
 
   const canForkGitHubGist = useMemo(
diff --git 
a/packages/online-editor/src/editor/Toolbar/GitIntegration/LoadOrganizationsSelect.tsx
 
b/packages/online-editor/src/editor/Toolbar/GitIntegration/LoadOrganizationsSelect.tsx
index 6212c4df66e..82d083bb621 100644
--- 
a/packages/online-editor/src/editor/Toolbar/GitIntegration/LoadOrganizationsSelect.tsx
+++ 
b/packages/online-editor/src/editor/Toolbar/GitIntegration/LoadOrganizationsSelect.tsx
@@ -68,10 +68,10 @@ const getSelectOptionValue = <K extends 
SelectOptionKindType>(
     selectedOption,
     kind,
     toString: () => {
-      return kind === "user" ? (selectedOption as string) : (selectedOption as 
Organization).name;
+      return kind === "user" ? (selectedOption as string) : (selectedOption as 
Organization)?.name;
     },
     compareTo: (selectOption: any) => {
-      const val = kind === "user" ? (selectedOption as string) : 
(selectedOption as Organization).name;
+      const val = kind === "user" ? (selectedOption as string) : 
(selectedOption as Organization)?.name;
       return val.toLowerCase() === selectOption.toString().toLowerCase();
     },
   };
diff --git 
a/packages/online-editor/src/editor/Toolbar/Share/GitDropdownGroup.tsx 
b/packages/online-editor/src/editor/Toolbar/Share/GitDropdownGroup.tsx
index 551dc28cb2b..cfe04c6698d 100644
--- a/packages/online-editor/src/editor/Toolbar/Share/GitDropdownGroup.tsx
+++ b/packages/online-editor/src/editor/Toolbar/Share/GitDropdownGroup.tsx
@@ -98,7 +98,7 @@ export const GitDropdownGroup = (props: Props) => {
         >
           {`Manage authentication sources for 
'${props.workspace.descriptor.name}' to be able to create Repository, GitHub 
Gist, Bitbucket Snippet or GitLab Snippet.`}
         </Alert>
-        {canCreateGitRepository && (
+        {authProvider && (
           <Tooltip
             data-testid={"create-git-repository-tooltip"}
             key={`dropdown-create-git-repository`}
@@ -129,7 +129,7 @@ export const GitDropdownGroup = (props: Props) => {
             </DropdownItem>
           </Tooltip>
         )}
-        {canCreateGistOrSnippet && (
+        {authProvider && (
           <Tooltip
             data-testid={"create-gist-or-snippet-tooltip"}
             key={`dropdown-create-gist-or-snippet`}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to