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

chore(deps): update nextjs monorepo to v13 (major) #8326

Merged
merged 37 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
645d133
chore(deps): update nextjs monorepo to v13
renovate[bot] Dec 21, 2022
ed055b4
follow up after update to next 13
znarf Dec 21, 2022
3d03201
upgrade react-dnd
znarf Dec 21, 2022
da4fae4
remove enzyme
znarf Dec 23, 2022
e2ff4c1
update package.json
znarf Dec 23, 2022
60ee73e
Merge branch 'main' into renovate/major-nextjs-monorepo
gustavlrsn Feb 21, 2023
480a93a
Merge branch 'main' into renovate/major-nextjs-monorepo
gustavlrsn Feb 23, 2023
fa5afc3
e2e fixes
gustavlrsn Feb 24, 2023
e3f5b3e
Set ssr: false on dynamic components on collective-page to avoid Susp…
gustavlrsn Feb 24, 2023
7a0504b
Use react@next
gustavlrsn Feb 24, 2023
5747dd7
Merge branch 'main' into renovate/major-nextjs-monorepo
gustavlrsn Feb 24, 2023
56a9cde
Webpack-hmr redirect
gustavlrsn Feb 27, 2023
d80b792
Stop inflight queries when logging out (fix for Store Reset Invariant…
gustavlrsn Feb 27, 2023
617d3cd
Image does not like "px"
gustavlrsn Feb 27, 2023
38cf8d1
Add some waiting in tests
gustavlrsn Feb 27, 2023
ad56a24
Merge branch 'main' of github.com:opencollective/opencollective-front…
gustavlrsn Mar 17, 2023
1cb8eab
Merge branch 'main' into renovate/major-nextjs-monorepo
znarf Jun 6, 2023
01975d6
upgrade related dependencies
znarf Jun 6, 2023
158e4aa
add styled-jsx for storybook
znarf Jun 6, 2023
0f01d34
add styled-jsx to depcheck ignore list
znarf Jun 6, 2023
ca4a551
test: restore & fix unit tests
Betree Jun 7, 2023
76999bc
Merge branch 'main' into renovate/major-nextjs-monorepo
Betree Jun 19, 2023
2a1c888
deps: Update React
Betree Jun 19, 2023
ad7741a
chore: Revert #38cf8d16fa2725b5232e86a8461caea10fc7310b
Betree Jun 19, 2023
9da4171
deps: Update webpack
Betree Jun 19, 2023
7672c76
deps(NextJS): Upagre Image imports to legacy
Betree Jun 19, 2023
8e7dbc9
fix(StyledDropzone): Update Typescript types
Betree Jun 19, 2023
c8987fa
fix(transactions): invalid state usage
Betree Jun 19, 2023
d06c921
test(E2E): Add missing check in 03-expenses-page.test.js
Betree Jun 19, 2023
c379b1a
deps(React): rollback to 18.2.0
Betree Jun 19, 2023
b46ed43
fix(ContributionFlow): change state management for latest react
Betree Jun 20, 2023
e3bd86e
test(E2E): revert more changes
Betree Jun 21, 2023
6cfa81f
Merge branch 'main' into renovate/major-nextjs-monorepo
Betree Jun 21, 2023
24c9fcc
test(E2E): More fixes following React update
Betree Jun 21, 2023
e473373
fix(ContributionFlow): rename Checkout step to FInalize
Betree Jun 22, 2023
d999226
Merge branch 'main' into renovate/major-nextjs-monorepo
Betree Jun 26, 2023
6deb103
typescript(StyledSelect): update typings for custom components
Betree Jun 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
engine-strict=true

legacy-peer-deps=true
2 changes: 1 addition & 1 deletion .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { RouterContext } from 'next/dist/shared/lib/router-context';
import { IntlProvider } from 'react-intl';
import theme from '../lib/theme';
import { ApolloProvider } from '@apollo/client';
import * as nextImage from 'next/image';
import * as nextImage from 'next/legacy/image';

import UserProvider from '../components/UserProvider';
import { initClient } from '../lib/apollo-client';
Expand Down
2 changes: 1 addition & 1 deletion components/Image.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import NextImage from 'next/image';
import NextImage from 'next/legacy/image';

// Default to no custom loader, will use Squoosh in dev
let loader;
Expand Down
2 changes: 1 addition & 1 deletion components/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Link extends React.Component {
);
} else {
return (
<NextLink {...pick(this.props, ['href', 'scroll'])}>
<NextLink legacyBehavior {...pick(this.props, ['href', 'scroll'])}>
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}
<a
className={className}
Expand Down
2 changes: 1 addition & 1 deletion components/StyledDropzone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ type StyledDropzoneProps = {
/** Name for the input */
name: string;
/** Content to show inside the dropzone. Defaults to message "Drag and drop one or..." */
children?: React.ReactChildren;
children?: React.ReactNode;
/** Force loading state to be displayed */
isLoading?: boolean;
/** Use this to override the loading progress indicator */
Expand Down
2 changes: 1 addition & 1 deletion components/StyledSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ export type StyledSelectProps = LayoutProps &
isClearable?: boolean;
options?: any;
value?: any;
components?: Record<string, React.ReactNode>;
components?: Record<string, React.ReactNode | React.Component | React.FunctionComponent>;
closeMenuOnSelect?: boolean;
hideSelectedOptions?: boolean;
isMulti?: boolean;
Expand Down
8 changes: 5 additions & 3 deletions components/contribution-flow/ContributionFlowButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ContributionFlowButtons extends React.Component {
paypalButtonProps: PropTypes.object,
currency: PropTypes.string,
isCrypto: PropTypes.bool,
disabled: PropTypes.bool,
tier: PropTypes.shape({ type: PropTypes.string }),
stepDetails: PropTypes.object,
stepSummary: PropTypes.object,
Expand Down Expand Up @@ -50,7 +51,8 @@ class ContributionFlowButtons extends React.Component {
}

render() {
const { goBack, isValidating, nextStep, paypalButtonProps, currency, tier, isCrypto, stepDetails } = this.props;
const { goBack, isValidating, nextStep, paypalButtonProps, currency, tier, isCrypto, stepDetails, disabled } =
this.props;
const totalAmount = getTotalAmount(stepDetails, this.props.stepSummary, isCrypto);
return (
<Flex flexWrap="wrap" justifyContent="center">
Expand All @@ -61,7 +63,7 @@ class ContributionFlowButtons extends React.Component {
minWidth={!nextStep ? 185 : 145}
onClick={goBack}
color="black.600"
disabled={isValidating}
disabled={disabled || isValidating}
data-cy="cf-prev-step"
type="button"
mt={2}
Expand All @@ -79,7 +81,7 @@ class ContributionFlowButtons extends React.Component {
minWidth={!nextStep ? 185 : 145}
buttonStyle="primary"
onClick={this.goNext}
disabled={isCrypto && totalAmount <= 0}
disabled={disabled || (isCrypto && totalAmount <= 0)}
loading={isValidating || this.state.isLoadingNext}
data-cy="cf-next-step"
type="submit"
Expand Down
2 changes: 1 addition & 1 deletion components/contribution-flow/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const STEPS = {
PAYMENT: 'payment',
SUMMARY: 'summary',
SUCCESS: 'success',
CHECKOUT: 'checkout',
FINALIZE: 'finalize',
};

export const PAYMENT_FLOW = {
Expand Down
82 changes: 51 additions & 31 deletions components/contribution-flow/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ class ContributionFlow extends React.Component {
stripeElements: null,
isSubmitted: false,
isSubmitting: false,
isInitializing: true,
isNavigating: false,
showSignIn: false,
createdOrder: null,
forceSummaryStep: this.getCurrentStepName() !== STEPS.DETAILS, // If not starting the flow with the details step, we force the summary step to make sure contributors have an easy way to review their contribution
Expand All @@ -182,7 +184,14 @@ class ContributionFlow extends React.Component {
};
}

componentDidUpdate(oldProps) {
async componentDidMount() {
if (!this.props.loadingLoggedInUser && this.state.isInitializing) {
await this.updateRouteFromState();
this.setState({ isInitializing: false });
}
}

async componentDidUpdate(oldProps) {
if (oldProps.LoggedInUser && !this.props.LoggedInUser) {
// User has logged out, reset the state
this.setState({ stepProfile: null, stepSummary: null, stepPayment: null });
Expand All @@ -204,32 +213,43 @@ class ContributionFlow extends React.Component {
} else if (oldProps.loadingLoggedInUser && !this.props.loadingLoggedInUser) {
// Login failed, reset the state to make sure we fallback on guest mode
this.setState({ stepProfile: this.getDefaultStepProfile() });
} else if (!this.props.loadingLoggedInUser) {
// Reflect state changes in the URL
const currentStepName = this.getCurrentStepName();
if (currentStepName !== STEPS.SUCCESS) {
const { stepDetails, stepProfile, stepPayment } = this.state;
const currentUrlState = this.getQueryParams();
const expectedUrlState = stepsDataToUrlParamsData(
currentUrlState,
stepDetails,
stepProfile,
stepPayment,
this.props.paymentFlow === PAYMENT_FLOW.CRYPTO,
this.props.isEmbed,
);
if (!isEqual(currentUrlState, omitBy(expectedUrlState, isNil))) {
const route = this.getRoute(currentStepName);
const queryHelper = this.getQueryHelper();
this.props.router.replace(
} else if (!this.props.loadingLoggedInUser && this.state.isInitializing) {
await this.updateRouteFromState();
this.setState({ isInitializing: false });
}
}

updateRouteFromState = async () => {
if (this.state.isNavigating) {
return;
}

const currentStepName = this.getCurrentStepName();
if (currentStepName !== STEPS.SUCCESS) {
const { stepDetails, stepProfile, stepPayment } = this.state;
const currentUrlState = this.getQueryParams();
const expectedUrlState = stepsDataToUrlParamsData(
currentUrlState,
stepDetails,
stepProfile,
stepPayment,
this.props.paymentFlow === PAYMENT_FLOW.CRYPTO,
this.props.isEmbed,
);
if (!isEqual(currentUrlState, omitBy(expectedUrlState, isNil))) {
const route = this.getRoute(currentStepName);
const queryHelper = this.getQueryHelper();
this.setState({ isNavigating: true }, async () => {
await this.props.router.replace(
{ pathname: route, query: omitBy(queryHelper.encode(expectedUrlState), isNil) },
null,
{ scroll: false, shallow: true },
);
}
this.setState({ isNavigating: false });
});
}
}
}
};

_getQueryParams = memoizeOne(query => {
return this.getQueryHelper().decode(query);
Expand Down Expand Up @@ -615,8 +635,8 @@ class ContributionFlow extends React.Component {
});
}

// This checkout step is where the QR code is displayed for crypto
if (step.name === 'checkout') {
// This finalize step is where the QR code is displayed for crypto
if (step.name === 'finalize') {
await this.submitOrder();
}

Expand All @@ -628,9 +648,7 @@ class ContributionFlow extends React.Component {
/** Navigate to another step, ensuring all route params are preserved */
pushStepRoute = async (stepName, { query: newQueryParams, replace = false } = {}) => {
// Reset errors if any
if (this.state.error) {
this.setState({ error: null });
}
this.setState({ error: null, isNavigating: true });

// Navigate to the new route
const { router } = this.props;
Expand All @@ -640,6 +658,7 @@ class ContributionFlow extends React.Component {
const route = this.getRoute(stepName === 'details' ? '' : stepName);
const navigateFn = replace ? router.replace : router.push;
await navigateFn({ pathname: route, query: omitBy(encodedQueryParams, value => !value) }, null, { shallow: true });
this.setState({ isNavigating: false });
this.scrollToTop();

// Reinitialize form on success
Expand Down Expand Up @@ -795,7 +814,7 @@ class ContributionFlow extends React.Component {
}

// Hide step payment if using a free tier with fixed price
// Also hide payment screen if using crypto payment method, we handle crypto flow in the `checkout` step below
// Also hide payment screen if using crypto payment method, we handle crypto flow in the `finalize` step below
if (!noPaymentRequired && !isCrypto) {
steps.push({
name: 'payment',
Expand Down Expand Up @@ -830,7 +849,7 @@ class ContributionFlow extends React.Component {

if (isCrypto) {
steps.push({
name: 'checkout',
name: 'finalize',
label: intl.formatMessage(STEP_LABELS.payment),
isCompleted: !stepProfile?.contributorRejectedCategories,
});
Expand Down Expand Up @@ -996,7 +1015,7 @@ class ContributionFlow extends React.Component {
collective={collective}
tier={tier}
mainState={this.state}
onChange={data => this.setState(data)}
onChange={data => this.setState(data, this.updateRouteFromState)}
step={currentStep}
isCrypto={isCrypto}
showPlatformTip={this.canHavePlatformTips()}
Expand All @@ -1021,10 +1040,10 @@ class ContributionFlow extends React.Component {
<Box mt={40}>
<ContributionFlowButtons
goNext={goNext}
// for crypto flow the user should not be able to go back after the order is created at checkout step
// for crypto flow the user should not be able to go back after the order is created at finalize step
// we also don't want to show the back button when linking directly to the payment step with `hideSteps=true`
goBack={
(isCrypto && currentStep.name === STEPS.CHECKOUT) ||
(isCrypto && currentStep.name === STEPS.FINALIZE) ||
(queryParams.hideSteps && currentStep.name === STEPS.PAYMENT)
? null
: goBack
Expand All @@ -1039,6 +1058,7 @@ class ContributionFlow extends React.Component {
tier={tier}
stepDetails={stepDetails}
stepSummary={stepSummary}
disabled={this.state.isInitializing || this.state.isNavigating}
/>
</Box>
{!isEmbed && (
Expand Down
2 changes: 1 addition & 1 deletion components/edit-collective/SocialLinksFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function SocialLinksFormField({ value = [], touched, onChange }:

return (
<DndContext collisionDetection={closestCenter} onDragEnd={handleDragEnd}>
<Flex width="100%" flexDirection="column">
<Flex width="100%" flexDirection="column" data-cy="social-link-inputs">
<SortableContext items={items.map(item => item.sortId)} strategy={verticalListSortingStrategy}>
{items.map(socialLink => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import PropTypes from 'prop-types';
import Image from 'next/image';
import { FormattedMessage } from 'react-intl';

import Container from '../../Container';
import FormattedMoneyAmount, { DEFAULT_AMOUNT_STYLES } from '../../FormattedMoneyAmount';
import { Box, Flex } from '../../Grid';
import Image from '../../Image';
import LoadingPlaceholder from '../../LoadingPlaceholder';
import { P, Span } from '../../Text';

Expand Down
Loading
Loading