From 749b9d0680c817e78697ccad4f0893b054867abc Mon Sep 17 00:00:00 2001 From: mbazhlekova Date: Mon, 20 Sep 2021 13:43:43 -0500 Subject: [PATCH] chore: send user to guided install nerdlet --- src/components/InstallButton.js | 21 +++++++++++++++++---- src/data/constants.js | 3 +++ src/utils/get-pack-nr1-url.js | 10 +++------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/components/InstallButton.js b/src/components/InstallButton.js index 55b1a5aee..8040a8589 100644 --- a/src/components/InstallButton.js +++ b/src/components/InstallButton.js @@ -3,15 +3,19 @@ import PropTypes from 'prop-types'; import { css } from '@emotion/react'; import { Button, Link, Icon } from '@newrelic/gatsby-theme-newrelic'; import getPackNr1Url from '../utils/get-pack-nr1-url'; -import { NR1_LOGIN_URL } from '../data/constants'; +import { + NR1_LOGIN_URL, + NR1_GUIDED_INSTALL_NERDLET, + NR1_PACK_DETAILS_NERDLET, +} from '../data/constants'; import { quickstart } from '../types'; /** * @param {String} id * @returns {String} */ -const createInstallLink = (id) => { - const platformUrl = getPackNr1Url(id); +const createInstallLink = (id, nerdletId) => { + const platformUrl = getPackNr1Url(id, nerdletId); const url = new URL( `?return_to=${encodeURIComponent(platformUrl)}`, NR1_LOGIN_URL @@ -31,15 +35,24 @@ const hasComponent = (quickstart, key) => const InstallButton = ({ quickstart, ...props }) => { const hasInstallableComponent = hasComponent(quickstart, 'installPlans'); + const hasGuidedInstall = + hasInstallableComponent && + 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; } + const destinationNerdletId = hasGuidedInstall + ? NR1_GUIDED_INSTALL_NERDLET + : NR1_PACK_DETAILS_NERDLET; + // If we have an install-able component, generate a URL. Otherwise, link to the // first documentation supplied. const url = hasInstallableComponent - ? createInstallLink(quickstart.id) + ? createInstallLink(quickstart.id, destinationNerdletId) : quickstart.documentation[0].url; return ( diff --git a/src/data/constants.js b/src/data/constants.js index 0637044b5..c8a77aeef 100644 --- a/src/data/constants.js +++ b/src/data/constants.js @@ -22,6 +22,9 @@ export const NR1_BASE_URL_LOCAL = 'https://dev-one.newrelic.com'; export const NR1_PACK_DETAILS_NERDLET = 'catalog-pack-details.catalog-pack-contents'; +export const NR1_GUIDED_INSTALL_NERDLET = + 'nr1-install-newrelic.nr1-install-newrelic'; + export const QUICKSTART_SUPPORT_LEVELS = { NEWRELIC: 'NEWRELIC', VERIFIED: 'VERIFIED', diff --git a/src/utils/get-pack-nr1-url.js b/src/utils/get-pack-nr1-url.js index fcc9b983a..8d056dfaa 100644 --- a/src/utils/get-pack-nr1-url.js +++ b/src/utils/get-pack-nr1-url.js @@ -1,8 +1,4 @@ -import { - NR1_BASE_URL, - NR1_BASE_URL_LOCAL, - NR1_PACK_DETAILS_NERDLET, -} from '../data/constants'; +import { NR1_BASE_URL, NR1_BASE_URL_LOCAL } from '../data/constants'; const NERDLET_PATH = `launcher/nr1-core.explorer/`; @@ -11,9 +7,9 @@ const NERDLET_PATH = `launcher/nr1-core.explorer/`; * @param {boolean} [debug] If set to true, this will add `packages=local`. * @returns {string} The URL for the pack details within the platform. */ -const getPackNr1Url = (quickstartId, debug = false) => { +const getPackNr1Url = (quickstartId, nerdletId, debug = false) => { const pane = JSON.stringify({ - nerdletId: NR1_PACK_DETAILS_NERDLET, + nerdletId, quickstartId, });