From ef05ac440eb165bcca7f8fdd18d3f565cf6e0e6f Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 12 Dec 2019 18:14:17 +0100 Subject: [PATCH] Invitation link UI --- www/common/common-ui-elements.js | 61 ++++++++++++++++++++++++++++++-- www/common/outer/team.js | 14 ++++++++ 2 files changed, 72 insertions(+), 3 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 411b082e7..6c53d91af 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -1611,9 +1611,7 @@ define([ buttons: contactsButtons }; }; - hasFriends = false; var friendsObject = hasFriends ? getContacts() : noContactsMessage(common); - console.log(friendsObject); var friendsList = friendsObject.content; var contactsButtons = friendsObject.buttons; contactsButtons.unshift({ @@ -1631,10 +1629,67 @@ define([ buttons: contactsButtons, }); + var linkName, linkPassword, linkMessage; + var linKError; // Invite from link var linkContent = h('div.cp-share-modal', [ + h('p', 'XXX Invite link description...'), // XXX + linkError = h('div.alert.alert-danger', {style : 'display: none;'}), + linkName = h('input', { + placeholder: 'name...' // XXX + }), + h('br'), + linkPassword = UI.passwordInput({ + id: 'cp-teams-invite-password', + placeholder: 'password...' // XXX + }), + h('br'), + linkMessage = h('textarea', { + placeholder: 'note...' + }) ]); - var linkButtons = []; + var process = function () { + $(linkError).text('').hide(); + var name = $(linkName).val(); + var pw = $(linkPassword).val(); + var msg = $(linkMessage).val(); + if (!name || !name.trim()) { + $(linkError).text('empty name...').show(); // XXX + return true; + } + var bytes; + nThen(function (waitFor) { + // Scrypt + }).nThen(function (waitFor) { + module.execCommand('CREATE_INVITE_LINK', { + name: name, + password: pw, + message: msg, + // send scrypt result + teamId: config.teamId, + }, waitFor(function (obj) { + if (obj && obj.error) { + waitFor.abort(); + return void $(linkError).text('ERROR '+obj.error).show(); // XXX + } + // Display result here + })); + }); + return true; + }; + var linkButtons = [{ + className: 'cancel', + name: Messages.cancel, + onClick: function () {}, + keys: [27] + }, { + className: 'primary', + name: 'CREATE LINK', // XXX + onClick: function () { + return process(); + }, + keys: [13] + }]; var frameLink = UI.dialog.customModal(linkContent, { buttons: linkButtons, diff --git a/www/common/outer/team.js b/www/common/outer/team.js index 62fc1b45b..eef9e05cc 100644 --- a/www/common/outer/team.js +++ b/www/common/outer/team.js @@ -1259,6 +1259,17 @@ define([ ctx.store.messenger.openTeamChat(team.getChatData(), onUpdate, cId, cb); }; + var createInviteLink = function (ctx, data, cId, cb) { + var team = ctx.teams[data.teamId]; + // var roster = team.roster; + // var name = data.name; + // var password = data.password; + // var msg = data.message; + cb({ + error: 'NOT_IMPLEMENTED' + }); + }; + Team.init = function (cfg, waitFor, emit) { var team = {}; var store = cfg.store; @@ -1412,6 +1423,9 @@ define([ if (cmd === 'GET_EDITABLE_FOLDERS') { return void getEditableFolders(ctx, data, clientId, cb); } + if (cmd === 'CREATE_INVITE_LINK') { + return void createInviteLink(ctx, data, clientId, cb); + } }; return team;