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

We introduced a tiny bug #22522.

When viewing the last revision of a post, we need to disable the  button. This fixes the issue.
This commit is contained in:
Natalie Tay 2023-07-26 00:44:57 +08:00 committed by GitHub
parent ad9ad55870
commit 1ab1116cda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -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)

View File

@ -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) {