codidact / qpixel

Q&A-based community knowledge-sharing software
https://codidact.com
GNU Affero General Public License v3.0
385 stars 69 forks source link

Rollback history (#340) #1141

Closed Taeir closed 1 year ago

Taeir commented 1 year ago

Rollback History

Adds support for history item rollbacks for post edits, closing/reopening and deleting/restoring. Please note: this does not restore state to a previous version, but undoes certain actions in the history.

Implementation was quite tricky, so please thoroughly review for mistakes or missing things (e.g. permissions).

Usage details

Something can only be rolled back (undone) if its changes are still present. E.g. you cannot rollback (undo) something that adds a tag that already is no longer present. You also cannot do a partial rollback. If one edit changes both a tag and the title, but the title was again changed after that, you won't be able to roll it back (though you can first rollback the title change and then rollback the larger edit).

Any previous state can be reached by just rolling back the changes from most recent to least recent.

Implementation Details

Images

The rolled back history item receives a strikethrough. The rolling back item has a comment about the rollback. image

Sometimes multiple rollback items can be rolled back. This can happen even if e.g. the title was changed multiple times, as long as the end title is the same as the one applied in the event. image

WIP

Fixes #215 Fixes #340

Taeir commented 1 year ago

With post history rollbacks, mods can now finally duke it out in the history in a nice way: image