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

Remove offline commenting feature and add post request handler to display offline/error templates. #728

Conversation

rutviksavsani
Copy link
Contributor

Fixes: #363

This PR

  • Removes the Offline commenting feature.
  • Introduces a request handler to display offline/error for POST requests.

Before

image (1)

After

image

@codecov-commenter
Copy link

codecov-commenter commented Mar 10, 2022

Codecov Report

Merging #728 (e1e38e2) into develop (124baab) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

@@              Coverage Diff              @@
##             develop     #728      +/-   ##
=============================================
- Coverage      19.03%   19.02%   -0.01%     
  Complexity       346      346              
=============================================
  Files             57       57              
  Lines           2322     2323       +1     
=============================================
  Hits             442      442              
- Misses          1880     1881       +1     
Flag Coverage Δ
php 19.02% <0.00%> (-0.01%) ⬇️
unit 19.02% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...wp-service-worker-navigation-routing-component.php 1.47% <0.00%> (ø)
wp-includes/template.php 10.90% <0.00%> (-0.21%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 124baab...e1e38e2. Read the comment docs.

@thelovekesh thelovekesh requested a review from westonruter March 10, 2022 19:21
@thelovekesh thelovekesh marked this pull request as draft March 11, 2022 06:32
@thelovekesh
Copy link
Collaborator

When a user makes a POST request and submission fails due to offline/server-error:

s1.mp4

When a user makes a POST request and it opens on a new page:

s-2.mp4

@thelovekesh thelovekesh marked this pull request as ready for review March 14, 2022 17:13
@thelovekesh
Copy link
Collaborator

@westonruter On thinking more about to show go back link, two use cases came up to my mind:

1 - When POST requests use the same tab to fulfill the request. In this case history.back() will work and go back to last occurrence that will be having bfcache.
2- When the user makes a POST request and it opens in a new tab(probably when target=_blank). In this case, there will be no history but document.referrer will be present.

I am considering both use cases as you can see in the upper comment. Please let me know your thought on it.

@westonruter
Copy link
Collaborator

@thelovekesh You've made a great point about the go back link not working as expected when opening in a new window. In the case of form submitting into a new window, we may not be able to get document.referrer either if the form had a rel="noreferrer" as well. The other possibility would be check history.length as noted in https://stackoverflow.com/a/3588420/93579 but that doesn't look reliable.

It may be better to just tell the user to go back manually.

@thelovekesh
Copy link
Collaborator

It may be better to just tell the user to go back manually.

This option looks cleaner to me.

@thelovekesh
Copy link
Collaborator

@westonruter I have changes made changes to go back as you suggested in the above comment. This PR is ready for your review now.

@westonruter
Copy link
Collaborator

Can you enable me to be able to push commits to your fork?

@westonruter westonruter added this to the 0.7 milestone Apr 1, 2022
@maitreyie-chavan
Copy link
Collaborator

Can you enable me to be able to push commits to your fork?

@westonruter I've sent over the invite ✔️

thelovekesh and others added 3 commits April 1, 2022 12:29
…ancement/363-remove-offline-commenting-and-add-post-request-handler

* 'develop' of github.com:GoogleChromeLabs/pwa-wp: (84 commits)
  Improve test phpdoc descriptions
  Further generalize naming for site icon code after bca28f1
  Add customize cap check before adding button to Customizer
  Add paragraph wrapper and harden translation escaping
  Improve name of JS file
  Reset notifications when site icon has been removed
  Remove extraneous comments
  Fix boolean condition for whether icon is too small
  Improve method naming and return value
  Improve strings and presentation of site health test
  Add warning notifications for non-PNG and non-square icons
  Reuse l10n object in Customizer
  Remove extraneous variable
  Show missing icon notification when attachment is no longer present
  Use attachment data for notifications and update notifications when setting changes
  Improve function name
  Add notifications to control instead of section
  Use warning notification type
  Reuse existing variable and improve variable name
  Skip test_pwa_validate_site_icon_not_png on PHP 7.1
  ...
…ancement/363-remove-offline-commenting-and-add-post-request-handler

* 'develop' of github.com:GoogleChromeLabs/pwa-wp:
  Bump eslint-plugin-jsdoc from 39.2.0 to 39.2.1
  Bump grunt from 1.5.1 to 1.5.2
  Bump workbox-cli from 6.5.2 to 6.5.3
  Bump eslint-plugin-jsdoc from 39.1.0 to 39.2.0
  Bump actions/setup-node from 3.1.0 to 3.1.1
  Bump eslint-plugin-jsdoc from 39.0.1 to 39.1.0
  Bump grunt from 1.4.1 to 1.5.1
  Bump eslint-plugin-jsdoc from 38.1.6 to 39.0.1
  Bump @wordpress/scripts from 22.3.0 to 22.4.0
  Bump php-stubs/wordpress-stubs from 5.9.1 to 5.9.3
  Bump eslint-plugin-import from 2.25.4 to 2.26.0
  Bump codecov/codecov-action from 2.1.0 to 3
  Bump eslint-plugin-jsdoc from 38.1.4 to 38.1.6
  Bump prettier from 2.6.1 to 2.6.2
  Bump actions/setup-node from 3.0.0 to 3.1.0
Comment on lines 74 to 77
body = body.replace(
'{{{WP_SERVICE_WORKER_SUBMISSION_FAILURE_MESSAGE}}}',
''
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

A problem here is that this will leave the document with:

<p><strong></strong></p>

@westonruter
Copy link
Collaborator

westonruter commented Apr 14, 2022

When I try navigating to a page while offline:

image

If I try submitting a comment while offline:

image

When I forcibly try to introduce a 500 error:

image

In this last case, I'm seeing something which may be a regression caused by #438:

infinite-reload-on-post-submission-failure.mov

This seems like a bug. If there is a 500 error, we definitely shouldn't be attempting to reload the page, and we shouldn't be doing a reload for a POST request either.

Copy link
Collaborator

@westonruter westonruter left a comment

Choose a reason for hiding this comment

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

But that can be addressed in another PR. This looks good and behaves as expected otherwise.

@westonruter westonruter merged commit f93356d into GoogleChromeLabs:develop Apr 14, 2022
@thelovekesh thelovekesh deleted the enhancement/363-remove-offline-commenting-and-add-post-request-handler branch April 15, 2022 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable offline commenting and offline browsing for authenticated users
5 participants