diff --git a/airlock/file_browser_api.py b/airlock/file_browser_api.py index 5e999d5c..8e4c30b9 100644 --- a/airlock/file_browser_api.py +++ b/airlock/file_browser_api.py @@ -47,18 +47,6 @@ class PathNotFound(Exception): # but this allow it to be overridden. display_text: str = None - DISPLAY_TYPES = { - "html": "iframe", - "jpeg": "image", - "jpg": "image", - "png": "image", - "svg": "image", - "csv": "table", - "tsv": "table", - "txt": "preformatted", - "log": "preformatted", - } - def __post_init__(self): # ensure is UrlPath self.relpath = UrlPath(self.relpath) @@ -121,9 +109,6 @@ def suffix(self): def file_type(self): return self.suffix().lstrip(".") - def display_type(self): - return self.DISPLAY_TYPES.get(self.file_type(), "preformatted") - def breadcrumbs(self): item = self crumbs = [item] diff --git a/airlock/templates/file_browser/contents.html b/airlock/templates/file_browser/contents.html index 96f7bced..6cfdad05 100644 --- a/airlock/templates/file_browser/contents.html +++ b/airlock/templates/file_browser/contents.html @@ -21,66 +21,53 @@ {% else %} {% fragment as add_button %} - {% if context == "workspace" %} - {% if form %} - {% #modal id="addRequestFile" button_text="Add File to Request" variant="success" %} - {% #card container=True title="Add a file" %} -
- {% csrf_token %} - {% form_select class="w-full max-w-lg mx-auto" label="Select a file group" field=form.filegroup choices=form.filegroup.field.choices %} - {% form_input class="w-full max-w-lg mx-auto" label="Or create a new file group" field=form.new_filegroup %} - -
- {% #button type="submit" variant="success" id="add-file-button" %}Add File to Request{% /button %} - {% #button variant="danger" type="cancel" %}Cancel{% /button %} -
-
- {% /card %} - {% /modal %} - {% elif file_in_request %} - {% #button type="button" disabled=True tooltip="This file has already been added to the current request" id="add-file-modal-button-disabled" %} - Add File to Request - {% /button %} - {% else %} - {% #button type="button" disabled=True tooltip="You do not have permission to add this file to a request" id="add-file-modal-button-disabled" %} - Add File to Request - {% /button %} +
+ {% if context == "workspace" %} + {% if form %} + {% #modal id="addRequestFile" button_text="Add File to Request" variant="success" %} + {% #card container=True title="Add a file" %} +
+ {% csrf_token %} + {% form_select class="w-full max-w-lg mx-auto" label="Select a file group" field=form.filegroup choices=form.filegroup.field.choices %} + {% form_input class="w-full max-w-lg mx-auto" label="Or create a new file group" field=form.new_filegroup %} + +
+ {% #button type="submit" variant="success" id="add-file-button" %}Add File to Request{% /button %} + {% #button variant="danger" type="cancel" %}Cancel{% /button %} +
+
+ {% /card %} + {% /modal %} + {% elif file_in_request %} + {% #button type="button" disabled=True tooltip="This file has already been added to the current request" id="add-file-modal-button-disabled" %} + Add File to Request + {% /button %} + {% else %} + {% #button type="button" disabled=True tooltip="You do not have permission to add this file to a request" id="add-file-modal-button-disabled" %} + Add File to Request + {% /button %} + {% endif %} + {% elif is_author %} +
+ {% csrf_token %} + {% #button type="submit" tooltip="Remove this file from this request" variant="warning" %}Remove File from Request{% /button %} +
+ {% elif is_output_checker %} + {% #button variant="primary" type="link" href=path_item.download_url id="download-button" %}Download file{% /button %} {% endif %} - {% elif is_author %} -
- {% csrf_token %} - {% #button type="submit" tooltip="Remove this file from this request" variant="warning" %}Remove File from Request{% /button %} -
- {% elif is_output_checker %} - {% #button variant="primary" type="link" href=path_item.download_url id="download-button" %}Download file{% /button %} - {% endif %} + {% #button variant="primary" type="link" href=path_item.contents_url external=True id="view-button" %}View ↗{% /button %} +
{% endfragment %} {% #card title=path_item.name container=True custom_button=add_button %}
- {% if path_item.display_type == "iframe" %} - - {% elif path_item.display_type == "image" %} -
- -
- {% elif path_item.display_type == "table" %} -
- {% include "file_browser/csv.html" with contents=path_item.contents %} -
- {% else %} -
-
{{ path_item.contents }}
-
- {% endif %} +