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

Update node properties to allow changing file #867

Merged
merged 9 commits into from
Aug 18, 2020

Conversation

vabarbosa
Copy link
Contributor

@vabarbosa vabarbosa commented Aug 17, 2020

This PR adds support for changing the file associated with a node in the Pipeline Editor.

Fixes #732

To achieve this a new BrowseFileDialog was added into @elyra/ui-components. The BrowseFileDialog displays a file browser in a dialog window which resolves to the selected files when accepted.

It is worth noting JupyterLab already contains a FileDialog in @jupyterlab/filebrowser. However, this does not allow flexibility and customization easily, hence the reason for creating the new BrowseFileDialog. Unlike the FileDialog, the BrowseFileDialog can be configured to allow for disabling/preventing multiselect and also allow for selecting directories (if needed). The FileDialog does includes the New Folder, Upload, and Refresh buttons (that appear in the default FileBrowser) but not options to opt out of displaying those buttons.

elyra-browse-file

Developer's Certificate of Origin 1.1

   By making a contribution to this project, I certify that:

   (a) The contribution was created in whole or in part by me and I
       have the right to submit it under the Apache License 2.0; or

   (b) The contribution is based upon previous work that, to the best
       of my knowledge, is covered under an appropriate open source
       license and I have the right under that license to submit that
       work with modifications, whether created in whole or in part
       by me, under the same open source license (unless I am
       permitted to submit under a different license), as indicated
       in the file; or

   (c) The contribution was provided directly to me by some other
       person who certified (a), (b) or (c) and I have not modified
       it.

   (d) I understand and agree that this project and the contribution
       are public and that a record of the contribution (including all
       personal information I submit with it, including my sign-off) is
       maintained indefinitely and may be redistributed consistent with
       this project or the open source license(s) involved.

Added a file browser dialog and added support for changing file from the properties dialog

Fixes elyra-ai#732
@kevin-bates
Copy link
Member

@vabarbosa - this looks great! Just curious if the same could be done for the File Dependencies section (where the start point is the location of the notebook file)? If so, then that would eliminate folks typing in names/paths to existing files. I'd be happy to open the issue if that's something we want to do.

@vabarbosa
Copy link
Contributor Author

@vabarbosa - this looks great! Just curious if the same could be done for the File Dependencies section (where the start point is the location of the notebook file)? If so, then that would eliminate folks typing in names/paths to existing files. I'd be happy to open the issue if that's something we want to do.

@kevin-bates you read my mind, i was thinking the same thing as was going to bring it up for discussion during the scrum to see if it is something would like to have included

@lresende
Copy link
Member

This looks awesome!!!

@marthacryan
Copy link
Member

marthacryan commented Aug 17, 2020

This is so cool!! Just one style thing - for some reason this is showing up a little misaligned for me (in chrome)
image
I didn't investigate a ton but it looks like it's being split in half between the filename and the button - any ideas?
image
And in safari it's the same:
image

@vabarbosa
Copy link
Contributor Author

vabarbosa commented Aug 17, 2020

This is so cool!! Just one style thing - for some reason this is showing up a little misaligned for me (in chrome)
I didn't investigate a ton but it looks like it's being split in half between the filename and the button - any ideas?
And in safari it's the same:

@marthacryan i've updated the button position so it is consistent across the browsers. the 50/50 split comes canvas. i am using the columnPanel provided by canvas to display/group multiple items in the same row:

https://github.com/elyra-ai/canvas/wiki/3.3-Common-Properties-Controls#grouppanel-controls

@marthacryan
Copy link
Member

Just tried your new changes and style is working as expected! One (very) small thing - definitely doesn't need to be part of this PR, but it'd be great if you could select a file in that browser by double-clicking. Not sure how easy that'd be to add, just a note.

Copy link
Member

@marthacryan marthacryan left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@marthacryan marthacryan left a comment

Choose a reason for hiding this comment

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

Sorry - just noticed that there's a console error that should probably be fixed before merging:
image

@vabarbosa
Copy link
Contributor Author

