Skip to content

Commit

Permalink
Upgrade app-project to [email protected]
Browse files Browse the repository at this point in the history
- [x] upgrade `next` to v13.
- [x] convert `router-context` to `router-context.shared-runtime`.
- [x] upgrade `next/link` to the v13 Link API.
- [x] fix build warnings.
- [ ] fix failing tests.
  • Loading branch information
eatyourgreens committed Nov 22, 2023
1 parent 5a938ee commit a3285a1
Show file tree
Hide file tree
Showing 26 changed files with 600 additions and 608 deletions.
8 changes: 0 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@
"workspaces": {
"packages": [
"packages/**"
],
"nohoist": [
"**/eslint-config-next",
"**/@storybook/*",
"**/storybook",
"**/storybook-i18n",
"**/storybook-react-i18next",
"**/next"
]
},
"resolutions": {
Expand Down
9 changes: 1 addition & 8 deletions packages/app-project/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,7 @@ const nextConfig = {

experimental: {
forceSwcTransforms: true,
modularizeImports: {
lodash: {
transform: 'lodash/{{member}}',
},
'@zooniverse/react-components': {
transform: '@zooniverse/react-components/{{member}}'
}
},
optimizePackageImports: ['@zooniverse/react-components', 'grommet', 'grommet-icons']
},

async headers() {
Expand Down
4 changes: 2 additions & 2 deletions packages/app-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"mobx-state-tree": "~5.3.0",
"morgan": "^1.10.0",
"newrelic": "~11.5.0",
"next": "~12.3.0",
"next": "~13.5.6",
"next-i18next": "~15.0.0",
"panoptes-client": "~5.5.1",
"path-match": "~1.2.4",
Expand Down Expand Up @@ -77,7 +77,7 @@
"chai-dom": "~1.12.0",
"dirty-chai": "~2.0.1",
"enzyme": "~3.11.0",
"eslint-config-next": "~12.3.0",
"eslint-config-next": "~13.5.6",
"eslint-plugin-jsx-a11y": "~6.8.0",
"jsdom": "~22.1.0",
"mocha": "~10.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ function Form ({ errors, handleBlur, handleChange, handleSubmit, isSubmitting, t
</FormField>

<Box align='center' margin={{ bottom: 'small' }}>
<Link href='/reset-password' passHref>
<Anchor size='small'>
<SpacedText>
{t('AuthModal.LoginForm.forgot')}
</SpacedText>
</Anchor>
</Link>
<Anchor as={Link} href='/reset-password' size='small'>
<SpacedText>
{t('AuthModal.LoginForm.forgot')}
</SpacedText>
</Anchor>
</Box>

<Button
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Provider } from 'mobx-react'
import { applySnapshot } from 'mobx-state-tree'
import { RouterContext } from 'next/dist/shared/lib/router-context'
import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime'

import initStore from '@stores'
import ProjectHeader from './ProjectHeader.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Box } from 'grommet'
import { Provider } from 'mobx-react'
import { applySnapshot } from 'mobx-state-tree'
import Router from 'next/router'
import { RouterContext } from 'next/dist/shared/lib/router-context'
import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime'
import PropTypes from 'prop-types'

import LocaleSwitcher from './LocaleSwitcher'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,22 @@ function ProjectTitle({
const isCurrentPage = router?.pathname === linkProps.href

const anchor = (
<StyledAnchor>
<StyledHeading color='white' margin='none' textAlign={textAlign}>
{title}
</StyledHeading>
</StyledAnchor>
<StyledHeading color='white' margin='none' textAlign={textAlign}>
{title}
</StyledHeading>
)

if (isCurrentPage) {
return anchor
return (
<StyledAnchor>
{anchor}
</StyledAnchor>
)
} else {
return (
<Link {...linkProps} passHref>
<StyledAnchor forwardedAs={Link} {...linkProps}>
{anchor}
</Link>
</StyledAnchor>
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Provider } from 'mobx-react'
import { applySnapshot } from 'mobx-state-tree'
import { Grommet } from 'grommet'
import zooTheme from '@zooniverse/grommet-theme'
import { RouterContext } from 'next/dist/shared/lib/router-context'
import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime'
import auth from 'panoptes-client/lib/auth'
import sinon from 'sinon'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RouterContext } from 'next/dist/shared/lib/router-context'
import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime'
import { Provider } from 'mobx-react'
import asyncStates from '@zooniverse/async-states'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import asyncStates from '@zooniverse/async-states'
import zooTheme from '@zooniverse/grommet-theme'
import { Provider } from 'mobx-react'
import { applySnapshot } from 'mobx-state-tree'
import { RouterContext } from 'next/dist/shared/lib/router-context'
import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime'

import { mockWorkflow as mockGroupedWorkflow } from '@shared/components/SubjectSetPicker/SubjectSetPicker.mock'
import initStore from '@stores'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@testing-library/react'
import { Grommet } from 'grommet'
import zooTheme from '@zooniverse/grommet-theme'
import { RouterContext } from 'next/dist/shared/lib/router-context'
import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime'
import sinon from 'sinon'
import ProjectAboutPageConnector from './ProjectAboutPageConnector'
import { ProjectAboutPage } from './ProjectAboutPage'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box } from 'grommet'
import { RouterContext } from 'next/dist/shared/lib/router-context'
import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime'
import Router from 'next/router'
import PropTypes from 'prop-types'
import AboutDropdownNav from '../AboutDropdownNav'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Grid } from 'grommet'
import { RouterContext } from 'next/dist/shared/lib/router-context'
import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime'
import Router from 'next/router'
import PropTypes from 'prop-types'
import AboutSidebar from './AboutSidebar'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Grid } from 'grommet'
import { RouterContext } from 'next/dist/shared/lib/router-context'
import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime'
import Router from 'next/router'
import PropTypes from 'prop-types'
import TeamMember from './TeamMember'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { render, screen } from '@testing-library/react'
import { Grommet } from 'grommet'
import { Provider } from 'mobx-react'
import { applySnapshot } from 'mobx-state-tree'
import { RouterContext } from 'next/dist/shared/lib/router-context'
import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime'
import nock from 'nock'

import initStore from '@stores'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MediaContextProvider } from '@shared/components/Media'
import asyncStates from '@zooniverse/async-states'
import { Provider } from 'mobx-react'
import { RouterContext } from 'next/dist/shared/lib/router-context'
import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime'
import Router from 'next/router'

import Store from '@stores/Store'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ function JoinInButton (props) {
const { linkProps } = props
const label = t('Home.ZooniverseTalk.button')
return (
<Link {...linkProps} passHref>
<StyledButton label={label} />
</Link>
<StyledButton {...linkProps} forwardedAs={Link} label={label} />
)
}

Expand Down
10 changes: 7 additions & 3 deletions packages/app-project/src/shared/components/NavLink/NavLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ function NavLink ({
}

return (
<Link href={addQueryParams(href)} color={color} passHref>
<StyledAnchor color={color} label={label} {...anchorProps} />
</Link>
<StyledAnchor
forwardedAs={Link}
href={addQueryParams(href)}
color={color}
label={label}
{...anchorProps}
/>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,11 @@ export default function SubjectPicker({ baseUrl, subjectSet, workflow }) {
}
return (
<>
<Link
<PlainButton
forwardedAs={Link}
href={addQueryParams(baseUrl)}
passHref
>
<PlainButton
text={t('SubjectPicker.back')}
/>
</Link>
text={t('SubjectPicker.back')}
/>
<StyledHeading
level={3}
margin={{ top: 'xsmall', bottom: 'none' }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Grommet } from 'grommet'
import Link from 'next/link'
import nock from 'nock'
import { within } from '@testing-library/dom'
import { render, screen } from '@testing-library/react'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import NavLink from '@shared/components/NavLink'
import slugify from './slugify.js'

function subjectLink({ subject_id }, baseUrl) {
const href = `${baseUrl}/subject/${subject_id}`
const href = `/projects/${baseUrl}/subject/${subject_id}`
const link = {
href,
text: subject_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Components > Subject Picker > helpers > columns', function () {
const linkComponent = column.render({ subject_id: '123' }, baseUrl)
const { link } = linkComponent.props
expect(link.text).to.equal('123')
expect(link.href).to.equal(`${baseUrl}/subject/123`)
expect(link.href).to.equal(`/projects/${baseUrl}/subject/123`)
})
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,11 @@ function SubjectSetPicker ({

return (
<>
<Link
<PlainButton
forwardedAs={Link}
href={addQueryParams(baseUrl)}
passHref
>
<PlainButton
text={t('SubjectSetPicker.back')}
/>
</Link>
text={t('SubjectSetPicker.back')}
/>
<StyledHeading
level={3}
margin={{ top: 'xsmall', bottom: 'none' }}
Expand All @@ -88,18 +85,17 @@ function SubjectSetPicker ({
const href = `${baseUrl}/workflow/${workflow.id}/subject-set/${subjectSet.id}`
const panoptesCompleteness = subjectSet.completeness[workflow.id]
return (
<Link
key={subjectSet.id}
href={addQueryParams(href)}
passHref
>
<Anchor className="test-subject-set-card" data-testid={`test-subject-set-card-${subjectSet.id}`}>
<SubjectSetCard
{...subjectSet}
completeness={panoptesCompleteness} /* This will override subjectSet.completeness */
/>
</Anchor>
</Link>
<Anchor
as={Link}
key={subjectSet.id}
href={addQueryParams(href)}
className="test-subject-set-card" data-testid={`test-subject-set-card-${subjectSet.id}`}
>
<SubjectSetCard
{...subjectSet}
completeness={panoptesCompleteness} /* This will override subjectSet.completeness */
/>
</Anchor>
)
})}
</Grid>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncStates from '@zooniverse/async-states'
import { Box } from 'grommet'
import { Provider } from 'mobx-react'
import { RouterContext } from 'next/dist/shared/lib/router-context'
import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime'

import WorkflowSelector from './WorkflowSelector'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ function WorkflowSelectButton ({
)
}
return (
<Link href={href} passHref>
<ThemedButton
completeness={completeness}
icon={<Next size='15px' />}
reverse
label={label}
primary
{...rest}
/>
</Link>
<ThemedButton
as={Link}
href={href}
completeness={completeness}
icon={<Next size='15px' />}
reverse
label={label}
primary
{...rest}
/>
)
}

Expand Down
Loading

0 comments on commit a3285a1

Please sign in to comment.