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

Fix: publish button delay #1263

Merged
merged 2 commits into from
May 5, 2023
Merged

Conversation

alexanderleegs
Copy link
Contributor

@alexanderleegs alexanderleegs commented May 4, 2023

This PR fixes an issue with the publish button not immediately reflecting the state of the reviewer's action. See video for current behaviour:

Screen.Recording.2023-05-04.at.4.38.25.PM.mov

The issue is that the publish now button is determined by our backend review request state instead of the user's direct action - the behaviour of the button state has been replicated to the publish now button as well.

As a safeguard, to prevent users from being able to publish even if the approval state has failed, an additional guard has been added to the backend in PR #752, to be reviewed in conjunction with this PR.

@alexanderleegs alexanderleegs temporarily deployed to staging May 4, 2023 09:56 — with GitHub Actions Inactive
@alexanderleegs alexanderleegs requested a review from a team May 4, 2023 09:57
@alexanderleegs alexanderleegs temporarily deployed to staging May 4, 2023 10:09 — with GitHub Actions Inactive
@alexanderleegs alexanderleegs temporarily deployed to staging May 4, 2023 10:10 — with GitHub Actions Inactive
setIsApproved(false)
onClose()
}}
/>
</>
)
}

// NOTE: Utility component exists to soothe over state management
Copy link
Contributor

Choose a reason for hiding this comment

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

is this comment still relevant?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, removed in 414b75d

useEffect(() => {
if (
reviewStatus === ReviewRequestStatus.CLOSED ||
reviewStatus === ReviewRequestStatus.MERGED
) {
setRedirectToPage(`/sites/${siteName}/dashboard`)
}
}, [reviewStatus, setRedirectToPage, siteName])
if (reviewStatus && isApproved === null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

hey I am confused with this code here :(
why are we setting it to approved when isApproved is null? if the idea to set them when we first run this code, this wouldn't play well well with a flow like approve -> disapprove -> approve? shouldnt this then just be if(reviewStatus) setIsApproved(reviewStatus === ReviewRequestStatus.APPROVED)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea for this code is to set isApproved only on initial load - isApproved is set to null originally, and if reviewStatus has finished loading, we set setIsApproved(reviewStatus === ReviewRequestStatus.APPROVED). From this point onwards, isApproved is only affected by the user's changes, which are immediate (as opposed to the previous behaviour of having to wait for the query from the backend)

Without the check for the first load, it gets stuck on the initial state of the page and has to rely on new information from the backend in order to change state!

@alexanderleegs alexanderleegs temporarily deployed to staging May 5, 2023 02:53 — with GitHub Actions Inactive
@alexanderleegs alexanderleegs temporarily deployed to staging May 5, 2023 03:06 — with GitHub Actions Inactive
@alexanderleegs alexanderleegs merged commit bc83b71 into develop May 5, 2023
@mergify mergify bot deleted the fix/IS-164-publish-button-delay branch May 5, 2023 07:23
@alexanderleegs alexanderleegs mentioned this pull request May 8, 2023
@mergify
Copy link

mergify bot commented Jun 4, 2023

This pull request has been stale for more than 30 days! Could someone please take a look at it @isomerpages/iso-engineers

@mergify mergify bot requested a review from a team June 4, 2023 07:24
@mergify
Copy link

mergify bot commented Jul 4, 2023

This pull request has been stale for more than 30 days! Could someone please take a look at it @isomerpages/iso-engineers

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