[PATCH 1 of 1] ui: Add support for 'quick' action icons in repo browser
Ross Thomas
ross at lns-nevasoft.com
Mon Feb 10 21:45:12 UTC 2020
# HG changeset patch
# User Ross Thomas <ross at lns-nevasoft.com>
# Date 1581113799 28800
# Fri Feb 07 14:16:39 2020 -0800
# Branch stable
# Node ID 0c6914676f88f7fae5818e27ae65c15ef45fba88
# Parent f273a7b53fe035c12a55b6a3e34f849af245d797
ui: Add support for 'quick' action icons in repo browser
config: Add new value 'repo_list_quick_actions' to enable/disable 'quick' action icons in repo browser
When setting 'repo_list_quick_actions' to a true value a new 'Action' column is added
to the repo list browser that contains quick action icons. These quick icons provide
direct access to selected repo operations:
- (heart icon) Toggle user's follow state for the repo
- (fork icon) Open the repo's Fork page
- (gear icon) Open the repo's Settings page (present if user is admin for repo)
diff -r f273a7b53fe0 -r 0c6914676f88 development.ini
--- a/development.ini Fri Feb 07 13:55:27 2020 -0800
+++ b/development.ini Fri Feb 07 14:16:39 2020 -0800
@@ -227,6 +227,9 @@
# INSTALL
# CHANGELOG
+## adds 'quick' action icons to repos listed in the repository browsing pages.
+repo_list_quick_actions = False
+
####################################
### SSH CONFIG ####
####################################
diff -r f273a7b53fe0 -r 0c6914676f88 kallithea/front-end/style.less
--- a/kallithea/front-end/style.less Fri Feb 07 13:55:27 2020 -0800
+++ b/kallithea/front-end/style.less Fri Feb 07 14:16:39 2020 -0800
@@ -957,3 +957,9 @@
/* the blue color doesn't look good, use normal color */
color: inherit;
}
+
+/* Repo list quick actions (could be combined with 'following' styles above */
+#content .follow .list-quick-actions.show-following,
+#content .following .list-quick-actions.show-follow {
+ display: none;
+}
diff -r f273a7b53fe0 -r 0c6914676f88 kallithea/lib/paster_commands/template.ini.mako
--- a/kallithea/lib/paster_commands/template.ini.mako Fri Feb 07 13:55:27 2020 -0800
+++ b/kallithea/lib/paster_commands/template.ini.mako Fri Feb 07 14:16:39 2020 -0800
@@ -324,6 +324,9 @@
# INSTALL
# CHANGELOG
+<%text>## adds 'quick' action icons to repos listed in the repository browsing pages.</%text>
+repo_list_quick_actions = False
+
<%text>####################################</%text>
<%text>### SSH CONFIG ####</%text>
<%text>####################################</%text>
diff -r f273a7b53fe0 -r 0c6914676f88 kallithea/model/repo.py
--- a/kallithea/model/repo.py Fri Feb 07 13:55:27 2020 -0800
+++ b/kallithea/model/repo.py Fri Feb 07 14:16:39 2020 -0800
@@ -32,6 +32,7 @@
import traceback
from datetime import datetime
+from kallithea import CONFIG
import kallithea.lib.utils2
from kallithea.lib import helpers as h
from kallithea.lib.auth import HasRepoPermissionLevel, HasUserGroupPermissionLevel
@@ -39,7 +40,7 @@
from kallithea.lib.exceptions import AttachedForksError
from kallithea.lib.hooks import log_delete_repository
from kallithea.lib.utils import is_valid_repo_uri, make_ui
-from kallithea.lib.utils2 import LazyProperty, get_current_authuser, obfuscate_url_pw, remove_prefix, safe_str, safe_unicode
+from kallithea.lib.utils2 import LazyProperty, get_current_authuser, obfuscate_url_pw, remove_prefix, safe_str, safe_unicode, str2bool
from kallithea.lib.vcs.backends import get_backend
from kallithea.model.db import (
Permission, RepoGroup, Repository, RepositoryField, Session, Statistics, Ui, User, UserGroup, UserGroupRepoGroupToPerm, UserGroupRepoToPerm, UserRepoGroupToPerm, UserRepoToPerm)
@@ -171,7 +172,11 @@
def owner_actions(owner_id, username):
return _render('user_name', owner_id, username)
+ def quick_actions(repo_id, repo_name, is_following):
+ return _render('quick_actions', repo_id, repo_name, is_following)
+
repos_data = []
+ with_quick = str2bool(CONFIG.get('repo_list_quick_actions', False))
for gr in repo_groups_list or []:
repos_data.append(dict(
@@ -199,6 +204,19 @@
"rss": rss_lnk(repo.repo_name),
"atom": atom_lnk(repo.repo_name),
}
+
+ # Add the quick actions if requested
+ if with_quick:
+ from tg import request
+ from kallithea.model.scm import ScmModel
+
+ is_following = ScmModel().is_following_repo(
+ repo.repo_name, request.authuser.user_id)
+
+ row.update({
+ "quick_actions": quick_actions(repo.repo_id, repo.repo_name, is_following)
+ })
+
if admin:
row.update({
"action": repo_actions(repo.repo_name),
@@ -210,7 +228,8 @@
return {
"sort": "name",
"dir": "asc",
- "records": repos_data
+ "records": repos_data,
+ "with_quick": with_quick
}
def _get_defaults(self, repo_name):
diff -r f273a7b53fe0 -r 0c6914676f88 kallithea/templates/data_table/_dt_elements.html
--- a/kallithea/templates/data_table/_dt_elements.html Fri Feb 07 13:55:27 2020 -0800
+++ b/kallithea/templates/data_table/_dt_elements.html Fri Feb 07 14:16:39 2020 -0800
@@ -59,6 +59,20 @@
%endif
</%def>
+<%def name="quick_actions(repo_id, repo_name, repo_following)">
+ ## N.B. Same reservations as expressed in base.html (from whence this came)
+ %if request.authuser.username != 'default':
+ ## NOTE: Needs to be one line or 'space' link rendered after icon
+ <a href="#" class="${'following' if repo_following else 'follow'}" onclick="toggleFollowingRepo(this, ${repo_id});"><i class="list-quick-actions icon-heart-empty show-follow" title="${_('Follow')}"></i><i class="list-quick-actions icon-heart show-following" title="${_('Unfollow')}"></i></a>
+
+ <a href="${h.url('repo_fork_home',repo_name=repo_name)}" title="${_('Fork')}"><i class="icon-fork"></i></a>
+ %endif
+
+ %if h.HasRepoPermissionLevel('admin')(repo_name):
+ <a href="${h.url('edit_repo',repo_name=repo_name)}" title="${_('Settings')}"><i class="icon-gear"></i></a>
+ %endif
+</%def>
+
<%def name="repo_actions(repo_name)">
<a href="${h.url('edit_repo',repo_name=repo_name)}" title="${_('Edit')}" class="btn btn-default btn-xs">
<i class="icon-pencil"></i>${_('Edit')}
diff -r f273a7b53fe0 -r 0c6914676f88 kallithea/templates/index_base.html
--- a/kallithea/templates/index_base.html Fri Feb 07 13:55:27 2020 -0800
+++ b/kallithea/templates/index_base.html Fri Feb 07 14:16:39 2020 -0800
@@ -61,6 +61,9 @@
{data: "last_rev_raw", defaultContent: '', visible: false, searchable: false},
{data: "last_changeset", defaultContent: '', title: ${h.jshtml(_('Tip'))}, orderData: [5,], searchable: false},
{data: "owner", defaultContent: '', title: ${h.jshtml(_('Owner'))}, searchable: false},
+ %if c.data['with_quick']:
+ {data: "quick_actions", defaultContent: '', title: ${h.jshtml(_('Action'))}, sortable: false},
+ %endif
{data: "atom", defaultContent: '', sortable: false}
],
order: [[1, "asc"]],
More information about the kallithea-general
mailing list