From 5024ea72d2e1968ad9a55f75ae9100e67a941a2d Mon Sep 17 00:00:00 2001 From: Dan Ungureanu Date: Thu, 18 Mar 2021 19:05:38 +0200 Subject: [PATCH] UX: Show first unique letters in invite link (#12434) --- app/assets/javascripts/discourse/app/models/invite.js | 5 +++++ .../discourse/app/templates/user-invited-show.hbs | 2 +- app/serializers/invite_serializer.rb | 1 + config/locales/client.en.yml | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/app/models/invite.js b/app/assets/javascripts/discourse/app/models/invite.js index 725c66e6b0b..7ad702f223c 100644 --- a/app/assets/javascripts/discourse/app/models/invite.js +++ b/app/assets/javascripts/discourse/app/models/invite.js @@ -34,6 +34,11 @@ const Invite = EmberObject.extend({ .catch(popupAjaxError); }, + @discourseComputed("invite_key") + shortKey(key) { + return key.substr(0, 4) + "..."; + }, + @discourseComputed("groups") groupIds(groups) { return groups ? groups.map((group) => group.id) : []; diff --git a/app/assets/javascripts/discourse/app/templates/user-invited-show.hbs b/app/assets/javascripts/discourse/app/templates/user-invited-show.hbs index 8fd6eb5dca3..7676543025b 100644 --- a/app/assets/javascripts/discourse/app/templates/user-invited-show.hbs +++ b/app/assets/javascripts/discourse/app/templates/user-invited-show.hbs @@ -107,7 +107,7 @@ {{#if invite.email}} {{invite.email}} {{else}} - {{i18n "user.invited.invited_via_link" count=invite.redemption_count max=invite.max_redemptions_allowed}} + {{i18n "user.invited.invited_via_link" key=invite.shortKey count=invite.redemption_count max=invite.max_redemptions_allowed}} {{/if}} {{#if currentUser.staff}} diff --git a/app/serializers/invite_serializer.rb b/app/serializers/invite_serializer.rb index c09ec9f5740..0d8f0dbf6bd 100644 --- a/app/serializers/invite_serializer.rb +++ b/app/serializers/invite_serializer.rb @@ -2,6 +2,7 @@ class InviteSerializer < ApplicationSerializer attributes :id, + :invite_key, :link, :email, :emailed, diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index dc23536138c..c788e394d58 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1448,7 +1448,7 @@ en: redeemed_tab: "Redeemed" redeemed_tab_with_count: "Redeemed (%{count})" invited_via: "Invitation" - invited_via_link: "link (%{count} / %{max} redeemed)" + invited_via_link: "link %{key} (%{count} / %{max} redeemed)" groups: "Groups" topic: "Topic" sent: "Created/Last Sent"