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">
<h1>Regenerate your Personal Token</h1>
<h1>Regenerate your Staff Access Token</h1>
</header>
<a class="close" href="" role="button" title="Close" {{action "closeModal"}}>{{svg-jar "close"}}<span class="hidden">Close</span></a>
<div class="modal-body">
<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>
{{#if this.errorMessage}}
<p class='red'> {{this.errorMessage}}</p>
@ -15,6 +15,6 @@
<div class="modal-footer">
<button {{action "closeModal"}} class="gh-btn" autofocus><span>Cancel</span></button>
<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>
</div>

View file

@ -1,5 +1,6 @@
import Controller from '@ember/controller';
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 validator from 'validator';
import windowProxy from 'ghost-admin/utils/window-proxy';
@ -471,5 +472,10 @@ export default Controller.extend({
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

@ -174,7 +174,7 @@
border-top: none;
}
.apps-card-left {
.apps-card-left {
display: flex;
align-items: center;
}
@ -372,6 +372,13 @@
right: -3px;
}
.app-api-personal-token-buttons {
display: flex;
align-items: center;
position: absolute;
right: 5px;
}
.app-button-regenerate {
display: flex;
align-items: center;
@ -512,4 +519,4 @@
.apps-card-app-orb.rot-3 {
transform: rotate(270deg);
}
}

View file

@ -354,34 +354,42 @@
<div class="pa5">
<fieldset class="user-details-form">
<GhFormGroup>
<label for="personal-token">Personal Token</label>
<GhTextInput
@id="personal-token"
@value={{readonly this.personalToken}}
@readonly
@type="text"
onclick="this.select()"
/>
<label for="personal-token">Staff Access Token</label>
<div class="relative flex items-center {{unless this.copyContentKey.isRunning "hide-child-instant"}}">
<GhTextInput
@id="personal-token"
@value={{readonly this.personalToken}}
@readonly
@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>
Give apps personal access without sharing your email/password.
</p>
{{#if this.personalTokenRegenerated}}
<p class="green"> Personal Token was successfully regenerated </p>
<p class="green"> Staff Access Token was successfully regenerated </p>
{{/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}}
<GhFullscreenModal @modal="regenerate-token"
@confirm={{action "regenerateToken"}}
@close={{action "cancelRegenerateTokenModal"}}
@modifier="action wide" />
{{/if}}
</div>
</GhFormGroup>
</fieldset>
</div>
</form>