From d90115fbc91b4f770d6e9b5809ab2695dc706602 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 24 Sep 2019 10:52:03 +0200 Subject: [PATCH 01/98] Add translation keys and remove/fix XXX --- www/common/common-messenger.js | 1052 ------------------------------ www/common/common-ui-elements.js | 17 +- www/common/messenger-ui.js | 4 +- www/common/notifications.js | 11 +- www/common/outer/roster.js | 2 +- www/team/inner.js | 50 +- 6 files changed, 39 insertions(+), 1097 deletions(-) delete mode 100644 www/common/common-messenger.js diff --git a/www/common/common-messenger.js b/www/common/common-messenger.js deleted file mode 100644 index c02d9d4eb..000000000 --- a/www/common/common-messenger.js +++ /dev/null @@ -1,1052 +0,0 @@ -define([ - '/bower_components/chainpad-crypto/crypto.js', - '/common/common-hash.js', - '/common/common-util.js', - '/common/common-realtime.js', - '/common/common-constants.js', - '/customize/messages.js', - - '/bower_components/nthen/index.js', -], function (Crypto, Hash, Util, Realtime, Constants, Messages, nThen) { - 'use strict'; - var Curve = Crypto.Curve; - - var Msg = { - inputs: [], - }; - - var Types = { - message: 'MSG', - update: 'UPDATE', - unfriend: 'UNFRIEND', - mapId: 'MAP_ID', - mapIdAck: 'MAP_ID_ACK' - }; - - var clone = function (o) { - return JSON.parse(JSON.stringify(o)); - }; - - var convertToUint8 = function (obj) { - var l = Object.keys(obj).length; - var u = new Uint8Array(l); - for (var i = 0; i we asked for an invalid last known hash - if (parsed.error && parsed.error === "EINVAL") { - setChannelHead(parsed.channel, '', function () { - getChannelMessagesSince(getChannel(parsed.channel), {}, {}); - }); - return; - } - - // End of initial history - if (parsed.state && parsed.state === 1 && parsed.channel) { - // parsed.channel is Ready - // channel[parsed.channel].ready(); - channels[parsed.channel].ready = true; - onChannelReady(parsed.channel); - return; - } - } - // Initial history message - var chan = parsed[3]; - if (!chan || !channels[chan]) { return; } - pushMsg(channels[chan], parsed[4]); - }; - - var onMessage = function (msg, sender, chan) { - if (!channels[chan.id]) { return; } - - var isMessage = pushMsg(channels[chan.id], msg); - if (isMessage) { - if (channels[chan.id].wc.myID !== sender) { - // Don't notify for your own messages - //channels[chan.id].notify(); - } - //channels[chan.id].refresh(); - } - }; - - // listen for messages... - network.on('message', function(msg, sender) { - onDirectMessage(msg, sender); - }); - - var removeFriend = function (curvePublic, _cb) { - var cb = Util.once(_cb); - if (typeof(cb) !== 'function') { throw new Error('NO_CALLBACK'); } - var data = getFriend(proxy, curvePublic); - - if (!data) { - // friend is not valid - console.error('friend is not valid'); - return void cb({error: 'INVALID_FRIEND'}); - } - - var channel = channels[data.channel]; - if (!channel) { - return void cb({error: "NO_SUCH_CHANNEL"}); - } - - if (!network.webChannels.some(function (wc) { - return wc.id === channel.id; - })) { - console.error('bad channel: ', curvePublic); - } - - var msg = [Types.unfriend, proxy.curvePublic, +new Date()]; - var msgStr = JSON.stringify(msg); - var cryptMsg = channel.encrypt(msgStr); - - try { - if (store.mailbox && data.curvePublic && data.notifications) { - store.mailbox.sendTo('UNFRIEND', { - curvePublic: proxy.curvePublic - }, { - channel: data.notifications, - curvePublic: data.curvePublic - }, function (obj) { - console.log(obj); - if (obj && obj.error) { - return void cb(obj); - } - removeFromFriendList(curvePublic, function () { - delete channels[channel.id]; - emit('UNFRIEND', { - curvePublic: curvePublic, - fromMe: true - }); - cb(); - }); - }); - } else { - removeFromFriendList(curvePublic, function () { - delete channels[channel.id]; - emit('UNFRIEND', { - curvePublic: curvePublic, - fromMe: true - }); - cb(); - }); - } - channel.wc.bcast(cryptMsg).then(function () {}, function (err) { - console.error(err); - }); - } catch (e) { - cb({error: e}); - } - }; - - var openChannel = function (data) { - var keys = data.keys; - var encryptor = data.encryptor || Curve.createEncryptor(keys); - var channel = { - id: data.channel, - isFriendChat: data.isFriendChat, - isPadChat: data.isPadChat, - padChan: data.padChan, - readOnly: data.readOnly, - sending: false, - messages: [], - userList: [], - mapId: {}, - }; - - channel.encrypt = function (msg) { - if (channel.readOnly) { return; } - return encryptor.encrypt(msg); - }; - channel.decrypt = data.decrypt || function (msg) { - return encryptor.decrypt(msg); - }; - - var onJoining = function (peer) { - if (peer === Msg.hk) { return; } - if (channel.userList.indexOf(peer) !== -1) { return; } - channel.userList.push(peer); - if (channel.readOnly) { return; } - - // Join event will be sent once we are able to ID this peer - var myData = createData(proxy); - delete myData.channel; - var msg = [Types.mapId, myData, channel.wc.myID]; - var msgStr = JSON.stringify(msg); - var cryptMsg = channel.encrypt(msgStr); - var data = { - channel: channel.id, - msg: cryptMsg - }; - network.sendto(peer, JSON.stringify(data)); - }; - - var onLeaving = function (peer) { - var i = channel.userList.indexOf(peer); - while (i !== -1) { - channel.userList.splice(i, 1); - i = channel.userList.indexOf(peer); - } - // update status - var otherData = channel.mapId[peer]; - if (!otherData) { return; } - - // Make sure the leaving user is not connected with another netflux id - if (channel.userList.some(function (nId) { - return channel.mapId[nId] - && channel.mapId[nId].curvePublic === otherData.curvePublic; - })) { return; } - - // Send the notification - emit('LEAVE', { - info: otherData, - id: channel.id - }); - }; - - var onOpen = function (chan) { - channel.wc = chan; - channels[data.channel] = channel; - - chan.on('message', function (msg, sender) { - onMessage(msg, sender, chan); - }); - - chan.members.forEach(function (peer) { - if (peer === Msg.hk) { return; } - if (channel.userList.indexOf(peer) !== -1) { return; } - channel.userList.push(peer); - }); - chan.on('join', onJoining); - chan.on('leave', onLeaving); - - // FIXME don't subscribe to the channel implicitly - getChannelMessagesSince(channel, data, keys); - }; - network.join(data.channel).then(onOpen, function (err) { - console.error(err); - }); - network.on('reconnect', function () { - if (channel && channel.stopped) { return; } - if (!channels[data.channel]) { return; } - - if (!joining[data.channel]) { - joining[data.channel] = function () { - console.log("reconnected to %s", data.channel); - }; - } else { - console.error("Reconnected to a chat channel (%s) which was not fully connected", data.channel); - } - - network.join(data.channel).then(onOpen, function (err) { - console.error(err); - }); - }); - }; - - messenger.getFriendList = function (cb) { - var friends = proxy.friends; - if (!friends) { return void cb(void 0, []); } - - cb(void 0, Object.keys(proxy.friends).filter(function (k) { - return k !== 'me'; - })); - }; - - var sendMessage = function (id, payload, cb) { - var channel = getChannel(id); - if (!channel) { return void cb({error: 'NO_CHANNEL'}); } - if (channel.readOnly) { return void cb({error: 'FORBIDDEN'}); } - if (!network.webChannels.some(function (wc) { - if (wc.id === channel.wc.id) { return true; } - })) { - return void cb({error: 'NO_SUCH_CHANNEL'}); - } - - var msg = [Types.message, proxy.curvePublic, +new Date(), payload]; - if (!channel.isFriendChat) { - var name = proxy[Constants.displayNameKey] || - Messages.anonymous + '#' + proxy.uid.slice(0,5); - msg.push(name); - } - var msgStr = JSON.stringify(msg); - var cryptMsg = channel.encrypt(msgStr); - - channel.wc.bcast(cryptMsg).then(function () { - pushMsg(channel, cryptMsg); - cb(); - }, function (err) { - cb({error: err}); - }); - }; - - var getStatus = function (chanId, cb) { - // Display green status if one member is not me - var channel = getChannel(chanId); - if (!channel) { return void cb('NO_SUCH_CHANNEL'); } - var online = channel.userList.some(function (nId) { - var data = channel.mapId[nId] || undefined; - if (!data) { return false; } - return data.curvePublic !== proxy.curvePublic; - }); - cb(online); - }; - - var getMyInfo = function (cb) { - cb({ - curvePublic: proxy.curvePublic, - displayName: proxy[Constants.displayNameKey] - }); - }; - - var loadFriend = function (friend, cb) { - var channel = friend.channel; - if (getChannel(channel)) { return void cb(); } - - joining[channel] = cb; - var keys = Curve.deriveKeys(friend.curvePublic, proxy.curvePrivate); - var data = { - keys: keys, - channel: friend.channel, - lastKnownHash: friend.lastKnownHash, - owners: [proxy.edPublic, friend.edPublic], - isFriendChat: true - }; - openChannel(data); - }; - - // Friend added in our contacts in the current worker - messenger.onFriendAdded = function (friendData) { - if (!allowFriendsChannels) { return; } - var friend = friends[friendData.curvePublic]; - if (typeof(friend) !== 'object') { return; } - var channel = friend.channel; - if (!channel) { return; } - loadFriend(friend, function () { - emit('FRIEND', { - curvePublic: friend.curvePublic, - }); - }); - }; - messenger.onFriendRemoved = function (curvePublic, chanId) { - var channel = channels[chanId]; - if (!channel) { return; } - if (channel.wc) { - channel.wc.leave(Types.unfriend); - } - delete channels[channel.id]; - emit('UNFRIEND', { - curvePublic: curvePublic, - fromMe: true - }); - }; - - var ready = false; - var initialized = false; - var init = function () { - allowFriendsChannels = true; - if (initialized) { return; } - initialized = true; - var friends = getFriendList(proxy); - - nThen(function (waitFor) { - Object.keys(friends).forEach(function (key) { - if (key === 'me') { return; } - var friend = clone(friends[key]); - if (typeof(friend) !== 'object') { return; } - var channel = friend.channel; - if (!channel) { return; } - loadFriend(friend, waitFor()); - }); - // TODO load rooms - }).nThen(function () { - ready = true; - emit('READY'); - }); - }; - //init(); - - var getRooms = function (data, cb) { - if (data && data.curvePublic) { - var curvePublic = data.curvePublic; - // We need to get data about a new friend's room - var friend = getFriend(proxy, curvePublic); - if (!friend) { return void cb({error: 'NO_SUCH_FRIEND'}); } - var channel = getChannel(friend.channel); - if (!channel) { return void cb({error: 'NO_SUCH_CHANNEL'}); } - return void cb([{ - id: channel.id, - isFriendChat: true, - name: friend.displayName, - lastKnownHash: friend.lastKnownHash, - curvePublic: friend.curvePublic, - messages: channel.messages - }]); - } - - if (data && data.padChat) { - var pCChannel = getChannel(data.padChat); - if (!pCChannel) { return void cb({error: 'NO_SUCH_CHANNEL'}); } - return void cb([{ - id: pCChannel.id, - isPadChat: true, - messages: pCChannel.messages - }]); - } - - var rooms = Object.keys(channels).map(function (id) { - var r = getChannel(id); - var name, lastKnownHash, curvePublic; - if (r.isFriendChat) { - var friend = getFriendFromChannel(id); - if (!friend) { return null; } - name = friend.displayName; - lastKnownHash = friend.lastKnownHash; - curvePublic = friend.curvePublic; - } else if (r.isPadChat) { - return; - } else { - // TODO room get metadata (name) && lastKnownHash - } - return { - id: r.id, - isFriendChat: r.isFriendChat, - name: name, - lastKnownHash: lastKnownHash, - curvePublic: curvePublic, - messages: r.messages - }; - }).filter(function (x) { return x; }); - cb(rooms); - }; - - var getUserList = function (data, cb) { - var room = getChannel(data.id); - if (!room) { return void cb({error: 'NO_SUCH_CHANNEL'}); } - if (room.isFriendChat) { - var friend = getFriendFromChannel(data.id); - if (!friend) { return void cb({error: 'NO_SUCH_FRIEND'}); } - cb([friend]); - } else { - // TODO room userlist in rooms... - // (this is the static userlist, not the netflux one) - cb([]); - } - }; - - var validateKeys = {}; - messenger.storeValidateKey = function (chan, key) { - validateKeys[chan] = key; - }; - - var openPadChat = function (data, cb) { - var channel = data.channel; - if (getChannel(channel)) { - emit('PADCHAT_READY', channel); - return void cb(); - } - var secret = data.secret; - if (secret.keys.cryptKey) { - secret.keys.cryptKey = convertToUint8(secret.keys.cryptKey); - } - var encryptor = Crypto.createEncryptor(secret.keys); - var vKey = (secret.keys && secret.keys.validateKey) || validateKeys[secret.channel]; - var chanData = { - padChan: data.secret && data.secret.channel, - readOnly: typeof(secret.keys) === "object" && !secret.keys.validateKey, - encryptor: encryptor, - channel: data.channel, - isPadChat: true, - decrypt: function (msg) { - return encryptor.decrypt(msg, vKey); - }, - //lastKnownHash: friend.lastKnownHash, - //owners: [proxy.edPublic, friend.edPublic], - //isFriendChat: true - }; - openChannel(chanData); - joining[channel] = function () { - emit('PADCHAT_READY', channel); - }; - cb(); - }; - - var clearOwnedChannel = function (id, cb) { - var channel = getChannel(id); - if (!channel) { return void cb({error: 'NO_CHANNEL'}); } - if (!store.rpc) { return void cb({error: 'RPC_NOT_READY'}); } - store.rpc.clearOwnedChannel(id, function (err) { - cb({error:err}); - }); - channel.messages = []; - }; - - network.on('disconnect', function () { - emit('DISCONNECT'); - }); - network.on('reconnect', function () { - emit('RECONNECT'); - }); - - messenger.leavePad = function (padChan) { - // Leave chat and prevent reconnect when we leave a pad - delete validateKeys[padChan]; - Object.keys(channels).some(function (chatChan) { - var channel = channels[chatChan]; - if (channel.padChan !== padChan) { return; } - if (channel.wc) { channel.wc.leave(); } - channel.stopped = true; - delete channels[chatChan]; - return true; - }); - }; - - messenger.execCommand = function (obj, cb) { - var cmd = obj.cmd; - var data = obj.data; - if (cmd === 'INIT_FRIENDS') { - init(); - return void cb(); - } - if (cmd === 'IS_READY') { - return void cb(ready); - } - if (cmd === 'GET_ROOMS') { - return void getRooms(data, cb); - } - if (cmd === 'GET_USERLIST') { - return void getUserList(data, cb); - } - if (cmd === 'OPEN_PAD_CHAT') { - return void openPadChat(data, cb); - } - if (cmd === 'GET_MY_INFO') { - return void getMyInfo(cb); - } - if (cmd === 'REMOVE_FRIEND') { - return void removeFriend(data, cb); - } - if (cmd === 'GET_STATUS') { - return void getStatus(data, cb); - } - if (cmd === 'GET_MORE_HISTORY') { - return void getMoreHistory(data.id, data.sig, data.count, cb); - } - if (cmd === 'SEND_MESSAGE') { - return void sendMessage(data.id, data.content, cb); - } - if (cmd === 'SET_CHANNEL_HEAD') { - return void setChannelHead(data.id, data.sig, cb); - } - if (cmd === 'CLEAR_OWNED_CHANNEL') { - return void clearOwnedChannel(data, cb); - } - }; - - Object.freeze(messenger); - - return messenger; - }; - - return Msg; -}); diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 129b6a46f..0ca2796bd 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -771,7 +771,7 @@ define([ id: id }; }); - var teamsList = UIElements.getFriendsList('Share with a team', { // XXX + var teamsList = UIElements.getFriendsList(Messages.share_linkTeam, { common: common, noFilter: true, friends: teams @@ -1182,7 +1182,7 @@ define([ var hasFriends = Object.keys(config.friends || {}).length !== 0; if (!hasFriends) { - return void UI.alert('No friend to invite'); // XXX + return void UI.alert(Messages.team_noFriend); } var privateData = common.getMetadataMgr().getPrivateData(); var team = privateData.teams[config.teamId]; @@ -1203,7 +1203,7 @@ define([ $btn.prop('disabled', 'disabled'); } }; - var list = UIElements.getFriendsList('Pick the friends you want to invite to the team', { // XXX + var list = UIElements.getFriendsList(Messages.team_pickFriends, { common: common, friends: config.friends, }, refreshButton); @@ -1217,7 +1217,7 @@ define([ keys: [27] }, { className: 'primary', - name: 'INVITE', // XXX + name: Messages.team_inviteModalButton, onClick: function () { var $sel = $div.find('.cp-share-friend.cp-selected'); var sel = $sel.toArray(); @@ -2895,7 +2895,7 @@ define([ 'data-value': teamId, 'href': '#' }, - content: 'TEAM: ' + t.name + '' // XXX + content: Messages._getKey('team_pcsSelectEntry', [Util.fixHTML(t.name)]) }; }); teamOptions.unshift({ @@ -2926,9 +2926,9 @@ define([ $teamBlock.setValue(id); }); team = h('div.cp-creation-team', [ - 'Store in', // XXX + Messages.team_pcsSelectLabel, $teamBlock[0], - createHelper('#', "The pad will be stored in your team's drive. If this is an owned pad, it will be owned by the team.") // XXX + createHelper('#', Messages.team_pcsSelectHelp) ]); if (privateData.storeInTeam) { $teamBlock.setValue(privateData.storeInTeam); @@ -3717,8 +3717,7 @@ define([ var verified = UIElements.getVerifiedFriend(common, msg.author, name); - //var text = Messages._getKey('', [name, title]); // XXX - var text = name + " has invited you to join the team " + teamName +""; + var text = Messages._getKey('team_invitedToTeam', [name, teamName]); var div = h('div', [ UI.setHTML(h('p'), text), diff --git a/www/common/messenger-ui.js b/www/common/messenger-ui.js index e11b33b93..4dcff9c8e 100644 --- a/www/common/messenger-ui.js +++ b/www/common/messenger-ui.js @@ -716,7 +716,7 @@ define([ if (room.isFriendChat) { $parentEl = $userlist.find('.cp-app-contacts-friends'); } else if (room.isTeamChat) { - $parentEl = $userlist.find('.cp-app-contacts-padchat'); // XXX + $parentEl = $userlist.find('.cp-app-contacts-padchat'); } else if (room.isPadChat) { $parentEl = $userlist.find('.cp-app-contacts-padchat'); } else { @@ -829,7 +829,7 @@ define([ return void console.error('Invalid team chat'); } var room = rooms[0]; - room.name = 'TEAMS'; // XXX + room.name = Messages.type.team; rooms.forEach(initializeRoom); }); }; diff --git a/www/common/notifications.js b/www/common/notifications.js index 6c1fd3c25..c5a94c275 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -261,8 +261,7 @@ define([ var name = Util.fixHTML(msg.content.user.displayName) || Messages.anonymous; var teamName = Util.fixHTML(Util.find(msg, ['content', 'team', 'metadata', 'name']) || ''); content.getFormatText = function () { - var text = name + " has invited you to join the team " + teamName +""; - // XXX + var text = Messages._getKey('team_invitedToTeam', [name, teamName]); return text; }; if (!content.archived) { @@ -280,8 +279,7 @@ define([ var name = Util.fixHTML(msg.content.user.displayName) || Messages.anonymous; var teamName = Util.fixHTML(Util.find(msg, ['content', 'teamName']) || ''); content.getFormatText = function () { - var text = name + " has kicked you from join the team " + teamName +""; - // XXX + var text = Messages._getKey('team_kickedFromTeam', [name, teamName]); return text; }; if (!content.archived) { @@ -296,10 +294,9 @@ define([ // Display the notification var name = Util.fixHTML(msg.content.user.displayName) || Messages.anonymous; var teamName = Util.fixHTML(Util.find(msg, ['content', 'team', 'metadata', 'name']) || ''); - //var key = 'owner_request_' + (msg.content.answer ? 'accepted' : 'declined'); + var key = 'team_' + (msg.content.answer ? 'accept' : 'decline') + 'Invitation'; content.getFormatText = function () { - //return Messages._getKey(key, [name, title]); // XXX - return name +' has ' + (msg.content.answer ? 'accepted' : 'declined') + ' your offer to join the team ' + teamName + ''; + return Messages._getKey(key, [name, teamName]); }; if (!content.archived) { content.dismissHandler = defaultDismiss(common, data); diff --git a/www/common/outer/roster.js b/www/common/outer/roster.js index 6730d3261..a8a3335e8 100644 --- a/www/common/outer/roster.js +++ b/www/common/outer/roster.js @@ -446,7 +446,7 @@ var factory = function (Util, Hash, CPNetflux, Sortify, nThen, Crypto) { // deleted while you are open // emit an event var onChannelError = function (info) { - if (!ready) { return void cb(info); } // XXX make sure we don't reconnect + if (!ready) { return void cb(info); } console.error("CHANNEL_ERROR", info); }; diff --git a/www/team/inner.js b/www/team/inner.js index 68851dd6e..27ee9a803 100644 --- a/www/team/inner.js +++ b/www/team/inner.js @@ -173,7 +173,7 @@ define([ showCategories(categories[key]); }); - $category.append(Messages['team_cat_'+key] || key); // XXX + $category.append(Messages['team_cat_'+key] || key); }); if (active === 'drive') { APP.$rightside.addClass('cp-rightside-drive'); @@ -259,8 +259,8 @@ define([ makeBlock('info', function (common, cb) { cb([ - h('h3', 'Team application'), // XXX - h('p', 'From here you can ...') // XXX + h('h3', Messages.team_infoLabel), + h('p', Messages.team_infoContent) ]); }); @@ -274,13 +274,12 @@ define([ var lis = []; Object.keys(obj).forEach(function (id) { var team = obj[id]; - var a = h('a', 'Open'); + var a = h('a', Messages.team_listLoad); var avatar = h('span.cp-avatar.cp-team-list-avatar'); - lis.push(h('li', h('ul', [ - h('li', avatar), // XXX - h('li', 'Name: ' + team.metadata.name), // XXX - h('li', 'ID: ' + id), // XXX - h('li', a) // XXX + lis.push(h('li', h('ul', [ // XXX UI + h('li', avatar), + h('li', team.metadata.name), + h('li', a) ]))); common.displayAvatar($(avatar), team.metadata.avatar, team.metadata.name); $(a).click(function () { @@ -305,11 +304,11 @@ define([ makeBlock('create', function (common, cb) { var content = []; - content.push(h('h3', 'Create a team')); // XXX - content.push(h('label', 'Team name')); // XXX + content.push(h('h3', Messages.team_createLabel)); + content.push(h('label', Messages.team_createName)); var input = h('input', {type:'text'}); content.push(input); - var button = h('button.btn.btn-success', 'Create'); // XXX + var button = h('button.btn.btn-success', Messages.creation_create); content.push(h('br')); content.push(h('br')); content.push(button); @@ -403,7 +402,7 @@ define([ // If they're a member and I have a higher role than them, I can promote them to admin if (!isMe && myRole > theirRole && theirRole === 0) { var promote = h('span.fa.fa-angle-double-up', { - title: 'Promote' // XXX + title: Messages.team_rosterPromote }); $(promote).click(function () { data.role = 'ADMIN'; @@ -416,7 +415,7 @@ define([ // (if they're not already a MEMBER) if (!isMe && myRole >= theirRole && theirRole > 0) { var demote = h('span.fa.fa-angle-double-down', { - title: 'Demote' // XXX + title: Messages.team_rosterDemote }); $(demote).click(function () { data.role = ROLES[theirRole - 1] || 'MEMBER'; @@ -428,7 +427,7 @@ define([ // If I'm not a member and I have an equal or higher role than them, I can remove them if (!isMe && myRole > 0 && myRole >= theirRole) { var remove = h('span.fa.fa-times', { - title: 'Remove' // XXX + title: Messages.team_rosterKick }); $(remove).click(function () { $(remove).hide(); @@ -487,15 +486,14 @@ define([ }).map(function (k) { return makeMember(common, roster[k], me); }); - // XXX LEAVE the team button - // XXX INVITE to the team button + var header = h('div.cp-app-team-roster-header'); var $header = $(header); // If you're an admin or an owner, you can invite your friends to the team // TODO and acquaintances later? if (me && (me.role === 'ADMIN' || me.role === 'OWNER')) { - var invite = h('button.btn.btn-primary', 'INVITE A FRIEND'); + var invite = h('button.btn.btn-primary', Messages.team_inviteButton); var inviteFriends = common.getFriends(); Object.keys(inviteFriends).forEach(function (curve) { // Keep only friends that are not already in the team and that you can contact @@ -517,9 +515,9 @@ define([ } if (me && (me.role === 'ADMIN' || me.role === 'MEMBER')) { - var leave = h('button.btn.btn-danger', 'LEAVE THE TEAM'); + var leave = h('button.btn.btn-danger', Messages.team_leaveButton); $(leave).click(function () { - UI.confirm("Your're going to leave this team and lose access to its entire drive. Are you sure?", function (yes) { + UI.confirm(Messages.team_leaveConfirm, function (yes) { if (!yes) { return; } APP.module.execCommand('LEAVE_TEAM', { teamId: APP.team @@ -535,11 +533,11 @@ define([ return [ header, - h('h3', 'OWNER'), // XXX + h('h3', Messages.team_owner), h('div', owner), - h('h3', 'ADMINS'), // XXX + h('h3', Messages.team_admins), h('div', admins), - h('h3', 'MEMBERS'), // XXX + h('h3', Messages.team_members), h('div', members) ]; }; @@ -557,7 +555,7 @@ define([ teamId: APP.team }, function (obj) { if (obj && obj.error) { - return void UI.alert(Messages.error); // XXX + return void UI.alert(Messages.error); } common.setTeamChat(obj.channel); MessengerUI.create($(container), common, true); @@ -700,7 +698,7 @@ define([ driveAPP.loggedIn = common.isLoggedIn(); if (!driveAPP.loggedIn) { throw new Error('NOT_LOGGED_IN'); } - common.setTabTitle('TEAMS (ALPHA)'); // XXX + common.setTabTitle(Messages.type.team); // Drive data if (privateData.newSharedFolder) { @@ -712,7 +710,7 @@ define([ var $bar = $('#cp-toolbar'); var configTb = { displayed: ['useradmin', 'pageTitle', 'newpad', 'limit', 'notifications'], - pageTitle: 'TEAMS (ALPHA)', // XXX + pageTitle: Messages.type.team, metadataMgr: metadataMgr, readOnly: privateData.readOnly, sfCommon: common, From b41fd12debcc25477d0c858519939d9a1f2a6142 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 24 Sep 2019 11:49:11 +0200 Subject: [PATCH 02/98] Teams... --- www/common/common-ui-elements.js | 2 +- www/team/inner.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 0ca2796bd..513cf445f 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2895,7 +2895,7 @@ define([ 'data-value': teamId, 'href': '#' }, - content: Messages._getKey('team_pcsSelectEntry', [Util.fixHTML(t.name)]) + content: Util.fixHTML(t.name) }; }); teamOptions.unshift({ diff --git a/www/team/inner.js b/www/team/inner.js index 27ee9a803..eac2e3687 100644 --- a/www/team/inner.js +++ b/www/team/inner.js @@ -76,15 +76,15 @@ define([ var setEditable = DriveUI.setEditable; var mainCategories = { - 'general': [ - 'cp-team-info', - ], 'list': [ 'cp-team-list', ], 'create': [ 'cp-team-create', ], + 'general': [ + 'cp-team-info', + ], }; var teamCategories = { 'back': { From 5f188a2fc4cb10815379a81a20d98b936b746723 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 24 Sep 2019 11:58:57 +0200 Subject: [PATCH 03/98] Move team to teams --- www/common/application_config_internal.js | 4 ++-- www/{team => teams}/app-team.less | 0 www/{team => teams}/index.html | 0 www/{team => teams}/inner.html | 2 +- www/{team => teams}/inner.js | 2 +- www/{team => teams}/main.js | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename www/{team => teams}/app-team.less (100%) rename www/{team => teams}/index.html (100%) rename www/{team => teams}/inner.html (85%) rename www/{team => teams}/inner.js (99%) rename www/{team => teams}/main.js (98%) diff --git a/www/common/application_config_internal.js b/www/common/application_config_internal.js index 4bfe1383a..09f1604f3 100644 --- a/www/common/application_config_internal.js +++ b/www/common/application_config_internal.js @@ -11,7 +11,7 @@ define(function() { * redirected to the drive. * You should never remove the drive from this list. */ - config.availablePadTypes = ['drive', 'team', 'pad', 'sheet', 'code', 'slide', 'poll', 'kanban', 'whiteboard', + config.availablePadTypes = ['drive', 'teams', 'pad', 'sheet', 'code', 'slide', 'poll', 'kanban', 'whiteboard', /*'oodoc', 'ooslide',*/ 'file', 'todo', 'contacts']; /* The registered only types are apps restricted to registered users. * You should never remove apps from this list unless you know what you're doing. The apps @@ -20,7 +20,7 @@ define(function() { * users and these users will be redirected to the login page if they still try to access * the app */ - config.registeredOnlyTypes = ['team', 'file', 'contacts', 'oodoc', 'ooslide', 'sheet', 'notifications']; + config.registeredOnlyTypes = ['teams', 'file', 'contacts', 'oodoc', 'ooslide', 'sheet', 'notifications']; /* CryptPad is available is multiple languages, but only English and French are maintained * by the developers. The other languages may be outdated, and any missing string for a langauge diff --git a/www/team/app-team.less b/www/teams/app-team.less similarity index 100% rename from www/team/app-team.less rename to www/teams/app-team.less diff --git a/www/team/index.html b/www/teams/index.html similarity index 100% rename from www/team/index.html rename to www/teams/index.html diff --git a/www/team/inner.html b/www/teams/inner.html similarity index 85% rename from www/team/inner.html rename to www/teams/inner.html index e053dd789..243a74edf 100644 --- a/www/team/inner.html +++ b/www/teams/inner.html @@ -2,7 +2,7 @@ - +