diff --git a/seahub/api2/views.py b/seahub/api2/views.py
index e9d338fa72..951b343b17 100644
--- a/seahub/api2/views.py
+++ b/seahub/api2/views.py
@@ -3136,6 +3136,8 @@ class GroupRepos(APIView):
else:
repos = seaserv.get_group_repos(group.id, username)
+ group.is_staff = is_group_staff(group, request.user)
+
repos_json = []
for r in repos:
repo = {
@@ -3149,11 +3151,12 @@ class GroupRepos(APIView):
"encrypted": r.encrypted,
"permission": check_permission(r.id, username),
"owner": r.owner,
- "owner_nickname": email2nickname(r.owner)
+ "owner_nickname": email2nickname(r.owner),
+ "share_from_me": r.share_from_me,
}
repos_json.append(repo)
- return Response(repos_json)
+ return Response({"is_staff":group.is_staff, "repos":repos_json})
class GroupRepo(APIView):
authentication_classes = (TokenAuthentication, SessionAuthentication)
diff --git a/seahub/templates/js/templates.html b/seahub/templates/js/templates.html
index 043076f87e..6ec1c67b46 100644
--- a/seahub/templates/js/templates.html
+++ b/seahub/templates/js/templates.html
@@ -57,7 +57,7 @@
<%- name %> |
- <% if (app.pageOptions.isGroupStaff) { %>
+ <% if (is_staff || share_from_me) { %>
<% } %>
|
diff --git a/static/scripts/app/collections/dirents.js b/static/scripts/app/collections/dirents.js
index 635e1e017b..065121650b 100644
--- a/static/scripts/app/collections/dirents.js
+++ b/static/scripts/app/collections/dirents.js
@@ -18,15 +18,15 @@ define([
},
parse: function (data) {
- this.repo_name = data.repo_name;
- this.user_perm = data.user_perm;
- this.encrypted = data.encrypted;
- this.is_repo_owner = data.is_repo_owner;
- this.is_virtual = data.is_virtual;
+ this.repo_name = data.repo_name;
+ this.user_perm = data.user_perm;
+ this.encrypted = data.encrypted;
+ this.is_repo_owner = data.is_repo_owner;
+ this.is_virtual = data.is_virtual;
- this.dirent_more = data.dirent_more;
- this.more_start = data.more_start;
- return data.dirent_list; // return the array
+ this.dirent_more = data.dirent_more;
+ this.more_start = data.more_start;
+ return data.dirent_list; // return the array
},
// category: 'my-libs', 'shared-libs'
diff --git a/static/scripts/app/collections/group-repos.js b/static/scripts/app/collections/group-repos.js
index 32703c4103..4df40c4076 100644
--- a/static/scripts/app/collections/group-repos.js
+++ b/static/scripts/app/collections/group-repos.js
@@ -14,6 +14,11 @@ define([
return Common.getUrl({name: 'group_repos', group_id: this.group_id});
},
+ parse: function(data) {
+ this.is_staff = data.is_staff;
+ return data.repos;
+ },
+
setGroupID: function(group_id) {
this.group_id = group_id;
}
diff --git a/static/scripts/app/views/group-repo.js b/static/scripts/app/views/group-repo.js
index 322b1756ac..c383a7ec5d 100644
--- a/static/scripts/app/views/group-repo.js
+++ b/static/scripts/app/views/group-repo.js
@@ -12,14 +12,14 @@ define([
template: _.template($('#group-repo-tmpl').html()),
events: {
- 'mouseenter': 'showAction',
- 'mouseleave': 'hideAction',
+ 'mouseenter': 'highlight',
+ 'mouseleave': 'rmHighlight',
'click .cancel-share': 'unshare'
},
initialize: function(options) {
this.group_id = options.group_id;
- Backbone.View.prototype.initialize.apply(this, arguments);
+ this.is_staff = options.is_staff;
this.listenTo(this.model, 'destroy', this.remove);
},
@@ -28,19 +28,18 @@ define([
var obj = this.model.toJSON();
$.extend(obj, {
group_id: this.group_id,
+ is_staff: this.is_staff
});
this.$el.html(this.template(obj));
return this;
},
- showAction: function() {
- this.$el.addClass('hl');
- this.$el.find('.op-icon').removeClass('vh');
+ highlight: function() {
+ this.$el.addClass('hl').find('.op-icon').removeClass('vh');
},
- hideAction: function() {
- this.$el.removeClass('hl');
- this.$el.find('.op-icon').addClass('vh');
+ rmHighlight: function() {
+ this.$el.removeClass('hl').find('.op-icon').addClass('vh');
},
unshare: function() {
diff --git a/static/scripts/app/views/group.js b/static/scripts/app/views/group.js
index da29de8772..d67d70c76a 100644
--- a/static/scripts/app/views/group.js
+++ b/static/scripts/app/views/group.js
@@ -38,7 +38,11 @@ define([
},
addOne: function(repo, collection, options) {
- var view = new GroupRepoView({model: repo, group_id: this.group_id});
+ var view = new GroupRepoView({
+ model: repo,
+ group_id: this.group_id,
+ is_staff: this.repos.is_staff
+ });
if (options.prepend) {
this.$tableBody.prepend(view.render().el);
} else {