Skip to content

Commit

Permalink
feat: global links (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasvinclav authored Oct 27, 2023
1 parent 02c2e57 commit 5c207b8
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
{% block object-tools-items %}
{% url opts|admin_urlname:'permissions' original.pk|admin_urlquote as history_url %}

<a href="{% add_preserved_filters history_url %}" class="permissionslink mx-1 px-3 py-2 rounded-md transition-all hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200">
{% trans "Object permissions" %}
</a>
{% trans "Object permissions" as title %}
{% add_preserved_filters history_url as link %}
{% include "unfold/helpers/tab_action.html" with title=title link=link %}

{{ block.super }}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{% load admin_urls i18n %}

{% if has_export_permission %}
<li class="border-r flex-grow text-center last:border-0 dark:border-gray-700">
<a href="{% url opts|admin_urlname:'export' %}{{ cl.get_query_string }}" class="block px-4 py-2 text-gray-500 whitespace-nowrap hover:text-gray-700 dark:text-gray-400 hover:dark:text-gray-200">
{% trans "Export" %}
</a>
</li>
{% trans "Export" as title %}
{% url opts|admin_urlname:'export' as link %}
{% include "unfold/helpers/tab_action.html" with title=title link=link|add:cl.get_query_string %}
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{% load admin_urls i18n %}

{% if has_import_permission %}
<li class="border-r flex-grow text-center last:border-0 dark:border-gray-700">
<a href="{% url opts|admin_urlname:"import" %}" class="block px-4 py-2 text-gray-500 whitespace-nowrap hover:text-gray-700 dark:text-gray-400 hover:dark:text-gray-200">
{% trans "Import" %}
</a>
</li>
{% trans "Import" as title %}
{% url opts|admin_urlname:"import" as link %}
{% include "unfold/helpers/tab_action.html" with title=title link=link %}
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "admin/change_form.html" %}

{% load admin_urls i18n %}
{% load url from simple_history_compat%}
{% load url from simple_history_compat %}

{% block breadcrumbs %}
<div class="px-4 lg:px-12">
Expand Down
2 changes: 1 addition & 1 deletion src/unfold/static/unfold/css/styles.css

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions src/unfold/templates/admin/change_form_object_tools.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
{% block object-tools-items %}
{% url opts|admin_urlname:'history' original.pk|admin_urlquote as history_url %}

<a href="{% add_preserved_filters history_url %}" class="historylink mx-1 px-3 py-2 rounded-md transition-all hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200">
{% trans 'History' %}
</a>
{% trans 'History' as title %}
{% add_preserved_filters history_url as link %}
{% include "unfold/helpers/tab_action.html" with title=title link=link %}

{% if has_absolute_url %}
<a href="{{ absolute_url }}" target="_blank" class="viewsitelink mx-1 px-3 py-2 rounded-md transition-all hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200">
{% trans 'View on site' %}
</a>
{% trans 'View on site' as title %}
{% include "unfold/helpers/tab_action.html" with title=title link=absolute_url blank=1 %}
{% endif %}
{% endblock %}
4 changes: 0 additions & 4 deletions src/unfold/templates/unfold/helpers/account_links.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
</span>
</div>

{% if nav_global %}
{{ nav_global }}
{% endif %}

{% if site_url %}
<a href="{{ site_url }}" target="_blank" class="mx-1 px-3 py-2 rounded hover:bg-gray-100 hover:text-gray-700 dark:hover:bg-gray-700 dark:hover:text-gray-200">
{% translate 'View site' %}
Expand Down
5 changes: 5 additions & 0 deletions src/unfold/templates/unfold/helpers/tab_action.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<li class="border-b flex-grow text-center md:border-b-0 md:border-r last:border-0 dark:border-gray-800">
<a href="{{ link }}" class="block px-4 py-2 text-gray-500 text-left whitespace-nowrap hover:text-gray-700 dark:text-gray-400 hover:dark:text-gray-200"{% if blank %} target="_blank"{% endif %}>
{{ title }}
</a>
</li>
15 changes: 8 additions & 7 deletions src/unfold/templates/unfold/helpers/tab_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@
</ul>
{% endif %}

{% if actions_list or actions_items %}
<ul class="border flex mb-4 mt-2 rounded-md shadow-sm md:mb-2 md:mt-0 dark:border-gray-700 max-md:w-full">
{% if actions_list or actions_items or nav_global %}
<ul class="border flex flex-col mb-4 mt-2 rounded-md shadow-sm md:flex-row md:mb-2 md:mt-0 dark:border-gray-800 max-md:w-full">
{% for action in actions_list %}
<li class="border-r flex-grow text-center last:border-0 dark:border-gray-700">
<a href="{{ action.path }}" class="block px-4 py-2 text-gray-500 whitespace-nowrap hover:text-gray-700 dark:text-gray-400 hover:dark:text-gray-200">
{{ action.title }}
</a>
</li>
{% include "unfold/helpers/tab_action.html" with title=action.title link=action.path %}
{% endfor %}

{% if actions_items %}
{{ actions_items }}
{% endif %}

{% if nav_global %}
{{ nav_global }}
{% endif %}
</ul>
{% endif %}
</div>
{% endif %}

{% endif %}
1 change: 1 addition & 0 deletions src/unfold/templatetags/unfold.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def tab_list(context, opts) -> str:
request=context.request,
context={
"tab_list": tabs,
"nav_global": context.get("nav_global"),
"actions_list": context.get("actions_list"),
"actions_items": context.get("actions_items"),
"is_popup": context.get("is_popup"),
Expand Down

0 comments on commit 5c207b8

Please sign in to comment.