Skip to content

Commit e3c656f

Browse files
committed
chore: refactor
1 parent 3c69c1d commit e3c656f

File tree

9 files changed

+87
-26
lines changed

9 files changed

+87
-26
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Fix License Headers
2+
3+
on:
4+
pull_request_target:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
header-license-fix:
12+
runs-on: ubuntu-latest
13+
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
with:
22+
token: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Checkout the branch from the PR that triggered the job
25+
run: gh pr checkout ${{ github.event.pull_request.number }}
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Fix License Header
30+
# pin to include https://github.com/apache/skywalking-eyes/pull/168
31+
uses: apache/skywalking-eyes/header@e19b828cea6a6027cceae78f05d81317347d21be
32+
with:
33+
mode: fix
34+
35+
- name: List files changed
36+
id: files-changed
37+
shell: bash -l {0}
38+
run: |
39+
set -ex
40+
export CHANGES=$(git status --porcelain | tee /tmp/modified.log | wc -l)
41+
cat /tmp/modified.log
42+
43+
echo "N_CHANGES=${CHANGES}" >> $GITHUB_OUTPUT
44+
45+
git diff
46+
47+
- name: Commit any changes
48+
if: steps.files-changed.outputs.N_CHANGES != '0'
49+
shell: bash -l {0}
50+
run: |
51+
git config user.name "github-actions[bot]"
52+
git config user.email "github-actions[bot]@users.noreply.github.com"
53+
54+
git pull --no-tags
55+
56+
git add *
57+
git commit -m "Automatic application of license header"
58+
59+
git config push.default upstream
60+
git push
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

src/Viewer.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { useNavigate } from "react-router-dom";
33
import { ThemeProvider, BaseStyles, Box, UnderlineNav, Pagehead, Heading, Link } from '@primer/react';
44
import { JupyterLabAppAdapter } from '@datalayer/jupyter-react';
55
import { DatalayerGreenIcon } from '@datalayer/icons-react';
6-
import { ViewerFormTab } from './tabs/ViewerFormTab';
7-
import { ViewerExamplesTab } from './tabs/ViewerExamplesTab';
8-
import { AboutTab } from './tabs/AboutTab';
6+
import { ViewerForm, ViewerExamples, ViewerAbout } from './views';
97
import { requestAPI } from './jupyterlab/handler';
108

119
export type JupyterViewerProps = {
@@ -58,9 +56,9 @@ const JupyterViewer = (props: JupyterViewerProps) => {
5856
</UnderlineNav>
5957
</Box>
6058
<Box m={3}>
61-
{tab === 1 && <ViewerFormTab />}
62-
{tab === 2 && <ViewerExamplesTab />}
63-
{tab === 3 && <AboutTab version={version} />}
59+
{tab === 1 && <ViewerForm />}
60+
{tab === 2 && <ViewerExamples />}
61+
{tab === 3 && <ViewerAbout version={version} />}
6462
</Box>
6563
</Box>
6664
</BaseStyles>

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export * from "./tabs";
21
export * from "./views";
32
export * from "./Viewer";
43
export * from "./ViewerRoutes";

src/tabs/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/tabs/AboutTab.tsx renamed to src/views/ViewerAbout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ type Props = {
66
version: string;
77
}
88

9-
export const AboutTab = (props: Props): JSX.Element => {
9+
export const ViewerAbout = (props: Props): JSX.Element => {
1010
const { version } = props;
1111
const [egg, setEgg] = useState(false);
1212
return (
1313
<>
14-
<Pagehead as="h2">🪐 👀 Jupyter Viewer<Label sx={{marginLeft: 1}}>{version}</Label></Pagehead>
14+
<Pagehead as="h2">🪐 👀 Jupyter Viewer{ version && <Label sx={{marginLeft: 1}}>{version}</Label>}</Pagehead>
1515
<Box>
1616
<Text>A revisited NbViewer as a modern Web application to view Jupyter notebooks.</Text>
1717
</Box>
@@ -30,4 +30,4 @@ export const AboutTab = (props: Props): JSX.Element => {
3030
);
3131
}
3232

33-
export default AboutTab;
33+
export default ViewerAbout;
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import { useState } from 'react';
22
import { Box, ActionMenu, ActionList } from '@primer/react';
33
import { NetworkIcon, JupyterBaseIcon, JupiterIcon, ScientistIcon } from '@datalayer/icons-react';
4-
import { Jupyter } from '@datalayer/jupyter-react/lib/jupyter/Jupyter';
5-
import { Viewer } from '@datalayer/jupyter-react/lib/components/viewer/Viewer';
4+
import { JupyterReactTheme, Viewer } from '@datalayer/jupyter-react';
65
import { visualisations, astronomies, dataSciences, MenuLine, NotebookExample } from './notebooks/Examples';
76

8-
export const ViewerExamplesTab = () => {
7+
export const ViewerExamples = () => {
98
const [notebookExample, setNotebookExample] = useState<NotebookExample>(visualisations[0]);
109
return (
1110
<>
1211
<Box m={3}>
13-
<Jupyter startDefaultKernel={false}>
12+
<JupyterReactTheme>
1413
<ActionMenu>
1514
<ActionMenu.Button leadingVisual={() => <JupyterBaseIcon colored/>}>
1615
Notebooks
@@ -22,30 +21,33 @@ export const ViewerExamplesTab = () => {
2221
</ActionList.GroupHeading>
2322
<ActionList.Group>
2423
{visualisations.map(visualisation =>
25-
<MenuLine notebookExample={visualisation} icon={<NetworkIcon colored/>} setNotebookExample={setNotebookExample} />)}
24+
<MenuLine notebookExample={visualisation} icon={<NetworkIcon colored/>} setNotebookExample={setNotebookExample} />)
25+
}
2626
</ActionList.Group>
2727
<ActionList.GroupHeading>
2828
Data Science
2929
</ActionList.GroupHeading>
3030
<ActionList.Group>
3131
{dataSciences.map(dataScience =>
32-
<MenuLine notebookExample={dataScience} icon={<ScientistIcon colored/>} setNotebookExample={setNotebookExample} />)}
32+
<MenuLine notebookExample={dataScience} icon={<ScientistIcon colored/>} setNotebookExample={setNotebookExample} />)
33+
}
3334
</ActionList.Group>
3435
<ActionList.GroupHeading>
3536
Astronomy
3637
</ActionList.GroupHeading>
3738
<ActionList.Group>
3839
{astronomies.map(astronomy =>
39-
<MenuLine notebookExample={astronomy} icon={<JupiterIcon colored/>} setNotebookExample={setNotebookExample} />)}
40+
<MenuLine notebookExample={astronomy} icon={<JupiterIcon colored/>} setNotebookExample={setNotebookExample} />)
41+
}
4042
</ActionList.Group>
4143
</ActionList>
4244
</ActionMenu.Overlay>
4345
</ActionMenu>
4446
<Viewer nbformatUrl={notebookExample.url} outputs={false} />
45-
</Jupyter>
47+
</JupyterReactTheme>
4648
</Box>
4749
</>
4850
)
4951
}
5052

51-
export default ViewerExamplesTab;
53+
export default ViewerExamples;

src/tabs/ViewerFormTab.tsx renamed to src/views/ViewerForm.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { INotebookContent } from '@jupyterlab/nbformat';
44
import { Box, Button, FormControl, TextInput, Spinner, ButtonGroup, Text, Link, Label } from '@primer/react';
55
import { Card } from '@datalayer/primer-addons';
66
// import { ThreeBarsIcon } from '@primer/octicons-react';
7-
import { EyesIcon, FourLeafCloverIcon, JupyterIcon } from '@datalayer/icons-react';
7+
import { FourLeafCloverIcon, JupyterIcon } from '@datalayer/icons-react';
88
import { Jupyter } from '@datalayer/jupyter-react/lib/jupyter/Jupyter';
99
import { Viewer } from '@datalayer/jupyter-react/lib/components/viewer/Viewer';
1010
import Masonry from 'react-layout-masonry';
@@ -46,7 +46,7 @@ const cards: CardContent[] = [
4646
},
4747
]
4848

49-
export const ViewerFormTab = () => {
49+
export const ViewerForm = () => {
5050
const navigate = useNavigate();
5151
const [input, setInput] = useState('');
5252
const [loading, setLoading] = useState(false);
@@ -115,7 +115,7 @@ export const ViewerFormTab = () => {
115115
</FormControl>
116116
</Box>
117117
<Box sx={{display: 'flex', justifyContent: 'center'}}>
118-
<Button leadingVisual={EyesIcon} sx={{margin: 1}} onClick={e => setNotebook({ title: '', url: input })} variant="primary">
118+
<Button sx={{margin: 1}} onClick={e => setNotebook({ title: '', url: input })} variant="default">
119119
Go!
120120
</Button>
121121
<Button leadingVisual={FourLeafCloverIcon} sx={{margin: 1}} onClick={e => setNotebook(randomNotebook())} variant="default">
@@ -176,4 +176,4 @@ export const ViewerFormTab = () => {
176176
)
177177
}
178178

179-
export default ViewerFormTab;
179+
export default ViewerForm;

src/views/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
export * from "./ViewerGitHub";
2+
export * from "./ViewerAbout";
3+
export * from "./ViewerExamples";
4+
export * from "./ViewerForm";
File renamed without changes.

0 commit comments

Comments
 (0)