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: clean up unnecessary props and types, refactor <Route> to always render as children #2995

Merged
merged 2 commits into from
Mar 15, 2023

Conversation

emmenko
Copy link
Member

@emmenko emmenko commented Mar 10, 2023

Extracted from #2821

  • The generic type argument AdditionalEnvironmentProperties is not really used and needed by the internal components. Let's remove it.
  • Renamed some types for component props.
  • Refactored <Route> components to render as children (as recommended when upgrading to v6).

@changeset-bot
Copy link

changeset-bot bot commented Mar 10, 2023

🦋 Changeset detected

Latest commit: 461f7ac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 35 packages
Name Type
@commercetools-frontend/application-shell-connectors Patch
@commercetools-frontend/application-shell Patch
@commercetools-frontend/permissions Patch
@commercetools-frontend/constants Patch
@commercetools-local/visual-testing-app Patch
@commercetools-frontend/application-components Patch
@commercetools-applications/merchant-center-template-starter-typescript Patch
@commercetools-applications/merchant-center-template-starter Patch
@commercetools-local/playground Patch
@commercetools-frontend/cypress Patch
@commercetools-frontend/actions-global Patch
@commercetools-frontend/mc-html-template Patch
@commercetools-frontend/mc-scripts Patch
@commercetools-frontend/react-notifications Patch
@commercetools-frontend/sdk Patch
@commercetools-frontend/sentry Patch
@commercetools-website/components-playground Patch
@commercetools-frontend/i18n Patch
@commercetools-frontend/l10n Patch
@commercetools-backend/eslint-config-node Patch
@commercetools-backend/express Patch
@commercetools-backend/loggers Patch
@commercetools-frontend/application-config Patch
@commercetools-frontend/assets Patch
@commercetools-frontend/babel-preset-mc-app Patch
@commercetools-frontend/browser-history Patch
@commercetools-frontend/codemod Patch
@commercetools-frontend/create-mc-app Patch
@commercetools-frontend/eslint-config-mc-app Patch
@commercetools-frontend/jest-preset-mc-app Patch
@commercetools-frontend/jest-stylelint-runner Patch
@commercetools-frontend/mc-dev-authentication Patch
@commercetools-frontend/notifications Patch
@commercetools-frontend/url-utils Patch
@commercetools-website/custom-applications Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

type Props<AdditionalEnvironmentProperties extends {}> = {
environment: TProviderProps<AdditionalEnvironmentProperties>['environment'];
type TApplicationEntryPointProps = {
environment: TProviderProps<{}>['environment'];
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 type of change is done in many places in this PR.

  • Renamed the type
  • Removed the type argument AdditionalEnvironmentProperties

const browserLocale = getBrowserLocale(window);
return (
<>
<Suspense fallback={<ApplicationLoader />}>
Copy link
Member Author

Choose a reason for hiding this comment

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

Just moved up...

<ReduxProvider store={internalReduxStore}>
<ApolloProvider client={apolloClient}>
<Suspense fallback={<ApplicationLoader />}>
Copy link
Member Author

Choose a reason for hiding this comment

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

...from here.

Needed for a follow up PR.

<Route
exact={true}
path="/"
render={() => {
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 more render or component prop, routes are rendered as children of <Route>

@@ -191,13 +191,9 @@ export interface ApplicationWindow extends Window {
frontendHost: string;
servedByProxy: boolean;
// Optional properties. To use them, pass them to the `additionalEnv` object of the application config.
mcProxyApiUrl?: string;
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 only used internally and should not be defined as a "default" field

Comment on lines -198 to -200
enableSignUp?: boolean;
enableLongLivedFeatureFlags?: boolean;
useFullRedirectsForLinks?: boolean;
Copy link
Member Author

Choose a reason for hiding this comment

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

Same for these

Comment on lines +33 to +35
type TAdditionalEnvironmentProperties = {
mcProxyApiUrl?: string;
};
Copy link
Member Author

Choose a reason for hiding this comment

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

We can then simply define a type to extend the app context and include the fields that we expect here to be optionally provided (via the additionalEnv config field)

Comment on lines +84 to +85
type TAdditionalEnvironmentProperties = {
enableLongLivedFeatureFlags?: boolean;
};
Copy link
Member Author

Choose a reason for hiding this comment

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

Here's another one

Comment on lines +120 to +121
const applicationContext = useApplicationContext<{
useFullRedirectsForLinks?: boolean;
}>();
Copy link
Member Author

Choose a reason for hiding this comment

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

Here as well

@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2023

Deploy preview for merchant-center-application-kit ready!

✅ Preview
https://merchant-center-application-rdrz91wa1-commercetools.vercel.app
https://appkit-sha-bda508a54474edb1a9ac2445ebfe4acf4c548966.commercetools.vercel.app
https://appkit-pr-2995.commercetools.vercel.app

Built with commit 461f7ac.
This pull request is being automatically deployed with vercel-action

@@ -25,14 +30,11 @@ import ApplicationEntryPoint from '../application-entry-point';
import messages from './messages';

type QueryParams = {
projectKey: string;
projectKey?: string;
Copy link
Member Author

Choose a reason for hiding this comment

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

The query param is actually optional.

type Props = {
projectKey: string;
type TFetchProjectProps = {
projectKey?: string;
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 optional!

@@ -1,4 +1,4 @@
query FetchProject($projectKey: String!) {
query FetchProject($projectKey: String) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, it's optional 😊

Copy link
Contributor

@kark kark left a comment

Choose a reason for hiding this comment

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

Thanks, it all looks good to me!

Copy link
Contributor

@CarlosCortizasCT CarlosCortizasCT left a comment

Choose a reason for hiding this comment

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

👍

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.

None yet

3 participants