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

refactor: [M3-7334] - Improve, clean up, and simplify app entrypoint and render tree logic #9844

Merged
merged 12 commits into from
Nov 1, 2023

Conversation

bnussman-akamai
Copy link
Member

@bnussman-akamai bnussman-akamai commented Oct 26, 2023

Description 📝

The goal of this PR is to simplify the entry point logic of Cloud Manager. Currently, the flow of index.tsx ➡️ AuthenticationWrapper.tsx ➡️ App.tsx ➡️ MainContent.tsx ➡️ ... is very complex and hard to follow, this ticket should help a little bit. There is a lot to clean up and improvement potential, but this PR is a solid start

Changes 🔄

  • Splashscreen simplification
  • AuthenticationWrapper is now a hook
  • IdentifyUser is now a hook
  • Uses less redux to track app loading state
  • Don't use unnecessarily complex preference toggle for Side Menu state, use preferences hooks directly

Preview 📷

Note

No UI changes are expected

How to test 🧪

Verification steps

  • Verify Cloud Manager loads like normal
  • Log out and verify you can log in without any issues
  • Verify that your remain logged in when you refresh
  • Verify Lish still works

As an Author I have considered 🤔

  • 👀 Doing a self review
  • ❔ Our contribution guidelines
  • 🤏 Splitting feature into small PRs
  • ➕ Adding a changeset
  • 🧪 Providing/Improving test coverage
  • 🔐 Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • 👣 Providing comprehensive reproduction steps
  • 📑 Providing or updating our documentation
  • 🕛 Scheduling a pair reviewing session
  • 📱 Providing mobile support
  • ♿ Providing accessibility support

@bnussman-akamai bnussman-akamai self-assigned this Oct 26, 2023
@bnussman-akamai bnussman-akamai requested a review from a team as a code owner October 26, 2023 18:15
@bnussman-akamai bnussman-akamai requested review from jdamore-linode and tyler-akamai and removed request for a team October 26, 2023 18:15
Comment on lines -15 to -20
export const defaultState: State = {
expiration: null,
loggedInAsCustomer: false,
scopes: null,
token: null,
};
Copy link
Member Author

Choose a reason for hiding this comment

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

No reason to default to null when we can synchronously know the default values form local storage

Copy link
Member Author

Choose a reason for hiding this comment

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

This is basically AuthenticationWrapper converted into a hook

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

Copy link
Member Author

@bnussman-akamai bnussman-akamai Oct 26, 2023

Choose a reason for hiding this comment

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

This enzyme test isn't providing much value anymore. Many of the test cases are no longer accurate and we have plenty of e2e coverage that checks that the app loads properly

Copy link
Contributor

@abailly-akamai abailly-akamai left a comment

Choose a reason for hiding this comment

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

Awesome cleanup 🎉 . Adds a lot of clarity to our entry point. I think it's pretty close, I have not noticed any issue while testing locally but left some comments to see about improving a few things

packages/manager/src/MainContent.tsx Outdated Show resolved Hide resolved
packages/manager/src/MainContent.tsx Show resolved Hide resolved
packages/manager/src/MainContent.tsx Show resolved Hide resolved
packages/manager/src/index.tsx Show resolved Hide resolved
desktop_sidebar_open: !preferences?.desktop_sidebar_open,
});
};

Copy link
Contributor

Choose a reason for hiding this comment

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

I really like this much cleaner approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

same 🧹

const {
expire: expiryInLocalStorage,
scopes: scopesInLocalStorage,
token: tokenInLocalStorage,
} = authentication;

const defaultToken = tokenInLocalStorage.get();
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 const declared here to avoid typing out tokenInLocalStorage.get() in line 25 and 27?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes!

Copy link
Contributor

@abailly-akamai abailly-akamai left a comment

Choose a reason for hiding this comment

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

Thanks for addressing the feedback.

This looks ready as far as I could test it. ✅

Have not found issues locally and we probably want to have this sit in develop sooner than later so we can catch any potential issue before the next release.

@tyler-akamai
Copy link
Contributor

tyler-akamai commented Nov 1, 2023

  • Verify Cloud Manager loads like normal
  • Log out and verify you can log in without any issues
  • Verify that your remain logged in when you refresh
  • Verify Lish still works

className={cx(classes.content, {
[classes.fullWidthContent]:
desktopMenuIsOpen ||
(desktopMenuIsOpen && desktopMenuIsOpen === true),
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm this line looks a little odd, good job cleaning it up

} = props;
const { desktopMenuToggle, isSideMenuOpen, openSideMenu, username } = props;

const { loggedInAsCustomer } = useAuthentication();
Copy link
Contributor

Choose a reason for hiding this comment

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

Good cleanup

desktop_sidebar_open: !preferences?.desktop_sidebar_open,
});
};

Copy link
Contributor

Choose a reason for hiding this comment

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

same 🧹

packages/manager/src/MainContent.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

import 'src/exceptionReporting';
import Logout from 'src/layouts/Logout';
import { setupInterceptors } from 'src/request';
import { storeFactory } from 'src/store';

import { App } from './App';
import { LinodeThemeWrapper } from './LinodeThemeWrapper';
import NullComponent from './components/NullComponent';
import { loadDevTools, shouldEnableDevTools } from './dev-tools/load';
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a small thing:
Should we dynamically import dev tools to ensure they arent part of the production bundle?

@bnussman-akamai bnussman-akamai merged commit 36e2adf into linode:develop Nov 1, 2023
13 checks passed
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.

5 participants