0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Updated the staff access token to use the existing patterns

issue https://github.com/TryGhost/Team/issues/497
This commit is contained in:
Thibaut Patel 2021-03-24 19:14:46 +01:00 committed by Thibaut Patel
parent e91e8f73fd
commit 0944fb39ba
4 changed files with 44 additions and 23 deletions

View file

@ -1,11 +1,11 @@
<header class="modal-header"> <header class="modal-header">
<h1>Regenerate your Personal Token</h1> <h1>Regenerate your Staff Access Token</h1>
</header> </header>
<a class="close" href="" role="button" title="Close" {{action "closeModal"}}>{{svg-jar "close"}}<span class="hidden">Close</span></a> <a class="close" href="" role="button" title="Close" {{action "closeModal"}}>{{svg-jar "close"}}<span class="hidden">Close</span></a>
<div class="modal-body"> <div class="modal-body">
<p> <p>
You can regenerate your Personal Token any time, but any scripts or applications using it will need to be updated. You can regenerate your Staff Access Token any time, but any scripts or applications using it will need to be updated.
</p> </p>
{{#if this.errorMessage}} {{#if this.errorMessage}}
<p class='red'> {{this.errorMessage}}</p> <p class='red'> {{this.errorMessage}}</p>
@ -15,6 +15,6 @@
<div class="modal-footer"> <div class="modal-footer">
<button {{action "closeModal"}} class="gh-btn" autofocus><span>Cancel</span></button> <button {{action "closeModal"}} class="gh-btn" autofocus><span>Cancel</span></button>
<button class="gh-btn gh-btn-icon gh-btn-red" {{action "confirm"}}> <button class="gh-btn gh-btn-icon gh-btn-red" {{action "confirm"}}>
<span>Regenerate your Personal Token</span> <span>Regenerate your Staff Access Token</span>
</button> </button>
</div> </div>

View file

@ -1,5 +1,6 @@
import Controller from '@ember/controller'; import Controller from '@ember/controller';
import boundOneWay from 'ghost-admin/utils/bound-one-way'; import boundOneWay from 'ghost-admin/utils/bound-one-way';
import copyTextToClipboard from 'ghost-admin/utils/copy-text-to-clipboard';
import isNumber from 'ghost-admin/utils/isNumber'; import isNumber from 'ghost-admin/utils/isNumber';
import validator from 'validator'; import validator from 'validator';
import windowProxy from 'ghost-admin/utils/window-proxy'; import windowProxy from 'ghost-admin/utils/window-proxy';
@ -471,5 +472,10 @@ export default Controller.extend({
this.notifications.showAPIError(error, {key: 'user.update'}); this.notifications.showAPIError(error, {key: 'user.update'});
} }
} }
}).group('saveHandlers') }).group('saveHandlers'),
copyContentKey: task(function* () {
copyTextToClipboard(this.personalToken);
yield timeout(this.isTesting ? 50 : 3000);
})
}); });

View file

@ -372,6 +372,13 @@
right: -3px; right: -3px;
} }
.app-api-personal-token-buttons {
display: flex;
align-items: center;
position: absolute;
right: 5px;
}
.app-button-regenerate { .app-button-regenerate {
display: flex; display: flex;
align-items: center; align-items: center;

View file

@ -354,34 +354,42 @@
<div class="pa5"> <div class="pa5">
<fieldset class="user-details-form"> <fieldset class="user-details-form">
<GhFormGroup> <GhFormGroup>
<label for="personal-token">Personal Token</label> <label for="personal-token">Staff Access Token</label>
<GhTextInput <div class="relative flex items-center {{unless this.copyContentKey.isRunning "hide-child-instant"}}">
@id="personal-token" <GhTextInput
@value={{readonly this.personalToken}} @id="personal-token"
@readonly @value={{readonly this.personalToken}}
@type="text" @readonly
onclick="this.select()" @type="text"
/> onclick="this.select()"
/>
<div class="app-api-personal-token-buttons child">
<button type="button" {{action "confirmRegenerateTokenModal"}} class="app-button-regenerate" data-tooltip="Regenerate">
{{svg-jar "reload" class="w4 h4 stroke-midgrey"}}
</button>
<button type="button" {{action (perform this.copyContentKey)}} class="app-button-copy">
{{#if this.copyContentKey.isRunning}}
{{svg-jar "check-circle" class="w3 v-mid mr2 stroke-white"}} Copied
{{else}}
Copy
{{/if}}
</button>
</div>
</div>
<p> <p>
Give apps personal access without sharing your email/password. Give apps personal access without sharing your email/password.
</p> </p>
{{#if this.personalTokenRegenerated}} {{#if this.personalTokenRegenerated}}
<p class="green"> Personal Token was successfully regenerated </p> <p class="green"> Staff Access Token was successfully regenerated </p>
{{/if}} {{/if}}
</GhFormGroup>
<div class="form-group">
<button class="gh-btn gh-btn-icon gh-btn-red" {{action "confirmRegenerateTokenModal"}}>
<span>Regenerate</span>
</button>
{{#if this.showRegenerateTokenModal}} {{#if this.showRegenerateTokenModal}}
<GhFullscreenModal @modal="regenerate-token" <GhFullscreenModal @modal="regenerate-token"
@confirm={{action "regenerateToken"}} @confirm={{action "regenerateToken"}}
@close={{action "cancelRegenerateTokenModal"}} @close={{action "cancelRegenerateTokenModal"}}
@modifier="action wide" /> @modifier="action wide" />
{{/if}} {{/if}}
</div>
</GhFormGroup>
</fieldset> </fieldset>
</div> </div>
</form> </form>