-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #164 from lsst-sqre/tickets/DM-43859
DM-43859: Include link to notebook on GitHub
- Loading branch information
Showing
10 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'squareone': minor | ||
--- | ||
|
||
Users can now download the Jupyter Notebook (ipynb) file that they are viewing, with the current parameters filled in. This enables further interactive exploration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'squareone': minor | ||
--- | ||
|
||
Times Square notebook pages show a link to the source notebook on GitHub. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
apps/squareone/src/components/TimesSquareGitHubPagePanel/GitHubEditLink.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import styled from 'styled-components'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
|
||
export default function GitHubEditLink({ owner, repository, sourcePath }) { | ||
if (!owner || !repository || !sourcePath) { | ||
return null; | ||
} | ||
|
||
const editUrl = `https://github.com/${owner}/${repository}/blob/main/${sourcePath}`; | ||
|
||
return ( | ||
<p> | ||
<a href={editUrl}> | ||
<StyledFontAwesomeIcon icon="fa-brands fa-github" /> | ||
{owner}/{repository} | ||
</a> | ||
</p> | ||
); | ||
} | ||
|
||
const StyledFontAwesomeIcon = styled(FontAwesomeIcon)` | ||
margin-right: 0.2em; | ||
font-size: 1em; | ||
color: ${(props) => props.color || 'inherit'}; | ||
`; |
31 changes: 31 additions & 0 deletions
31
apps/squareone/src/components/TimesSquareGitHubPagePanel/GitHubEditLink.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
|
||
import GitHubEditLink from './GitHubEditLink'; | ||
|
||
export default { | ||
component: GitHubEditLink, | ||
title: 'Components/TimesSquare/GitHubEditLink', | ||
parameters: { | ||
viewport: { | ||
viewports: { | ||
sidebar: { | ||
name: 'Sidebar', | ||
styles: { | ||
width: '280px', | ||
height: '900px', | ||
}, | ||
}, | ||
}, | ||
}, | ||
defaultViewport: 'sidebar', | ||
}, | ||
}; | ||
|
||
const Template = (args) => <GitHubEditLink {...args} />; | ||
|
||
export const Default = Template.bind({}); | ||
Default.args = { | ||
owner: 'lsst-sqre', | ||
repository: 'times-square-demo', | ||
sourcePath: 'demo.ipynb', | ||
}; |
25 changes: 25 additions & 0 deletions
25
apps/squareone/src/components/TimesSquareGitHubPagePanel/IpynbDownloadLink.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import styled from 'styled-components'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
|
||
export default function IpynbDownloadLink({ url, sourcePath }) { | ||
// get the filename from the sourcePath | ||
const filename = sourcePath.split('/').pop(); | ||
|
||
return ( | ||
<StyledP> | ||
<a href={url} title={filename} download={filename}> | ||
<StyledFontAwesomeIcon icon="download" /> Download notebook | ||
</a> | ||
</StyledP> | ||
); | ||
} | ||
|
||
const StyledP = styled.p` | ||
margin-top: 2rem; | ||
`; | ||
|
||
const StyledFontAwesomeIcon = styled(FontAwesomeIcon)` | ||
margin-right: 0.2em; | ||
font-size: 1em; | ||
color: ${(props) => props.color || 'inherit'}; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.