From 2c7406d9a8d8e961b99286f317c6ed0a48427853 Mon Sep 17 00:00:00 2001
From: Maxim Filippov <colixer@gmail.com>
Date: Tue, 12 Feb 2019 21:53:59 +0300
Subject: Add OAuth Tokens management to settings

---
 src/components/user_settings/user_settings.vue | 36 ++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

(limited to 'src/components/user_settings/user_settings.vue')

diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index 983cbda0..ac75ad86 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -121,6 +121,30 @@
             <p v-if="changePasswordError">{{changePasswordError}}</p>
           </div>
 
+          <div class="setting-item">
+            <h2>{{$t('settings.oauth_tokens')}}</h2>
+            <table class="oauth-tokens">
+              <thead>
+                <tr>
+                  <th>Token</th>
+                  <th>Refresh Token</th>
+                  <th>Valid Until</th>
+                  <th></th>
+                </tr>
+              </thead>
+              <tbody>
+                <tr v-for="oauthToken in oauthTokens" :key="oauthToken.id">
+                  <td>{{oauthToken.token}}</td>
+                  <td>{{oauthToken.refreshToken}}</td>
+                  <td>{{oauthToken.validUntil}}</td>
+                  <td class="actions">
+                    <button class="btn btn-default" @click="revokeToken(oauthToken.id)">Revoke</button>
+                  </td>
+                </tr>
+              </tbody>
+            </table>
+          </div>
+
           <div class="setting-item">
             <h2>{{$t('settings.delete_account')}}</h2>
             <p v-if="!deletingAccount">{{$t('settings.delete_account_description')}}</p>
@@ -213,5 +237,17 @@
     border-radius: $fallback--avatarRadius;
     border-radius: var(--avatarRadius, $fallback--avatarRadius);
   }
+
+  .oauth-tokens {
+    width: 100%;
+
+    th {
+      text-align: left;
+    }
+
+    .actions {
+      text-align: right;
+    }
+  }
 }
 </style>
-- 
cgit v1.2.3-70-g09d2


From afbe524a2e7fa7002c4b1f5883e08b2d135a2eda Mon Sep 17 00:00:00 2001
From: Maxim Filippov <colixer@gmail.com>
Date: Tue, 12 Feb 2019 22:07:10 +0300
Subject: use translations

---
 src/components/user_settings/user_settings.vue | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'src/components/user_settings/user_settings.vue')

diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index ac75ad86..116c1335 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -126,9 +126,9 @@
             <table class="oauth-tokens">
               <thead>
                 <tr>
-                  <th>Token</th>
-                  <th>Refresh Token</th>
-                  <th>Valid Until</th>
+                  <th>{{$t('settings.token')}}</th>
+                  <th>{{$t('settings.refresh_token')}}</th>
+                  <th>{{$t('settings.valid_until')}}</th>
                   <th></th>
                 </tr>
               </thead>
@@ -138,7 +138,9 @@
                   <td>{{oauthToken.refreshToken}}</td>
                   <td>{{oauthToken.validUntil}}</td>
                   <td class="actions">
-                    <button class="btn btn-default" @click="revokeToken(oauthToken.id)">Revoke</button>
+                    <button class="btn btn-default" @click="revokeToken(oauthToken.id)">
+                      {{$t('settings.revoke_token')}}
+                    </button>
                   </td>
                 </tr>
               </tbody>
-- 
cgit v1.2.3-70-g09d2


From c71f411ad6593a496a041505f8a6642a4ae55eea Mon Sep 17 00:00:00 2001
From: Maxim Filippov <colixer@gmail.com>
Date: Mon, 18 Feb 2019 00:01:18 +0300
Subject: Show only "app_name" and "valid_until" (OAuth tokens table)

---
 src/components/user_settings/user_settings.js  | 12 ++----------
 src/components/user_settings/user_settings.vue |  6 ++----
 src/i18n/en.json                               |  1 +
 3 files changed, 5 insertions(+), 14 deletions(-)

(limited to 'src/components/user_settings/user_settings.vue')

diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js
index 5e972d82..e7a961f1 100644
--- a/src/components/user_settings/user_settings.js
+++ b/src/components/user_settings/user_settings.js
@@ -1,11 +1,6 @@
-<<<<<<< HEAD
 import { compose } from 'vue-compose'
 import unescape from 'lodash/unescape'
 import get from 'lodash/get'
-=======
-import { unescape, truncate } from 'lodash'
->>>>>>> Add OAuth Tokens management to settings
-
 import TabSwitcher from '../tab_switcher/tab_switcher.js'
 import ImageCropper from '../image_cropper/image_cropper.vue'
 import StyleSwitcher from '../style_switcher/style_switcher.vue'
@@ -94,20 +89,17 @@ const UserSettings = {
         direct: { selected: this.newDefaultScope === 'direct' }
       }
     },
-<<<<<<< HEAD
     currentSaveStateNotice () {
       return this.$store.state.interface.settings.currentSaveStateNotice
-=======
+    },
     oauthTokens () {
       return this.$store.state.oauthTokens.tokens.map(oauthToken => {
         return {
           id: oauthToken.id,
-          token: truncate(oauthToken.token, { length: 15 }),
-          refreshToken: truncate(oauthToken.refresh_token, { length: 15 }),
+          appName: oauthToken.app_name,
           validUntil: new Date(oauthToken.valid_until).toLocaleDateString()
         }
       })
->>>>>>> Add OAuth Tokens management to settings
     }
   },
   methods: {
diff --git a/src/components/user_settings/user_settings.vue b/src/components/user_settings/user_settings.vue
index 116c1335..a1123638 100644
--- a/src/components/user_settings/user_settings.vue
+++ b/src/components/user_settings/user_settings.vue
@@ -126,16 +126,14 @@
             <table class="oauth-tokens">
               <thead>
                 <tr>
-                  <th>{{$t('settings.token')}}</th>
-                  <th>{{$t('settings.refresh_token')}}</th>
+                  <th>{{$t('settings.app_name')}}</th>
                   <th>{{$t('settings.valid_until')}}</th>
                   <th></th>
                 </tr>
               </thead>
               <tbody>
                 <tr v-for="oauthToken in oauthTokens" :key="oauthToken.id">
-                  <td>{{oauthToken.token}}</td>
-                  <td>{{oauthToken.refreshToken}}</td>
+                  <td>{{oauthToken.appName}}</td>
                   <td>{{oauthToken.validUntil}}</td>
                   <td class="actions">
                     <button class="btn btn-default" @click="revokeToken(oauthToken.id)">
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 0aeb70ab..df8f6f6c 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -106,6 +106,7 @@
     }
   },
   "settings": {
+    "app_name": "App name",
     "attachmentRadius": "Attachments",
     "attachments": "Attachments",
     "autoload": "Enable automatic loading when scrolled to the bottom",
-- 
cgit v1.2.3-70-g09d2

