refactor(files): drop the always-True download_supported flag
download_supported was set to True at every call site (3 templates, 2
route render calls) and never to False. The {% set show_download =
download_supported and not entry.broken %} branch in
_overlay_file_node.html was therefore equivalent to {% set
show_download = not entry.broken %}, and {% set has_actions =
(files_overlay or show_download) and not entry.broken %} simplifies
further: when not broken, both clauses make has_actions True
regardless of files_overlay; when broken, both clauses make it False.
So has_actions = not entry.broken.
Collapsed:
* Removed download_supported = True from overlay_detail.html (×2),
server_detail.html, and the two render_template calls in
files_routes.py
* Removed the show_download intermediate and the inner {% if
show_download %} guard in _overlay_file_node.html (the surrounding
{% if has_actions %} already guarantees not entry.broken)
* has_actions now directly equals not entry.broken
If a future requirement actually wants per-overlay download-disable,
re-introduce a flag at that point with a real callsite that sets it
False (and a test that exercises that path).
pytest: 577 passed, 1 skipped, 3 deselected — unchanged. None of the
existing tests gated on download_supported.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b6db596d0f
commit
1de61e8e4d
4 changed files with 1 additions and 9 deletions
|
|
@ -129,7 +129,6 @@ def overlay_files_fragment(overlay_id: int):
|
||||||
truncated=truncated_count > 0,
|
truncated=truncated_count > 0,
|
||||||
truncated_count=truncated_count,
|
truncated_count=truncated_count,
|
||||||
files_base_url=f"/overlays/{overlay_id}",
|
files_base_url=f"/overlays/{overlay_id}",
|
||||||
download_supported=True,
|
|
||||||
files_overlay=(overlay.type == "files"),
|
files_overlay=(overlay.type == "files"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -195,7 +194,6 @@ def server_files_fragment(server_id: int):
|
||||||
truncated=truncated_count > 0,
|
truncated=truncated_count > 0,
|
||||||
truncated_count=truncated_count,
|
truncated_count=truncated_count,
|
||||||
files_base_url=f"/servers/{server_id}",
|
files_base_url=f"/servers/{server_id}",
|
||||||
download_supported=True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,7 @@
|
||||||
<div class="file-tree-children" hidden></div>
|
<div class="file-tree-children" hidden></div>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set show_download = download_supported and not entry.broken %}
|
{% set has_actions = not entry.broken %}
|
||||||
{% set has_actions = (files_overlay or show_download) and not entry.broken %}
|
|
||||||
<li class="file-tree-row file-tree-row-file{% if has_actions %} files-row{% endif %}"
|
<li class="file-tree-row file-tree-row-file{% if has_actions %} files-row{% endif %}"
|
||||||
{% if files_overlay %}draggable="true" data-target-path="{{ entry.rel }}" data-row-kind="file" data-editable="{{ '1' if entry.editable else '0' }}"{% endif %}>
|
{% if files_overlay %}draggable="true" data-target-path="{{ entry.rel }}" data-row-kind="file" data-editable="{{ '1' if entry.editable else '0' }}"{% endif %}>
|
||||||
{% if entry.broken %}
|
{% if entry.broken %}
|
||||||
|
|
@ -36,9 +35,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if has_actions %}
|
{% if has_actions %}
|
||||||
<span class="files-row-actions" aria-label="File actions">
|
<span class="files-row-actions" aria-label="File actions">
|
||||||
{% if show_download %}
|
|
||||||
<a class="files-row-action" href="{{ files_base_url }}/files/download?path={{ entry.rel|urlencode }}" title="Download">⬇</a>
|
<a class="files-row-action" href="{{ files_base_url }}/files/download?path={{ entry.rel|urlencode }}" title="Download">⬇</a>
|
||||||
{% endif %}
|
|
||||||
{% if files_overlay %}
|
{% if files_overlay %}
|
||||||
<button type="button" class="files-row-action files-row-danger" data-action="delete" data-target-path="{{ entry.rel }}" data-row-kind="file" data-row-name="{{ entry.name }}" title="Delete">✕</button>
|
<button type="button" class="files-row-action files-row-danger" data-action="delete" data-target-path="{{ entry.rel }}" data-row-kind="file" data-row-name="{{ entry.name }}" title="Delete">✕</button>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,6 @@
|
||||||
{% set truncated = file_tree_truncated %}
|
{% set truncated = file_tree_truncated %}
|
||||||
{% set truncated_count = file_tree_truncated_count %}
|
{% set truncated_count = file_tree_truncated_count %}
|
||||||
{% set files_base_url = "/overlays/" ~ overlay.id %}
|
{% set files_base_url = "/overlays/" ~ overlay.id %}
|
||||||
{% set download_supported = True %}
|
|
||||||
{% set files_overlay = True %}
|
{% set files_overlay = True %}
|
||||||
{% include "_overlay_file_tree.html" %}
|
{% include "_overlay_file_tree.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
@ -106,7 +105,6 @@
|
||||||
{% set truncated = file_tree_truncated %}
|
{% set truncated = file_tree_truncated %}
|
||||||
{% set truncated_count = file_tree_truncated_count %}
|
{% set truncated_count = file_tree_truncated_count %}
|
||||||
{% set files_base_url = "/overlays/" ~ overlay.id %}
|
{% set files_base_url = "/overlays/" ~ overlay.id %}
|
||||||
{% set download_supported = True %}
|
|
||||||
{% include "_overlay_file_tree.html" %}
|
{% include "_overlay_file_tree.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,6 @@
|
||||||
{% set truncated = file_tree_truncated %}
|
{% set truncated = file_tree_truncated %}
|
||||||
{% set truncated_count = file_tree_truncated_count %}
|
{% set truncated_count = file_tree_truncated_count %}
|
||||||
{% set files_base_url = "/servers/" ~ server.id %}
|
{% set files_base_url = "/servers/" ~ server.id %}
|
||||||
{% set download_supported = True %}
|
|
||||||
{% include "_overlay_file_tree.html" %}
|
{% include "_overlay_file_tree.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue