From 6eb24629c0c470ecf4e7e0e9854611a0f9642d96 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 10 Sep 2020 12:12:16 +0530 Subject: [PATCH 1/2] WIP hint at how to add contacts from access modal --- www/common/inner/access.js | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/www/common/inner/access.js b/www/common/inner/access.js index 2e1f4b4a8..d22509a48 100644 --- a/www/common/inner/access.js +++ b/www/common/inner/access.js @@ -152,7 +152,8 @@ define([ var $div = $(h('div.cp-share-column')); var _friends = Util.clone(friends); - Object.keys(_friends).forEach(function (curve) { + var friendKeys = Object.keys(_friends); + friendKeys.forEach(function (curve) { if (owners.indexOf(_friends[curve].edPublic) !== -1 || pending_owners.indexOf(_friends[curve].edPublic) !== -1 || !_friends[curve].notifications) { @@ -160,10 +161,21 @@ define([ } }); if (!Object.keys(_friends).length) { + var friendText; + if (!friendKeys.length) { + console.error(UIElements.noContactsMessage(common)); + var findContacts = UIElements.noContactsMessage(common); + friendText = h('span.cp-app-prop-content', + findContacts.content // XXX display copy-link button too? + ); + } else { + friendText = h('span.cp-app-prop-content', Messages.access_noContact); + } + $div.append(h('div.cp-app-prop', [ Messages.contacts, h('br'), - h('span.cp-app-prop-content', Messages.access_noContact) + friendText ])); } else { var addCol = UIElements.getUserGrid(Messages.contacts, { @@ -528,7 +540,7 @@ define([ ]); }; - // Add owners column + // Add allow list column var drawAdd = function () { var priv = metadataMgr.getPrivateData(); var teamsData = Util.tryParse(JSON.stringify(priv.teams)) || {}; @@ -538,17 +550,28 @@ define([ $div.addClass('cp-overlay-container').append(h('div.cp-overlay')); var _friends = Util.clone(friends); - Object.keys(_friends).forEach(function (curve) { + var friendKeys = Object.keys(_friends); + friendKeys.forEach(function (curve) { if (owners.indexOf(_friends[curve].edPublic) !== -1 || allowed.indexOf(_friends[curve].edPublic) !== -1) { delete _friends[curve]; } }); if (!Object.keys(_friends).length) { + var friendText; + if (!friendKeys.length) { + var findContacts = UIElements.noContactsMessage(common); + friendText = h('span.cp-app-prop-content', + findContacts.content // XXX display copy-link button too? + ); + } else { + friendText = h('span.cp-app-prop-content', Messages.access_noContact); + } + $div.append(h('div.cp-app-prop', [ Messages.contacts, h('br'), - h('span.cp-app-prop-content', Messages.access_noContact) + friendText ])); } else { var addCol = UIElements.getUserGrid(Messages.contacts, { From 1eccb3f86104cd72ab23691a11775453da5a60b6 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 24 Sep 2020 11:21:46 +0530 Subject: [PATCH 2/2] add 'copy profile link' button to relevant access modal tabs --- www/common/inner/access.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/www/common/inner/access.js b/www/common/inner/access.js index 150478e50..fde29f8fe 100644 --- a/www/common/inner/access.js +++ b/www/common/inner/access.js @@ -166,7 +166,7 @@ define([ console.error(UIElements.noContactsMessage(common)); var findContacts = UIElements.noContactsMessage(common); friendText = h('span.cp-app-prop-content', - findContacts.content // XXX display copy-link button too? + findContacts.content ); } else { friendText = h('span.cp-app-prop-content', Messages.access_noContact); @@ -562,7 +562,7 @@ define([ if (!friendKeys.length) { var findContacts = UIElements.noContactsMessage(common); friendText = h('span.cp-app-prop-content', - findContacts.content // XXX display copy-link button too? + findContacts.content ); } else { friendText = h('span.cp-app-prop-content', Messages.access_noContact); @@ -1071,6 +1071,16 @@ define([ opts = opts || {}; opts.wide = true; opts.access = true; + + var hasFriends = Object.keys(common.getFriends()).length; + var buttons = hasFriends? []: UIElements.noContactsMessage(common).buttons; + buttons.unshift({ + className: 'cancel', + name: Messages.filePicker_close, + onClick: function () {}, + keys: [27], + }); + var tabs = [{ getTab: getAccessTab, title: Messages.access_main, @@ -1079,10 +1089,12 @@ define([ getTab: getAllowTab, title: Messages.access_allow, icon: "fa fa-list", + buttons: buttons, }, { getTab: getOwnersTab, title: Messages.creation_owners, icon: "fa fa-id-badge", + buttons: buttons, }]; Modal.getModal(common, opts, tabs, cb); };