Skip to content

A platform for community discussion. Free, open, simple.

FIX: Disable the previous revision button if it is the last revision (#22784)

Natalie Tay1ab1116cda76
diff --git a/app/assets/javascripts/discourse/app/components/modal/history.js b/app/assets/javascripts/discourse/app/components/modal/history.js
index 01c534153b3..814bccddda7 100644
--- a/app/assets/javascripts/discourse/app/components/modal/history.js
+++ b/app/assets/javascripts/discourse/app/components/modal/history.js
@@ -45,6 +45,7 @@ export default class History extends Component {
get loadPreviousDisabled() {
return (
this.loading ||
+ !this.postRevision.previous_revision ||
(!this.postRevision.previous_revision &&
this.postRevision.current_revision <=
this.postRevision.previous_revision)
diff --git a/app/assets/javascripts/discourse/tests/acceptance/history-test.js b/app/assets/javascripts/discourse/tests/acceptance/history-test.js
index fdad8e4cf15..420c8254b1b 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/history-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/history-test.js
@@ -47,7 +47,11 @@ acceptance("History Modal - authorized", function (needs) {
});
server.get("/posts/419/revisions/1.json", () => {
- return helper.response({ ...revisionResponse, current_revision: 1 });
+ return helper.response({
+ ...revisionResponse,
+ current_revision: 1,
+ previous_revision: null,
+ });
});
});
@@ -69,6 +73,15 @@ acceptance("History Modal - authorized", function (needs) {
"hides the edit post button when not on the latest revision"
);
});
+
+ test("previous revision button", async function (assert) {
+ await visit("/t/internationalization-localization/280");
+ await click("article[data-post-id='419'] .edits button");
+
+ await click(".history-modal .previous-revision");
+
+ assert.dom(".history-modal .previous-revision").isDisabled();
+ });
});
acceptance("History Modal - anonymous", function (needs) {