mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
Loosen realm filter pattern validator to support Git commit IDs.
Specify, we no longer require a prefix. Also improves the clarity of the examples in the documentation. Fixes: #2696.
This commit is contained in:
committed by
Tim Abbott
parent
39f0ffdedd
commit
9931ad1324
@@ -208,7 +208,7 @@ casper.waitForSelector('.admin-filter-form', function () {
|
||||
});
|
||||
|
||||
casper.waitUntilVisible('div#admin-filter-pattern-status', function () {
|
||||
casper.test.assertSelectorHasText('div#admin-filter-pattern-status', 'Failed: Invalid filter pattern, you must use the following format PREFIX-(?P<id>.+)');
|
||||
casper.test.assertSelectorHasText('div#admin-filter-pattern-status', 'Failed: Invalid filter pattern, you must use the following format OPTIONAL_PREFIX(?P<id>.+)');
|
||||
});
|
||||
|
||||
function get_suggestions(str) {
|
||||
|
||||
@@ -1,7 +1,29 @@
|
||||
<div id="filter-settings" class="settings-section" data-name="filter-settings">
|
||||
<div class="settings-section-title"><i class="icon-vector-filter settings-section-icon"></i>{{t "Custom linkification filters" }}</div>
|
||||
<div class="admin-table-wrapper">
|
||||
<p>{{#tr this}}Configure patterns that will be automatically linkified when used in Zulip message bodies or topics. For example, you could make typing "#123" automatically become a link to issue #123 in an issue tracker.{{/tr}}</p>
|
||||
|
||||
<p>
|
||||
{{#tr this}}
|
||||
Configure regular expression patterns that will be
|
||||
automatically linkified when used in Zulip message bodies or
|
||||
topics. For example to automatically linkify commit IDs and
|
||||
issue numbers (e.g. #123) to the corresponding items in a GitHub
|
||||
project, you could use the following:
|
||||
{{/tr}}
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<code>#(?P<id>[0-9]+)</code>
|
||||
{{t "and" }}
|
||||
<code>https://github.com/zulip/zulip/issues/%(id)s</code>
|
||||
</li>
|
||||
<li>
|
||||
<code>(?P<id>[0-9a-f]{40})</code>
|
||||
{{t "and" }}
|
||||
<code>https://github.com/zulip/zulip/commit/%(id)s</code>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<table class="table table-condensed table-striped admin_filters_table">
|
||||
<tbody id="admin_filters_table">
|
||||
<th>{{t "Pattern" }}</th>
|
||||
|
||||
@@ -400,8 +400,8 @@ post_delete.connect(flush_realm_emoji, sender=RealmEmoji)
|
||||
|
||||
def filter_pattern_validator(value):
|
||||
# type: (Text) -> None
|
||||
regex = re.compile(r'(?:[\w\-#]+)(\(\?P<\w+>.+\))')
|
||||
error_msg = 'Invalid filter pattern, you must use the following format PREFIX-(?P<id>.+)'
|
||||
regex = re.compile(r'(?:[\w\-#]*)(\(\?P<\w+>.+\))')
|
||||
error_msg = 'Invalid filter pattern, you must use the following format OPTIONAL_PREFIX(?P<id>.+)'
|
||||
|
||||
if not regex.match(str(value)):
|
||||
raise ValidationError(error_msg)
|
||||
|
||||
@@ -32,11 +32,11 @@ class RealmFilterTest(ZulipTestCase):
|
||||
|
||||
data['pattern'] = '$a'
|
||||
result = self.client_post("/json/realm/filters", info=data)
|
||||
self.assert_json_error(result, 'Invalid filter pattern, you must use the following format PREFIX-(?P<id>.+)')
|
||||
self.assert_json_error(result, 'Invalid filter pattern, you must use the following format OPTIONAL_PREFIX(?P<id>.+)')
|
||||
|
||||
data['pattern'] = 'ZUL-(?P<id>\d++)'
|
||||
result = self.client_post("/json/realm/filters", info=data)
|
||||
self.assert_json_error(result, 'Invalid filter pattern, you must use the following format PREFIX-(?P<id>.+)')
|
||||
self.assert_json_error(result, 'Invalid filter pattern, you must use the following format OPTIONAL_PREFIX(?P<id>.+)')
|
||||
|
||||
data['pattern'] = 'ZUL-(?P<id>\d+)'
|
||||
data['url_format_string'] = '$fgfg'
|
||||
|
||||
Reference in New Issue
Block a user