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

feat: Add preview to workflow execution files #949

Open
wants to merge 61 commits into
base: main
Choose a base branch
from

Conversation

joshsadam
Copy link
Contributor

@joshsadam joshsadam commented Feb 16, 2025

What does this PR do and why?

Describe in detail what your merge request does and why.

  1. Users can access the preview by clicking on the 'Preview' link on the Workflow Execution > Files tab.
  2. Previews are available for the following types:
    1. Images
    2. Text
    3. JSON
    4. CSV Files
    5. TSV Files
    6. Excel Files
  3. Text from files can either be copied (except for Images and Excel files) or downloaded.
  4. If the file type is not supported yet, the user can still download the file and is displayed a message that it is unavailable for preview.
  5. All pages have been checked for dark mode compliance.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other pull requests.

Text:
image

JSON:
image

CSV:
image

TSV:
image

Excel:
image

Images:
image

If the file type is not supported:
image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

PR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

@joshsadam joshsadam force-pushed the preview-pipeline-result-files branch 4 times, most recently from 3d0be02 to ad1087c Compare February 21, 2025 15:50

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link

@joshsadam joshsadam marked this pull request as ready for review February 26, 2025 14:58
@joshsadam joshsadam self-assigned this Feb 26, 2025
@joshsadam joshsadam added the enhancement New feature or request label Feb 26, 2025
Copy link
Collaborator

@ChrisHuynh333 ChrisHuynh333 left a comment

Choose a reason for hiding this comment

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

Handful of comments to start, apologies if you were already working through them.

Your previews from the seeded files work fine, but I ran a iridanextexample pipeline and now have this error if I try to preview any attached file format (fasta or text) associated with the workflow.
image

@@ -14,6 +14,7 @@ class Attachment < ApplicationRecord
'spreadsheet' => /^\S+\.(xls|xlsx)?$/,
'json' => /^\S+\.(json)?(\.gz)?$/,
'genbank' => /^\S+\.(gbk|gbf|genbank)?(\.gz)?$/,
'image' => /^\S+\.(png|jpg|jpeg|gif|bmp|tiff|svg|webp)$/,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add a pill color for image in pill_color_helper.rb

Copy link
Contributor Author

@joshsadam joshsadam Feb 28, 2025

Choose a reason for hiding this comment

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

Added in 4a741f2

Comment on lines 83 to 84
<%= link_to workflow_executions_attachments_path(attachment: attachment.id, workflow_execution: @workflow_execution.id), class: "text-blue-600 dark:text-blue-100 font-semibold hover:underline" do %>
<%= t(".preview") %>
<% end %>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was thinking maybe we just hide any preview links for formats that are not previewable, but figure you don't want to confuse users with seemingly 'random' missing preview links?

Copy link
Contributor Author

@joshsadam joshsadam Feb 28, 2025

Choose a reason for hiding this comment

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

I actually like the idea of not showing the button. I simplified some of the logic by moving some functionality onto the attachment model. 0f170ab

@@ -75,4 +78,25 @@
<td class="px-6 py-4">
<%= local_time_ago(attachment.created_at) %>
</td>

<td class="flex justify-end px-6 py-4 space-x-2">
<%= link_to workflow_executions_attachments_path(attachment: attachment.id, workflow_execution: @workflow_execution.id), class: "text-blue-600 dark:text-blue-100 font-semibold hover:underline" do %>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can the font be updated to use font-medium as that's more in line with the rest of the action links for the website

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to match styles on workflow executions and data exports table.  Thanks for the catch f35670a

Comment on lines 92 to 99
class: "text-blue-900 dark:text-blue-100 font-semibold hover:underline" %>
<% else %>
<%= link_to t(".download"),
rails_blob_path(attachment.file),
data: {
turbo: false,
},
class: "text-blue-600 dark:text-blue-100 font-semibold hover:underline" %>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can the font be updated to use font-medium as that's more in line with the rest of the action links for the website

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to match styles on workflow executions and data exports table.  Thanks for the catch f35670a

Comment on lines 36 to 34
def context_crumbs
@context_crumbs = [base_crumb].then do |crumbs|
@workflow_execution ? crumbs.concat(workflow_execution_crumbs) : crumbs
end
end
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be simplified to just use:

def context_crumbs
      super
      @context_crumbs += workflow_execution_crumbs
    end

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're smarter than me ;), updated in d7d7a15

create:
error_message: 'The following errors prevented the Workflow Execution from being created:'
error_message: 'Les erreurs suivantes ont empêché la création de l''exécution du pipeline:'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Vous avez un typo ici (l''execution).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maudit copilote de GitHub, je ne peux même pas traduire correctement 😂, updated in 132ff4f

- Add new "Actions" column to workflow execution files table
- Implement preview and download buttons for attachments
- Update localization files with new translation keys for actions
- Improve table layout and styling for better user interaction
- Standardize string value quotes in en.yml and fr.yml to single quotes
- Maintain consistent formatting across localization files
- Improve readability and consistency of translation files
- Add new "Actions" column to workflow execution files table
- Implement preview and download buttons for attachments
- Update localization files with new translation keys for actions
- Improve table layout and styling for better user interaction
- Standardize string value quotes in en.yml and fr.yml to single quotes
- Maintain consistent formatting across localization files
- Improve readability and consistency of translation files
- Implement new AttachmentsController for handling attachment previews
- Create dedicated view for attachment preview with file details and download option
- Add route for attachment preview in workflow executions
- Support preview for image and text file types
- Update attachment partial to link to new preview page
- Refactor clipboard controller to provide better copy interaction
- Add visual feedback for successful text copying
- Implement clipboard button for text attachments with success state
- Update attachment preview view to support clipboard interaction
- Add localization keys for copy, copied, and download actions
- Replace hardcoded text with translation method calls
- Update both English and French locale files
- Improve code readability and maintainability
- Add localization keys for file preview unavailability
- Update view to use translation method for preview messages
- Adjust icon size for better visual presentation
- Update both English and French locale files
- Enhance file preview with line numbers for better readability
- Implement line-by-line rendering with sequential numbering
- Style line numbers with subtle visual separation
- Enhance AttachmentsController with breadcrumb navigation
- Add workflow execution context to attachment preview route
- Update attachment partial to include workflow execution context
- Refactor context crumbs generation for better navigation
- Add workflow execution ID to attachment preview route
- Ensure proper navigation context when previewing attachments
- Maintain existing styling and functionality
- Add error handling for non-existent attachments
- Render 404 page when workflow execution is not found
- Update context crumbs to include 'files' tab for better navigation
- Enhance user experience with clear error messaging
- Enhance context crumbs generation to handle nil workflow execution
- Simplify breadcrumb generation logic
- Remove redundant error handling in workflow_execution method
- Ensure robust navigation context for attachments preview
- Extract base and workflow execution crumbs into separate methods
- Improve code organization and readability
- Simplify context_crumbs method with method extraction
- Maintain existing breadcrumb navigation logic
Introduces methods to determine if an attachment can be previewed or copied based on its file format. Defines constants PREVIEWABLE_TYPES and COPYABLE_TYPES to support these methods, with comprehensive test coverage for various file types.
Removes the FileFormatHandler concern and its corresponding test file, likely due to the implementation of similar functionality in the Attachment model in a previous commit.
Updates the workflow execution attachments views and controller to leverage new Attachment model methods for determining preview and copy capabilities. Removes redundant preview type determination logic and uses model-level methods instead.
…ttachmentsController

Updates the context_crumbs method to use super and append workflow execution crumbs, reducing redundant code and improving method clarity.
@joshsadam joshsadam force-pushed the preview-pipeline-result-files branch from 132ff4f to 3d6881f Compare February 28, 2025 03:06
@joshsadam
Copy link
Contributor Author

joshsadam commented Feb 28, 2025

Handful of comments to start, apologies if you were already working through them.

Your previews from the seeded files work fine, but I ran a iridanextexample pipeline and now have this error if I try to preview any attached file format (fasta or text) associated with the workflow. 

I couldn't get the demo pipeline running tonight, I am off tomorrow but I will figure it out on Monday.  I also need to figure out why the back button doesn't work to get back to the file listing page. (Updated in 53bfa5d, now back button works)

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

Successfully merging this pull request may close these issues.

2 participants