diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c90d9d..83b1768 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,9 +7,6 @@ on: pull_request: types: [opened, synchronize, reopened] -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true jobs: build: @@ -29,7 +26,7 @@ jobs: uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 - name: Install dependencies - run: python -m pip install -U "jupyterlab>=4.0.0,<5" ebrains-drive pytest pytest-mock "pytest-jupyter[server]>=0.6.0" pytest_tornasync pytest-cov + run: python -m pip install -U "jupyterlab>=4.0.0,<5" ebrains-drive pytest pytest-mock "pytest-jupyter[server]>=0.6.0" pytest_tornasync build - name: Lint the extension run: | @@ -37,7 +34,7 @@ jobs: jlpm jlpm run lint:check - - name: Test the extension + - name: Test the extension with jlpm run: | set -eux jlpm run test @@ -47,13 +44,15 @@ jobs: set -eux python -m pip install .[test] - pytest -vv -r ap --cov --cov-report=xml tvb_ext_bucket - jupyter server extension list jupyter server extension list 2>&1 | grep -ie "tvb_ext_bucket.*OK" - - jupyter labextension list jupyter labextension list 2>&1 | grep -ie "tvb-ext-bucket.*OK" python -m jupyterlab.browser_check + + - name: Run Python & JS tests + run: | + set -eux + pytest tvb_ext_bucket -r ap + yarn test - name: Package the extension run: | @@ -63,12 +62,6 @@ jobs: python -m build pip uninstall -y "tvb-ext-bucket" jupyterlab - - name: SonarCloud Scan - uses: sonarsource/sonarcloud-github-action@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: Upload extension packages uses: actions/upload-artifact@v4 with: @@ -76,6 +69,31 @@ jobs: path: dist/tvb_ext_bucket* if-no-files-found: error + sonar_cloud: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Base Setup + uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1 + + - name: Install dependencies + run: python -m pip install -U "jupyterlab>=4.0.0,<5" ebrains-drive pytest pytest-mock "pytest-jupyter[server]>=0.6.0" pytest_tornasync pytest-cov + + - name: Compute coverage + run: | + python -m pip install .[test] + pytest -vv -r ap --cov --cov-report=xml tvb_ext_bucket + yarn test --coverage + + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + test_isolated: needs: build runs-on: ubuntu-latest @@ -99,10 +117,7 @@ jobs: pip install "jupyterlab>=4.0.0,<5" tvb_ext_bucket*.whl - jupyter server extension list jupyter server extension list 2>&1 | grep -ie "tvb_ext_bucket.*OK" - - jupyter labextension list jupyter labextension list 2>&1 | grep -ie "tvb-ext-bucket.*OK" python -m jupyterlab.browser_check --no-browser-test diff --git a/README.md b/README.md index ab55e5e..241ff18 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ pip install -e ".[test]" # Link your development version of the extension with JupyterLab jupyter labextension develop . --overwrite # Server extension must be manually installed in develop mode -jupyter server extension enable tvb_ext_bucket +jupyter server extension enable tvbextbucket # Rebuild extension Typescript source after making changes jlpm build ``` diff --git a/src/DropZone.tsx b/src/DropZone.tsx index f7f5b0e..d765836 100644 --- a/src/DropZone.tsx +++ b/src/DropZone.tsx @@ -5,7 +5,7 @@ import React, { useCallback, useMemo } from 'react'; -import { Drag, IDragEvent } from '@lumino/dragdrop'; // must use the deprecated interface +import { Drag } from '@lumino/dragdrop'; import { useBucketContext } from './BucketContext'; import { JpFileBrowser } from './JpFileBrowser'; import { MimeData } from '@lumino/coreutils'; @@ -62,10 +62,9 @@ export const DropZone: React.FC = ({ let isValidDragSource = false; let item = possibleTargets?.next(); - while (item) { - const currentItem = item.value; - items.push(currentItem); - if (currentItem.name === dragSourceElement?.innerText) { + while (item.value) { + items.push(item.value); + if (item.value.name === dragSourceElement?.innerText) { isValidDragSource = true; } item = possibleTargets?.next(); @@ -100,43 +99,43 @@ export const DropZone: React.FC = ({ console.log('handling: ', ev.type); switch (ev.type) { case 'lm-dragenter': - handler._dragEnter(ev as IDragEvent); + handler._dragEnter(ev as Drag.Event); break; case 'lm-dragover': - handler._dragOver(ev as IDragEvent); + handler._dragOver(ev as Drag.Event); break; case 'lm-drop': handler - ._drop(ev as IDragEvent) + ._drop(ev as Drag.Event) .then(() => console.log('drop handled')); break; case 'lm-dragleave': - handler._dragLeave(ev as IDragEvent); + handler._dragLeave(ev as Drag.Event); break; } }, - _dragEnter: (ev: IDragEvent): void => { + _dragEnter: (ev: Drag.Event): void => { ev.preventDefault(); ev.stopPropagation(); setMode('hover'); - Drag.overrideCursor('pointer'); }, - _dragOver: (ev: IDragEvent): void => { + _dragOver: (ev: Drag.Event): void => { ev.preventDefault(); ev.stopPropagation(); ev.dropAction = ev.proposedAction; // needed to trigger lm-drop - Drag.overrideCursor('pointer'); setMode('hover'); }, - _dragLeave: (ev: IDragEvent): void => { + _dragLeave: (ev: Drag.Event): void => { ev.preventDefault(); ev.stopPropagation(); - Drag.overrideCursor('auto'); setMode('default'); }, - _drop: async (ev: IDragEvent): Promise => { + _drop: async (ev: Drag.Event): Promise => { ev.preventDefault(); ev.stopPropagation(); + if (!ev.source) { + return; + } if (uploadingRef.current) { await showErrorMessage( notAllowedUpload.title, @@ -154,7 +153,6 @@ export const DropZone: React.FC = ({ ); } - Drag.overrideCursor('auto'); setMode('default'); setUploading(false); } diff --git a/src/index.ts b/src/index.ts index 9b14e2d..fa119f9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,10 @@ import { JupyterFrontEndPlugin } from '@jupyterlab/application'; -import { IFileBrowserFactory } from '@jupyterlab/filebrowser'; +import { + IFileBrowserFactory, + IDefaultFileBrowser +} from '@jupyterlab/filebrowser'; import { ICommandPalette, WidgetTracker } from '@jupyterlab/apputils'; @@ -27,7 +30,8 @@ const plugin: JupyterFrontEndPlugin = { ILayoutRestorer, IConsoleTracker, ILabShell, - IFileBrowserFactory + IFileBrowserFactory, + IDefaultFileBrowser ], activate: ( app: JupyterFrontEnd, @@ -35,12 +39,13 @@ const plugin: JupyterFrontEndPlugin = { restorer: ILayoutRestorer, consoleTracker: IConsoleTracker, labShell: ILabShell, - fileBrowserFactory: IFileBrowserFactory + fileBrowserFactory: IFileBrowserFactory, + defaultFileBrowser: IDefaultFileBrowser ) => { console.log('JupyterLab extension tvb-ext-bucket is activated!'); // set up the default file browser - JpFileBrowser.current = fileBrowserFactory.createFileBrowser('default'); + JpFileBrowser.current = defaultFileBrowser; const id = 'tvb-ext-bucket'; const sidebar = new BucketWidget(); diff --git a/yarn.lock b/yarn.lock index 90dc550..075e0bf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1984,19 +1984,6 @@ __metadata: languageName: node linkType: hard -"@jest/types@npm:^26.6.2": - version: 26.6.2 - resolution: "@jest/types@npm:26.6.2" - dependencies: - "@types/istanbul-lib-coverage": ^2.0.0 - "@types/istanbul-reports": ^3.0.0 - "@types/node": "*" - "@types/yargs": ^15.0.0 - chalk: ^4.0.0 - checksum: a0bd3d2f22f26ddb23f41fddf6e6a30bf4fab2ce79ec1cb6ce6fdfaf90a72e00f4c71da91ec61e13db3b10c41de22cf49d07c57ff2b59171d64b29f909c1d8d6 - languageName: node - linkType: hard - "@jest/types@npm:^29.6.3": version: 29.6.3 resolution: "@jest/types@npm:29.6.3" @@ -3517,15 +3504,6 @@ __metadata: languageName: node linkType: hard -"@types/yargs@npm:^15.0.0": - version: 15.0.19 - resolution: "@types/yargs@npm:15.0.19" - dependencies: - "@types/yargs-parser": "*" - checksum: 6a509db36304825674f4f00300323dce2b4d850e75819c3db87e9e9f213ac2c4c6ed3247a3e4eed6e8e45b3f191b133a356d3391dd694d9ea27a0507d914ef4c - languageName: node - linkType: hard - "@types/yargs@npm:^17.0.8": version: 17.0.33 resolution: "@types/yargs@npm:17.0.33" @@ -4347,7 +4325,7 @@ __metadata: languageName: node linkType: hard -"bs-logger@npm:0.x": +"bs-logger@npm:0.x, bs-logger@npm:^0.2.6": version: 0.2.6 resolution: "bs-logger@npm:0.2.6" dependencies: @@ -4365,7 +4343,7 @@ __metadata: languageName: node linkType: hard -"buffer-from@npm:1.x, buffer-from@npm:^1.0.0": +"buffer-from@npm:^1.0.0": version: 1.1.2 resolution: "buffer-from@npm:1.1.2" checksum: 0448524a562b37d4d7ed9efd91685a5b77a50672c556ea254ac9a6d30e3403a517d8981f10e565db24e8339413b43c97ca2951f10e399c6125a0d8911f5679bb @@ -4487,13 +4465,6 @@ __metadata: languageName: node linkType: hard -"ci-info@npm:^2.0.0": - version: 2.0.0 - resolution: "ci-info@npm:2.0.0" - checksum: 3b374666a85ea3ca43fa49aa3a048d21c9b475c96eb13c133505d2324e7ae5efd6a454f41efe46a152269e9b6a00c9edbe63ec7fa1921957165aae16625acd67 - languageName: node - linkType: hard - "ci-info@npm:^3.2.0": version: 3.9.0 resolution: "ci-info@npm:3.9.0" @@ -6450,17 +6421,6 @@ __metadata: languageName: node linkType: hard -"is-ci@npm:^2.0.0": - version: 2.0.0 - resolution: "is-ci@npm:2.0.0" - dependencies: - ci-info: ^2.0.0 - bin: - is-ci: bin.js - checksum: 77b869057510f3efa439bbb36e9be429d53b3f51abd4776eeea79ab3b221337fe1753d1e50058a9e2c650d38246108beffb15ccfd443929d77748d8c0cc90144 - languageName: node - linkType: hard - "is-core-module@npm:^2.13.0, is-core-module@npm:^2.5.0": version: 2.15.0 resolution: "is-core-module@npm:2.15.0" @@ -7202,20 +7162,6 @@ __metadata: languageName: node linkType: hard -"jest-util@npm:^26.1.0": - version: 26.6.2 - resolution: "jest-util@npm:26.6.2" - dependencies: - "@jest/types": ^26.6.2 - "@types/node": "*" - chalk: ^4.0.0 - graceful-fs: ^4.2.4 - is-ci: ^2.0.0 - micromatch: ^4.0.2 - checksum: 3c6a5fba05c4c6892cd3a9f66196ea8867087b77a5aa1a3f6cd349c785c3f1ca24abfd454664983aed1a165cab7846688e44fe8630652d666ba326b08625bc3d - languageName: node - linkType: hard - "jest-util@npm:^29.0.0, jest-util@npm:^29.7.0": version: 29.7.0 resolution: "jest-util@npm:29.7.0" @@ -7458,7 +7404,7 @@ __metadata: languageName: node linkType: hard -"json5@npm:2.x, json5@npm:^2.1.2, json5@npm:^2.2.3": +"json5@npm:^2.1.2, json5@npm:^2.2.3": version: 2.2.3 resolution: "json5@npm:2.2.3" bin: @@ -7636,7 +7582,7 @@ __metadata: languageName: node linkType: hard -"lodash.memoize@npm:4.x": +"lodash.memoize@npm:4.x, lodash.memoize@npm:^4.1.2": version: 4.1.2 resolution: "lodash.memoize@npm:4.1.2" checksum: 9ff3942feeccffa4f1fafa88d32f0d24fdc62fd15ded5a74a5f950ff5f0c6f61916157246744c620173dddf38d37095a92327d5fd3861e2063e736a5c207d089 @@ -7664,7 +7610,7 @@ __metadata: languageName: node linkType: hard -"lodash@npm:4.x, lodash@npm:^4.17.20, lodash@npm:^4.17.21, lodash@npm:^4.17.4, lodash@npm:^4.7.0": +"lodash@npm:^4.17.20, lodash@npm:^4.17.21, lodash@npm:^4.17.4, lodash@npm:^4.7.0": version: 4.17.21 resolution: "lodash@npm:4.17.21" checksum: eb835a2e51d381e561e508ce932ea50a8e5a68f4ebdd771ea240d3048244a8d13658acbd502cd4829768c56f2e16bdd4340b9ea141297d472517b83868e677f7 @@ -7725,7 +7671,7 @@ __metadata: languageName: node linkType: hard -"make-error@npm:1.x": +"make-error@npm:1.x, make-error@npm:^1.3.6": version: 1.3.6 resolution: "make-error@npm:1.3.6" checksum: b86e5e0e25f7f777b77fabd8e2cbf15737972869d852a22b7e73c17623928fccb826d8e46b9951501d3f20e51ad74ba8c59ed584f610526a48f8ccf88aaec402 @@ -7839,7 +7785,7 @@ __metadata: languageName: node linkType: hard -"micromatch@npm:^4.0.2, micromatch@npm:^4.0.4, micromatch@npm:^4.0.5": +"micromatch@npm:^4.0.4, micromatch@npm:^4.0.5": version: 4.0.7 resolution: "micromatch@npm:4.0.7" dependencies: @@ -8038,7 +7984,7 @@ __metadata: languageName: node linkType: hard -"mkdirp@npm:1.x, mkdirp@npm:^1.0.3, mkdirp@npm:^1.0.4": +"mkdirp@npm:^1.0.3, mkdirp@npm:^1.0.4": version: 1.0.4 resolution: "mkdirp@npm:1.0.4" bin: @@ -9135,21 +9081,21 @@ __metadata: languageName: node linkType: hard -"semver@npm:7.x, semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.5.3, semver@npm:^7.5.4": - version: 7.6.3 - resolution: "semver@npm:7.6.3" +"semver@npm:^6.3.0, semver@npm:^6.3.1": + version: 6.3.1 + resolution: "semver@npm:6.3.1" bin: semver: bin/semver.js - checksum: 4110ec5d015c9438f322257b1c51fe30276e5f766a3f64c09edd1d7ea7118ecbc3f379f3b69032bacf13116dc7abc4ad8ce0d7e2bd642e26b0d271b56b61a7d8 + checksum: ae47d06de28836adb9d3e25f22a92943477371292d9b665fb023fae278d345d508ca1958232af086d85e0155aee22e313e100971898bbb8d5d89b8b1d4054ca2 languageName: node linkType: hard -"semver@npm:^6.3.0, semver@npm:^6.3.1": - version: 6.3.1 - resolution: "semver@npm:6.3.1" +"semver@npm:^7.3.4, semver@npm:^7.3.5, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.3": + version: 7.6.3 + resolution: "semver@npm:7.6.3" bin: semver: bin/semver.js - checksum: ae47d06de28836adb9d3e25f22a92943477371292d9b665fb023fae278d345d508ca1958232af086d85e0155aee22e313e100971898bbb8d5d89b8b1d4054ca2 + checksum: 4110ec5d015c9438f322257b1c51fe30276e5f766a3f64c09edd1d7ea7118ecbc3f379f3b69032bacf13116dc7abc4ad8ce0d7e2bd642e26b0d271b56b61a7d8 languageName: node linkType: hard @@ -9948,26 +9894,40 @@ __metadata: languageName: node linkType: hard -"ts-jest@npm:^26.0.0": - version: 26.5.6 - resolution: "ts-jest@npm:26.5.6" +"ts-jest@npm:^29.0.0": + version: 29.2.5 + resolution: "ts-jest@npm:29.2.5" dependencies: - bs-logger: 0.x - buffer-from: 1.x - fast-json-stable-stringify: 2.x - jest-util: ^26.1.0 - json5: 2.x - lodash: 4.x - make-error: 1.x - mkdirp: 1.x - semver: 7.x - yargs-parser: 20.x + bs-logger: ^0.2.6 + ejs: ^3.1.10 + fast-json-stable-stringify: ^2.1.0 + jest-util: ^29.0.0 + json5: ^2.2.3 + lodash.memoize: ^4.1.2 + make-error: ^1.3.6 + semver: ^7.6.3 + yargs-parser: ^21.1.1 peerDependencies: - jest: ">=26 <27" - typescript: ">=3.8 <5.0" + "@babel/core": ">=7.0.0-beta.0 <8" + "@jest/transform": ^29.0.0 + "@jest/types": ^29.0.0 + babel-jest: ^29.0.0 + jest: ^29.0.0 + typescript: ">=4.3 <6" + peerDependenciesMeta: + "@babel/core": + optional: true + "@jest/transform": + optional: true + "@jest/types": + optional: true + babel-jest: + optional: true + esbuild: + optional: true bin: ts-jest: cli.js - checksum: 6f65ad4fe67ab3f0fd4c7f9954acbee863af05b2b3f88dd0f490bbcdc58002960fac908b2cb9f009ec14da6fe13cb00a39e291260d6e555abe72448d1c0a017f + checksum: d60d1e1d80936f6002b1bb27f7e062408bc733141b9d666565503f023c340a3196d506c836a4316c5793af81a5f910ab49bb9c13f66e2dc66de4e0f03851dbca languageName: node linkType: hard @@ -10061,7 +10021,7 @@ __metadata: stylelint-config-standard: ^34.0.0 stylelint-csstree-validator: ^3.0.0 stylelint-prettier: ^4.0.0 - ts-jest: ^26.0.0 + ts-jest: ^29.0.0 typescript: ~5.0.2 webpack: ^5.0.0 yjs: ^13.5.40 @@ -10830,7 +10790,7 @@ __metadata: languageName: node linkType: hard -"yargs-parser@npm:20.x, yargs-parser@npm:^20.2.9": +"yargs-parser@npm:^20.2.9": version: 20.2.9 resolution: "yargs-parser@npm:20.2.9" checksum: 8bb69015f2b0ff9e17b2c8e6bfe224ab463dd00ca211eece72a4cd8a906224d2703fb8a326d36fdd0e68701e201b2a60ed7cf81ce0fd9b3799f9fe7745977ae3