Demote yourself as owner only if there are no other owners

pull/1/head
yflory 5 years ago
parent 1f14f75e95
commit b8f6b57019

@ -444,8 +444,14 @@ define([
redrawRoster(common); redrawRoster(common);
}); });
}; };
var makeMember = function (common, data, me) { var makeMember = function (common, data, me, roster) {
if (!data.curvePublic) { return; } if (!data.curvePublic) { return; }
var otherOwners = Object.keys(roster || {}).some(function (key) {
var user = roster[key];
return user.role === "OWNER" && user.curvePublic !== me.curvePublic && !user.pendingOwner;
});
// Avatar // Avatar
var avatar = h('span.cp-avatar.cp-team-member-avatar'); var avatar = h('span.cp-avatar.cp-team-member-avatar');
common.displayAvatar($(avatar), data.avatar, data.displayName); common.displayAvatar($(avatar), data.avatar, data.displayName);
@ -455,7 +461,6 @@ define([
$(name).append(h('em', { $(name).append(h('em', {
title: Messages.team_pendingOwnerTitle title: Messages.team_pendingOwnerTitle
}, ' ' + Messages.team_pendingOwner)); }, ' ' + Messages.team_pendingOwner));
// + XXX ability to demote yourself as owner if there is another owner
} }
// Status // Status
var status = h('span.cp-team-member-status'+(data.online ? '.online' : '')); var status = h('span.cp-team-member-status'+(data.online ? '.online' : ''));
@ -523,8 +528,10 @@ define([
} }
todo(); todo();
}); });
if (!(isMe && myRole === 2 && !otherOwners)) {
$actions.append(demote); $actions.append(demote);
} }
}
// If I'm not a member and I have an equal or higher role than them, I can remove them // If I'm not a member and I have an equal or higher role than them, I can remove them
// Note: we can't remove owners, we have to demote them first // Note: we can't remove owners, we have to demote them first
if (!isMe && myRole > 0 && myRole >= theirRole && theirRole !== 2) { if (!isMe && myRole > 0 && myRole >= theirRole && theirRole !== 2) {
@ -579,7 +586,7 @@ define([
if (roster[k].pending) { return; } if (roster[k].pending) { return; }
return roster[k].role === "OWNER" || roster[k].pendingOwner; return roster[k].role === "OWNER" || roster[k].pendingOwner;
}).map(function (k) { }).map(function (k) {
return makeMember(common, roster[k], me); return makeMember(common, roster[k], me, roster);
}); });
var admins = Object.keys(roster).filter(function (k) { var admins = Object.keys(roster).filter(function (k) {
if (roster[k].pending) { return; } if (roster[k].pending) { return; }

Loading…
Cancel
Save