Organization settings: "Filter settings" tab view-only support.

This changes the layout of "organization settings" for
non-administrators such that they can view "Filter settings".
("Actions" column and form to add a new filter are not available).

Fixes: #3636
This commit is contained in:
Abhijeet Kaur 2017-04-15 03:26:33 +05:30 committed by Tim Abbott
parent dc801eb5ed
commit ddfdf0e4c6
6 changed files with 55 additions and 25 deletions

View File

@ -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<id>[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 += '</tbody>';
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<id>[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<id>[0-9]+)",
url_format_string: "https://trac.example.com/ticket/%(id)s",
},
can_modify: false,
};
html = '';
html += '<tbody id="admin_filters_table">';
html += render('admin_filter_list', args);
html += '</tbody>';
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<id>[0-9]+)');
assert.equal(filter_format.text(), 'https://trac.example.com/ticket/%(id)s');
}());
(function admin_streams_list() {

View File

@ -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);
}
};

View File

@ -22,6 +22,7 @@ exports.populate_filters = function (filters_data) {
url_format_string: filter[1],
id: filter[2],
},
can_modify: page_params.is_admin,
}
)
);

View File

@ -6,10 +6,12 @@
<td>
<span class="filter_url_format_string">{{url_format_string}}</span>
</td>
{{#if ../can_modify}}
<td>
<button class="btn delete btn-danger" data-filter-id="{{id}}">
{{t "Delete" }}
</button>
</td>
{{/if}}
</tr>
{{/with}}

View File

@ -28,10 +28,13 @@
<tbody id="admin_filters_table">
<th>{{t "Pattern" }}</th>
<th>{{t "URL format string" }}</th>
{{#if is_admin}}
<th>{{t "Actions" }}</th>
{{/if}}
</tbody>
</table>
</div>
{{#if is_admin}}
<form class="form-horizontal admin-filter-form">
<div class="add-new-filter-box grey-bg green-bg">
<div class="new-filter-form">
@ -55,4 +58,5 @@
</div>
</div>
</form>
{{/if}}
</div>

View File

@ -72,12 +72,10 @@
<i class="icon icon-vector-exchange"></i>
<div class="text">{{ _('Default streams') }}</div>
</li>
{% if is_admin %}
<li class="admin" tabindex="1" data-section="filter-settings">
<i class="icon icon-vector-font"></i>
<div class="text">{{ _('Filter settings') }}</div>
</li>
{% endif %}
</ul>
</div>