Skip to content

Commit

Permalink
🍕 Fix scheduling/unscheduling workflow (#1554)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjpaulino authored Dec 21, 2022
1 parent 21db40d commit 56a2346
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
3 changes: 3 additions & 0 deletions lib/drawers/publish-layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@
})
.then(() => {
store.commit(FINISH_PROGRESS);
// reset date and time values
this.clearScheduleForm();
store.dispatch('showSnackbar', 'Unscheduled Layout');
});
},
Expand Down Expand Up @@ -324,6 +326,7 @@
},
clearScheduleForm() {
this.dateValue = null;
this.timeValue = null;
this.$refs.timepicker.clear();
},
saveTitle() {
Expand Down
5 changes: 4 additions & 1 deletion lib/drawers/publish-page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
const store = this.$store;
store.commit(START_PROGRESS);
store.dispatch('unschedulePage', this.uri)
store.dispatch('unschedulePage')
.catch((e) => {
store.commit(FINISH_PROGRESS, 'error');
log.error(`Error unscheduling page: ${e.message}`, { action: 'unschedulePage' });
Expand All @@ -241,6 +241,8 @@
})
.then(() => {
store.commit(FINISH_PROGRESS);
// reset date and time values
this.clearScheduleForm();
store.dispatch('showSnackbar', 'Unscheduled Page');
});
},
Expand Down Expand Up @@ -326,6 +328,7 @@
},
clearScheduleForm() {
this.dateValue = null;
this.timeValue = null;
this.$refs.timepicker.clear();
},
saveLocation(undoUrl) {
Expand Down
10 changes: 5 additions & 5 deletions lib/layout-state/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ export function scheduleLayout(store, { timestamp }) {
*/
export function unscheduleLayout(store, publishing = false) {
const layoutUri = _.get(store, 'state.layout.uri'),
scheduleId = btoa(layoutUri),
scheduledId = btoa(layoutUri),
prefix = _.get(store, 'state.site.prefix'),
scheduleUri = `${prefix}${scheduleRoute}/${scheduleId}`;
scheduledUri = `${prefix}${scheduleRoute}/${scheduledId}`;

store.dispatch('startProgress', 'scheduled');
store.dispatch('startProgress', 'unscheduled');

return remove(scheduleUri)
return remove(scheduledUri)
.then(() => {
if (publishing) {
return Promise.resolve();
Expand All @@ -118,7 +118,7 @@ export function unscheduleLayout(store, publishing = false) {
return getMeta(layoutUri);
})
.then((layoutMeta) => {
store.dispatch('finishProgress', 'scheduled');
store.dispatch('finishProgress', 'unscheduled');

if (publishing) {
return;
Expand Down
10 changes: 5 additions & 5 deletions lib/page-data/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,13 @@ export function schedulePage(store, { uri, timestamp }) {
*/
export function unschedulePage(store, publishing = false) {
const pageUri = _.get(store, 'state.page.uri'),
scheduleId = btoa(pageUri),
scheduledId = btoa(pageUri),
prefix = _.get(store, 'state.site.prefix'),
scheduleUri = `${prefix}${scheduleRoute}/${scheduleId}`;
scheduledUri = `${prefix}${scheduleRoute}/${scheduledId}`;

store.dispatch('startProgress', 'scheduled');
store.dispatch('startProgress', 'unscheduled');

return remove(scheduleUri)
return remove(scheduledUri)
.then(() => {
if (publishing) {
return Promise.resolve();
Expand All @@ -236,7 +236,7 @@ export function unschedulePage(store, publishing = false) {
return getMeta(pageUri);
})
.then((updatedState) => {
store.dispatch('finishProgress', 'scheduled');
store.dispatch('finishProgress', 'unscheduled');

if (publishing) {
return;
Expand Down

0 comments on commit 56a2346

Please sign in to comment.