From d74c7fd69f850e79e8067e8323e454baba72fdbd Mon Sep 17 00:00:00 2001 From: Kris Kenney <70179215+nr-kkenney@users.noreply.github.com> Date: Fri, 5 Nov 2021 12:24:16 -0700 Subject: [PATCH] fix: fix for install button having signup as link too often * when a user visits a quickstart page directly, or reloads a page, the install button links to signup, despite ajs_user_id existing. With this change, we force the page to re-render to have the correct url -- if they have the cookie set. --- src/components/InstallButton.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/components/InstallButton.js b/src/components/InstallButton.js index 423ba0556..938a23c2a 100644 --- a/src/components/InstallButton.js +++ b/src/components/InstallButton.js @@ -103,11 +103,6 @@ const InstallButton = ({ quickstart, location, ...props }) => { quickstart.installPlans.length === 1 && quickstart.installPlans[0].id.includes('guided-install'); - // If there is nothing to install AND no documentation, don't show this button. - if (!hasInstallableComponent && !hasComponent(quickstart, 'documentation')) { - return null; - } - let nerdletId = hasGuidedInstall ? NR1_GUIDED_INSTALL_NERDLET : NR1_PACK_DETAILS_NERDLET; @@ -129,6 +124,18 @@ const InstallButton = ({ quickstart, location, ...props }) => { ) : quickstart.documentation[0].url; + const [installUrl, setInstallUrl] = useState(SIGNUP_LINK); + useEffect(() => { + setInstallUrl(url); + + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + // If there is nothing to install AND no documentation, don't show this button. + if (!hasInstallableComponent && !hasComponent(quickstart, 'documentation')) { + return null; + } + const writeCookie = () => { const currentEnvironment = process.env.ENV || process.env.NODE_ENV || 'development'; @@ -156,7 +163,7 @@ const InstallButton = ({ quickstart, location, ...props }) => {