silverstripe-cms icon indicating copy to clipboard operation
silverstripe-cms copied to clipboard

Disable the Publish button if there is nothing to publish

Open Firesphere opened this issue 7 years ago • 9 comments

Experience shows that users expect onBefore|AfterPublish to be called when they hit the Publish Button.

This doesn't happen, because there is nothing to publish when no changes are made. It would add value to disable the publish button unless there are changes to publish.

Firesphere avatar Apr 17 '17 07:04 Firesphere

I've confirmed that Verioned->publishSingle() does NOT call $owner->invokeWithExtensions('onBeforePublish'); when no changes need to be published (in SS4). Both "safe draft" and "publish" buttons are clickable regardless of any changes, but they are highlighted green when changes are detected. We could disable the buttons altogether, but I'm not confident enough in our change detection to do that just yet (e.g. TinyMCE needs a newline inserted in order to trigger change detection, doesn't trigger on any keypress).

Keen to get @clarkepaul UX feedback on this.

chillu avatar Apr 19 '17 23:04 chillu

I think it would be good to disable the buttons but only if we are certain that our change detection is working every time for every scenario. That would be the most frustrating thing to have changes that you can't save or publish because we don't allow it.

The way it is designed is to give the actions more of a disabled look but not too much to make users think they can't click it again.

clarkepaul avatar May 08 '17 23:05 clarkepaul

@Firesphere Can you add some more detail on the context of this issue here? Did you expect the extension to have an effect on publish, even though core didn't think a publish needed to happen?

chillu avatar May 09 '17 11:05 chillu

Can we, perhaps, add a "onAfterSkippedPublish" just like we doe for DataObject::write()?

dhensby avatar May 09 '17 11:05 dhensby

Can you add some more detail on the context of this issue here? Did you expect the extension to have an effect on publish, even though core didn't think a publish needed to happen?

This was discussed in the CMS-users channel in the users Slack. Several developers found it confusing that when clicking the publish button (regardless of it's state) did not consistently invoke onBefore/After publish.

Firesphere avatar Jun 11 '17 00:06 Firesphere

@Firesphere Do you want to send a PR for onAfterSkippedPublish?

chillu avatar Jun 16 '17 01:06 chillu

I can have a look at it, sure.

Firesphere avatar Jun 16 '17 01:06 Firesphere

Just to add another thought on this - I don't think that disabling the publish/save buttons is a good idea even if our change detection is good because there are instances where you might want to force a publish/save event even if the current page has no explicit changes... perhaps you need to force a static publish action or some other onAfterSave hook that's needed

dhensby avatar Jun 16 '17 10:06 dhensby

Yeah ... change detections could be a bit difficult here. The current page might not have any change to publish, but their could be related owned objects that do. Unless we have a full proof way of communicating back to the UI to decide if we should disable the button, disabling the button could be difficult.

Should point out that the publish button doesn't currently use its "dirty" state when a child object has draft changes. e.g.: You edit a form field on a UserForm page, save your changes and go back the main page. The "Publish" button comes back with it's green border (as opposed to the green background when its dirty).

maxime-rainville avatar Aug 07 '20 02:08 maxime-rainville