jupyter / nbgrader

A system for assigning and grading notebooks
https://nbgrader.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.3k stars 317 forks source link

Eliminate compatibility issues in supporting notebook and jupyterlab #1902

Closed shreve closed 3 months ago

shreve commented 4 months ago

Formgrader could be loaded in one of two different contexts: on its own from a notebook, or inside an iframe a lab. When navigating to a page outside the formgrader application, this presents an issue in that these two contexts need different navigation mechanisms.

Previously, the mechanism was decided by looking at the name of the jupyter-server application. If it was jupyter-notebook (notebook<7), use href. Otherwise, use postMessage. However, it's possible to use the notebook interface without jupyter-notebook, e.g. jupyter-server.

Now the mechanism is decided by context clues inside the browser, i.e. whether formgrader is inside an iframe.

This commit adds a linkTo function which is applied to jQuery elements via .map and applies either href or postMessage nav mechanisms based on whether the current window is the top window.

Additionally, it completely removes the is_lab and is_jlab checks as they were relatively naive and add complexity that doesn't need to be there.

Fixes #1888

github-actions[bot] commented 4 months ago

Binder :point_left: Launch a Binder on branch _shreve/nbgrader/remove-isjlab

shreve commented 4 months ago

The two "Check Release" failures and the "Make SDist" failure are related to Automattic/node-canvas. I think this might need a yarn.lock bump, but I'm not sure how safe that is.

The test_nbgrader(docs) failure is a timeout because checking GitHub links in the changelog keeps getting rate limited and eventually times out. It seems like it might be worth adding a filter which auto-approves links that start with github.com/search.

brichet commented 3 months ago

@meeseeksdev backport to main

lumberbot-app[bot] commented 3 months ago

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout main
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:

    git cherry-pick -x -m1 c7828a5110bd34b9409f252d3563e1f7781d6826
  2. You will likely have some merge/cherry-pick conflict here, fix them and commit:

git commit -am 'Backport PR #1902: Eliminate compatibility issues in supporting notebook and jupyterlab'
  1. Push to a named branch:
git push YOURFORK main:auto-backport-of-pr-1902-on-main
  1. Create a PR against branch main, I would have named this PR:

"Backport PR #1902 on branch main (Eliminate compatibility issues in supporting notebook and jupyterlab)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.