Merge pull request #1315 from cryptpad/premiumTeams
Option to increase team slots for premium users only
This commit is contained in:
commit
a6427766e9
4 changed files with 22 additions and 9 deletions
|
@ -274,6 +274,10 @@ define(function() {
|
|||
// You can change the value here.
|
||||
// AppConfig.maxOwnedTeams = 5;
|
||||
|
||||
// Same settings but for premium users (users with a custom limit included)
|
||||
// AppConfig.maxPremiumTeamsSlots = 10;
|
||||
// AppConfig.maxPremiumTeamsOwned = 10;
|
||||
|
||||
// The userlist displayed in collaborative documents is stored alongside the document data.
|
||||
// Everytime someone with edit rights joins a document or modify their user data (display
|
||||
// name, avatar, color, etc.), they update the "userlist" part of the document. When too many
|
||||
|
|
|
@ -22,6 +22,8 @@ define(['/customize/application_config.js'], function (AppConfig) {
|
|||
deprecatedKey: 'deprecated',
|
||||
MAX_TEAMS_SLOTS: AppConfig.maxTeamsSlots || 5,
|
||||
MAX_TEAMS_OWNED: AppConfig.maxOwnedTeams || 5,
|
||||
MAX_PREMIUM_TEAMS_SLOTS: Math.max(AppConfig.maxTeamsSlots || 0, AppConfig.maxPremiumTeamsSlots || 0) || 5,
|
||||
MAX_PREMIUM_TEAMS_OWNED: Math.max(AppConfig.maxTeamsOwned || 0, AppConfig.maxPremiumTeamsOwned || 0) || 5,
|
||||
// Apps
|
||||
criticalApps: ['profile', 'settings', 'debug', 'admin', 'support', 'notifications', 'calendar'],
|
||||
earlyAccessApps: ['doc', 'presentation']
|
||||
|
|
|
@ -3735,9 +3735,9 @@ define([
|
|||
});
|
||||
};
|
||||
|
||||
var MAX_TEAMS_SLOTS = Constants.MAX_TEAMS_SLOTS;
|
||||
var todo = function (yes) {
|
||||
var priv = common.getMetadataMgr().getPrivateData();
|
||||
var MAX_TEAMS_SLOTS = priv.plan ? Constants.MAX_PREMIUM_TEAMS_SLOTS : Constants.MAX_TEAMS_SLOTS;
|
||||
var numberOfTeams = Object.keys(priv.teams || {}).length;
|
||||
if (yes) {
|
||||
if (numberOfTeams >= MAX_TEAMS_SLOTS) {
|
||||
|
|
|
@ -398,7 +398,6 @@ define([
|
|||
]);
|
||||
});
|
||||
|
||||
var MAX_TEAMS_SLOTS = Constants.MAX_TEAMS_SLOTS;
|
||||
var openTeam = function (common, id, team) {
|
||||
var sframeChan = common.getSframeChannel();
|
||||
APP.module.execCommand('SUBSCRIBE', id, function () {
|
||||
|
@ -426,14 +425,18 @@ define([
|
|||
});
|
||||
});
|
||||
};
|
||||
var canCreateTeams = function (teams) {
|
||||
var canCreateTeams = function (common, teams) {
|
||||
var owned = Object.keys(teams || {}).filter(function (id) {
|
||||
return teams[id].owner;
|
||||
}).length;
|
||||
return Constants.MAX_TEAMS_OWNED - owned;
|
||||
var priv = common.getMetadataMgr().getPrivateData();
|
||||
var MAX_TEAMS_OWNED = priv.plan ? Constants.MAX_PREMIUM_TEAMS_OWNED : Constants.MAX_TEAMS_OWNED;
|
||||
return MAX_TEAMS_OWNED - owned;
|
||||
};
|
||||
var refreshList = function (common, cb) {
|
||||
var content = [];
|
||||
var priv = common.getMetadataMgr().getPrivateData();
|
||||
var MAX_TEAMS_SLOTS = priv.plan ? Constants.MAX_PREMIUM_TEAMS_SLOTS : Constants.MAX_TEAMS_SLOTS;
|
||||
APP.module.execCommand('LIST_TEAMS', null, function (obj) {
|
||||
if (!obj) { return; }
|
||||
if (obj.error === "OFFLINE") { return UI.alert(Messages.driveOfflineError); }
|
||||
|
@ -441,7 +444,7 @@ define([
|
|||
var list = [];
|
||||
var keys = Object.keys(obj).slice(0,MAX_TEAMS_SLOTS);
|
||||
var slots = '('+Math.min(keys.length, MAX_TEAMS_SLOTS)+'/'+MAX_TEAMS_SLOTS+')';
|
||||
var createSlots = canCreateTeams(obj);
|
||||
var createSlots = canCreateTeams(common, obj);
|
||||
for (var i = keys.length; i < MAX_TEAMS_SLOTS; i++) {
|
||||
obj[i] = {
|
||||
empty: true
|
||||
|
@ -526,9 +529,12 @@ define([
|
|||
var privateData = metadataMgr.getPrivateData();
|
||||
var content = [];
|
||||
|
||||
var MAX_TEAMS_OWNED = privateData.plan ? Constants.MAX_PREMIUM_TEAMS_OWNED : Constants.MAX_TEAMS_OWNED;
|
||||
var MAX_TEAMS_SLOTS = privateData.plan ? Constants.MAX_PREMIUM_TEAMS_SLOTS : Constants.MAX_TEAMS_SLOTS;
|
||||
|
||||
var isOwner = Object.keys(privateData.teams || {}).filter(function (id) {
|
||||
return privateData.teams[id].owner;
|
||||
}).length >= Constants.MAX_TEAMS_OWNED && !privateData.devMode;
|
||||
}).length >= MAX_TEAMS_OWNED && !privateData.devMode;
|
||||
|
||||
var getWarningBox = function () {
|
||||
return h('div.alert.alert-warning', {
|
||||
|
@ -536,7 +542,7 @@ define([
|
|||
}, Messages._getKey('team_maxTeams', [MAX_TEAMS_SLOTS]));
|
||||
};
|
||||
|
||||
if (Object.keys(privateData.teams || {}).length >= Constants.MAX_TEAMS_SLOTS || isOwner) {
|
||||
if (Object.keys(privateData.teams || {}).length >= MAX_TEAMS_SLOTS || isOwner) {
|
||||
content.push(getWarningBox());
|
||||
return void cb(content);
|
||||
}
|
||||
|
@ -1266,12 +1272,13 @@ define([
|
|||
var password = hashData.password;
|
||||
var seeds = InviteInner.deriveSeeds(hashData.key);
|
||||
var sframeChan = common.getSframeChannel();
|
||||
var MAX_TEAMS_SLOTS = privateData.plan ? Constants.MAX_PREMIUM_TEAMS_SLOTS : Constants.MAX_TEAMS_SLOTS;
|
||||
|
||||
if (Object.keys(privateData.teams || {}).length >= Constants.MAX_TEAMS_SLOTS) {
|
||||
if (Object.keys(privateData.teams || {}).length >= MAX_TEAMS_SLOTS) {
|
||||
return void cb([
|
||||
h('div.alert.alert-danger', {
|
||||
role: 'alert'
|
||||
}, Messages._getKey('team_maxTeams', [Constants.MAX_TEAMS_SLOTS]))
|
||||
}, Messages._getKey('team_maxTeams', [MAX_TEAMS_SLOTS]))
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue