1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-24 21:07:17 +00:00

Merge pull request #1751 from haiwen/share-admin-permission

[share] add admin permission
This commit is contained in:
Daniel Pan
2017-08-30 18:08:33 +08:00
committed by GitHub
16 changed files with 335 additions and 39 deletions

View File

@@ -824,6 +824,9 @@ define([
'dirent_path': path,
'obj_name': path == '/' ? dir.repo_name : path.substr(path.lastIndexOf('/') + 1)
};
if (app.pageOptions.is_pro) {
options.is_admin = dir.is_admin;
}
new ShareView(options);
},

View File

@@ -203,6 +203,10 @@ define([
'dirent_path': dirent_path,
'obj_name': obj_name
};
if (app.pageOptions.is_pro) {
options.is_admin = dir.is_admin;
}
new ShareView(options);
this.closeMenu();
return false;

View File

@@ -361,6 +361,10 @@ define([
'dirent_path': dirent_path,
'obj_name': obj_name
};
if (app.pageOptions.is_pro) {
options.is_admin = dir.is_admin;
}
new ShareView(options);
this._hideMenu();

View File

@@ -20,11 +20,17 @@ define([
this.repo_id = options.repo_id;
this.path = options.path;
// show info about 'is_admin'
this.show_admin = false;
if (app.pageOptions.is_pro && this.path == '/' && this.item_data.for_user) {
this.show_admin = true;
}
this.render();
},
render: function () {
this.$el.html(this.template(this.item_data));
this.$el.html(this.template($.extend({}, this.item_data, {'show_admin': this.show_admin})));
return this;
},
@@ -74,7 +80,13 @@ define([
'permission': perm
},
success: function () {
item_data.permission = perm;
if (perm == 'admin'){
item_data.is_admin = true;
item_data.permission = 'rw';
} else {
item_data.permission = perm;
item_data.is_admin = false;
}
_this.render();
},
error: function(xhr) {

View File

@@ -4,7 +4,7 @@ define([
'backbone',
'common',
'app/collections/repos',
'app/views/shared-repo',
'app/views/shared-repo'
], function($, _, Backbone, Common, RepoCollection, SharedRepoView) {
'use strict';

View File

@@ -14,6 +14,8 @@ define([
initialize: function(options) {
this.is_repo_owner = options.is_repo_owner;
// for shared repo
this.is_admin = options.is_admin; // true or undefined
this.is_virtual = options.is_virtual;
this.user_perm = options.user_perm;
this.repo_id = options.repo_id;
@@ -44,7 +46,7 @@ define([
if (this.user_perm == 'rw' && !this.repo_encrypted && app.pageOptions.can_generate_upload_link) {
this.uploadLinkPanelInit();
}
if (!this.is_virtual && this.is_repo_owner) {
if (!this.is_virtual && (this.is_repo_owner || this.is_admin)) {
this.dirUserSharePanelInit();
this.dirGroupSharePanelInit();
@@ -66,12 +68,14 @@ define([
.replace('{placeholder}', '<span class="op-target ellipsis ellipsis-op-target" title="' + Common.HTMLescape(this.obj_name) + '">' + Common.HTMLescape(this.obj_name) + '</span>'),
is_dir: this.is_dir,
is_repo_owner: this.is_repo_owner,
is_admin: this.is_admin,
is_virtual: this.is_virtual,
user_perm: this.user_perm,
repo_id: this.repo_id,
can_generate_share_link: app.pageOptions.can_generate_share_link,
can_generate_upload_link: app.pageOptions.can_generate_upload_link,
repo_encrypted: this.repo_encrypted
repo_encrypted: this.repo_encrypted,
dirent_path: this.dirent_path
}));
return this;
@@ -576,6 +580,7 @@ define([
"user_email": item.user_info.name,
"user_name": item.user_info.nickname,
"permission": item.permission,
'is_admin': item.is_admin,
'for_user': true
}
});
@@ -756,14 +761,15 @@ define([
"user_email": item.user_info.name,
"user_name": item.user_info.nickname,
"permission": item.permission,
'is_admin': item.is_admin,
'for_user': true
}
});
$add_item.after(new_item.el);
});
emails_input.select2("val", "");
$('option', $perm).removeAttr('selected');
$('[value="rw"]', $perm).attr('selected', 'selected');
$('[value="r"]', $perm).removeAttr('selected');
$error.addClass('hide');
}
if (data.failed.length > 0) {

View File

@@ -3,8 +3,9 @@ define([
'underscore',
'backbone',
'common',
'app/views/widgets/hl-item-view'
], function($, _, Backbone, Common, HLItemView) {
'app/views/widgets/hl-item-view',
'app/views/share'
], function($, _, Backbone, Common, HLItemView, ShareView) {
'use strict';
var SharedRepoView = HLItemView.extend({
@@ -14,13 +15,31 @@ define([
mobileTemplate: _.template($('#shared-repo-mobile-tmpl').html()),
events: {
'click .unshare-btn': 'removeShare'
'click .unshare-btn': 'removeShare',
'click .repo-share-btn': 'share'
},
initialize: function() {
HLItemView.prototype.initialize.call(this);
},
share: function() {
var options = {
'is_repo_owner': false,
'is_admin': true, // only for shared repo
'is_virtual': false,
'user_perm': 'rw',
'repo_id': this.model.get('id'),
'repo_encrypted': this.model.get('encrypted'),
'is_dir': true,
'dirent_path': '/',
'obj_name': this.model.get('name')
};
new ShareView(options);
return false;
},
removeShare: function(e) {
var _this = this,
success_callback = function(data) {