From 5cdb4c29ea9e736ea5a52483c2e62009c4c7d27e Mon Sep 17 00:00:00 2001 From: Wojtek Kosior Date: Fri, 2 Sep 2022 13:51:25 +0200 Subject: [proxy] allow packages to be frozen and unfrozen in the web UI This commit also makes some minor changes and fixes in other parts of the web UI. --- .../web_ui/templates/items/item_view.html.jinja | 60 ++++++----- .../templates/items/item_viewversion.html.jinja | 18 ++-- .../templates/items/library_viewversion.html.jinja | 15 ++- .../templates/items/package_viewversion.html.jinja | 119 +++++++++++++++++---- 4 files changed, 151 insertions(+), 61 deletions(-) (limited to 'src/hydrilla/proxy/web_ui/templates/items') diff --git a/src/hydrilla/proxy/web_ui/templates/items/item_view.html.jinja b/src/hydrilla/proxy/web_ui/templates/items/item_view.html.jinja index 861d5ef..1ad8df3 100644 --- a/src/hydrilla/proxy/web_ui/templates/items/item_view.html.jinja +++ b/src/hydrilla/proxy/web_ui/templates/items/item_view.html.jinja @@ -19,6 +19,15 @@ file's licenses. Although I request that you do not make use this code in a proprietary work, I am not going to enforce this in court. #} {% extends "base.html.jinja" %} + +{% macro versioned_identifier_with_repo(info) %} + {{ info.info.versioned_identifier }} + {% if not info.is_local %} + @ + {{ info.info.repo }} + {% endif %} +{% endmacro %} + {% block style %} {{ super() }} @@ -28,38 +37,37 @@ in a proprietary work, I am not going to enforce this in court. {% block main_info %}

{% block heading required %}{% endblock %}

{% endblock %} - {% if version_display_infos|length > 0 %} + {% if display_info.all_versions|length > 0 %}

{% block version_list_heading required %} {% endblock %}

- {% endif %}{# version_display_infos|length > 0 #} + {% endif %}{# display_info.all_versions|length > 0 #} {% endblock main %} diff --git a/src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja b/src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja index 54cb3cf..de62330 100644 --- a/src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja +++ b/src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja @@ -39,25 +39,25 @@ in a proprietary work, I am not going to enforce this in court. {{ super() }}
- {{ display_info.info.versioned_identifier }} + {{ versioned_identifier_with_repo(version_display_info) }}
{% block main_info_bulk %} TODO: add more info... {% endblock %} - {% if display_info.active == ActiveStatus.REQUIRED %} + {% if version_display_info.active == ActiveStatus.REQUIRED %}
{% block item_required_msg required %}{% endblock %}
- {% elif display_info.active == ActiveStatus.AUTO %} + {% elif version_display_info.active == ActiveStatus.AUTO %}
{% block item_auto_activated_msg required %}{% endblock %}
{% else %} - {# display_info.active == ActiveStatus.NOT_ACTIVE #} + {# version_display_info.active == ActiveStatus.NOT_ACTIVE #}
{% block item_not_activated_msg required %}{% endblock %}
{% endif %} {% set install_but_classes = ['green-button', 'button-bordering-left'] %} {% set uninstall_but_classes = ['green-button', 'button-bordering-right'] %} - {% if display_info.installed == InstalledStatus.FAILED_TO_INSTALL %} + {% if version_display_info.installed == InstalledStatus.FAILED_TO_INSTALL %} {% set install_text = _('web_ui.items.single_version.retry_install_button') @@ -70,19 +70,19 @@ in a proprietary work, I am not going to enforce this in court. {% else %} {% set install_text = _('web_ui.items.single_version.install_button') %} {% set uninstall_text = _('web_ui.items.single_version.uninstall_button') %} - {% if display_info.installed == InstalledStatus.INSTALLED %} + {% if version_display_info.installed == InstalledStatus.INSTALLED %} {% do install_but_classes.append('disabled-button') %} {% if uninstall_disallowed is defined or - display_info.active == ActiveStatus.REQUIRED + version_display_info.active == ActiveStatus.REQUIRED %} {% do uninstall_but_classes.append('disabled-button') %} {% endif %} {% else %} - {# display_info.installed == InstalledStatus.NOT_INSTALLED #} + {# version_display_info.installed == InstalledStatus.NOT_INSTALLED #} {% do uninstall_but_classes.append('disabled-button') %} {% endif %} - {% endif %}{# else/ display_info.installed == InstalledStatus.FAILED_TO_I...#} + {% endif %}{# else/ version_display_info.installed == InstalledStatus.FA... #} {{ button_row([ (uninstall_but_classes, uninstall_text, 'uninstall_item_version'), diff --git a/src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja b/src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja index 30e084d..9e0a32e 100644 --- a/src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja +++ b/src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja @@ -25,10 +25,17 @@ in a proprietary work, I am not going to enforce this in court. {% endblock %} {% block heading %} - {{ - _('web_ui.items.single_version.library.heading.name_{}') - .format(display_info.info.long_name) - }} + {% if version_display_info.is_local %} + {{ + _('web_ui.items.single_version.library_local.heading.name_{}') + .format(version_display_info.info.long_name) + }} + {% else %} + {{ + _('web_ui.items.single_version.library.heading.name_{}') + .format(version_display_info.info.long_name) + }} + {% endif %} {% endblock %} {% block item_required_msg %} diff --git a/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja b/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja index a532b5f..ea8b7d3 100644 --- a/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja +++ b/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja @@ -25,10 +25,17 @@ in a proprietary work, I am not going to enforce this in court. {% endblock %} {% block heading %} - {{ - _('web_ui.items.single_version.package.heading.name_{}') - .format(display_info.info.long_name) - }} + {% if version_display_info.is_local %} + {{ + _('web_ui.items.single_version.package_local.heading.name_{}') + .format(version_display_info.info.long_name) + }} + {% else %} + {{ + _('web_ui.items.single_version.package.heading.name_{}') + .format(version_display_info.info.long_name) + }} + {% endif %} {% endblock %} {% block item_required_msg %} @@ -66,28 +73,18 @@ in a proprietary work, I am not going to enforce this in court. {% set unenable_text = _('web_ui.items.single_version.unenable_button') %} {% set disable_text = _('web_ui.items.single_version.disable_button') %} - {% - if display_info.mapping_enabled == EnabledStatus.ENABLED and - display_info.active == ActiveStatus.NOT_ACTIVE - %} - {% - set enable_text = - _('web_ui.items.single_version.freeze_to_this_button') - %} - {% else %} - {% set enable_text = _('web_ui.items.single_version.enable_button') %} - {% endif %} + {% set enable_text = _('web_ui.items.single_version.enable_button') %} - {% if display_info.mapping_enabled == EnabledStatus.NO_MARK %} + {% if display_info.enabled == EnabledStatus.NO_MARK %} {% do unenable_but_classes.append('disabled-button') %} - {% elif display_info.mapping_enabled == EnabledStatus.DISABLED %} +
{{ _('web_ui.items.single_version.item_not_marked') }}
+ {% elif display_info.enabled == EnabledStatus.DISABLED %} {% do disable_but_classes.append('disabled-button') %} +
{{ _('web_ui.items.single_version.item_disabled') }}
{% else %} - {% if display_info.active == ActiveStatus.REQUIRED %} - {% do enable_but_classes.append('disabled-button') %} - {% else %} -
{{ _('web_ui.items.single_version.other_version_enabled') }}
- {% endif %} + {# display_info.enabled == EnabledStatus.ENABLED #} + {% do enable_but_classes.append('disabled-button') %} +
{{ _('web_ui.items.single_version.item_enabled') }}
{% endif %} {{ @@ -97,4 +94,82 @@ in a proprietary work, I am not going to enforce this in court. (enable_but_classes, enable_text, 'enable_item_version') ]) }} + + {% if display_info.enabled == EnabledStatus.ENABLED %} + {% set unpin_but_classes = ['green-button', 'button-bordering-right'] %} + {% + set pin_repo_but_classes = [ + 'green-button', + 'button-bordering-right', + 'button-bordering-left' + ] + %} + {% set pin_ver_but_classes = ['green-button', 'button-bordering-left'] %} + + {% set unpin_text = _('web_ui.items.single_version.unpin_button') %} + + {% if display_info.frozen == FrozenStatus.NOT_FROZEN %} + {% do unpin_but_classes.append('disabled-button') %} +
{{ _('web_ui.items.single_version.not_pinned') }}
+ {% endif %} + + {% if display_info.frozen == FrozenStatus.REPOSITORY %} + {% if display_info.active_version.is_local %} +
{{ _('web_ui.items.single_version.pinned_repo_local') }}
+ {% else %} +
+ {{ + _('web_ui.items.single_version.pinned_repo_{}') + .format(display_info.active_version.info.repo) + }} +
+ {% endif %} + {% + if display_info.active_version.info.repo == + version_display_info.info.repo + %} + {% if version_display_info.is_local %} + {% + set pin_repo_text = + _('web_ui.items.single_version.pin_local_repo_button') + %} + {% else %} + {% + set pin_repo_text = _('web_ui.items.single_version.pin_repo_button') + %} + {% endif %} + {% do pin_repo_but_classes.append('disabled-button') %} + {% else %} + {% + set pin_repo_text = + _('web_ui.items.single_version.repin_repo_button') + %} + {% endif %} + {% else %}{# display_info.frozen == FrozenStatus.REPOSITORY #} + {% set pin_repo_text = _('web_ui.items.single_version.pin_repo_button') %} + {% endif %}{# else/ display_info.frozen == FrozenStatus.REPOSITORY #} + + {% if display_info.frozen == FrozenStatus.EXACT_VERSION %} + {% if display_info.active_version.ref == version_display_info.ref %} + {% set pin_ver_text = _('web_ui.items.single_version.pin_ver_button') %} + {% do pin_ver_but_classes.append('disabled-button') %} +
{{ _('web_ui.items.single_version.pinned_ver') }}
+ {% else %} + {% + set pin_ver_text = _('web_ui.items.single_version.repin_ver_button') + %} +
{{ _('web_ui.items.single_version.pinned_other_ver') }}
+ {% endif %} + {% else %} + {% set pin_ver_text = _('web_ui.items.single_version.pin_ver_button') %} + {% endif %}{# else/ display_info.frozen == FrozenStatus.EXACT_VERSION #} + + {{ + button_row([ + (unpin_but_classes, unpin_text, 'unfreeze_item'), + (pin_repo_but_classes, pin_repo_text, 'freeze_to_repo'), + (pin_ver_but_classes, pin_ver_text, 'freeze_to_version') + ]) + }} + {% endif %}{# display_info.enabled == EnabledStatus.ENABLED #} {% endblock main_info_bulk %} -- cgit v1.2.3