diff --git a/addons/website/static/src/components/switch/switch.js b/addons/website/static/src/components/switch/switch.js index 6f6586dbd98..67cbc236ce0 100644 --- a/addons/website/static/src/components/switch/switch.js +++ b/addons/website/static/src/components/switch/switch.js @@ -12,6 +12,7 @@ export class Switch extends Component { Switch.props = { value: Boolean, extraClasses: String, + disabled: {type: Boolean, optional: true}, label: {type: String, optional: true}, onChange: { Function, optional: true }, }; @@ -20,7 +21,7 @@ Switch.defaultProps = { }; Switch.template = xml` diff --git a/addons/website/static/src/systray_items/publish.js b/addons/website/static/src/systray_items/publish.js index c10ca6d6d1a..d035816ab3e 100644 --- a/addons/website/static/src/systray_items/publish.js +++ b/addons/website/static/src/systray_items/publish.js @@ -15,6 +15,7 @@ class PublishSystray extends Component { this.state = useState({ published: this.website.currentWebsite.metadata.isPublished, + processing: false, }); useBus(websiteSystrayRegistry, 'CONTENT-UPDATED', () => this.state.published = this.website.currentWebsite.metadata.isPublished); @@ -24,19 +25,38 @@ class PublishSystray extends Component { return this.state.published ? this.env._t("Published") : this.env._t("Unpublished"); } - publishContent() { + /** + * @todo event handlers should probably never return a Promise using OWL, + * to adapt in master. + */ + async publishContent() { + if (this.state.processing) { + return; + } + this.state.processing = true; this.state.published = !this.state.published; const { metadata: { mainObject } } = this.website.currentWebsite; return this.rpc('/website/publish', { id: mainObject.id, object: mainObject.model, - }); + }).then( + published => { + this.state.published = published; + this.state.processing = false; + return published; + }, + err => { + this.state.published = !this.state.published; + this.state.processing = false; + throw err; + } + ); } } PublishSystray.template = xml` -
+
- +
`;