Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Hide edit action buttons from users without proper permissions

akjanike9f1d27327d7
diff --git a/templates/dashboard/group/detail.html b/templates/dashboard/group/detail.html
index 65670a445f..f3a0606ee4 100644
--- a/templates/dashboard/group/detail.html
+++ b/templates/dashboard/group/detail.html
@@ -47,12 +47,14 @@
<svg data-src="{% static "dashboard/images/more_vert.svg" %}" height="24" width="24" />
</a>
<ul id="context-menu" class="dropdown-content">
+ {% if perms.userprofile.edit_group %}
<li>
<a href="#base-modal" data-href="{% url 'dashboard:group-delete' pk=group.pk %}"
class="modal-trigger-custom">
{% trans 'Remove group' context 'Group form action' %}
</a>
</li>
+ {% endif %}
</ul>
{% endif %}
{% endblock %}
@@ -77,6 +79,7 @@
</div>
</div>
</div>
+ {% if perms.userprofile.edit_group %}
<div class="card-action right-align">
<a href="{% url 'dashboard:group-list' %}" class="btn btn-flat">
{% trans "Cancel" context "Dashboard cancel action" %}
@@ -88,6 +91,7 @@
{% trans 'Add' context 'Dashboard add action' %}
{% endif %}
</button>
+ {% endif %}
</div>
</div>
</form>
diff --git a/templates/dashboard/group/list.html b/templates/dashboard/group/list.html
index 3378e78556..ccdc93e2ad 100644
--- a/templates/dashboard/group/list.html
+++ b/templates/dashboard/group/list.html
@@ -13,13 +13,16 @@
{% block menu_groups_class %}active{% endblock %}
{% block header_extra %}
- <div class="fixed-action-btn">
- <a class="btn-fab btn-floating btn-large waves-effect waves-light"
- title="{% trans "Add group" context "Group list add button text" %}"
- href="{% url 'dashboard:group-create' %}">
- <svg data-src="{% static "dashboard/images/add.svg" %}"/>
- </a>
- </div>
+
+{% if perms.userprofile.edit_group %}
+ <div class="fixed-action-btn">
+ <a class="btn-fab btn-floating btn-large waves-effect waves-light"
+ title="{% trans "Add group" context "Group list add button text" %}"
+ href="{% url 'dashboard:group-create' %}">
+ <svg data-src="{% static "dashboard/images/add.svg" %}" />
+ </a>
+ </div>
+{% endif %}
{% endblock %}
{% block breadcrumbs %}
diff --git a/templates/dashboard/staff/detail.html b/templates/dashboard/staff/detail.html
index d9c91499aa..1cc5d58088 100644
--- a/templates/dashboard/staff/detail.html
+++ b/templates/dashboard/staff/detail.html
@@ -43,12 +43,14 @@
<svg data-src="{% static "dashboard/images/more_vert.svg" %}" height="24" width="24" />
</a>
<ul id="context-menu" class="dropdown-content">
+ {% if perms.userprofile.edit_staff %}
<li>
<a href="#base-modal" data-href="{% url 'dashboard:staff-delete' pk=staff_member.pk %}"
class="modal-trigger-custom">
{% trans 'Remove staff member' context 'Staff member form action' %}
</a>
</li>
+ {% endif %}
</ul>
{% endif %}
{% endblock %}
@@ -69,6 +71,7 @@
</div>
</div>
</div>
+ {% if perms.userprofile.edit_staff %}
<div class="card-action right-align">
<a href="{% url 'dashboard:staff-list' %}" class="btn btn-flat">
{% trans "Cancel" context "Dashboard cancel action" %}
@@ -81,6 +84,7 @@
{% endif %}
</button>
</div>
+ {% endif %}
</form>
{% endif %}
</div>
diff --git a/templates/dashboard/staff/list.html b/templates/dashboard/staff/list.html
index 99280f9e56..9aa899dd3c 100644
--- a/templates/dashboard/staff/list.html
+++ b/templates/dashboard/staff/list.html
@@ -14,6 +14,7 @@
{% block menu_staff_class %}active{% endblock %}
{% block header_extra %}
+{% if perms.userprofile.edit_staff %}
<div class="fixed-action-btn">
<a class="btn-fab btn-floating btn-large waves-effect waves-light"
title="{% trans "Add staff member" context "Staff members list add button text" %}"
@@ -21,6 +22,7 @@
<svg data-src="{% static "dashboard/images/add.svg" %}" />
</a>
</div>
+{% endif %}
{% endblock %}
{% block breadcrumbs %}