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 commands to open URL in new window, and to deploy App in new window #7

Closed
wants to merge 8 commits into from

Conversation

nenb
Copy link

@nenb nenb commented Sep 19, 2024

This PR adds a new command: deploy-app.

deploy-app

  • Opens the URL for the deploy-app page in a new browser tab. Also passes a query parameter for filepath that is generated from the current workspace in JLab.

Reference Issues or PRs

nebari-dev/jhub-apps#472

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 nenb/jupyterlab-nebari-mode/deploy-app-ext

style/base.css Outdated
@@ -17,3 +17,10 @@
outline-offset: -3px;
outline-style: auto;
}

.nebari-DeployAppIcon {
Copy link
Author

Choose a reason for hiding this comment

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

The CSS needs to be fixed - currently it only displays when I give fixed size (e.g. 16px).

@nenb nenb changed the title Added commands to open URL in new window, and to open deploy App in n… Add commands to open URL in new window, and to deploy App in new window Sep 19, 2024
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.

Great start! Do you plan to add the button to the toolbar and context menu in this PR or subsequent one?

src/index.ts Outdated
});
},
label: () => 'Deploy App',
iconClass: () => 'nebari-DeployAppIcon'
Copy link
Member

Choose a reason for hiding this comment

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

Ideally we would use proper icon (an instance of LabIcon) here - iconClass is de-facto deprecated. The less CSS rules the better for performance.

See
https://github.com/nebari-dev/jupyterlab-gallery/blob/ef56fc616bae4ec8305c01e3341b773ca4cfd48f/src/icons.ts#L5-L8 and https://github.com/nebari-dev/jupyterlab-gallery/blob/ef56fc616bae4ec8305c01e3341b773ca4cfd48f/src/svg.d.ts

src/index.ts Outdated
Comment on lines 225 to 239
app.commands.addCommand(CommandIDs.openURL, {
execute: async (args: IOpenURLArgs) => {
const { url } = resolveURLAndAlias(args);
try {
window.open(url, '_blank', 'noopener,noreferrer');
} catch (error) {
console.warn('Error opening URL:', url, error);
return;
}
},
label: (args: IOpenURLArgs = {}) => {
const { alias } = resolveURLAndAlias(args);
return `Open ${alias}`;
}
});
Copy link
Member

Choose a reason for hiding this comment

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

I would suggest removing the command for opening an arbitrary URL to reduce the API surface

@nenb
Copy link
Author

nenb commented Sep 19, 2024

@krassowski Quick follow-up:

Great start! Do you plan to add the button to the toolbar and context menu in this PR or subsequent one?

I was under the impression that these would be configured in the settings in jhub-apps/nebari, rather than adding them here.

What's the usual practice? That an extension includes these settings by default, and then a user (e.g. nebari deployment) can disable them if they require?

@krassowski
Copy link
Member

I was under the impression that these would be configured in the settings in jhub-apps/nebari, rather than adding them here.

I think its better to include them here in a single plugin rather than in nebari. This is because it will be much easier to test it if it is completely independent of nebari. jhub-apps currently has no JupyterLab extensions. We can later extract that plugin to make it live closer to jhub-apps.

@krassowski
Copy link
Member

That an extension includes these settings by default, and then a user (e.g. nebari deployment) can disable them if they require?

Yes, it is much easier to:

  • do proper visual testing here and ship a standalone plugin
  • flip "enabled" flag one per-plugin basis in nebari

than if we were to split the logic between the two.

@kcpevey
Copy link

kcpevey commented Sep 19, 2024

Just wanted to mention that we need to keep in mind that jhub-apps is an optional feature of Nebari and therefore the changes we introduce here should also be safe for when jhub-apps is not present. (Maybe this is already true, I dont know about the technical details here 😀)

"context": [
{
"command": "jhub-apps:deploy-app",
"selector": ".jp-DirListing-item",
Copy link
Author

Choose a reason for hiding this comment

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

Question: Does selector really need to be here (it seems so), and if so, what should I set it as?

Copy link
Member

Choose a reason for hiding this comment

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

Yes. I think that for now it only makes sense for files not for directories so the selector should reflect that.

src/index.ts Outdated
},
label: () => 'Deploy App',
icon: () => {
// Add logic to only display the icon if the command is not in the main menu
Copy link
Author

Choose a reason for hiding this comment

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

Is there a way to do this i.e. display the icon only except for the main menu (see the screenshots and compare them to the Figma diagrams)?

Copy link
Member

Choose a reason for hiding this comment

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

This method takes an argument that can be used to display this icon or not - I don't remember all attributes of top of my head but it should have something like isToolbar and the underlying event.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I've just added a new argument (origin) to the schema JSON that controls this, I couldn't figure out how to get something like isToolbar working.

@nenb
Copy link
Author

nenb commented Sep 19, 2024

Some screenshots of what it is currently looking like:

Context Menu
Screenshot 2024-09-19 at 18 36 39

Main Menu and Toolbar
Screenshot 2024-09-19 at 18 36 49

New Tab on Click
Screenshot 2024-09-19 at 18 37 02

@nenb nenb marked this pull request as ready for review September 19, 2024 21:48
@krassowski
Copy link
Member

Closing in favour of nebari-dev/jupyterlab-jhub-apps#1 that was just merged :) 🎉

@krassowski krassowski closed this Sep 30, 2024
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.

3 participants