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:
|
||||
|
||||
|
||||
Jira Integration
|
||||
----------------
|
||||
|
||||
* Regex = ``(?:^#|\s#)(\w+-\d+)``
|
||||
* URL = ``https://myissueserver.com/browse/${id}``
|
||||
* Issue Prefix = ``#``
|
||||
Please check examples in the view for configuration the issue trackers.
|
||||
|
||||
|
||||
Confluence (Wiki)
|
||||
-----------------
|
||||
|
||||
* Regex = ``(?:conf-)([A-Z0-9]+)``
|
||||
* URL = ``https://example.atlassian.net/display/wiki/${id}/${repo_name}``
|
||||
* issue prefix = ``CONF-``
|
||||
Please check examples in the view for configuration the issue trackers.
|
||||
|
||||
|
||||
Redmine Integration
|
||||
-------------------
|
||||
|
||||
* Regex = ``(issue-+\d+)``
|
||||
* URL = ``https://myissueserver.com/redmine/issue/${id}``
|
||||
* Issue Prefix = ``issue-``
|
||||
Please check examples in the view for configuration the issue trackers.
|
||||
|
||||
Redmine (wiki)
|
||||
--------------
|
||||
|
||||
* Regex = ``(?:wiki-)([a-zA-Z0-9]+)``
|
||||
* URL = ``https://example.com/redmine/projects/wiki/${repo_name}``
|
||||
* Issue prefix = ``Issue-``
|
||||
Redmine wiki Integration
|
||||
------------------------
|
||||
|
||||
Please check examples in the view for configuration the issue trackers.
|
||||
|
||||
|
||||
Pivotal Tracker
|
||||
---------------
|
||||
|
||||
* Regex = ``(?:pivot-)(?<project_id>\d+)-(?<story>\d+)``
|
||||
* URL = ``https://www.pivotaltracker.com/s/projects/${project_id}/stories/${story}``
|
||||
* Issue prefix = ``Piv-``
|
||||
Please check examples in the view for configuration the issue trackers.
|
||||
|
||||
|
||||
Trello
|
||||
------
|
||||
|
||||
* Regex = ``(?:trello-)(?<card_id>[a-zA-Z0-9]+)``
|
||||
* URL = ``https://trello.com/example.com/${card_id}``
|
||||
* Issue prefix = ``Trello-``
|
||||
Please check examples in the view for configuration the issue trackers.
|
||||
|
||||
|
|
|
|||
|
|
@ -726,7 +726,7 @@ class TestAdminSettingsIssueTracker(object):
|
|||
IssueTrackerSettingsModel().delete_entries(self.uid)
|
||||
|
||||
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'
|
||||
uid = md5(pattern)
|
||||
settings_util.create_rhodecode_setting(
|
||||
|
|
@ -737,6 +737,6 @@ class TestAdminSettingsIssueTracker(object):
|
|||
'uid': uid,
|
||||
'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()
|
||||
assert 'rhodecode_%s%s' % (self.SHORT_PATTERN_KEY, uid) not in settings
|
||||
|
|
|
|||
|
|
@ -518,7 +518,7 @@ class AdminSettingsView(BaseAppView):
|
|||
@CSRFRequired()
|
||||
@view_config(
|
||||
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):
|
||||
_ = self.request.translate
|
||||
self.load_default_context()
|
||||
|
|
@ -528,8 +528,11 @@ class AdminSettingsView(BaseAppView):
|
|||
except Exception:
|
||||
log.exception('Failed to delete issue tracker setting %s', uid)
|
||||
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()
|
||||
@HasPermissionAllDecorator('hg.admin')
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ class TestRepoIssueTracker(object):
|
|||
self.settings_model.delete_entries(self.uid)
|
||||
|
||||
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_name = repo.repo_name
|
||||
entry_key = 'issuetracker_pat_'
|
||||
|
|
@ -141,8 +141,9 @@ class TestRepoIssueTracker(object):
|
|||
repo_name=backend.repo.repo_name),
|
||||
{
|
||||
'uid': uid,
|
||||
'csrf_token': csrf_token
|
||||
}, status=302)
|
||||
'csrf_token': csrf_token,
|
||||
'': ''
|
||||
}, extra_environ=xhr_header, status=200)
|
||||
settings = IssueTrackerSettingsModel(
|
||||
repo=Repository.get_by_repo_name(repo_name)).get_repo_settings()
|
||||
assert 'rhodecode_%s%s' % (entry_key, uid) not in settings
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
import logging
|
||||
|
||||
from pyramid.httpexceptions import HTTPFound
|
||||
from pyramid.httpexceptions import HTTPFound, HTTPNotFound
|
||||
from pyramid.view import view_config
|
||||
import formencode
|
||||
|
||||
|
|
@ -31,7 +31,7 @@ from rhodecode.lib.auth import (
|
|||
LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired)
|
||||
from rhodecode.model.forms import IssueTrackerPatternsForm
|
||||
from rhodecode.model.meta import Session
|
||||
from rhodecode.model.settings import IssueTrackerSettingsModel
|
||||
from rhodecode.model.settings import IssueTrackerSettingsModel, SettingsModel
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -64,7 +64,7 @@ class RepoSettingsIssueTrackersView(RepoAppView):
|
|||
@CSRFRequired()
|
||||
@view_config(
|
||||
route_name='edit_repo_issuetracker_test', request_method='POST',
|
||||
xhr=True, renderer='string')
|
||||
renderer='string', xhr=True)
|
||||
def repo_issuetracker_test(self):
|
||||
return h.urlify_commit_message(
|
||||
self.request.POST.get('test_text', ''),
|
||||
|
|
@ -75,7 +75,7 @@ class RepoSettingsIssueTrackersView(RepoAppView):
|
|||
@CSRFRequired()
|
||||
@view_config(
|
||||
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):
|
||||
_ = self.request.translate
|
||||
uid = self.request.POST.get('uid')
|
||||
|
|
@ -85,10 +85,12 @@ class RepoSettingsIssueTrackersView(RepoAppView):
|
|||
except Exception:
|
||||
h.flash(_('Error occurred during deleting issue tracker entry'),
|
||||
category='error')
|
||||
else:
|
||||
h.flash(_('Removed issue tracker entry'), category='success')
|
||||
raise HTTPFound(
|
||||
h.route_path('edit_repo_issuetracker', repo_name=self.db_repo_name))
|
||||
raise HTTPNotFound()
|
||||
|
||||
SettingsModel().invalidate_settings_cache()
|
||||
h.flash(_('Removed issue tracker entry.'), category='success')
|
||||
|
||||
return {'deleted': uid}
|
||||
|
||||
def _update_patterns(self, form, repo_settings):
|
||||
for uid in form['delete_patterns']:
|
||||
|
|
|
|||
|
|
@ -191,6 +191,24 @@ table.dataTable {
|
|||
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 {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,24 +5,101 @@
|
|||
## ${its.issue_tracker_settings_test(test_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">
|
||||
<tr>
|
||||
<th>${_('Description')}</th>
|
||||
<th>${_('Pattern')}</th>
|
||||
<th>${_('Url')}</th>
|
||||
<th>${_('Prefix')}</th>
|
||||
<th>${_('Extra Prefix')}</th>
|
||||
<th ></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="td-description issue-tracker-example">Example</td>
|
||||
<td class="td-regex issue-tracker-example">${'(?:#)(?P<issue_id>\d+)'}</td>
|
||||
<td class="td-url issue-tracker-example">${'https://myissueserver.com/${repo}/issue/${issue_id}'}</td>
|
||||
<td class="td-prefix issue-tracker-example">#</td>
|
||||
<td class="issue-tracker-example"><a href="${h.route_url('enterprise_issue_tracker_settings')}" target="_blank">${_('Read more')}</a></td>
|
||||
</tr>
|
||||
% for name, pat, url, pref in examples:
|
||||
<tr class="it-examples" style="${'' if loop.index == 0 else 'display:none'}">
|
||||
<td class="td-issue-tracker-name issue-tracker-example">${name}</td>
|
||||
<td class="td-regex issue-tracker-example">${pat}</td>
|
||||
<td class="td-url issue-tracker-example">${url}</td>
|
||||
<td class="td-prefix issue-tracker-example">${pref}</td>
|
||||
<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:
|
||||
<tr id="entry_${uid}">
|
||||
<td class="td-description issuetracker_desc">
|
||||
<td class="td-issue-tracker-name issuetracker_desc">
|
||||
<span class="entry">
|
||||
${entry.desc}
|
||||
</span>
|
||||
|
|
@ -30,7 +107,7 @@
|
|||
${h.text('new_pattern_description_'+uid, class_='medium-inline', value=entry.desc or '')}
|
||||
</span>
|
||||
</td>
|
||||
<td class="td-regex issuetracker_pat">
|
||||
<td class="td-issue-tracker-regex issuetracker_pat">
|
||||
<span class="entry">
|
||||
${entry.pat}
|
||||
</span>
|
||||
|
|
@ -95,13 +172,13 @@
|
|||
if (confirm("${_('Confirm to remove this pattern:')} "+$(entry).data('desc'))) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "${delete_url}",
|
||||
url: "${delete_url}",
|
||||
data: {
|
||||
'csrf_token': CSRF_TOKEN,
|
||||
'uid':$(entry).data('uid')
|
||||
},
|
||||
success: function(){
|
||||
location.reload();
|
||||
window.location.reload();
|
||||
},
|
||||
error: function(data, textStatus, errorThrown){
|
||||
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) {
|
||||
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>
|
||||
</%def>
|
||||
|
||||
|
|
@ -144,12 +239,12 @@
|
|||
<table id="add-row-tmpl" style="display: none;">
|
||||
<tbody>
|
||||
<tr class="new_pattern">
|
||||
<td class="td-description issuetracker_desc">
|
||||
<td class="td-issue-tracker-name issuetracker_desc">
|
||||
<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>
|
||||
</td>
|
||||
<td class="td-regex issuetracker_pat">
|
||||
<td class="td-issue-tracker-regex issuetracker_pat">
|
||||
<span class="entry">
|
||||
<input class="medium-inline" id="pattern_##UUID##" name="new_pattern_pattern_##UUID##" placeholder="Pattern"
|
||||
value="##PATTERN##" type="text">
|
||||
|
|
@ -178,9 +273,14 @@
|
|||
<div class="fields">
|
||||
<div class="field">
|
||||
<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 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 !
|
||||
Added tag v1.3.0 for commit 0f3b629be725
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue