Skip to content

Commit

Permalink
Merge branch 'develop' into New-Article-Page
Browse files Browse the repository at this point in the history
  • Loading branch information
wlliaml committed Jan 12, 2024
2 parents ff9dce3 + 8c67b29 commit f13d982
Show file tree
Hide file tree
Showing 15 changed files with 56 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ NEXT_PUBLIC_CLOUDFLARE_TURNSTILE_SITE_KEY=0x4AAAAAAAKVODkJMwfIxG78
DEBUG=false
NEXT_PUBLIC_GOOGLE_CLIENT_ID=751677068109-rkml7q9ujf8ems09cclh7qckf14svcgs.apps.googleusercontent.com
NEXT_PUBLIC_TWITTER_CLIENT_ID=cmdKbUlyd1ZZZDZYa3dTampidGo6MTpjaQ
NEXT_PUBLIC_FACEBOOK_CLIENT_ID=161556310354354
NEXT_PUBLIC_FACEBOOK_CLIENT_ID=687698420193159
NEXT_PUBLIC_NOMAD_MATTERS_CAMPAIGN_LINK_EN=/@hi176/476405-a-guide-to-invite
NEXT_PUBLIC_NOMAD_MATTERS_CAMPAIGN_LINK=/@hi176/476404
NEXT_PUBLIC_NOMAD_MATTERS_CAMPAIGN_LINK=/@hi176/476404
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ jobs:
uses: actions/checkout@master

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16.14'
node-version: '18'
cache: 'npm'

- name: Install Dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
uses: actions/checkout@master

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16.14'
node-version: '18'
cache: 'npm'

- name: Install Dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
uses: actions/checkout@master

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16.14'
node-version: '18'
cache: 'npm'

- name: Install Dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
uses: actions/checkout@master

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16.14'
node-version: '18'
cache: 'npm'

- name: Install Dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
uses: actions/checkout@master

- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: '16.14'
node-version: '18'
cache: 'npm'

- name: Install Dependencies
Expand Down
2 changes: 1 addition & 1 deletion lang/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,7 @@
"defaultMessage": "追踪中"
},
"cQ+Lyq": {
"defaultMessage": "游牧者计画纪念徽章",
"defaultMessage": "游牧者计划纪念徽章",
"description": "src/views/User/UserProfile/Badges/index.tsx"
},
"cQYXjl": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "codebase of Matters' website",
"author": "Matters <[email protected]>",
"engines": {
"node": ">=16.14 <17.0"
"node": ">=16.14 <19.0"
},
"license": "Apache-2.0",
"sideEffects": false,
Expand Down
4 changes: 2 additions & 2 deletions src/common/utils/oauth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ describe('utils/oauth', () => {
vi.stubEnv('NEXT_PUBLIC_SITE_DOMAIN', 'web-dev.matters.town')

it('should get signupCallbackUrl correctly', () => {
expect(signupCallbackUrl('email', 'code')).toEqual(
'https://web-dev.matters.town/callback/email-signup?email=email&referral=code'
expect(signupCallbackUrl('[email protected]', 'code')).toEqual(
'https://web-dev.matters.town/callback/email-signup?email=test%2Babc%40matters.news&referral=code'
)
expect(signupCallbackUrl('email')).toEqual(
'https://web-dev.matters.town/callback/email-signup?email=email'
Expand Down
6 changes: 2 additions & 4 deletions src/common/utils/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,8 @@ export const signupCallbackUrl = (email: string, referralCode?: string) => {
return `https://${process.env.NEXT_PUBLIC_SITE_DOMAIN}/callback/${
CALLBACK_PROVIDERS.EmailSignup
}?${new URLSearchParams({
email: encodeURIComponent(email),
...(referralCode
? { [REFERRAL_QUERY_REFERRAL_KEY]: encodeURIComponent(referralCode) }
: null),
email,
...(referralCode ? { [REFERRAL_QUERY_REFERRAL_KEY]: referralCode } : null),
}).toString()}`
}

Expand Down
31 changes: 31 additions & 0 deletions src/components/Forms/EmailLoginForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ import {
LanguageContext,
LanguageSwitch,
Media,
ReCaptchaContext,
TextIcon,
Turnstile,
TurnstileInstance,
useCountdown,
// toast,
useMutation,
useRoute,
ViewerContext,
} from '~/components'
import { EMAIL_LOGIN } from '~/components/GQL/mutations/emailLogin'
import SEND_CODE from '~/components/GQL/mutations/sendCode'
Expand Down Expand Up @@ -77,6 +81,7 @@ export const EmailLoginForm: React.FC<FormProps> = ({
setAuthFeedType,
back,
}) => {
const viewer = useContext(ViewerContext)
const [login] = useMutation<EmailLoginMutation>(EMAIL_LOGIN, undefined, {
showToast: false,
})
Expand All @@ -93,6 +98,9 @@ export const EmailLoginForm: React.FC<FormProps> = ({

const isNormal = authFeedType === 'normal'
const isWallet = authFeedType === 'wallet'
const { token: reCaptchaToken, refreshToken } = useContext(ReCaptchaContext)
const turnstileRef = useRef<TurnstileInstance>(null)
const [turnstileToken, setTurnstileToken] = useState<string>()

const [isSelectMethod, setIsSelectMethod] = useState(false)
const [errorCode, setErrorCode] = useState<ERROR_CODES | null>(null)
Expand Down Expand Up @@ -225,6 +233,9 @@ export const EmailLoginForm: React.FC<FormProps> = ({
input: {
email: values.email,
type: 'email_otp',
token: turnstileToken
? `${reCaptchaToken} ${turnstileToken}`
: reCaptchaToken,
redirectUrl,
language: lang,
},
Expand Down Expand Up @@ -255,13 +266,33 @@ export const EmailLoginForm: React.FC<FormProps> = ({
)
}
})
refreshToken?.()
turnstileRef.current?.reset()
}
}

const fieldMsgId = `field-msg-sign-in`

const siteKey = process.env
.NEXT_PUBLIC_CLOUDFLARE_TURNSTILE_SITE_KEY as string
const InnerForm = (
<>
<Turnstile
ref={turnstileRef}
siteKey={siteKey}
options={{
action: 'email_login',
cData: `user-group-${viewer.info.group}`,
size: 'invisible',
}}
scriptOptions={{
compat: 'recaptcha',
appendTo: 'body',
}}
onSuccess={(token) => {
setTurnstileToken(token)
}}
/>
<Form id={formId} onSubmit={handleSubmit}>
<Form.Input
label={<FormattedMessage defaultMessage="Email" id="sy+pv5" />}
Expand Down
9 changes: 3 additions & 6 deletions src/components/Forms/EmailSignUpForm/Init.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,9 @@ const Init: React.FC<FormProps> = ({
input: {
email,
type: 'register',
token:
// (viewer.info.group === UserGroup.A && turnstileToken) ||
// turnstileRef.current?.getResponse() || // fallback to ReCaptchaContext token
turnstileToken
? `${reCaptchaToken} ${turnstileToken}`
: reCaptchaToken,
token: turnstileToken
? `${reCaptchaToken} ${turnstileToken}`
: reCaptchaToken,
redirectUrl,
language: lang,
},
Expand Down
3 changes: 2 additions & 1 deletion src/components/Hook/useRoute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { PATHS } from '~/common/enums'
import { useRoute } from './useRoute'

beforeEach(() => {
mockRouter.push(PATHS.ABOUT + '?name=foo')
mockRouter.push(PATHS.ABOUT + '?name=foo&email=test%2Babc%40matters.news')
})

describe('components/Hook/useRoute', () => {
Expand All @@ -26,6 +26,7 @@ describe('components/Hook/useRoute', () => {
it('should return query value by key', () => {
const { result } = renderHook(() => useRoute())
expect(result.current.getQuery('name')).toBe('foo')
expect(result.current.getQuery('email')).toBe('[email protected]')
expect(result.current.getQuery('mediaHash')).toBe('')
})

Expand Down
2 changes: 2 additions & 0 deletions src/views/Home/Announcements/Carousel/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@

& img {
@mixin object-fit-cover;

object-position: right bottom;
}

& picture,
Expand Down
4 changes: 0 additions & 4 deletions src/views/User/UserProfile/DropdownActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@ const DropdownActions = ({ user, isMe, isInAside }: DropdownActionsProps) => {
hasRssFeed: user?.articles.totalCount > 0 && !!user?.info.ipnsKey,
}

if (_isEmpty(_pickBy(controls))) {
return null
}

const WithShare = withDialog<Omit<ShareDialogProps, 'children'>>(
BaseDropdownActions,
ShareDialog,
Expand Down

0 comments on commit f13d982

Please sign in to comment.