@marthacryan i used a different panel layout and worked around the 50/50 split. yes, i noticed the console errors when switching to chrome. looking into it now. and will look into enabling double-click to select also. thanks

@vabarbosa
Copy link
Contributor Author

Sorry - just noticed that there's a console error that should probably be fixed before merging:

@marthacryan i believe the error is coming from the carbon components modal (used by common canvas to display the properties dialog). more specifically, carbon components modal does not support stacked modals:

carbon-design-system/carbon#5947
carbon-design-system/carbon#582

in any case, i was able to figure out a workaround the issue and the error should no longer be thrown.

@vabarbosa
Copy link
Contributor Author

Just tried your new changes and style is working as expected! One (very) small thing - definitely doesn't need to be part of this PR, but it'd be great if you could select a file in that browser by double-clicking. Not sure how easy that'd be to add, just a note.

@marthacryan, you should now be able to select a file by double-clicking

@vabarbosa vabarbosa requested a review from marthacryan August 17, 2020 21:02
@marthacryan
Copy link
Member

marthacryan commented Aug 17, 2020

@vabarbosa Thanks for addressing those! Tried with new changes locally and LGTM

Copy link
Member

@lresende lresende left a comment

Choose a reason for hiding this comment

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

Tested locally with chrome, LGTM.

@vabarbosa vabarbosa requested a review from kevin-bates August 17, 2020 22:43
Copy link
Member

@ajbozarth ajbozarth left a comment

Choose a reason for hiding this comment

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

still need to test locally and review the BrowseFileDialog file, but wanted to get these early comments in

packages/pipeline-editor/src/PipelineEditorWidget.tsx Outdated Show resolved Hide resolved
packages/pipeline-editor/src/PipelineEditorWidget.tsx Outdated Show resolved Hide resolved
@@ -456,6 +464,13 @@ export class PipelineEditor extends React.Component<
}
const app_data = node.app_data;

if (app_data.filename !== propertySet.filename) {
app_data.filename = propertySet.filename;
Copy link
Member

Choose a reason for hiding this comment

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

As a note: this line will need to be updated to work with #861 is merged (in whichever PR is merged last)

packages/pipeline-editor/src/utils.ts Outdated Show resolved Hide resolved
Copy link
Member

@ajbozarth ajbozarth left a comment

Choose a reason for hiding this comment

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

One clarifying question, otherwise I've checked this out and run it locally and it works great. Once my previous review is addressed I'll approve

const propertyId = { name: data.parameter_ref };
showBrowseFileDialog(this.browserFactory.defaultBrowser.model.manager, {
filter: (model: any): boolean => {
return model.type == 'notebook';
Copy link
Member

Choose a reason for hiding this comment

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

Is the intension here that we would update this when we add support for other file types?

Copy link
Contributor Author

@vabarbosa vabarbosa Aug 17, 2020

Choose a reason for hiding this comment

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

yes, the filter is so you only show files that should be selectable. in this case, we only want to show notebook files (no point in showing all available files if user shouldn't be selecting them). and yeah, if the dialog is to be re-used in other context then you can configure what files do appear. for example, with File Dependencies (#873) browser dialog would show files other than just notebook files

@vabarbosa vabarbosa requested a review from ajbozarth August 17, 2020 23:08
Comment on lines +467 to +468
if (app_data.filename !== propertySet.filename) {
app_data.filename = propertySet.filename;
Copy link
Member

Choose a reason for hiding this comment

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

Note this would specifically need to be updated to the following once #861 is merged or in #861 once this is merged.

Suggested change
if (app_data.filename !== propertySet.filename) {
app_data.filename = propertySet.filename;
const propertyFilename = PipelineService.getPipelineRelativeNodePath(
this.widgetContext.path,
propertySet.filename
);
if (app_data.filename !== propertyFilename) {
app_data.filename = propertyFilename;

Copy link
Member

@ajbozarth ajbozarth left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@kevin-bates kevin-bates left a comment

Choose a reason for hiding this comment

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

Good stuff Va - thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pipeline editor: allow for changing of the notebook [name/location]
5 participants