@@ -13,6 +13,7 @@ import {
1313import { selectSignInUrl } from "domains/global/selectors"
1414import { useRequestRefreshOfAccessMessage } from "hooks/use-user-node-access"
1515import { selectIsCloudEnabled } from "domains/global/selectors"
16+ import { selectRegistry } from "domains/global/selectors"
1617
1718// const PROMO_SIGN_UP_CLOUD: PromoProps = { userStatus: "UNKNOWN", nodeClaimedStatus: "NOT_CLAIMED" } //CLOUD
1819// const PROMO_SIGN_IN_CLOUD: PromoProps = {
@@ -54,8 +55,12 @@ import { selectIsCloudEnabled } from "domains/global/selectors"
5455// } //CLOUD
5556
5657const MigrationManager = ( ) => {
57- const cloudUrl = useSelector ( state => selectSignInUrl ( "go-to-cloud-migration" ) ( state as any ) )
5858 const cloudEnabled = useSelector ( selectIsCloudEnabled )
59+ const registry = useSelector ( selectRegistry )
60+
61+ const cloudUrl = useSelector ( state =>
62+ selectSignInUrl ( { content : "agent-auto-redirect" , term : registry . machineGuid } ) ( state as any )
63+ )
5964
6065 const linkToCoud = useMemo ( ( ) => {
6166 const { href } = window . location
@@ -72,12 +77,21 @@ const MigrationManager = () => {
7277
7378 const prefrenceID = migrationModalPromoInfo ?. tickBoxOption . prefrenceID || ""
7479
75- const [ hasPromoSelectionSaved , savePromoRemindMeSelection ] = useLocalStorage ( prefrenceID )
80+ /**
81+ * There is seem to be a bug when we are using the useLocalStorage,
82+ * the value to be returned does not change when prefrenceID is changing.
83+ * For that reason we acces the localStorage directly
84+ */
85+ const [ , savePromoRemindMeSelection ] = useLocalStorage ( prefrenceID )
86+ const hasPromoSelectionSaved = localStorage . getItem ( prefrenceID )
7687
7788 const closeModal = ( ) => {
7889 setModalOpen ( false )
7990 }
8091
92+ const isPromoEligibleForShow =
93+ cloudEnabled && migrationModalPromoInfo && isModalOpen && ! hasPromoSelectionSaved
94+
8195 const requestRefreshOfAccess = useRequestRefreshOfAccessMessage ( )
8296
8397 /** We are delaying the show of modal because some time the userNodeAccess is equal to null
@@ -93,14 +107,24 @@ const MigrationManager = () => {
93107 } , [ ] )
94108
95109 useEffect ( ( ) => {
96- if ( goToCloud ( { userSavedPreference, ...userNodeAccess } ) ) window . location . href = linkToCoud
110+ if ( goToCloud ( { userSavedPreference, ...userNodeAccess } ) ) {
111+ window . location . href = linkToCoud
112+ }
97113 } , [ linkToCoud , userNodeAccess , userSavedPreference ] )
98114
99115 useEffect ( ( ) => {
100116 if ( goToAgentDashboard ( { userSavedPreference } ) ) console . log ( "Lets go to Agent" )
101117 } , [ userSavedPreference ] )
102118
103- if ( cloudEnabled && migrationModalPromoInfo && isModalOpen && ! hasPromoSelectionSaved )
119+ useEffect ( ( ) => {
120+ if ( isPromoEligibleForShow ) {
121+ document . documentElement . style . overflow = "hidden"
122+ } else {
123+ document . documentElement . style . overflow = "auto"
124+ }
125+ } , [ isModalOpen ] )
126+
127+ if ( isPromoEligibleForShow )
104128 return (
105129 < MigrationModal
106130 savePromoRemindMeSelection = { savePromoRemindMeSelection }
0 commit comments