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

New extension - Code Viewer #2553

Merged
merged 8 commits into from
Mar 18, 2022
Merged

Conversation

ajbozarth
Copy link
Member

@ajbozarth ajbozarth commented Mar 12, 2022

Adds a new Elyra extension: Code Viewer

Code Viewer adds a command that will display a given chunk of
code (string) in a transient read-only "editor" without needing to
create a file.

The new command takes in a string of the code chunk or text to
display as well as an option mime type or extension to enable code
highlighting. It then opens a read-only "editor" containing the given
content. This allows for transient display of text without the need to
persist it to a file to display it to a user.

Frontend for #2549

Remaining To Do's:

  • Add support for extensions in addition to mime types
  • Remove temporary test code from pipeline editor

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.

As an initial POC I've created the TextViewer as a widget within
the pipeline editor widget package. In a final version it would be
a separate package. The POC also includes a button the pipeline
toolbar that opens the viewer with the pipeline file contents as
an example of how it works.

Frontend POC for elyra-ai#2549
@ajbozarth ajbozarth added the status:Work in Progress Development in progress. A PR tagged with this label is not review ready unless stated otherwise. label Mar 12, 2022
@ajbozarth ajbozarth added this to the 3.7.0 milestone Mar 12, 2022
@ajbozarth ajbozarth requested a review from ptitzler March 12, 2022 04:49
@ajbozarth ajbozarth self-assigned this Mar 12, 2022
@elyra-bot
Copy link

elyra-bot bot commented Mar 12, 2022

Thanks for making a pull request to Elyra!

To try out this branch on binder, follow this link: Binder

@ajbozarth ajbozarth removed the status:Work in Progress Development in progress. A PR tagged with this label is not review ready unless stated otherwise. label Mar 14, 2022
@ajbozarth ajbozarth changed the title Text Viewer Widget Initial POC New extension - Code Viewer Mar 14, 2022
@ajbozarth ajbozarth marked this pull request as ready for review March 14, 2022 22:56
@akchinSTC akchinSTC requested a review from marthacryan March 15, 2022 15:40
@ptitzler
Copy link
Member

ptitzler commented Mar 15, 2022

Would it be possible to enable the copy [to clipboard] action on the context menu?

image

Edit: it appears that users can use <cmd/ctrl><c> to copy selected text, so this is mostly a nice-to-have to improve usability.

@ajbozarth
Copy link
Member Author

Would it be possible to enable the copy [to clipboard] action on the context menu?

I actually checked and I need to work on the context menu in general. If you open a md file then switch to a viewer the open preview option shows up and opens the preview for the md tab that was just open

@ptitzler
Copy link
Member

Since there isn't anything code specific about the viewer's functionality, should we perhaps change the extension name to something more generic? For example, one might use the viewer to display plain text.

@ptitzler
Copy link
Member

I've created a new label component:code-viewer in this repo to allow for proper classification of follow-up work.

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.

Code LGTM - haven't tested locally

@akchinSTC akchinSTC added the status:Work in Progress Development in progress. A PR tagged with this label is not review ready unless stated otherwise. label Mar 17, 2022
@ajbozarth ajbozarth removed the status:Work in Progress Development in progress. A PR tagged with this label is not review ready unless stated otherwise. label Mar 18, 2022
@ajbozarth
Copy link
Member Author

I "solved" the context menu issues by simply disabling the jupyterlab context menu and letting the normal system context menu open when inside the viewer. (This lets users copy text).

I've also removed the test code so this is ready to merge. If further testing is desired you will want to check out the code then revert one commit to re-add the test code.

@akchinSTC akchinSTC requested a review from marthacryan March 18, 2022 21:36
Copy link
Member

@ptitzler ptitzler left a comment

Choose a reason for hiding this comment

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

LGTM

@akchinSTC akchinSTC merged commit 89de928 into elyra-ai:master Mar 18, 2022
@ajbozarth ajbozarth deleted the text_viewer branch March 21, 2022 15:09
kevin-bates pushed a commit to kevin-bates/elyra that referenced this pull request Mar 22, 2022
Code Viewer adds a command that will display a given chunk of
code (string) in a transient read-only "editor" without needing to
create a file.
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.

4 participants