diff --git a/src/components/InstallButton.js b/src/components/InstallButton.js index 009dd954a..3e190671f 100644 --- a/src/components/InstallButton.js +++ b/src/components/InstallButton.js @@ -6,22 +6,18 @@ import { getPackNr1Url, getGuidedInstallStackedNr1Url, } from '../utils/get-pack-nr1-url'; -import { - NR1_LOGIN_URL, - NR1_GUIDED_INSTALL_NERDLET, - NR1_PACK_DETAILS_NERDLET, -} from '../data/constants'; +import { NR1_LOGIN_URL } from '../data/constants'; import { quickstart } from '../types'; /** * @param {String} id + * @param {String} nerdletId * @returns {String} */ -const createInstallLink = (id, nerdletId) => { - const platformUrl = - nerdletId === NR1_GUIDED_INSTALL_NERDLET - ? getGuidedInstallStackedNr1Url(nerdletId) - : getPackNr1Url(id, nerdletId); +const createInstallLink = (id, hasGuidedInstall) => { + const platformUrl = hasGuidedInstall + ? getGuidedInstallStackedNr1Url() + : getPackNr1Url(id); const url = new URL( `?return_to=${encodeURIComponent(platformUrl)}`, NR1_LOGIN_URL @@ -50,15 +46,10 @@ const InstallButton = ({ quickstart, ...props }) => { 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, destinationNerdletId) + ? createInstallLink(quickstart.id, hasGuidedInstall) : quickstart.documentation[0].url; return ( diff --git a/src/data/constants.js b/src/data/constants.js index 03dcf41e7..ec7408b38 100644 --- a/src/data/constants.js +++ b/src/data/constants.js @@ -20,6 +20,8 @@ export const NR1_PACK_DETAILS_NERDLET = export const NR1_GUIDED_INSTALL_NERDLET = 'nr1-install-newrelic.nr1-install-newrelic'; +export const NR1_EXPLORER_NERDLET = 'nr1-core.listing'; + 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 cf77bfd4b..53a8b733b 100644 --- a/src/utils/get-pack-nr1-url.js +++ b/src/utils/get-pack-nr1-url.js @@ -1,16 +1,22 @@ +import { + NR1_PACK_DETAILS_NERDLET, + NR1_GUIDED_INSTALL_NERDLET, + NR1_EXPLORER_NERDLET, +} from '../data/constants'; + // FIXME: update this to production URL when deployed / launched const NR1_BASE_URL = 'https://staging-one.newrelic.com'; const NR1_BASE_URL_LOCAL = 'https://dev-one.newrelic.com'; const NERDLET_PATH = `launcher/nr1-core.explorer/`; /** - * @param {string} packId The ID for an observability pack. + * @param {string} quickstartId The ID for an observability pack. * @param {boolean} [debug] If set to true, this will add `packages=local`. * @returns {string} The URL for the pack details within the platform. */ -export const getPackNr1Url = (quickstartId, nerdletId, debug = false) => { +export const getPackNr1Url = (quickstartId, debug = false) => { const pane = JSON.stringify({ - nerdletId, + nerdletId: NR1_PACK_DETAILS_NERDLET, quickstartId, }); @@ -32,9 +38,13 @@ export const getPackNr1Url = (quickstartId, nerdletId, debug = false) => { return packDetailsUrl.href; }; -export const getGuidedInstallStackedNr1Url = (nerdletId, debug = false) => { - const pane = JSON.stringify({ nerdletId: 'nr1-core.listing' }); - const card = JSON.stringify({ nerdletId }); +/** + * @param {boolean} [debug] If set to true, this will add `packages=local`. + * @returns {string} The URL for the pack details within the platform. + */ +export const getGuidedInstallStackedNr1Url = (debug = false) => { + const pane = JSON.stringify({ nerdletId: NR1_EXPLORER_NERDLET }); + const card = JSON.stringify({ nerdletId: NR1_GUIDED_INSTALL_NERDLET }); const paneHash = window && window.btoa