[FIX] website: propagate action_demand onFailure to promises
Before this commit The code called `action_demand` without specifying a failure method. In website, there is bug arising where a promises is not rejected causing spinner of the sidebar of the website builder to never stop. After this commit Failure is propagated and the website builder bug does not prevent the user from continuing to work. closes odoo/odoo#87125 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com> Signed-off-by: Antoine Guenet <age@odoo.com>
This commit is contained in:
@@ -2067,11 +2067,12 @@ const VisibilityPageOptionUpdate = options.Class.extend({
|
||||
*/
|
||||
async visibility(previewMode, widgetValue, params) {
|
||||
const show = (widgetValue !== 'hidden');
|
||||
await new Promise(resolve => {
|
||||
await new Promise((resolve, reject) => {
|
||||
this.trigger_up('action_demand', {
|
||||
actionName: 'toggle_page_option',
|
||||
params: [{name: this.pageOptionName, value: show}],
|
||||
onSuccess: () => resolve(),
|
||||
onFailure: reject,
|
||||
});
|
||||
});
|
||||
this.trigger_up('snippet_option_visibility_update', {show: show});
|
||||
@@ -2096,11 +2097,12 @@ const VisibilityPageOptionUpdate = options.Class.extend({
|
||||
* @returns {boolean}
|
||||
*/
|
||||
async _isShown() {
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.trigger_up('action_demand', {
|
||||
actionName: 'get_page_option',
|
||||
params: [this.pageOptionName],
|
||||
onSuccess: v => resolve(!!v),
|
||||
onFailure: reject,
|
||||
});
|
||||
});
|
||||
},
|
||||
@@ -2141,21 +2143,23 @@ options.registry.TopMenuVisibility = VisibilityPageOptionUpdate.extend({
|
||||
return;
|
||||
}
|
||||
const transparent = (widgetValue === 'transparent');
|
||||
await new Promise(resolve => {
|
||||
await new Promise((resolve, reject) => {
|
||||
this.trigger_up('action_demand', {
|
||||
actionName: 'toggle_page_option',
|
||||
params: [{name: 'header_overlay', value: transparent}],
|
||||
onSuccess: () => resolve(),
|
||||
onFailure: reject,
|
||||
});
|
||||
});
|
||||
if (!transparent) {
|
||||
return;
|
||||
}
|
||||
await new Promise(resolve => {
|
||||
await new Promise((resolve, reject) => {
|
||||
this.trigger_up('action_demand', {
|
||||
actionName: 'toggle_page_option',
|
||||
params: [{name: 'header_color', value: ''}],
|
||||
onSuccess: () => resolve(),
|
||||
onFailure: reject,
|
||||
});
|
||||
});
|
||||
},
|
||||
@@ -2165,11 +2169,12 @@ options.registry.TopMenuVisibility = VisibilityPageOptionUpdate.extend({
|
||||
async _computeWidgetState(methodName, params) {
|
||||
const _super = this._super.bind(this);
|
||||
if (methodName === 'visibility') {
|
||||
this.shownValue = await new Promise(resolve => {
|
||||
this.shownValue = await new Promise((resolve, reject) => {
|
||||
this.trigger_up('action_demand', {
|
||||
actionName: 'get_page_option',
|
||||
params: ['header_overlay'],
|
||||
onSuccess: v => resolve(v ? 'transparent' : 'regular'),
|
||||
onFailure: reject,
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -2207,11 +2212,12 @@ options.registry.topMenuColor = options.Class.extend({
|
||||
if (!show) {
|
||||
return false;
|
||||
}
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.trigger_up('action_demand', {
|
||||
actionName: 'get_page_option',
|
||||
params: ['header_overlay'],
|
||||
onSuccess: value => resolve(!!value),
|
||||
onFailure: reject,
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@@ -180,6 +180,7 @@ var AceEditorMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({
|
||||
self.trigger_up('action_demand', {
|
||||
actionName: 'close_all_widgets',
|
||||
onSuccess: resolve,
|
||||
onFailure: reject,
|
||||
});
|
||||
});
|
||||
prom.then(function () {
|
||||
|
||||
@@ -179,6 +179,7 @@ var NewContentMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({
|
||||
self.trigger_up('action_demand', {
|
||||
actionName: 'close_all_widgets',
|
||||
onSuccess: resolve,
|
||||
onFailure: reject,
|
||||
});
|
||||
}).then(function () {
|
||||
self.firstTab = true;
|
||||
|
||||
Reference in New Issue
Block a user