Add permissions table

pull/1/head
yflory 5 years ago
parent 289f71ae8b
commit b04d8c0821

@ -798,6 +798,25 @@ define([
cb(members); cb(members);
}; };
// Return folders with edit rights available to everybody (decrypted pad href)
var getEditableFolders = function (ctx, data, cId, cb) {
var teamId = data.teamId;
if (!teamId) { return void cb({error: 'EINVAL'}); }
var team = ctx.teams[teamId];
if (!team) { return void cb ({error: 'ENOENT'}); }
var folders = team.manager.folders || {};
var ids = Object.keys(folders).filter(function (id) {
return !folders[id].proxy.version;
});
cb(ids.map(function (id) {
var uo = Util.find(team, ['user', 'userObject']);
return {
name: Util.find(folders, [id, 'proxy', 'metadata', 'title']),
path: uo ? uo.findFile(id)[0] : []
};
}));
};
var getTeamMetadata = function (ctx, data, cId, cb) { var getTeamMetadata = function (ctx, data, cId, cb) {
var teamId = data.teamId; var teamId = data.teamId;
if (!teamId) { return void cb({error: 'EINVAL'}); } if (!teamId) { return void cb({error: 'EINVAL'}); }
@ -1379,6 +1398,9 @@ define([
if (cmd === 'CREATE_TEAM') { if (cmd === 'CREATE_TEAM') {
return void createTeam(ctx, data, clientId, cb); return void createTeam(ctx, data, clientId, cb);
} }
if (cmd === 'GET_EDITABLE_FOLDERS') {
return void getEditableFolders(ctx, data, clientId, cb);
}
}; };
return team; return team;

@ -138,6 +138,11 @@
} }
.cp-team-roster { .cp-team-roster {
.avatar_main(50px); .avatar_main(50px);
.cp-app-team-roster-header {
button:not(:last-child) {
margin-right: 5px;
}
}
.cp-team-roster-member { .cp-team-roster-member {
display: flex; display: flex;
align-items: center; align-items: center;
@ -184,5 +189,25 @@
} }
} }
} }
#cp-teams-roster-dialog {
table {
width: 100%;
table-layout: fixed;
&.cp-teams-generic {
margin-bottom: 30px;
}
}
p {
text-align: left;
}
ul {
text-align: left;
padding-left: 30px;
}
li {
font-weight: bold;
}
}
} }

@ -727,6 +727,58 @@ define([
$header.append(leave); $header.append(leave);
} }
var table = h('button.btn.btn-primary', Messages.teams_table);
$(table).click(function (e) {
e.stopPropagation();
var $blockContainer = UIElements.createModal({
id: 'cp-teams-roster-dialog',
}).show();
var makeRow = function (arr, first) {
return arr.map(function (val) {
return h(first ? 'th' : 'td', val);
});
};
// Global rights
var rows = [];
var firstRow = ['', Messages.share_linkView, Messages.share_linkEdit,
Messages.teams_table_admins, Messages.teams_table_owners];
rows.push(h('tr', makeRow(firstRow, true)));
rows.push(h('tr', makeRow([Messages.team_viewers, 'x', '', '', ''])));
rows.push(h('tr', makeRow([Messages.team_members, 'x', 'x', '', ''])));
rows.push(h('tr', makeRow([Messages.team_admins, 'x', 'x', 'x', ''])));
rows.push(h('tr', makeRow([Messages.team_owner, 'x', 'x', 'x', 'x'])));
var t = h('table.cp-teams-generic', rows);
var content = [
h('h4', Messages.teams_table_generic),
h('p', Messages.teams_table_genericHint),
t
];
APP.module.execCommand('GET_EDITABLE_FOLDERS', {
teamId: APP.team
}, function (arr) {
console.log(arr);
if (!Array.isArray(arr) || !arr.length) {
return void $blockContainer.find('.cp-modal').append(content);
}
content.push(h('h4', Messages.teams_table_specific));
content.push(h('p', Messages.teams_table_specificHint));
var paths = arr.map(function (obj) {
obj.path.push(obj.name);
return h('li', obj.path.join('/'));
});
content.push(h('ul', paths));
var rows = [];
rows.push(h('tr', makeRow(firstRow, true)));
rows.push(h('tr', makeRow([Messages.team_viewers, 'x', 'x', '', ''])));
content.push(h('table', rows));
$blockContainer.find('.cp-modal').append(content);
});
});
$header.append(table);
var noPending = pending.length ? '' : '.cp-hidden'; var noPending = pending.length ? '' : '.cp-hidden';
return [ return [

Loading…
Cancel
Save