diff --git a/frontend/src/components/ListItemPersonalAccessToken.vue b/frontend/src/components/ListItemPersonalAccessToken.vue index f5d669a8c..9bc8ed8b5 100644 --- a/frontend/src/components/ListItemPersonalAccessToken.vue +++ b/frontend/src/components/ListItemPersonalAccessToken.vue @@ -2,27 +2,38 @@ - {{ token.lastChars }} + {{ token.id }} {{ token.name }} - - Created: - {{ token.createdAt | dateParse() | dateFormat("DD MMM YY") }} ( - - ) Last Used: - {{ token.lastUsed | dateParse() | dateFormat("DD MMM YY") }} ( - - ) + + Created: + {{ token.createdAt | dateParse() | dateFormat("DD MMM YYYY") }} + Last Used: + {{ token.lastUsed | dateParse() | dateFormat("DD MMM YYYY") }} - + mdi-delete + + + Are you sure? + + You cannot undo this action. This will permanently delete this token. + + + Delete + Cancel + + + diff --git a/frontend/src/components/dialogs/TokenDialog.vue b/frontend/src/components/dialogs/TokenDialog.vue index 49f678861..26c272aa1 100644 --- a/frontend/src/components/dialogs/TokenDialog.vue +++ b/frontend/src/components/dialogs/TokenDialog.vue @@ -1,10 +1,12 @@ - + Create a New Personal Access Token + + mdi-close - + Token Scopes It's good practice to limit the scopes of your token to the absolute @@ -46,8 +48,21 @@ autofocus > - Save + Save + Cancel + + + Your new token: + {{ fullTokenResult }} + + + Note: + This is the first and last time you will be able to see the full + token. Please copy paste it somewhere safe now. + + Close + @@ -83,19 +98,41 @@ export default { (v) => !!v || "Name is required", (v) => (v && v.length <= 60) || "Name must be less than 60 characters" ], - selectedScopes: [] + selectedScopes: [], + fullTokenResult: null } }, - computed: { - showDialog: { - get() { - return this.show - }, - set(value) { - this.$emit("input", value) + methods: { + clearAndClose() { + this.fullTokenResult = null + this.name = null + this.selectedScopes = [] + this.$emit("close") + }, + async createToken() { + try { + let res = await this.$apollo.mutate({ + mutation: gql` + mutation($token: ApiTokenCreateInput!) { + apiTokenCreate(token: $token) + } + `, + variables: { + token: { + name: this.name, + scopes: this.selectedScopes + } + } + }) + this.fullTokenResult = res.data.apiTokenCreate + this.name = null + this.selectedScopes = [] + this.$emit("token-added") + } catch (e) { + // TODO: how do we catch and display errors? + console.log(e) } } - }, - methods: {} + } }
It's good practice to limit the scopes of your token to the absolute @@ -46,8 +48,21 @@ autofocus > - Save + Save + Cancel
{{ fullTokenResult }}