mirror of https://github.com/zulip/zulip.git
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:
parent
dc801eb5ed
commit
ddfdf0e4c6
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ exports.populate_filters = function (filters_data) {
|
|||
url_format_string: filter[1],
|
||||
id: filter[2],
|
||||
},
|
||||
can_modify: page_params.is_admin,
|
||||
}
|
||||
)
|
||||
);
|
||||
|
|
|
@ -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}}
|
||||
|
|
|
@ -28,31 +28,35 @@
|
|||
<tbody id="admin_filters_table">
|
||||
<th>{{t "Pattern" }}</th>
|
||||
<th>{{t "URL format string" }}</th>
|
||||
<th>{{t "Actions" }}</th>
|
||||
{{#if is_admin}}
|
||||
<th>{{t "Actions" }}</th>
|
||||
{{/if}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<form class="form-horizontal admin-filter-form">
|
||||
<div class="add-new-filter-box grey-bg green-bg">
|
||||
<div class="new-filter-form">
|
||||
<div class="settings-section-title new-filter-section-title">{{t "Add a new filter" }}</div>
|
||||
<div class="alert" id="admin-filter-status"></div>
|
||||
<div class="control-group">
|
||||
<label for="filter_pattern" class="control-label">{{t "Regular expression" }}</label>
|
||||
<input type="text" id="filter_pattern" name="pattern" placeholder="#(?P<id>[0-9]+)" />
|
||||
<div class="alert" id="admin-filter-pattern-status"></div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label for="filter_format_string" class="control-label">{{t "URL format string" }}</label>
|
||||
<input type="text" id="filter_format_string" name="url_format_string" placeholder="https://github.com/zulip/zulip/issues/%(id)s" />
|
||||
<div class="alert" id="admin-filter-format-status"></div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<input type="submit" class="btn btn-big btn-primary" value="{{t 'Add filter' }}" />
|
||||
{{#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">
|
||||
<div class="settings-section-title new-filter-section-title">{{t "Add a new filter" }}</div>
|
||||
<div class="alert" id="admin-filter-status"></div>
|
||||
<div class="control-group">
|
||||
<label for="filter_pattern" class="control-label">{{t "Regular expression" }}</label>
|
||||
<input type="text" id="filter_pattern" name="pattern" placeholder="#(?P<id>[0-9]+)" />
|
||||
<div class="alert" id="admin-filter-pattern-status"></div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label for="filter_format_string" class="control-label">{{t "URL format string" }}</label>
|
||||
<input type="text" id="filter_format_string" name="url_format_string" placeholder="https://github.com/zulip/zulip/issues/%(id)s" />
|
||||
<div class="alert" id="admin-filter-format-status"></div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<input type="submit" class="btn btn-big btn-primary" value="{{t 'Add filter' }}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Reference in New Issue