issue-tracker: moved example to the input box
- removed docs which had bad examples - improved regex for matching newline character properly - added nicer formatting in examples
This commit is contained in:
parent
acf245b8e1
commit
8bfbe9e1dc
7 changed files with 172 additions and 53 deletions
|
|
@ -38,44 +38,39 @@ default one. See the instructions in :ref:`repo-it`
|
||||||
|
|
||||||
.. _issue-tr-eg-ref:
|
.. _issue-tr-eg-ref:
|
||||||
|
|
||||||
|
|
||||||
Jira Integration
|
Jira Integration
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
* Regex = ``(?:^#|\s#)(\w+-\d+)``
|
Please check examples in the view for configuration the issue trackers.
|
||||||
* URL = ``https://myissueserver.com/browse/${id}``
|
|
||||||
* Issue Prefix = ``#``
|
|
||||||
|
|
||||||
Confluence (Wiki)
|
Confluence (Wiki)
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
* Regex = ``(?:conf-)([A-Z0-9]+)``
|
Please check examples in the view for configuration the issue trackers.
|
||||||
* URL = ``https://example.atlassian.net/display/wiki/${id}/${repo_name}``
|
|
||||||
* issue prefix = ``CONF-``
|
|
||||||
|
|
||||||
Redmine Integration
|
Redmine Integration
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
* Regex = ``(issue-+\d+)``
|
Please check examples in the view for configuration the issue trackers.
|
||||||
* URL = ``https://myissueserver.com/redmine/issue/${id}``
|
|
||||||
* Issue Prefix = ``issue-``
|
|
||||||
|
|
||||||
Redmine (wiki)
|
|
||||||
--------------
|
|
||||||
|
|
||||||
* Regex = ``(?:wiki-)([a-zA-Z0-9]+)``
|
Redmine wiki Integration
|
||||||
* URL = ``https://example.com/redmine/projects/wiki/${repo_name}``
|
------------------------
|
||||||
* Issue prefix = ``Issue-``
|
|
||||||
|
Please check examples in the view for configuration the issue trackers.
|
||||||
|
|
||||||
|
|
||||||
Pivotal Tracker
|
Pivotal Tracker
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
* Regex = ``(?:pivot-)(?<project_id>\d+)-(?<story>\d+)``
|
Please check examples in the view for configuration the issue trackers.
|
||||||
* URL = ``https://www.pivotaltracker.com/s/projects/${project_id}/stories/${story}``
|
|
||||||
* Issue prefix = ``Piv-``
|
|
||||||
|
|
||||||
Trello
|
Trello
|
||||||
------
|
------
|
||||||
|
|
||||||
* Regex = ``(?:trello-)(?<card_id>[a-zA-Z0-9]+)``
|
Please check examples in the view for configuration the issue trackers.
|
||||||
* URL = ``https://trello.com/example.com/${card_id}``
|
|
||||||
* Issue prefix = ``Trello-``
|
|
||||||
|
|
|
||||||
|
|
@ -726,7 +726,7 @@ class TestAdminSettingsIssueTracker(object):
|
||||||
IssueTrackerSettingsModel().delete_entries(self.uid)
|
IssueTrackerSettingsModel().delete_entries(self.uid)
|
||||||
|
|
||||||
def test_delete_issuetracker_pattern(
|
def test_delete_issuetracker_pattern(
|
||||||
self, autologin_user, backend, csrf_token, settings_util):
|
self, autologin_user, backend, csrf_token, settings_util, xhr_header):
|
||||||
pattern = 'issuetracker_pat'
|
pattern = 'issuetracker_pat'
|
||||||
uid = md5(pattern)
|
uid = md5(pattern)
|
||||||
settings_util.create_rhodecode_setting(
|
settings_util.create_rhodecode_setting(
|
||||||
|
|
@ -737,6 +737,6 @@ class TestAdminSettingsIssueTracker(object):
|
||||||
'uid': uid,
|
'uid': uid,
|
||||||
'csrf_token': csrf_token
|
'csrf_token': csrf_token
|
||||||
}
|
}
|
||||||
self.app.post(post_url, post_data, status=302)
|
self.app.post(post_url, post_data, extra_environ=xhr_header, status=200)
|
||||||
settings = SettingsModel().get_all_settings()
|
settings = SettingsModel().get_all_settings()
|
||||||
assert 'rhodecode_%s%s' % (self.SHORT_PATTERN_KEY, uid) not in settings
|
assert 'rhodecode_%s%s' % (self.SHORT_PATTERN_KEY, uid) not in settings
|
||||||
|
|
|
||||||
|
|
@ -518,7 +518,7 @@ class AdminSettingsView(BaseAppView):
|
||||||
@CSRFRequired()
|
@CSRFRequired()
|
||||||
@view_config(
|
@view_config(
|
||||||
route_name='admin_settings_issuetracker_delete', request_method='POST',
|
route_name='admin_settings_issuetracker_delete', request_method='POST',
|
||||||
renderer='rhodecode:templates/admin/settings/settings.mako')
|
renderer='json_ext', xhr=True)
|
||||||
def settings_issuetracker_delete(self):
|
def settings_issuetracker_delete(self):
|
||||||
_ = self.request.translate
|
_ = self.request.translate
|
||||||
self.load_default_context()
|
self.load_default_context()
|
||||||
|
|
@ -528,8 +528,11 @@ class AdminSettingsView(BaseAppView):
|
||||||
except Exception:
|
except Exception:
|
||||||
log.exception('Failed to delete issue tracker setting %s', uid)
|
log.exception('Failed to delete issue tracker setting %s', uid)
|
||||||
raise HTTPNotFound()
|
raise HTTPNotFound()
|
||||||
h.flash(_('Removed issue tracker entry'), category='success')
|
|
||||||
raise HTTPFound(h.route_path('admin_settings_issuetracker'))
|
SettingsModel().invalidate_settings_cache()
|
||||||
|
h.flash(_('Removed issue tracker entry.'), category='success')
|
||||||
|
|
||||||
|
return {'deleted': uid}
|
||||||
|
|
||||||
@LoginRequired()
|
@LoginRequired()
|
||||||
@HasPermissionAllDecorator('hg.admin')
|
@HasPermissionAllDecorator('hg.admin')
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ class TestRepoIssueTracker(object):
|
||||||
self.settings_model.delete_entries(self.uid)
|
self.settings_model.delete_entries(self.uid)
|
||||||
|
|
||||||
def test_delete_issuetracker_pattern(
|
def test_delete_issuetracker_pattern(
|
||||||
self, autologin_user, backend, csrf_token, settings_util):
|
self, autologin_user, backend, csrf_token, settings_util, xhr_header):
|
||||||
repo = backend.create_repo()
|
repo = backend.create_repo()
|
||||||
repo_name = repo.repo_name
|
repo_name = repo.repo_name
|
||||||
entry_key = 'issuetracker_pat_'
|
entry_key = 'issuetracker_pat_'
|
||||||
|
|
@ -141,8 +141,9 @@ class TestRepoIssueTracker(object):
|
||||||
repo_name=backend.repo.repo_name),
|
repo_name=backend.repo.repo_name),
|
||||||
{
|
{
|
||||||
'uid': uid,
|
'uid': uid,
|
||||||
'csrf_token': csrf_token
|
'csrf_token': csrf_token,
|
||||||
}, status=302)
|
'': ''
|
||||||
|
}, extra_environ=xhr_header, status=200)
|
||||||
settings = IssueTrackerSettingsModel(
|
settings = IssueTrackerSettingsModel(
|
||||||
repo=Repository.get_by_repo_name(repo_name)).get_repo_settings()
|
repo=Repository.get_by_repo_name(repo_name)).get_repo_settings()
|
||||||
assert 'rhodecode_%s%s' % (entry_key, uid) not in settings
|
assert 'rhodecode_%s%s' % (entry_key, uid) not in settings
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from pyramid.httpexceptions import HTTPFound
|
from pyramid.httpexceptions import HTTPFound, HTTPNotFound
|
||||||
from pyramid.view import view_config
|
from pyramid.view import view_config
|
||||||
import formencode
|
import formencode
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ from rhodecode.lib.auth import (
|
||||||
LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired)
|
LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired)
|
||||||
from rhodecode.model.forms import IssueTrackerPatternsForm
|
from rhodecode.model.forms import IssueTrackerPatternsForm
|
||||||
from rhodecode.model.meta import Session
|
from rhodecode.model.meta import Session
|
||||||
from rhodecode.model.settings import IssueTrackerSettingsModel
|
from rhodecode.model.settings import IssueTrackerSettingsModel, SettingsModel
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ class RepoSettingsIssueTrackersView(RepoAppView):
|
||||||
@CSRFRequired()
|
@CSRFRequired()
|
||||||
@view_config(
|
@view_config(
|
||||||
route_name='edit_repo_issuetracker_test', request_method='POST',
|
route_name='edit_repo_issuetracker_test', request_method='POST',
|
||||||
xhr=True, renderer='string')
|
renderer='string', xhr=True)
|
||||||
def repo_issuetracker_test(self):
|
def repo_issuetracker_test(self):
|
||||||
return h.urlify_commit_message(
|
return h.urlify_commit_message(
|
||||||
self.request.POST.get('test_text', ''),
|
self.request.POST.get('test_text', ''),
|
||||||
|
|
@ -75,7 +75,7 @@ class RepoSettingsIssueTrackersView(RepoAppView):
|
||||||
@CSRFRequired()
|
@CSRFRequired()
|
||||||
@view_config(
|
@view_config(
|
||||||
route_name='edit_repo_issuetracker_delete', request_method='POST',
|
route_name='edit_repo_issuetracker_delete', request_method='POST',
|
||||||
renderer='rhodecode:templates/admin/repos/repo_edit.mako')
|
renderer='json_ext', xhr=True)
|
||||||
def repo_issuetracker_delete(self):
|
def repo_issuetracker_delete(self):
|
||||||
_ = self.request.translate
|
_ = self.request.translate
|
||||||
uid = self.request.POST.get('uid')
|
uid = self.request.POST.get('uid')
|
||||||
|
|
@ -85,10 +85,12 @@ class RepoSettingsIssueTrackersView(RepoAppView):
|
||||||
except Exception:
|
except Exception:
|
||||||
h.flash(_('Error occurred during deleting issue tracker entry'),
|
h.flash(_('Error occurred during deleting issue tracker entry'),
|
||||||
category='error')
|
category='error')
|
||||||
else:
|
raise HTTPNotFound()
|
||||||
h.flash(_('Removed issue tracker entry'), category='success')
|
|
||||||
raise HTTPFound(
|
SettingsModel().invalidate_settings_cache()
|
||||||
h.route_path('edit_repo_issuetracker', repo_name=self.db_repo_name))
|
h.flash(_('Removed issue tracker entry.'), category='success')
|
||||||
|
|
||||||
|
return {'deleted': uid}
|
||||||
|
|
||||||
def _update_patterns(self, form, repo_settings):
|
def _update_patterns(self, form, repo_settings):
|
||||||
for uid in form['delete_patterns']:
|
for uid in form['delete_patterns']:
|
||||||
|
|
|
||||||
|
|
@ -191,6 +191,24 @@ table.dataTable {
|
||||||
padding-left: .65em;
|
padding-left: .65em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.td-issue-tracker-name {
|
||||||
|
width: 180px;
|
||||||
|
input {
|
||||||
|
width: 180px;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
&.td-issue-tracker-regex {
|
||||||
|
white-space: nowrap;
|
||||||
|
|
||||||
|
min-width: 300px;
|
||||||
|
input {
|
||||||
|
min-width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
&.td-url {
|
&.td-url {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,24 +5,101 @@
|
||||||
## ${its.issue_tracker_settings_test(test_url)}
|
## ${its.issue_tracker_settings_test(test_url)}
|
||||||
|
|
||||||
<%def name="issue_tracker_settings_table(patterns, form_url, delete_url)">
|
<%def name="issue_tracker_settings_table(patterns, form_url, delete_url)">
|
||||||
|
<%
|
||||||
|
# Name/desc, pattern, issue prefix
|
||||||
|
examples = [
|
||||||
|
(
|
||||||
|
' ',
|
||||||
|
' ',
|
||||||
|
' ',
|
||||||
|
' '
|
||||||
|
),
|
||||||
|
|
||||||
|
(
|
||||||
|
'Redmine',
|
||||||
|
'(^#|\s#)(?P<issue_id>\d+)',
|
||||||
|
'https://myissueserver.com/${repo}/issue/${issue_id}',
|
||||||
|
''
|
||||||
|
),
|
||||||
|
|
||||||
|
(
|
||||||
|
'Redmine - Alternative',
|
||||||
|
'(?:issue-)(\d+)',
|
||||||
|
'https://myissueserver.com/redmine/issue/${id}',
|
||||||
|
''
|
||||||
|
),
|
||||||
|
|
||||||
|
(
|
||||||
|
'Redmine - Wiki',
|
||||||
|
'(?:wiki-)([a-zA-Z0-9]+)',
|
||||||
|
'http://example.org/projects/${repo_name}/wiki/${id}',
|
||||||
|
'wiki-'
|
||||||
|
),
|
||||||
|
|
||||||
|
(
|
||||||
|
'JIRA - All tickets',
|
||||||
|
'(^|\s\w+-\d+)',
|
||||||
|
'https://myjira.com/browse/${id}',
|
||||||
|
''
|
||||||
|
),
|
||||||
|
|
||||||
|
(
|
||||||
|
'JIRA - Project (JRA)',
|
||||||
|
'(?:(^|\s)(?P<issue_id>(?:JRA-|JRA-)(?:\d+)))',
|
||||||
|
'https://myjira.com/${issue_id}',
|
||||||
|
''
|
||||||
|
),
|
||||||
|
|
||||||
|
(
|
||||||
|
'Confluence WIKI',
|
||||||
|
'(?:conf-)([A-Z0-9]+)',
|
||||||
|
'https://example.atlassian.net/display/wiki/${id}/${repo_name}',
|
||||||
|
'CONF-',
|
||||||
|
),
|
||||||
|
|
||||||
|
(
|
||||||
|
'Pivotal Tracker',
|
||||||
|
'(?:pivot-)(?<project_id>\d+)-(?<story>\d+)',
|
||||||
|
'https://www.pivotaltracker.com/s/projects/${project_id}/stories/${story}',
|
||||||
|
'PIV-',
|
||||||
|
),
|
||||||
|
|
||||||
|
(
|
||||||
|
'Trello',
|
||||||
|
'(?:trello-)(?<card_id>[a-zA-Z0-9]+)',
|
||||||
|
'https://trello.com/example.com/${card_id}',
|
||||||
|
'TRELLO-',
|
||||||
|
),
|
||||||
|
]
|
||||||
|
%>
|
||||||
|
|
||||||
<table class="rctable issuetracker">
|
<table class="rctable issuetracker">
|
||||||
<tr>
|
<tr>
|
||||||
<th>${_('Description')}</th>
|
<th>${_('Description')}</th>
|
||||||
<th>${_('Pattern')}</th>
|
<th>${_('Pattern')}</th>
|
||||||
<th>${_('Url')}</th>
|
<th>${_('Url')}</th>
|
||||||
<th>${_('Prefix')}</th>
|
<th>${_('Extra Prefix')}</th>
|
||||||
<th ></th>
|
<th ></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
% for name, pat, url, pref in examples:
|
||||||
<td class="td-description issue-tracker-example">Example</td>
|
<tr class="it-examples" style="${'' if loop.index == 0 else 'display:none'}">
|
||||||
<td class="td-regex issue-tracker-example">${'(?:#)(?P<issue_id>\d+)'}</td>
|
<td class="td-issue-tracker-name issue-tracker-example">${name}</td>
|
||||||
<td class="td-url issue-tracker-example">${'https://myissueserver.com/${repo}/issue/${issue_id}'}</td>
|
<td class="td-regex issue-tracker-example">${pat}</td>
|
||||||
<td class="td-prefix issue-tracker-example">#</td>
|
<td class="td-url issue-tracker-example">${url}</td>
|
||||||
<td class="issue-tracker-example"><a href="${h.route_url('enterprise_issue_tracker_settings')}" target="_blank">${_('Read more')}</a></td>
|
<td class="td-prefix issue-tracker-example">${pref}</td>
|
||||||
</tr>
|
<td>
|
||||||
|
% if loop.index == 0:
|
||||||
|
<a href="#showMore" onclick="$('.it-examples').toggle(); return false">${_('show examples')}</a>
|
||||||
|
% else:
|
||||||
|
<a href="#copyToInput" onclick="copyToInput(this, '${h.json.dumps(name)}', '${h.json.dumps(pat)}', '${h.json.dumps(url)}', '${h.json.dumps(pref)}'); return false">copy to input</a>
|
||||||
|
% endif
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
% endfor
|
||||||
|
|
||||||
%for uid, entry in patterns:
|
%for uid, entry in patterns:
|
||||||
<tr id="entry_${uid}">
|
<tr id="entry_${uid}">
|
||||||
<td class="td-description issuetracker_desc">
|
<td class="td-issue-tracker-name issuetracker_desc">
|
||||||
<span class="entry">
|
<span class="entry">
|
||||||
${entry.desc}
|
${entry.desc}
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -30,7 +107,7 @@
|
||||||
${h.text('new_pattern_description_'+uid, class_='medium-inline', value=entry.desc or '')}
|
${h.text('new_pattern_description_'+uid, class_='medium-inline', value=entry.desc or '')}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="td-regex issuetracker_pat">
|
<td class="td-issue-tracker-regex issuetracker_pat">
|
||||||
<span class="entry">
|
<span class="entry">
|
||||||
${entry.pat}
|
${entry.pat}
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -95,13 +172,13 @@
|
||||||
if (confirm("${_('Confirm to remove this pattern:')} "+$(entry).data('desc'))) {
|
if (confirm("${_('Confirm to remove this pattern:')} "+$(entry).data('desc'))) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "${delete_url}",
|
url: "${delete_url}",
|
||||||
data: {
|
data: {
|
||||||
'csrf_token': CSRF_TOKEN,
|
'csrf_token': CSRF_TOKEN,
|
||||||
'uid':$(entry).data('uid')
|
'uid':$(entry).data('uid')
|
||||||
},
|
},
|
||||||
success: function(){
|
success: function(){
|
||||||
location.reload();
|
window.location.reload();
|
||||||
},
|
},
|
||||||
error: function(data, textStatus, errorThrown){
|
error: function(data, textStatus, errorThrown){
|
||||||
alert("Error while deleting entry.\nError code {0} ({1}). URL: {2}".format(data.status,data.statusText,$(entry)[0].url));
|
alert("Error while deleting entry.\nError code {0} ({1}). URL: {2}".format(data.status,data.statusText,$(entry)[0].url));
|
||||||
|
|
@ -137,6 +214,24 @@
|
||||||
$('#add_pattern').on('click', function(e) {
|
$('#add_pattern').on('click', function(e) {
|
||||||
addNewPatternInput();
|
addNewPatternInput();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var copied = false;
|
||||||
|
copyToInput = function (elem, name, pat, url, pref) {
|
||||||
|
if (copied === false) {
|
||||||
|
addNewPatternInput();
|
||||||
|
copied = true;
|
||||||
|
}
|
||||||
|
$(elem).hide();
|
||||||
|
var load = function(text){
|
||||||
|
return text.replace(/["]/g, "")
|
||||||
|
};
|
||||||
|
$('#description_1').val(load(name));
|
||||||
|
$('#pattern_1').val(load(pat));
|
||||||
|
$('#url_1').val(load(url));
|
||||||
|
$('#prefix_1').val(load(pref));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
|
@ -144,12 +239,12 @@
|
||||||
<table id="add-row-tmpl" style="display: none;">
|
<table id="add-row-tmpl" style="display: none;">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr class="new_pattern">
|
<tr class="new_pattern">
|
||||||
<td class="td-description issuetracker_desc">
|
<td class="td-issue-tracker-name issuetracker_desc">
|
||||||
<span class="entry">
|
<span class="entry">
|
||||||
<input class="medium-inline" id="description_##UUID##" name="new_pattern_description_##UUID##" value="##DESCRIPTION##" type="text">
|
<input class="medium-inline" id="description_##UUID##" name="new_pattern_description_##UUID##" value="##DESCRIPTION##" type="text">
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="td-regex issuetracker_pat">
|
<td class="td-issue-tracker-regex issuetracker_pat">
|
||||||
<span class="entry">
|
<span class="entry">
|
||||||
<input class="medium-inline" id="pattern_##UUID##" name="new_pattern_pattern_##UUID##" placeholder="Pattern"
|
<input class="medium-inline" id="pattern_##UUID##" name="new_pattern_pattern_##UUID##" placeholder="Pattern"
|
||||||
value="##PATTERN##" type="text">
|
value="##PATTERN##" type="text">
|
||||||
|
|
@ -178,9 +273,14 @@
|
||||||
<div class="fields">
|
<div class="fields">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<div class='textarea-full'>
|
<div class='textarea-full'>
|
||||||
<textarea id="test_pattern_data" rows="10">
|
<textarea id="test_pattern_data" rows="12">
|
||||||
This is an example text for testing issue tracker patterns.
|
This is an example text for testing issue tracker patterns.
|
||||||
This commit fixes ticket #451.
|
This commit fixes ticket #451 and ticket #910.
|
||||||
|
Following tickets will get mentioned:
|
||||||
|
#123
|
||||||
|
#456
|
||||||
|
JRA-123
|
||||||
|
JRA-456
|
||||||
Open a pull request !101 to contribute !
|
Open a pull request !101 to contribute !
|
||||||
Added tag v1.3.0 for commit 0f3b629be725
|
Added tag v1.3.0 for commit 0f3b629be725
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue