Skip to content

Commit

Permalink
Merge pull request #84 from lsst-sqre/tickets/DM-35816
Browse files Browse the repository at this point in the history
DM-35816: Add page for viewing PR-preview pages
  • Loading branch information
jonathansick authored Aug 19, 2022
2 parents 8935f68 + 5dc31ff commit 8bcefd6
Show file tree
Hide file tree
Showing 17 changed files with 682 additions and 44 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Change log
##########

0.8.0
=====

- New pages for Times Square to preview pages in GitHub pull requests at ``/times-square/github-pr/:owner/:repo:/:commit`` paths.
- Initial integration with Storybook for designing and documenting components within Squareone.

0.7.1 (2022-06-26)
==================

Expand Down
252 changes: 252 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "squareone",
"version": "0.7.0",
"version": "0.8.0",
"private": true,
"scripts": {
"dev": "next dev -p 3000",
Expand Down
2 changes: 1 addition & 1 deletion src/components/TimesSquareGitHubNav/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function Page({ title, path, current }) {
return (
<Wrapper current={current}>
<StyledFontAwesomeIcon icon="file" />
<Link href={`/times-square/github/${path}`}>{title}</Link>
<Link href={path}>{title}</Link>
</Wrapper>
);
}
Expand Down
50 changes: 15 additions & 35 deletions src/components/TimesSquareGitHubNav/TimesSquareGitHubNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
*/

import styled from 'styled-components';
import getConfig from 'next/config';

import Directory from './Directory';
import Page from './Page';
import useGitHubContentsListing from './useGitHubContentsListing';

function generateChildren(contents, currentPath, props) {
function generateChildren(contents, currentPath, pathRoot, { ...props }) {
return contents.map((item) => {
if (item.node_type != 'page') {
return (
Expand All @@ -21,14 +19,14 @@ function generateChildren(contents, currentPath, props) {
key={item.path}
current={currentPath ? currentPath.startsWith(item.path) : false}
>
{generateChildren(item.contents, currentPath, { ...props })}
{generateChildren(item.contents, currentPath, pathRoot, { ...props })}
</Directory>
);
} else {
return (
<Page
title={item.title}
path={item.path}
path={`${pathRoot}/${item.path}`}
key={item.path}
current={currentPath ? currentPath.startsWith(item.path) : false}
/>
Expand All @@ -37,28 +35,18 @@ function generateChildren(contents, currentPath, props) {
});
}

export default function TimesSquareGitHubNav({ pagePath }) {
const { publicRuntimeConfig } = getConfig();
const { timesSquareUrl } = publicRuntimeConfig;
const githubContents = useGitHubContentsListing(timesSquareUrl);

const children = generateChildren(githubContents.contents, pagePath, {});

if (githubContents) {
return (
<NavWrapper>
<SectionTitle>Rubin’s boards</SectionTitle>
<ContentsWrapper>{children}</ContentsWrapper>
</NavWrapper>
);
} else {
return (
<NavWrapper>
<SectionTitle>Rubin’s boards</SectionTitle>
<p>Loading...</p>
</NavWrapper>
);
}
export default function TimesSquareGitHubNav({
pagePath,
contentNodes,
pagePathRoot,
}) {
const children = generateChildren(contentNodes, pagePath, pagePathRoot, {});

return (
<NavWrapper>
<ContentsWrapper>{children}</ContentsWrapper>
</NavWrapper>
);
}

// FIXME these mostly come from Comeau's example
Expand All @@ -72,11 +60,3 @@ const ContentsWrapper = styled.div`
`;

const NavWrapper = styled.nav``;

const SectionTitle = styled.p`
font-size: 1rem;
margin-bottom: 1rem;
font-weight: bold;
text-transform: uppercase;
color: var(--rsd-component-text-headline-color);
`;
Loading

0 comments on commit 8bcefd6

Please sign in to comment.