hovercards: added commit hovercard for files, and dashboard views.
This commit is contained in:
parent
7716757866
commit
1e60975f0e
8 changed files with 49 additions and 20 deletions
|
|
@ -17,7 +17,6 @@
|
|||
# This program is dual-licensed. If you wish to learn more about the
|
||||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
from rhodecode.config import routing_links
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
|
@ -31,8 +30,8 @@ def includeme(config):
|
|||
pattern='/_hovercard/user_group/{user_group_id}')
|
||||
|
||||
config.add_route(
|
||||
name='hovercard_commit',
|
||||
pattern='/_hovercard/commit/{repo_name}/{user_id}')
|
||||
name='hovercard_repo_commit',
|
||||
pattern='/_hovercard/commit/{repo_name:.*?[^/]}/{commit_id}', repo_route=True)
|
||||
|
||||
# Scan module for configuration decorators.
|
||||
config.scan('.views', ignore='.tests')
|
||||
|
|
|
|||
|
|
@ -24,10 +24,11 @@ import collections
|
|||
|
||||
from pyramid.view import view_config
|
||||
|
||||
from rhodecode.apps._base import BaseAppView
|
||||
from rhodecode.apps._base import BaseAppView, RepoAppView
|
||||
from rhodecode.lib import helpers as h
|
||||
from rhodecode.lib.auth import (
|
||||
LoginRequired, NotAnonymous, HasRepoGroupPermissionAnyDecorator, CSRFRequired)
|
||||
LoginRequired, NotAnonymous, HasRepoGroupPermissionAnyDecorator, CSRFRequired,
|
||||
HasRepoPermissionAnyDecorator)
|
||||
from rhodecode.lib.codeblocks import filenode_as_lines_tokens
|
||||
from rhodecode.lib.index import searcher_from_config
|
||||
from rhodecode.lib.utils2 import safe_unicode, str2bool, safe_int
|
||||
|
|
@ -69,3 +70,21 @@ class HoverCardsView(BaseAppView):
|
|||
user_group_id = self.request.matchdict['user_group_id']
|
||||
c.user_group = UserGroup.get_or_404(user_group_id)
|
||||
return self._get_template_context(c)
|
||||
|
||||
|
||||
class HoverCardsRepoView(RepoAppView):
|
||||
def load_default_context(self):
|
||||
c = self._get_local_tmpl_context()
|
||||
return c
|
||||
|
||||
@LoginRequired()
|
||||
@HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin')
|
||||
@view_config(
|
||||
route_name='hovercard_repo_commit', request_method='GET', xhr=True,
|
||||
renderer='rhodecode:templates/hovercards/hovercard_repo_commit.mako')
|
||||
def hovercard_repo_commit(self):
|
||||
c = self.load_default_context()
|
||||
commit_id = self.request.matchdict['commit_id']
|
||||
pre_load = ['author', 'branch', 'date', 'message']
|
||||
c.commit = self.rhodecode_vcs_repo.get_commit(commit_id=commit_id, pre_load=pre_load)
|
||||
return self._get_template_context(c)
|
||||
|
|
|
|||
|
|
@ -1690,8 +1690,9 @@ def process_patterns(text_string, repo_name, link_format='html', active_entries=
|
|||
|
||||
active_entries = active_entries or get_active_pattern_entries(repo_name)
|
||||
issues_data = []
|
||||
newtext = text_string
|
||||
new_text = text_string
|
||||
|
||||
log.debug('Got %s entries to process', len(active_entries))
|
||||
for uid, entry in active_entries.items():
|
||||
log.debug('found issue tracker entry with uid %s', uid)
|
||||
|
||||
|
|
@ -1705,9 +1706,7 @@ def process_patterns(text_string, repo_name, link_format='html', active_entries=
|
|||
try:
|
||||
pattern = re.compile(r'%s' % entry['pat'])
|
||||
except re.error:
|
||||
log.exception(
|
||||
'issue tracker pattern: `%s` failed to compile',
|
||||
entry['pat'])
|
||||
log.exception('issue tracker pattern: `%s` failed to compile', entry['pat'])
|
||||
continue
|
||||
|
||||
data_func = partial(
|
||||
|
|
@ -1721,10 +1720,10 @@ def process_patterns(text_string, repo_name, link_format='html', active_entries=
|
|||
_process_url_func, repo_name=repo_name, entry=entry, uid=uid,
|
||||
link_format=link_format)
|
||||
|
||||
newtext = pattern.sub(url_func, newtext)
|
||||
new_text = pattern.sub(url_func, new_text)
|
||||
log.debug('processed prefix:uid `%s`', uid)
|
||||
|
||||
return newtext, issues_data
|
||||
return new_text, issues_data
|
||||
|
||||
|
||||
def urlify_commit_message(commit_text, repository=None, active_pattern_entries=None):
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ function registerRCRoutes() {
|
|||
pyroutes.register('repo_integrations_edit', '/%(repo_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_name', 'integration', 'integration_id']);
|
||||
pyroutes.register('hovercard_user', '/_hovercard/user/%(user_id)s', ['user_id']);
|
||||
pyroutes.register('hovercard_user_group', '/_hovercard/user_group/%(user_group_id)s', ['user_group_id']);
|
||||
pyroutes.register('hovercard_commit', '/_hovercard/commit/%(repo_name)s/%(user_id)s', ['repo_name', 'user_id']);
|
||||
pyroutes.register('hovercard_repo_commit', '/_hovercard/commit/%(repo_name)s/%(commit_id)s', ['repo_name', 'commit_id']);
|
||||
pyroutes.register('ops_ping', '/_admin/ops/ping', []);
|
||||
pyroutes.register('ops_error_test', '/_admin/ops/error', []);
|
||||
pyroutes.register('ops_redirect_test', '/_admin/ops/redirect', []);
|
||||
|
|
|
|||
|
|
@ -248,16 +248,18 @@ var tooltipActivate = function () {
|
|||
|
||||
if (hovercardCache[id] !== undefined) {
|
||||
callback(hovercardCache[id]);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
hovercardCache[id] = undefined;
|
||||
$.get(url, function (data) {
|
||||
hovercardCache[id] = data;
|
||||
callback(hovercardCache[id]);
|
||||
return true;
|
||||
}).fail(function (data, textStatus, errorThrown) {
|
||||
var msg = "Error while fetching hovercard.\nError code {0} ({1}).".format(data.status,data.statusText);
|
||||
var msg = "<p class='error-message'>Error while fetching hovercard.\nError code {0} ({1}).</p>".format(data.status,data.statusText);
|
||||
callback(msg);
|
||||
return false
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -291,7 +293,7 @@ var tooltipActivate = function () {
|
|||
var hovercardUrl = $origin.data('hovercardUrl');
|
||||
|
||||
if (hovercardUrl !== undefined && hovercardUrl !== "") {
|
||||
loadHoverCard(hovercardUrl, function (data) {
|
||||
var loaded = loadHoverCard(hovercardUrl, function (data) {
|
||||
instance.content(data);
|
||||
})
|
||||
} else {
|
||||
|
|
@ -300,12 +302,12 @@ var tooltipActivate = function () {
|
|||
} else {
|
||||
var data = '<div style="white-space: pre-wrap">{0}</div>'.format($origin.data('hovercardAlt'))
|
||||
}
|
||||
|
||||
var loaded = true;
|
||||
instance.content(data);
|
||||
}
|
||||
|
||||
// to remember that the data has been loaded
|
||||
$origin.data('loaded', true);
|
||||
$origin.data('loaded', loaded);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -141,10 +141,10 @@ ${h.style_metatag(tag_type, tag)|n,trim}
|
|||
${h.age_component(last_change, time_is_local=True)}
|
||||
</%def>
|
||||
|
||||
<%def name="revision(name,rev,tip,author,last_msg, commit_date)">
|
||||
<%def name="revision(repo_name, rev, commit_id, author, last_msg, commit_date)">
|
||||
<div>
|
||||
%if rev >= 0:
|
||||
<code><a title="${h.tooltip('%s\n%s\n\n%s' % (author, commit_date, last_msg))}" class="tooltip" href="${h.route_path('repo_commit',repo_name=name,commit_id=tip)}">${'r%s:%s' % (rev,h.short_id(tip))}</a></code>
|
||||
<code><a class="tooltip-hovercard" data-hovercard-alt="${last_msg}" data-hovercard-url="${h.route_path('hovercard_repo_commit', repo_name=repo_name, commit_id=commit_id)}" href="${h.route_path('repo_commit',repo_name=repo_name,commit_id=commit_id)}">${'r{}:{}'.format(rev,h.short_id(commit_id))}</a></code>
|
||||
%else:
|
||||
${_('No commits yet')}
|
||||
%endif
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
<%namespace name="base" file="/base/base.mako"/>
|
||||
|
||||
<%
|
||||
if request.GET.get('at'):
|
||||
query={'at': request.GET.get('at')}
|
||||
|
|
@ -60,7 +62,7 @@
|
|||
</td>
|
||||
<td class="td-hash" data-attr-name="commit_id">
|
||||
% if c.full_load:
|
||||
<div class="tooltip" title="${h.tooltip(node.last_commit.message)}">
|
||||
<div class="tooltip-hovercard" data-hovercard-alt="${node.last_commit.message}" data-hovercard-url="${h.route_path('hovercard_repo_commit', repo_name=c.repo_name, commit_id=node.last_commit.raw_id)}">
|
||||
<pre data-commit-id="${node.last_commit.raw_id}">r${node.last_commit.idx}:${node.last_commit.short_id}</pre>
|
||||
</div>
|
||||
% endif
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
<%namespace name="base" file="/base/base.mako"/>
|
||||
<%namespace name="dt" file="/data_table/_dt_elements.mako"/>
|
||||
|
||||
<div class="clear-fix">${base.gravatar_with_user(c.commit.author, tooltip=True)}</div>
|
||||
<br/>
|
||||
<a href="${h.route_path('repo_commit', repo_name=c.repo_name, commit_id=c.commit.raw_id)}">${h.show_id(c.commit)}</a> - ${c.commit.date}
|
||||
<br/><br/>
|
||||
<pre>${h.urlify_commit_message(c.commit.message, c.repo_name)}</pre>
|
||||
Loading…
Add table
Add a link
Reference in a new issue