Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Updated redirection to cloud in the same window. (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
novykh authored May 4, 2022
1 parent 025d426 commit e6a4db7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const CloudConnectionStatusModal = ({
const handleClickedCTA1 = useCallback(
({ link }: { link: string }) => {
closeModal()
window.open(link, "_blank")
window.location.href = link
},
[closeModal]
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/sidebar/spaces/userSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SignIn from "components/auth/signIn"
const SignInItem = () => {
const onClick = (e, link) => {
e.stopPropagation()
window.open(link, "_blank", "noopener,noreferrer")
window.location.href = link
}
return (
<SignIn utmParameters={{ content: "userSettings" }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ const MigrationManager = () => {
...userNodeAccess,
})

const prefrenceID = migrationModalPromoInfo?.tickBoxOption.prefrenceID || ""
const preferenceID = migrationModalPromoInfo?.tickBoxOption.preferenceID || ""

/**
* There is seem to be a bug when we are using the useLocalStorage,
* the value to be returned does not change when prefrenceID is changing.
* the value to be returned does not change when preferenceID is changing.
* For that reason we acces the localStorage directly
*/
const [, savePromoRemindMeSelection] = useLocalStorage(prefrenceID)
const hasPromoSelectionSaved = localStorage.getItem(prefrenceID)
const [, savePromoRemindMeSelection] = useLocalStorage(preferenceID)
const hasPromoSelectionSaved = localStorage.getItem(preferenceID)

const closeModal = () => {
setModalOpen(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const MigrationModal = ({
setUserPrefrence(CTA1.userPreference)
savePromoRemindMeSelection(isRememberChoiceChecked)
}
if (toPath !== "agent") window.open(link, "_blank")
if (toPath !== "agent") window.location.href = link
closeModal()
} else if (CTA1.action === "REFRESH") {
requestRefreshOfAccess()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type MigrationModalContent = {
bullets?: Array<string | ((props?: any) => React.ReactNode)>
footer?: ((props: any) => React.ReactNode) | string
}
tickBoxOption: { text: string; prefrenceID: MigrationModalPromos }
tickBoxOption: { text: string; preferenceID: MigrationModalPromos }
CTA1: MigrationModalActions
CTA2?: MigrationModalActions
}
Expand Down Expand Up @@ -72,7 +72,7 @@ export const migrationmodalInfo: MigrationModalInfo = {
},
tickBoxOption: {
text: "Remember my choice",
prefrenceID: MigrationModalPromos.PROMO_SIGN_UP_CLOUD,
preferenceID: MigrationModalPromos.PROMO_SIGN_UP_CLOUD,
},
CTA1: {
text: "Wow! Let’s go to Netdata Cloud",
Expand Down Expand Up @@ -112,7 +112,7 @@ export const migrationmodalInfo: MigrationModalInfo = {
},
tickBoxOption: {
text: "Remember my choice",
prefrenceID: MigrationModalPromos.PROMO_SIGN_IN_CLOUD,
preferenceID: MigrationModalPromos.PROMO_SIGN_IN_CLOUD,
},
CTA1: {
text: "Sign-in or get a Netdata Cloud account",
Expand Down Expand Up @@ -140,7 +140,7 @@ export const migrationmodalInfo: MigrationModalInfo = {
},
tickBoxOption: {
text: "Don't remind me of this again",
prefrenceID: MigrationModalPromos.PROMO_IVNITED_TO_SPACE,
preferenceID: MigrationModalPromos.PROMO_IVNITED_TO_SPACE,
},
CTA1: {
text: "Thanks, stay at Agent dashboard for now",
Expand Down Expand Up @@ -198,7 +198,7 @@ export const migrationmodalInfo: MigrationModalInfo = {
},
tickBoxOption: {
text: "Remember my choice.",
prefrenceID: MigrationModalPromos.PROMO_CLAIM_NODE,
preferenceID: MigrationModalPromos.PROMO_CLAIM_NODE,
},
CTA1: {
text: "Wow! Let’s go to Netdata Cloud",
Expand Down Expand Up @@ -226,7 +226,7 @@ export const migrationmodalInfo: MigrationModalInfo = {
},
tickBoxOption: {
text: "Remember my choice",
prefrenceID: MigrationModalPromos.PROMO_TO_USE_NEW_DASHBAORD,
preferenceID: MigrationModalPromos.PROMO_TO_USE_NEW_DASHBAORD,
},
CTA1: {
text: "Wow! Let’s go to Netdata Cloud ",
Expand Down Expand Up @@ -273,7 +273,7 @@ export const migrationmodalInfo: MigrationModalInfo = {
},
tickBoxOption: {
text: "Don't show this again",
prefrenceID: MigrationModalPromos.FALLBACK_TO_AGENT,
preferenceID: MigrationModalPromos.FALLBACK_TO_AGENT,
},
CTA1: {
text: "Check again please",
Expand Down Expand Up @@ -308,7 +308,7 @@ export const migrationmodalInfo: MigrationModalInfo = {
},
tickBoxOption: {
text: "Don't show this again",
prefrenceID: MigrationModalPromos.NO_INFO_FALLBACK_TO_AGENT,
preferenceID: MigrationModalPromos.NO_INFO_FALLBACK_TO_AGENT,
},
CTA1: {
text: "Check again please",
Expand Down Expand Up @@ -417,25 +417,28 @@ export const goToCloud = ({
nodeLiveness === "LIVE" &&
userNodeAccess === "ACCESS_OK"

const modalStatusWithPromoFunctions: Record<MigrationModalPromos, (props: PromoProps) => boolean> =
{
[MigrationModalPromos.FALLBACK_TO_AGENT]: isFallbackToAgent,
[MigrationModalPromos.NO_INFO_FALLBACK_TO_AGENT]: isNoInfoFallbackToAgent,
[MigrationModalPromos.PROMO_TO_USE_NEW_DASHBAORD]: isPromoToNewDasboardOnCloud,
[MigrationModalPromos.PROMO_CLAIM_NODE]: isPromoToClaimThisNode,
[MigrationModalPromos.PROMO_IVNITED_TO_SPACE]: isPromoInvitedToSpace,
[MigrationModalPromos.PROMO_SIGN_IN_CLOUD]: isPromoSignIn,
[MigrationModalPromos.PROMO_SIGN_UP_CLOUD]: isPromoSignUp,
}
const modalStatusWithPromoFunctions: Record<
MigrationModalPromos,
(props: PromoProps) => boolean
> = {
[MigrationModalPromos.FALLBACK_TO_AGENT]: isFallbackToAgent,
[MigrationModalPromos.NO_INFO_FALLBACK_TO_AGENT]: isNoInfoFallbackToAgent,
[MigrationModalPromos.PROMO_TO_USE_NEW_DASHBAORD]: isPromoToNewDasboardOnCloud,
[MigrationModalPromos.PROMO_CLAIM_NODE]: isPromoToClaimThisNode,
[MigrationModalPromos.PROMO_IVNITED_TO_SPACE]: isPromoInvitedToSpace,
[MigrationModalPromos.PROMO_SIGN_IN_CLOUD]: isPromoSignIn,
[MigrationModalPromos.PROMO_SIGN_UP_CLOUD]: isPromoSignUp,
}

const useMigrationModal = ({
userStatus,
nodeClaimedStatus,
userNodeAccess,
nodeLiveness,
}: PromoProps) => {
const [userSavedPreference, setUserPrefrence] =
useLocalStorage<UserPreference>("USER_SAVED_PREFERENCE")
const [userSavedPreference, setUserPrefrence] = useLocalStorage<UserPreference>(
"USER_SAVED_PREFERENCE"
)

const migrationModalPromo = useMemo<MigrationModalPromos>(() => {
return Object.keys(modalStatusWithPromoFunctions).find(modalStatus => {
Expand Down

0 comments on commit e6a4db7

Please sign in to comment.