Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add main area widget (form in headless mode) with state restoration #12

Merged
merged 13 commits into from
Oct 24, 2024

Conversation

nenb
Copy link
Collaborator

@nenb nenb commented Oct 18, 2024

Reference Issues or PRs

#4 and #6

What does this implement/fix?

Put a x in the boxes that apply

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds a feature)
  • Breaking change (fix or feature that would cause existing features not to work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • Other (please describe):

Testing

  • Did you test the pull request locally?
  • Did you add new tests?

Documentation

Access-centered content checklist

Text styling

  • The content is written with plain language (where relevant).
  • If there are headers, they use the proper header tags (with only one level-one header: H1 or # in markdown).
  • All links describe where they link to (for example, check the Nebari website).
  • This content adheres to the Nebari style guides.

Non-text content

  • All content is represented as text (for example, images need alt text, and videos need captions or descriptive transcripts).
  • If there are emojis, there are not more than three in a row.
  • Don't use flashing GIFs or videos.
  • If the content were to be read as plain text, it still makes sense, and no information is missing.

Any other comments?

Copy link
Contributor

Binder 👈 Launch a Binder on branch nebari-dev/jupyterlab-jhub-apps/headless-mode-v2

src/index.ts Outdated
? currentWidget.context.path
: '';

const selectedFilepath =
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a filepath field is passed in the queryParameters initially, then this takes precedence. This is important information for restoring the tab later.

src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@nenb nenb force-pushed the headless-mode-v2 branch from d7fe955 to ed7923f Compare October 21, 2024 12:39
"label": "Deploy App"
}
]
},
"title": "jupyterlab-jhub-apps",
"description": "jupyterlab-jhub-apps custom command settings.",
"type": "object",
"properties": {},
"properties": {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved to properties as I was unable to find another way to update the settings values at runtime. This is useful for situations like testing, where I want to test different settings values. I took this approach from https://github.com/jupyterlab/extension-examples/tree/main/settings.

I also noticed that if a user updates their settings, then the application will not notice this. I have now used properties and settings.changed.connect below to handle this.

src/index.ts Outdated
* These are read from the settings registry and updated any
* time a user changes their settings.
*/
const runtimeSettings = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are now global state. They are read from the settings registry at initialization. Then they are updated via settings.changed.connect whenever a user updates their settings.

};
}

function applySettings(setting: ISettingRegistry.ISettings): void {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the callback used by settings.changed.connect. It closes over the global state runtimeSettings and updates these values.

) => {
const { commands, shell } = app;

try {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 205 - 211 are the new code that try to deal with when a user updates their settings.

@nenb nenb marked this pull request as ready for review October 22, 2024 20:34
@nenb nenb mentioned this pull request Oct 22, 2024
18 tasks
@nenb
Copy link
Collaborator Author

nenb commented Oct 23, 2024

bot please update snapshots

@krassowski
Copy link
Member

Reopening to trigger the CI run after bot update

@krassowski krassowski closed this Oct 24, 2024
@krassowski krassowski reopened this Oct 24, 2024
@krassowski
Copy link
Member

Let's close the file browser (IMO preferred as we don't want changes in file browser upstream to affect our CI) or mask the date column, as it will show different time since last modification on snapshots depending on runner speed:

Actual Expected
multiple-tabs-actual multiple-tabs-expected

I think:

await page.sidebar.close();

should do it.

@krassowski
Copy link
Member

Or maybe even better, let's not close it but take screenshot of only the relevant area (again to reduce maintenance cost as we would need to update and review snapshots if anything changes in UI upstream).

@nenb
Copy link
Collaborator Author

nenb commented Oct 24, 2024

bot please update snapshots

@krassowski krassowski closed this Oct 24, 2024
@krassowski krassowski reopened this Oct 24, 2024
@nenb
Copy link
Collaborator Author

nenb commented Oct 24, 2024

@krassowski I'm not sure what the current CI release error is related to: fatal: couldn't find remote ref refs/pull/12/merge.

Could it be related to the closing/re-opening of the PR? Or is it something I need to fix?

@krassowski
Copy link
Member

Could it be related to the closing/re-opening of the PR?

Yes, it is, no need to worry about it. I mean I will have to worry about it at some point 🫠

Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @nenb, let's give it a try!

@krassowski krassowski changed the title Headless mode v2 Add main area widget (form in headless mode) with state restoration Oct 24, 2024
@krassowski krassowski merged commit cbf5c22 into main Oct 24, 2024
5 of 6 checks passed
@krassowski krassowski deleted the headless-mode-v2 branch October 24, 2024 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants