diff --git a/frontend_tests/node_tests/templates.js b/frontend_tests/node_tests/templates.js index bf7cf886d2..c08fd4c299 100644 --- a/frontend_tests/node_tests/templates.js +++ b/frontend_tests/node_tests/templates.js @@ -172,11 +172,14 @@ function render(template_name, args) { }()); (function admin_filter_list() { + + // When the logged in user is admin var args = { filter: { pattern: "#(?P[0-9]+)", url_format_string: "https://trac.example.com/ticket/%(id)s", }, + can_modify: true, }; var html = ''; @@ -184,13 +187,33 @@ function render(template_name, args) { html += render('admin_filter_list', args); html += ''; - global.write_test_output('admin_filter_list', html); - var filter_pattern = $(html).find('tr.filter_row:first span.filter_pattern'); var filter_format = $(html).find('tr.filter_row:first span.filter_url_format_string'); assert.equal(filter_pattern.text(), '#(?P[0-9]+)'); assert.equal(filter_format.text(), 'https://trac.example.com/ticket/%(id)s'); + + // When the logged in user is not admin + args = { + filter: { + pattern: "#(?P[0-9]+)", + url_format_string: "https://trac.example.com/ticket/%(id)s", + }, + can_modify: false, + }; + + html = ''; + html += ''; + html += render('admin_filter_list', args); + html += ''; + + global.write_test_output('admin_filter_list', html); + + filter_pattern = $(html).find('tr.filter_row:first span.filter_pattern'); + filter_format = $(html).find('tr.filter_row:first span.filter_url_format_string'); + + assert.equal(filter_pattern.text(), '#(?P[0-9]+)'); + assert.equal(filter_format.text(), 'https://trac.example.com/ticket/%(id)s'); }()); (function admin_streams_list() { diff --git a/static/js/admin.js b/static/js/admin.js index 760593460b..a83d02bc99 100644 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -17,6 +17,8 @@ exports.show_or_hide_menu_item = function () { .find("input, button, select, checked").attr("disabled", true); $(".organization-box [data-name='default-streams-list']") .find("input, button, select").attr("disabled", true); + $(".organization-box [data-name='filter-settings']") + .find("input, button, select").attr("disabled", true); } }; diff --git a/static/js/settings_filters.js b/static/js/settings_filters.js index 1e615f7341..1fb5b83f27 100644 --- a/static/js/settings_filters.js +++ b/static/js/settings_filters.js @@ -22,6 +22,7 @@ exports.populate_filters = function (filters_data) { url_format_string: filter[1], id: filter[2], }, + can_modify: page_params.is_admin, } ) ); diff --git a/static/templates/admin_filter_list.handlebars b/static/templates/admin_filter_list.handlebars index 9adc4f3991..d72e54431d 100644 --- a/static/templates/admin_filter_list.handlebars +++ b/static/templates/admin_filter_list.handlebars @@ -6,10 +6,12 @@ {{url_format_string}} + {{#if ../can_modify}} + {{/if}} {{/with}} diff --git a/static/templates/settings/realm-filter-settings-admin.handlebars b/static/templates/settings/realm-filter-settings-admin.handlebars index 540bf3fcca..6cb68771d4 100644 --- a/static/templates/settings/realm-filter-settings-admin.handlebars +++ b/static/templates/settings/realm-filter-settings-admin.handlebars @@ -28,31 +28,35 @@ {{t "Pattern" }} {{t "URL format string" }} - {{t "Actions" }} + {{#if is_admin}} + {{t "Actions" }} + {{/if}} -
-
-
-
{{t "Add a new filter" }}
-
-
- - -
-
-
- - -
-
-
-
- + {{#if is_admin}} + +
+
+
{{t "Add a new filter" }}
+
+
+ + +
+
+
+ + +
+
+
+
+ +
-
- + + {{/if}}
diff --git a/templates/zerver/settings_overlay.html b/templates/zerver/settings_overlay.html index 7f3a72f19b..21109f7a11 100644 --- a/templates/zerver/settings_overlay.html +++ b/templates/zerver/settings_overlay.html @@ -72,12 +72,10 @@
{{ _('Default streams') }}
- {% if is_admin %}
  • {{ _('Filter settings') }}
  • - {% endif %}