Skip to content

Commit

Permalink
Merge pull request #2 from huntdatacenter/dev
Browse files Browse the repository at this point in the history
add support for dark mode and setup CI
  • Loading branch information
matuskosut authored Mar 22, 2023
2 parents 07d2bf2 + 683944c commit 09e416c
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 31 deletions.
36 changes: 17 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,44 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: '12.x'
node-version: '16'
- name: Install Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.7'
architecture: 'x64'


python-version: '3.10'
# architecture: 'x64'

- name: Setup pip cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-3.7-${{ hashFiles('package.json') }}
key: ${{ runner.os }}-pip-3.10-${{ hashFiles('package.json') }}
restore-keys: |
pip-3.7-
pip-
${{ runner.os }}-pip-3.10-
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Setup yarn cache
uses: actions/cache@v2
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: yarn-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
yarn-
${{ runner.os }}-yarn-
- name: Install dependencies
run: python -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.7.9
run: python3 -m pip install -U jupyterlab~=3.0 jupyter_packaging~=0.7.9
- name: Build the extension
run: |
jlpm
jlpm run eslint:check
python -m pip install .
python3 -m pip install .
jupyter labextension list 2>&1 | grep -ie "jupyterlab-logout.*OK"
python -m jupyterlab.browser_check
python3 -m jupyterlab.browser_check
61 changes: 61 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build

on:
push:
branches-ignore:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
# architecture: 'x64'

- name: Setup pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-3.10-${{ hashFiles('package.json') }}
restore-keys: |
${{ runner.os }}-pip-3.10-
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Setup yarn cache
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install test dependencies
run: python3 -m pip install -U build jupyterlab~=3.0 jupyter_packaging~=0.7.9
- name: Test the extension
run: |
jlpm
jlpm run eslint:check
python3 -m pip install .
jupyter labextension list 2>&1 | grep -ie "jupyterlab-logout.*OK"
python3 -m jupyterlab.browser_check
- name: Build extension package
run: |
python3 -m build --sdist --wheel --outdir dist/ .
- name: Upload package artifact
uses: actions/upload-artifact@v3
with:
name: hcc-topbar-buttons
path: dist/hcc_topbar_buttons-0.5.0-py3-none-any.whl
62 changes: 62 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Publish package

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name }}
- name: Install node
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
# architecture: 'x64'

- name: Setup pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-3.10-${{ hashFiles('package.json') }}
restore-keys: |
${{ runner.os }}-pip-3.10-
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Setup yarn cache
uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install test dependencies
run: python3 -m pip install -U build jupyterlab~=3.0 jupyter_packaging~=0.7.9
- name: Test the extension
run: |
jlpm
jlpm run eslint:check
python3 -m pip install .
jupyter labextension list 2>&1 | grep -ie "jupyterlab-logout.*OK"
python3 -m jupyterlab.browser_check
- name: Build extension package
run: |
python3 -m build --sdist --wheel --outdir dist/ .
- name: Publish extension package
# if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"singleQuote": true,
"printWidth": 120,
"trailingComma": "none",
"arrowParens": "avoid"
}
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# jupyterlab-logout
# Workbench custom buttons

[![Extension status](https://img.shields.io/badge/status-ready-success "ready to be used")](https://jupyterlab-contrib.github.io/)
![Github Actions Status](https://github.com/jupyterlab-contrib/jupyterlab-logout/workflows/Build/badge.svg)
Expand All @@ -19,6 +19,28 @@ pip install jupyterlab-logout

## Contributing

### Setup dev environment

```bash
mamba create -n jlpm -c conda-forge --yes "python=3.10" "nodejs=14" "jupyterlab=3" "jupyterlab-topbar>=0.6.0" "jupyter" "notebook" "yarn"

mamba activate jlpm

jlpm install
```

Run lint checks after editing code:

```bash
jlpm run eslint:check
```

### Install from dev branch

```bash
python3 -m pip install "git+https://github.com/huntdatacenter/jupyterlab-logout.git@dev"
```

### Development install

Note: You will need NodeJS to build the extension package.
Expand Down
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
("share/jupyter/labextensions/%s" % labext_name, str(HERE), "install.json"),
]

cmdclass = create_cmdclass("jsdeps",
cmdclass = create_cmdclass(
"jsdeps",
package_data_spec=package_data_spec,
data_files_spec=data_files_spec
)
Expand All @@ -58,11 +59,11 @@
pkg_json = json.loads((HERE / "package.json").read_bytes())

setup_args = dict(
name=name,
name="hcc-topbar-buttons",
version=pkg_json["version"],
url=pkg_json["homepage"],
author=pkg_json["author"]["name"],
#author_email=pkg_json["author"]["email"],
# author_email=pkg_json["author"]["email"],
description=pkg_json["description"],
license=pkg_json["license"],
long_description=long_description,
Expand All @@ -86,6 +87,8 @@
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Framework :: Jupyter",
],
)
Expand Down
48 changes: 40 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
JupyterFrontEnd,
JupyterFrontEndPlugin,
IRouter
} from '@jupyterlab/application';
import { JupyterFrontEnd, JupyterFrontEndPlugin, IRouter } from '@jupyterlab/application';

import { Widget } from '@lumino/widgets';

Expand All @@ -17,15 +13,51 @@ const extension: JupyterFrontEndPlugin<void> = {
autoStart: true,
requires: [IRouter, ITopBar],
activate: async (app: JupyterFrontEnd, router: IRouter, topBar: ITopBar) => {
const logout = document.createElement('a');
const docs = document.createElement('button');
docs.id = 'hunt-cloud-documentation';
docs.innerHTML = 'Documentation';
// docs.setAttribute('style', 'padding: 0px 5px;');
docs.addEventListener('click', () => {
window.open('https://docs.hdc.ntnu.no/', '_blank');
});

const docsWidget = new Widget({ node: docs });
docsWidget.addClass('bp3-button');
docsWidget.addClass('bp3-minimal');
docsWidget.addClass('minimal');
docsWidget.addClass('jp-Button');
docsWidget.addClass('jp-ToolbarButtonComponent');
topBar.addItem('docs-button', docsWidget);

const hub = document.createElement('button');
hub.id = 'control-panel';
hub.innerHTML = 'Control Panel';
hub.addEventListener('click', () => {
window.open('/hub/home', '_blank');
});

const hubWidget = new Widget({ node: hub });
hubWidget.addClass('bp3-button');
hubWidget.addClass('bp3-minimal');
hubWidget.addClass('minimal');
hubWidget.addClass('jp-Button');
hubWidget.addClass('jp-ToolbarButtonComponent');
topBar.addItem('hub-button', hubWidget);

const logout = document.createElement('button');
logout.id = 'logout';
logout.innerHTML = 'Log Out';
logout.type = 'button';
logout.innerHTML = '<span class="bp3-button-text"><i aria-hidden="true" class="fa fa-sign-out"></i> Logout</span>';
logout.addEventListener('click', () => {
router.navigate('/logout', { hard: true });
});

const widget = new Widget({ node: logout });
widget.addClass('jp-Button-flat');
widget.addClass('bp3-button');
widget.addClass('bp3-minimal');
widget.addClass('minimal');
widget.addClass('jp-Button');
widget.addClass('jp-ToolbarButtonComponent');
topBar.addItem('logout-button', widget);
}
};
Expand Down

0 comments on commit 09e416c

Please sign in to comment.