repositories: bring back watch action in summary view
This commit is contained in:
parent
a5e99cc7c9
commit
4ff7ba8955
7 changed files with 41 additions and 44 deletions
|
|
@ -237,6 +237,8 @@ class RepoAppView(BaseAppView):
|
|||
c.rhodecode_db_repo = self.db_repo
|
||||
c.repo_name = self.db_repo_name
|
||||
c.repository_pull_requests = self.db_repo_pull_requests
|
||||
c.repository_is_user_following = ScmModel().is_following_repo(
|
||||
self.db_repo_name, self._rhodecode_user.user_id)
|
||||
self.path_filter = PathFilter(None)
|
||||
|
||||
c.repository_requirements_missing = {}
|
||||
|
|
|
|||
|
|
@ -297,8 +297,7 @@ class JournalView(BaseAppView):
|
|||
user_id = self.request.POST.get('follows_user_id')
|
||||
if user_id:
|
||||
try:
|
||||
ScmModel().toggle_following_user(
|
||||
user_id, self._rhodecode_user.user_id)
|
||||
ScmModel().toggle_following_user(user_id, self._rhodecode_user.user_id)
|
||||
Session().commit()
|
||||
return 'ok'
|
||||
except Exception:
|
||||
|
|
@ -307,8 +306,7 @@ class JournalView(BaseAppView):
|
|||
repo_id = self.request.POST.get('follows_repo_id')
|
||||
if repo_id:
|
||||
try:
|
||||
ScmModel().toggle_following_repo(
|
||||
repo_id, self._rhodecode_user.user_id)
|
||||
ScmModel().toggle_following_repo(repo_id, self._rhodecode_user.user_id)
|
||||
Session().commit()
|
||||
return 'ok'
|
||||
except Exception:
|
||||
|
|
|
|||
|
|
@ -360,7 +360,7 @@ class MyAccountView(BaseAppView, DataGridAppView):
|
|||
'repository.read', 'repository.write', 'repository.admin'])
|
||||
|
||||
repos_data = RepoModel().get_repos_as_dict(
|
||||
repo_list=repo_list, admin=admin)
|
||||
repo_list=repo_list, admin=admin, short_name=False)
|
||||
# json used to render the grid
|
||||
return json.dumps(repos_data)
|
||||
|
||||
|
|
|
|||
|
|
@ -233,8 +233,6 @@ class RepoSummaryView(RepoAppView):
|
|||
c.enable_downloads = self.db_repo.enable_downloads
|
||||
c.repository_followers = scm_model.get_followers(self.db_repo)
|
||||
c.repository_forks = scm_model.get_forks(self.db_repo)
|
||||
c.repository_is_user_following = scm_model.is_following_repo(
|
||||
self.db_repo_name, self._rhodecode_user.user_id)
|
||||
|
||||
# first interaction with the VCS instance after here...
|
||||
if c.repository_requirements_missing:
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ class RepoModel(BaseModel):
|
|||
repo.update_commit_cache()
|
||||
|
||||
def get_repos_as_dict(self, repo_list=None, admin=False,
|
||||
super_user_actions=False):
|
||||
super_user_actions=False, short_name=None):
|
||||
_render = get_current_request().get_partial_renderer(
|
||||
'rhodecode:templates/data_table/_dt_elements.mako')
|
||||
c = _render.get_call_context()
|
||||
|
|
@ -208,8 +208,12 @@ class RepoModel(BaseModel):
|
|||
return _render('quick_menu', repo_name)
|
||||
|
||||
def repo_lnk(name, rtype, rstate, private, archived, fork_of):
|
||||
if short_name is not None:
|
||||
short_name_var = short_name
|
||||
else:
|
||||
short_name_var = not admin
|
||||
return _render('repo_name', name, rtype, rstate, private, archived, fork_of,
|
||||
short_name=not admin, admin=False)
|
||||
short_name=short_name_var, admin=False)
|
||||
|
||||
def last_change(last_change):
|
||||
if admin and isinstance(last_change, datetime.datetime) and not last_change.tzinfo:
|
||||
|
|
|
|||
|
|
@ -16,58 +16,44 @@
|
|||
// # RhodeCode Enterprise Edition, including its added features, Support services,
|
||||
// # and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
var onSuccessFollow = function(target){
|
||||
var f = $(target);
|
||||
var f_cnt = $('#current_followers_count');
|
||||
var onSuccessFollow = function (target) {
|
||||
var targetEl = $(target);
|
||||
|
||||
if(f.hasClass('follow')){
|
||||
f.removeClass('follow');
|
||||
f.addClass('following');
|
||||
f.attr('title', _gettext('Stop following this repository'));
|
||||
$(f).html(_gettext('Unfollow'));
|
||||
if(f_cnt.length){
|
||||
var cnt = Number(f_cnt.html())+1;
|
||||
f_cnt.html(cnt);
|
||||
var callback = function () {
|
||||
targetEl.animate({'opacity': 1.00}, 200);
|
||||
if (targetEl.hasClass('watching')) {
|
||||
targetEl.removeClass('watching');
|
||||
targetEl.attr('title', _gettext('Stopped watching this repository'));
|
||||
$(targetEl).html(_gettext('Watch'));
|
||||
} else {
|
||||
targetEl.addClass('watching');
|
||||
targetEl.attr('title', _gettext('Started watching this repository'));
|
||||
$(targetEl).html(_gettext('Unwatch'));
|
||||
}
|
||||
}
|
||||
else{
|
||||
f.removeClass('following');
|
||||
f.addClass('follow');
|
||||
f.attr('title', _gettext('Start following this repository'));
|
||||
$(f).html(_gettext('Follow'));
|
||||
if(f_cnt.length){
|
||||
var cnt = Number(f_cnt.html())-1;
|
||||
f_cnt.html(cnt);
|
||||
}
|
||||
}
|
||||
};
|
||||
targetEl.animate({'opacity': 0.15}, 200, callback);
|
||||
};
|
||||
|
||||
// TODO:: check if the function is needed. 0 usage found
|
||||
var toggleFollowingUser = function(target,follows_user_id,token,user_id){
|
||||
|
||||
var toggleFollowingUser = function (target, follows_user_id) {
|
||||
var args = {
|
||||
'follows_user_id': follows_user_id,
|
||||
'auth_token': token,
|
||||
'csrf_token': CSRF_TOKEN
|
||||
};
|
||||
if(user_id != undefined){
|
||||
args.user_id = user_id
|
||||
}
|
||||
ajaxPOST(pyroutes.url('toggle_following'), args, function(){
|
||||
|
||||
ajaxPOST(pyroutes.url('toggle_following'), args, function () {
|
||||
onSuccessFollow(target);
|
||||
});
|
||||
return false;
|
||||
};
|
||||
|
||||
var toggleFollowingRepo = function(target,follows_repo_id,token,user_id){
|
||||
var toggleFollowingRepo = function (target, follows_repo_id) {
|
||||
var args = {
|
||||
'follows_repo_id': follows_repo_id,
|
||||
'auth_token': token,
|
||||
'csrf_token': CSRF_TOKEN
|
||||
};
|
||||
if(user_id != undefined){
|
||||
args.user_id = user_id
|
||||
}
|
||||
ajaxPOST(pyroutes.url('toggle_following'), args, function(){
|
||||
|
||||
ajaxPOST(pyroutes.url('toggle_following'), args, function () {
|
||||
onSuccessFollow(target);
|
||||
});
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -217,6 +217,15 @@
|
|||
<div class="pull-right">
|
||||
%if c.rhodecode_user.username != h.DEFAULT_USER:
|
||||
<a href="${h.route_path('atom_feed_home', repo_name=c.rhodecode_db_repo.repo_name, _query=dict(auth_token=c.rhodecode_user.feed_token))}" title="${_('RSS Feed')}" class="btn btn-sm"><i class="icon-rss-sign"></i>RSS</a>
|
||||
|
||||
<a href="#WatchRepo" onclick="toggleFollowingRepo(this, templateContext.repo_id); return false" title="${_('Watch this Repository and actions on it in your personalized journal')}" class="btn btn-sm ${('watching' if c.repository_is_user_following else '')}">
|
||||
% if c.repository_is_user_following:
|
||||
Unwatch
|
||||
% else:
|
||||
Watch
|
||||
% endif
|
||||
|
||||
</a>
|
||||
%else:
|
||||
<a href="${h.route_path('atom_feed_home', repo_name=c.rhodecode_db_repo.repo_name)}" title="${_('RSS Feed')}" class="btn btn-sm"><i class="icon-rss-sign"></i>RSS</a>
|
||||
%endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue