Feature/completeUsernameCopy (#1913)
authorNassim Bounouas <NassimBounouas@users.noreply.github.com>
Wed, 19 Jun 2019 12:57:39 +0000 (14:57 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 19 Jun 2019 12:57:39 +0000 (14:57 +0200)
* #1843 Copy icon added to account page to copy Username

* #1843 Store an account name with the host forced and bind it to copy button

* #1843 tslint correction

* #1843 copy to clipboard replaced by ngx-clipboard

client/src/app/+accounts/accounts.component.html
client/src/app/shared/account/account.model.ts
client/src/app/shared/actor/actor.model.ts

index 038e18c4bd5413878237e2888a96ca5dcc94848c..1172f7ba72c874dbb07276675e6de9c81af48d5b 100644 (file)
@@ -7,8 +7,11 @@
       <div class="actor-info">
         <div class="actor-names">
           <div class="actor-display-name">{{ account.displayName }}</div>
-          <div class="actor-name">{{ account.nameWithHost }}</div>
-
+          <div class="actor-name">{{ account.nameWithHost }}
+          <button ngxClipboard [cbContent]="account.nameWithHostForced" type="button" class="btn btn-outline-secondary btn-sm">
+            <span class="glyphicon glyphicon-copy"></span>
+          </button>
+          </div>
           <span *ngIf="user?.blocked" [ngbTooltip]="user.blockedReason" class="badge badge-danger" i18n>Banned</span>
           <span *ngIf="account.mutedByUser" class="badge badge-danger" i18n>Muted</span>
           <span *ngIf="account.mutedServerByUser" class="badge badge-danger" i18n>Muted by your instance</span>
index c5cd2051ca858d8e3727b4c5612dbbc0ce80c50b..61f09fc0627ef5478aef524096074ffcebb2670e 100644 (file)
@@ -5,6 +5,7 @@ export class Account extends Actor implements ServerAccount {
   displayName: string
   description: string
   nameWithHost: string
+  nameWithHostForced: string
   mutedByUser: boolean
   mutedByInstance: boolean
   mutedServerByUser: boolean
@@ -19,6 +20,7 @@ export class Account extends Actor implements ServerAccount {
     this.description = hash.description
     this.userId = hash.userId
     this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host)
+    this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true)
 
     this.mutedByUser = false
     this.mutedByInstance = false
index 5a517c975b67e614cd11b012462c40a519d999b9..285f71ce0d1dc3c0627223a3d7fba85ff12b5830 100644 (file)
@@ -23,11 +23,11 @@ export abstract class Actor implements ActorServer {
     return window.location.origin + '/client/assets/images/default-avatar.png'
   }
 
-  static CREATE_BY_STRING (accountName: string, host: string) {
+  static CREATE_BY_STRING (accountName: string, host: string, forceHostname = false) {
     const absoluteAPIUrl = getAbsoluteAPIUrl()
     const thisHost = new URL(absoluteAPIUrl).host
 
-    if (host.trim() === thisHost) return accountName
+    if (host.trim() === thisHost && !forceHostname) return accountName
 
     return accountName + '@' + host
   }