Skip to content

Commit

Permalink
fix: fix for install button having signup as link too often
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
moonlight-komorebi committed Nov 5, 2021
1 parent 11ecd21 commit d74c7fd
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/components/InstallButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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';
Expand Down Expand Up @@ -156,7 +163,7 @@ const InstallButton = ({ quickstart, location, ...props }) => {
<Button
{...props}
as={Link}
to={url}
to={installUrl}
onClick={handleInstallClick}
variant={Button.VARIANT.PRIMARY}
>
Expand Down

0 comments on commit d74c7fd

Please sign in to comment.