From 007c73d36b55a3d939414e440eb8cfd38420bcd5 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 24 Sep 2019 15:25:54 +0200 Subject: [PATCH] Add a limit of teams --- www/common/outer/team.js | 1 + www/teams/inner.js | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/www/common/outer/team.js b/www/common/outer/team.js index 32cb1e617..58b486943 100644 --- a/www/common/outer/team.js +++ b/www/common/outer/team.js @@ -748,6 +748,7 @@ define([ var t = {}; Object.keys(teams).forEach(function (id) { t[id] = { + owner: teams[id].owner, name: teams[id].metadata.name, edPublic: Util.find(teams[id], ['keys', 'drive', 'edPublic']), avatar: Util.find(teams[id], ['metadata', 'avatar']) diff --git a/www/teams/inner.js b/www/teams/inner.js index 99853f415..102cb8ce8 100644 --- a/www/teams/inner.js +++ b/www/teams/inner.js @@ -303,7 +303,20 @@ define([ }); makeBlock('create', function (common, cb) { + var metadataMgr = common.getMetadataMgr(); + var privateData = metadataMgr.getPrivateData(); var content = []; + + var isOwner = Object.keys(privateData.teams || {}).some(function (id) { + return privateData.teams[id].owner; + }); + if (Object.keys(privateData.teams || {}).length >= 3 || isOwner) { + content.push(h('div.alert.alert-warning', { + role:'alert' + }, isOwner ? Messages.team_maxOwner : Messages.team_maxTeams)); + return void cb(content); + } + content.push(h('h3', Messages.team_createLabel)); content.push(h('label', Messages.team_createName)); var input = h('input', {type:'text'});