Skip to content

Commit

Permalink
feat: add button with link to pack directory
Browse files Browse the repository at this point in the history
* now on each pack page, there is a button with a link to the pack
directory in the page section.
* added github images copied from opensource repo.
  • Loading branch information
moonlight-komorebi committed Jul 7, 2021
1 parent d7cccef commit b2385c2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/images/github/icon-github-dark-green.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/images/github/icon-github-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 43 additions & 1 deletion src/templates/ObservabilityPackDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import {
PageTools,
useTessen,
useInstrumentedHandler,
Button,
} from '@newrelic/gatsby-theme-newrelic';
import ImageGallery from '../components/ImageGallery';
import Intro from '../components/Intro';
import InstallButton from '../components/InstallButton';
import ImageSlider from '../components/ImageSlider';
import iconGitHubWhite from '../images/github/icon-github-white.svg';

const ObservabilityPackDetails = ({ data, location }) => {
const pack = data.observabilityPacks;
Expand All @@ -32,6 +34,23 @@ const ObservabilityPackDetails = ({ data, location }) => {
packId: pack.id,
}
);

const getPackUrl = () => {
const baseUrl =
'https://github.com/newrelic/newrelic-observability-packs/tree/main/packs';

if (!pack.logoUrl) {
return baseUrl;
}

/**
* logoUrl looks something like: 'https://raw.githubusercontent.com/newrelic/newrelic-observability-packs/v0.8.2/packs/couchbase/logo.svg'
*/
const [packName, ..._] = pack.logoUrl.split('/').slice(-2);

return `${baseUrl}/${packName}`;
};

return (
<>
<DevSiteSeo title={pack.name} location={location} />
Expand All @@ -45,7 +64,7 @@ const ObservabilityPackDetails = ({ data, location }) => {
`}
>
<InstallButton
title={`Install Pack`}
title="Install Pack"
guid={pack.id}
onClick={handleInstallClick}
/>
Expand Down Expand Up @@ -230,6 +249,28 @@ const ObservabilityPackDetails = ({ data, location }) => {
}
`}
>
<PageTools.Section>
<div>
<Button
as="a"
variant={Button.VARIANT.PRIMARY}
href={getPackUrl()}
rel="noopener noreferrer"
css={css`
margin-top: 0.5rem;
`}
>
<img
css={css`
margin-right: 0.5rem;
`}
src={iconGitHubWhite}
alt="GitHub logo"
/>
View Repo
</Button>
</div>
</PageTools.Section>
<PageTools.Section>
<PageTools.Title>How to use this pack</PageTools.Title>
<ol>
Expand Down Expand Up @@ -271,6 +312,7 @@ export const pageQuery = graphql`
level
id
description
logoUrl
dashboards {
description
name
Expand Down

0 comments on commit b2385c2

Please sign in to comment.