From 472a62730bb5a2739e2fc43e02a2299633e61e92 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 30 Jun 2017 17:24:22 +0200 Subject: [PATCH] Fix profile creation and add a link to the profile app --- customize.dist/translations/messages.fr.js | 2 ++ customize.dist/translations/messages.js | 2 ++ www/common/cryptpad-common.js | 14 ++++++++++++++ www/profile/main.js | 9 +++------ www/profile/main.less | 7 +++++++ 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/customize.dist/translations/messages.fr.js b/customize.dist/translations/messages.fr.js index 5a087d8ee..bca33cb26 100644 --- a/customize.dist/translations/messages.fr.js +++ b/customize.dist/translations/messages.fr.js @@ -241,7 +241,9 @@ define(function () { out.canvas_widthLabel = "taille: {0}"; // Profile + out.profileButton = "Profil"; // dropdown menu out.profile_urlPlaceholder = 'URL'; + out.profile_namePlaceholder = 'Nom ou pseudo pour le profil'; out.profile_avatar = "Avatar"; out.profile_upload = " Importer un nouvel avatar"; out.profile_error = "Erreur lors de la création du profil : {0}"; diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 671109e12..02f682d4d 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -243,7 +243,9 @@ define(function () { out.canvas_widthLabel = "Width: {0}"; // Profile + out.profileButton = "Profile"; // dropdown menu out.profile_urlPlaceholder = 'URL'; + out.profile_namePlaceholder = 'Name displayed in your profile'; out.profile_avatar = "Avatar"; out.profile_upload = " Upload a new avatar"; out.profile_error = "Error while creating your profile: {0}"; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 0bc7c3680..628982c29 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -1476,6 +1476,13 @@ define([ content: Messages.user_rename }); } + if (account) { + options.push({ + tag: 'a', + attributes: {'class': 'profile'}, + content: Messages.profileButton + }); + } if (parsed && (!parsed.type || parsed.type !== 'settings')) { options.push({ tag: 'a', @@ -1535,6 +1542,13 @@ define([ window.location.href = '/settings/'; } }); + $userAdmin.find('a.profile').click(function () { + if (parsed && parsed.type) { + window.open('/profile/'); + } else { + window.location.href = '/profile/'; + } + }); $userAdmin.find('a.login').click(function () { if (window.location.pathname !== "/") { sessionStorage.redirectTo = window.location.href; diff --git a/www/profile/main.js b/www/profile/main.js index d901433b3..3077c73d0 100644 --- a/www/profile/main.js +++ b/www/profile/main.js @@ -156,11 +156,11 @@ define([ var getValue = function (cb) { cb(APP.lm.proxy.name); }; - var placeholder = Messages.anonymous; + var placeholder = Messages.profile_namePlaceholder; if (APP.readOnly) { var $span = $('', {'class': DISPLAYNAME_ID}).appendTo($block); getValue(function (value) { - $span.text(value || placeholder); + $span.text(value || Messages.anonymous); }); return; } @@ -257,7 +257,6 @@ define([ Cryptpad.whenRealtimeSyncs(APP.lm.realtime, function () { var driveRt = Cryptpad.getStore().getProxy().info.realtime; Cryptpad.whenRealtimeSyncs(driveRt, function () { - Cryptpad.changeDisplayName(); displayAvatar(); }); }); @@ -393,14 +392,12 @@ define([ } obj.profile.edit = Cryptpad.getEditHashFromKeys(channel, secret.keys); obj.profile.view = Cryptpad.getViewHashFromKeys(channel, secret.keys); - obj.profile.name = APP.rt.proxy[Cryptpad.displayNameKey] || ''; - Cryptpad.changeDisplayName(); andThen(obj.profile.edit); }); }; if (!Cryptpad.isLoggedIn()) { - var $p = $('

').text(Messages.error_register); + var $p = $('

', {id: CREATE_ID}).append(Messages.profile_register); var $a = $('', { href: '/register/' }); diff --git a/www/profile/main.less b/www/profile/main.less index 50461e6fc..abdcf8d0d 100644 --- a/www/profile/main.less +++ b/www/profile/main.less @@ -129,4 +129,11 @@ } } } + #createProfile { + height: 100%; + display: flex; + flex-flow: column; + align-items: center; + justify-content: center; + } }