Skip to content

Commit

Permalink
chore: clean up documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mbazhlekova committed Sep 21, 2021
1 parent 1b776d4 commit 2a04d89
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 22 deletions.
23 changes: 7 additions & 16 deletions src/components/InstallButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 (
Expand Down
2 changes: 2 additions & 0 deletions src/data/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
22 changes: 16 additions & 6 deletions src/utils/get-pack-nr1-url.js
Original file line number Diff line number Diff line change
@@ -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,
});

Expand All @@ -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
Expand Down

0 comments on commit 2a04d89

Please sign in to comment.