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

Server Settings: Fix warning in SFTP users #98584

Merged
merged 1 commit into from
Jan 21, 2025
Merged

Conversation

tyxla
Copy link
Member

@tyxla tyxla commented Jan 20, 2025

Proposed Changes

Simplify the code to retrieve SFTP users. Currently, it creates a new object inside a useSelector(), triggering a bunch of additional rerenders. Instead, we can derive the state and avoid those rerenders.

Why are these changes being made?

To reduce rerenders and remove this warning:

Screenshot 2025-01-20 at 10 24 52

Testing Instructions

  • Go to /hosting-config/:site where :site is one of your Atomic sites.
  • Verify the warning doesn't appear anymore.

@tyxla tyxla added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. [Goal] Hosting Panel Label for issues relating to the Atomic Hosting panel exposing SFTP/PhpMyAdmin access Hosting Configuration labels Jan 20, 2025
@tyxla tyxla requested review from nightnei and a team January 20, 2025 08:27
@tyxla tyxla self-assigned this Jan 20, 2025
@matticbot
Copy link
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • notifications
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug fix/sftp-form-users-warning on your sandbox.

@matticbot
Copy link
Contributor

matticbot commented Jan 20, 2025

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

Sections (~14 bytes removed 📉 [gzipped])

name          parsed_size           gzip_size
staging-site        -55 B  (-0.0%)      -14 B  (-0.0%)
site-tools          -55 B  (-0.0%)      -14 B  (-0.0%)
hosting             -55 B  (-0.0%)      -14 B  (-0.0%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

@tyxla tyxla force-pushed the fix/sftp-form-users-warning branch from 3f400d2 to ba44a36 Compare January 20, 2025 08:34
Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

I created an atomic site and confirmed that the warning is gone.

@@ -152,7 +147,7 @@ export const SftpForm = ( {

const handleResetPassword = () => {
setPasswordLoading( true );
dispatch( resetSftpPassword( siteId, username ) );
dispatch( resetSftpPassword( siteId, username as string ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

As a follow-up, we could improve the logic in this file, since it currently doesn't take into account the possibility that username is not defined.

I suggest adding some checks and return a fallback UI while they are not defined.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's all under a username && check already, I believe that should be enough:

Or are you referring to something else?

Copy link
Contributor

Choose a reason for hiding this comment

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

The JSX is, but that doesn't mean guarantee TypeScript that username in the highlighted line is defined. It's at best an implicit typecase, at at worst a possible edge-case runtime error.

@tyxla tyxla merged commit f74022a into trunk Jan 21, 2025
13 checks passed
@tyxla tyxla deleted the fix/sftp-form-users-warning branch January 21, 2025 10:32
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Goal] Hosting Panel Label for issues relating to the Atomic Hosting panel exposing SFTP/PhpMyAdmin access Hosting Configuration [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants