Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Set Published button dirty state when Link is an unpublished state #193

Conversation

emteknetnz
Copy link
Member

@emteknetnz emteknetnz commented Jan 30, 2024

Issue #152

I've tested this for:

  • Links on Pages
  • Links on Elemental
  • Links on DataObjects managed by ModelAdmins

It will set the "Publish" button to a dirty state when the LinkPickerTitle has either a 'Draft' or a 'Modified' versionedState. It won't change the state of "Save" button as LinkField constantly saves everything via AJAX.

Note that for Elemental this is only true if the Link if modifed via the link modal. The "Save" button will still get a dirty state when new links are added or deleted. This is due to existing logic in Elemental to that will trigger the jQuery changetracker which will alter both the Save and the Publish buttons. There's nothing we can really do about this without a lot of hacking around it, and I don't think this is worth it since a dirty Save button is far from the worse thing ever.

I've also created a new issue for the all the CMS inconsistency I discovered about the changetracker while doing this work

@@ -136,7 +137,7 @@ const LinkField = ({
/**
* Update the component when the 'Delete' button in the LinkPicker is clicked
*/
const onDelete = (linkID, deleteType) => {
const handleDelete = (linkID, deleteType) => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated refactoring to follow the consistent naming of defining 'handle*' methods and passing them to 'on*' props

@emteknetnz emteknetnz force-pushed the pulls/4/versioned-button-state branch from 0b60cc9 to 5155f17 Compare January 31, 2024 21:44
Copy link
Contributor

@sabina-talipova sabina-talipova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Tested locally.

@sabina-talipova sabina-talipova merged commit 03ffff8 into silverstripe:4 Jan 31, 2024
10 checks passed
@sabina-talipova sabina-talipova deleted the pulls/4/versioned-button-state branch January 31, 2024 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants