mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
🎨 Publish menu wording and saving states improvements (#788)
closes TryGhost/Ghost#8696 - Changes the `gh-save-button` component to allow a custom `runningText` which would be rendered in the button when the current task is running. - Adds a `runningText` CP to `gh-publishmenu` component, which will render (depending of post status and desired save type) 'Unpublishing', 'Publishing', 'Scheduling', 'Updating', 'Unpublishing', 'Rescheduling', and 'Unscheduling'.
This commit is contained in:
parent
2cbb181866
commit
c478564513
6 changed files with 59 additions and 16 deletions
|
@ -39,9 +39,31 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
buttonText: computed('postState', 'saveType', function() {
|
_runningText: computed('postState', 'saveType', function() {
|
||||||
let postState = this.get('postState');
|
|
||||||
let saveType = this.get('saveType');
|
let saveType = this.get('saveType');
|
||||||
|
let postState = this.get('postState');
|
||||||
|
let runningText;
|
||||||
|
|
||||||
|
if (postState === 'draft') {
|
||||||
|
runningText = saveType === 'publish' ? 'Publishing' : 'Scheduling';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (postState === 'published') {
|
||||||
|
runningText = saveType === 'publish' ? 'Updating' : 'Unpublishing';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (postState === 'scheduled') {
|
||||||
|
runningText = saveType === 'schedule' ? 'Rescheduling' : 'Unscheduling';
|
||||||
|
}
|
||||||
|
|
||||||
|
return runningText || 'Publishing';
|
||||||
|
}),
|
||||||
|
|
||||||
|
runningText: null,
|
||||||
|
|
||||||
|
buttonText: computed('postState', 'saveType', function() {
|
||||||
|
let saveType = this.get('saveType');
|
||||||
|
let postState = this.get('postState');
|
||||||
let buttonText;
|
let buttonText;
|
||||||
|
|
||||||
if (postState === 'draft') {
|
if (postState === 'draft') {
|
||||||
|
@ -49,11 +71,11 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (postState === 'published') {
|
if (postState === 'published') {
|
||||||
buttonText = saveType === 'publish' ? 'Update' : 'Un-publish';
|
buttonText = saveType === 'publish' ? 'Update' : 'Unpublish';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (postState === 'scheduled') {
|
if (postState === 'scheduled') {
|
||||||
buttonText = saveType === 'schedule' ? 'Re-schedule' : 'Un-schedule';
|
buttonText = saveType === 'schedule' ? 'Reschedule' : 'Unschedule';
|
||||||
}
|
}
|
||||||
|
|
||||||
return buttonText || 'Publish';
|
return buttonText || 'Publish';
|
||||||
|
@ -69,17 +91,20 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (previousStatus === 'published') {
|
if (previousStatus === 'published') {
|
||||||
buttonText = postState === 'draft' ? 'Un-published' : 'Updated';
|
buttonText = postState === 'draft' ? 'Unpublished' : 'Updated';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (previousStatus === 'scheduled') {
|
if (previousStatus === 'scheduled') {
|
||||||
buttonText = postState === 'draft' ? 'Un-scheduled' : 'Re-scheduled';
|
buttonText = postState === 'draft' ? 'Unscheduled' : 'Rescheduled';
|
||||||
}
|
}
|
||||||
|
|
||||||
return buttonText;
|
return buttonText;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
save: task(function* () {
|
save: task(function* () {
|
||||||
|
// runningText needs to be declared before the other states change during the
|
||||||
|
// save action.
|
||||||
|
this.set('runningText', this.get('_runningText'));
|
||||||
this.set('_previousStatus', this.get('post.status'));
|
this.set('_previousStatus', this.get('post.status'));
|
||||||
this.get('setSaveType')(this.get('saveType'));
|
this.get('setSaveType')(this.get('saveType'));
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
{{gh-task-button buttonText
|
{{gh-task-button buttonText
|
||||||
task=save
|
task=save
|
||||||
successText=successText
|
successText=successText
|
||||||
|
runningText=runningText
|
||||||
class="gh-btn gh-btn-blue gh-publishmenu-button gh-btn-icon"
|
class="gh-btn gh-btn-blue gh-publishmenu-button gh-btn-icon"
|
||||||
data-test-publishmenu-save=true}}
|
data-test-publishmenu-save=true}}
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
)}}
|
)}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<span>
|
<span>
|
||||||
{{#if isRunning}}{{inline-svg "spinner" class="gh-icon-spinner"}}{{/if}}
|
{{#if isRunning}}{{inline-svg "spinner" class="gh-icon-spinner"}}{{runningText}}{{/if}}
|
||||||
{{if (or isIdle isRunning) buttonText}}
|
{{#if isIdle}}{{buttonText}}{{/if}}
|
||||||
{{#if isSuccess}}{{inline-svg "check-circle"}} {{successText}}{{/if}}
|
{{#if isSuccess}}{{inline-svg "check-circle"}} {{successText}}{{/if}}
|
||||||
{{#if isFailure}}{{inline-svg "retry"}} {{failureText}}{{/if}}
|
{{#if isFailure}}{{inline-svg "retry"}} {{failureText}}{{/if}}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -188,7 +188,7 @@ describe('Acceptance: Editor', function() {
|
||||||
expect(
|
expect(
|
||||||
find(testSelector('publishmenu-save')).text().trim(),
|
find(testSelector('publishmenu-save')).text().trim(),
|
||||||
'published post unpublish button text'
|
'published post unpublish button text'
|
||||||
).to.equal('Un-publish');
|
).to.equal('Unpublish');
|
||||||
|
|
||||||
// post id 2 is a published post, checking for published post behaviour now
|
// post id 2 is a published post, checking for published post behaviour now
|
||||||
await visit('/editor/2');
|
await visit('/editor/2');
|
||||||
|
@ -258,14 +258,14 @@ describe('Acceptance: Editor', function() {
|
||||||
expect(
|
expect(
|
||||||
find(testSelector('publishmenu-save')).text().trim(),
|
find(testSelector('publishmenu-save')).text().trim(),
|
||||||
'published post unpublish button text'
|
'published post unpublish button text'
|
||||||
).to.equal('Un-publish');
|
).to.equal('Unpublish');
|
||||||
|
|
||||||
await click(testSelector('publishmenu-save'));
|
await click(testSelector('publishmenu-save'));
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
find(testSelector('publishmenu-save')).text().trim(),
|
find(testSelector('publishmenu-save')).text().trim(),
|
||||||
'publish menu save button updated after published post is unpublished'
|
'publish menu save button updated after published post is unpublished'
|
||||||
).to.equal('Un-published');
|
).to.equal('Unpublished');
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
find(testSelector('publishmenu-draft')),
|
find(testSelector('publishmenu-draft')),
|
||||||
|
@ -324,14 +324,14 @@ describe('Acceptance: Editor', function() {
|
||||||
expect(
|
expect(
|
||||||
find(testSelector('publishmenu-save')).text().trim(),
|
find(testSelector('publishmenu-save')).text().trim(),
|
||||||
'scheduled post button reschedule text'
|
'scheduled post button reschedule text'
|
||||||
).to.equal('Re-schedule');
|
).to.equal('Reschedule');
|
||||||
|
|
||||||
await click(testSelector('publishmenu-save'));
|
await click(testSelector('publishmenu-save'));
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
find(testSelector('publishmenu-save')).text().trim(),
|
find(testSelector('publishmenu-save')).text().trim(),
|
||||||
'publish menu save button text for a rescheduled post'
|
'publish menu save button text for a rescheduled post'
|
||||||
).to.equal('Re-scheduled');
|
).to.equal('Rescheduled');
|
||||||
|
|
||||||
await click(testSelector('publishmenu-cancel'));
|
await click(testSelector('publishmenu-cancel'));
|
||||||
|
|
||||||
|
@ -352,14 +352,14 @@ describe('Acceptance: Editor', function() {
|
||||||
expect(
|
expect(
|
||||||
find(testSelector('publishmenu-save')).text().trim(),
|
find(testSelector('publishmenu-save')).text().trim(),
|
||||||
'publish menu save button updated after scheduled post is unscheduled'
|
'publish menu save button updated after scheduled post is unscheduled'
|
||||||
).to.equal('Un-schedule');
|
).to.equal('Unschedule');
|
||||||
|
|
||||||
await click(testSelector('publishmenu-save'));
|
await click(testSelector('publishmenu-save'));
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
find(testSelector('publishmenu-save')).text().trim(),
|
find(testSelector('publishmenu-save')).text().trim(),
|
||||||
'publish menu save button updated after scheduled post is unscheduled'
|
'publish menu save button updated after scheduled post is unscheduled'
|
||||||
).to.equal('Un-scheduled');
|
).to.equal('Unscheduled');
|
||||||
|
|
||||||
await click(testSelector('publishmenu-cancel'));
|
await click(testSelector('publishmenu-cancel'));
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,23 @@ describe('Integration: Component: gh-task-button', function() {
|
||||||
wait().then(done);
|
wait().then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('shows running text when passed whilst running', function (done) {
|
||||||
|
this.set('myTask', task(function* () {
|
||||||
|
yield timeout(50);
|
||||||
|
}));
|
||||||
|
|
||||||
|
this.render(hbs`{{gh-task-button task=myTask runningText="Running"}}`);
|
||||||
|
|
||||||
|
this.get('myTask').perform();
|
||||||
|
|
||||||
|
run.later(this, function () {
|
||||||
|
expect(this.$('button')).to.have.descendants('svg');
|
||||||
|
expect(this.$('button')).to.contain('Running');
|
||||||
|
}, 20);
|
||||||
|
|
||||||
|
wait().then(done);
|
||||||
|
});
|
||||||
|
|
||||||
it('appears disabled whilst running', function (done) {
|
it('appears disabled whilst running', function (done) {
|
||||||
this.set('myTask', task(function* () {
|
this.set('myTask', task(function* () {
|
||||||
yield timeout(50);
|
yield timeout(50);
|
||||||
|
|
Loading…
Add table
Reference in a new issue