Skip to content

Commit

Permalink
Merge pull request #1498 from thematters/develop
Browse files Browse the repository at this point in the history
Release: v3.15.0
  • Loading branch information
devformatters authored Sep 11, 2020
2 parents 945ca51 + 88e96c0 commit b5ff4d3
Show file tree
Hide file tree
Showing 42 changed files with 916 additions and 288 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
branches:
- master
- develop
pull_request:
branches:
- '*'

env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Test

on:
pull_request:
branches:
- '*'

jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master

- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: '12.16'

- name: Cache Dependencies
id: cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install Dependencies
run: npm ci

- name: Generate Types
if: github.ref == 'refs/heads/develop' || github.base_ref == 'develop'
run: |
npm run gen:clean \
&& npm run gen:type
- name: Generate Types (production)
if: github.ref == 'refs/heads/master' || github.base_ref == 'master'
run: |
npm run gen:clean \
&& npm run gen:type:prod
- name: Lint
run: |
npm run lint \
&& npm run format:check
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# matters-web

![Deploy Status](https://github.com/thematters/matters-web/workflows/Deployment/badge.svg) ![Release Status](https://github.com/thematters/matters-web/workflows/Create%20Release/badge.svg) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
![Deployment Status](https://github.com/thematters/matters-web/workflows/Deployment/badge.svg) ![Test Status](https://github.com/thematters/matters-web/workflows/Test/badge.svg) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)

## Getting Started

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matters-web",
"version": "3.14.0",
"version": "3.15.0",
"description": "codebase of Matters' website",
"sideEffects": false,
"author": "Matters <[email protected]>",
Expand Down
3 changes: 3 additions & 0 deletions src/common/enums/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ export const OPEN_SIGNUP_DIALOG = 'openSignUpDialog'
export const OPEN_RESET_PASSWORD_DIALOG = 'openPassword'
export const CLOSE_ACTIVE_DIALOG = 'closeActiveDialog'
export const OPEN_LIKE_COIN_DIALOG = 'openLikeCoinDialog'

// Preference
export const CHANGE_NEW_USER_HOME_FEED_SORT_BY = 'changeNewUserHomeFeedSortBy'
53 changes: 41 additions & 12 deletions src/common/enums/oauth.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,58 @@
import { TEXT } from '~/common/enums'

export const OAUTH_PROVIDER = ['likecoin', 'stripe-connect']

export const OAUTH_SCOPE_TREE = {
query: {
viewer: {
__text__: {
zh_hant: ` Liker ID、${TEXT.zh_hant.email}${TEXT.zh_hant.settingsAccount}${TEXT.zh_hant.draft}、收藏作品、${TEXT.zh_hant.readHistory}`,
zh_hans: ` Liker ID、${TEXT.zh_hant.email}${TEXT.zh_hant.settingsAccount}${TEXT.zh_hant.draft}、收藏作品、${TEXT.zh_hant.readHistory}`,
_t: {
zh_hant: `Liker ID、電子信箱、帳戶設定、草稿、收藏作品、瀏覽記錄等`,
zh_hans: `Liker ID、邮箱、帳戶设定、草稿、收藏作品、浏览记录等`,
},
likerId: {
__text__: {
zh_hant: ' Liker ID',
zh_hans: ' Liker ID',
_t: {
zh_hant: 'Liker ID',
zh_hans: 'Liker ID',
},
},
info: {
email: {
__text__: {
zh_hant: TEXT.zh_hant.email,
zh_hans: TEXT.zh_hant.email,
_t: {
zh_hant: '電子信箱',
zh_hans: '邮箱',
},
},
},
},
},
mutation: {},
mutation: {
level1: {
_t: {
zh_hant: '基本信息、標籤、評論、封鎖、追蹤等',
zh_hans: '基本信息、标签、评论、屏蔽、追踪等',
},
},
level2: {
_t: {
zh_hant: '作品發佈、評論修改、草稿刪除等',
zh_hans: '作品发布、评论修改、草稿删除等',
},
publishArticle: {
_t: {
zh_hant: '作品發佈',
zh_hans: '作品发布',
},
},
},
level3: {
_t: {
zh_hant: '作品修訂、錢包、金流等',
zh_hans: '文章修订、钱包、支付等',
},
putDraft: {
_t: {
zh_hant: '作品草稿',
zh_hans: '作品草稿',
},
},
},
},
}
4 changes: 2 additions & 2 deletions src/common/enums/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export const TEXT = {
tagEdited: '標籤已更新',
tagName: '標籤名稱',
tagAddArticle: '添加我的作品',
tagAddSelectedArticle: '添加精選內容',
tagAddSelectedArticle: '添加精選',
term: '用戶協議',
termAndPrivacy: '用戶協議與隱私政策',
termHint: '我們的用戶協議和隱私政策發生了更改,請閱讀並同意後繼續使用。',
Expand Down Expand Up @@ -529,7 +529,7 @@ export const TEXT = {
tagEdited: '标签已更新',
tagName: '标签名称',
tagAddArticle: '添加我的作品',
tagAddSelectedArticle: '添加精选內容',
tagAddSelectedArticle: '添加精选',
term: '用户协议',
termAndPrivacy: '用户协议与隐私政策',
termHint: '我们的用户协议和隐私政策发生了更改,请阅读并同意后继续使用。',
Expand Down
1 change: 1 addition & 0 deletions src/common/gql/fragmentTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"possibleTypes": [
{ "name": "ArticleConnection" },
{ "name": "CommentConnection" },
{ "name": "FolloweeDonatedArticleConnection" },
{ "name": "ResponseConnection" },
{ "name": "TagConnection" },
{ "name": "UserConnection" },
Expand Down
16 changes: 11 additions & 5 deletions src/common/utils/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ const iterateScopeTexts = (
lang: Language,
scopeTexts: string[]
) => {
// retrieve root scope's __text__
if (scopes.__text__ && scopes.__text__[lang]) {
scopeTexts.push(scopes.__text__[lang])
// retrieve root scope's _t
if (scopes._t && scopes._t[lang]) {
scopeTexts.push(scopes._t[lang])
return
}

// retrieve all nested scopes' __text__
// retrieve all nested scopes' _t
Object.keys(scopes).forEach((key) => {
if (key === lang) {
scopeTexts.push(scopes[key])
Expand Down Expand Up @@ -46,7 +46,13 @@ export const toReadableScope = ({
prefix = {
zh_hant: '讀取你的',
zh_hans: '读取你的',
en: '讀取你的',
en: 'Query your',
}[lang]
} else if (scope.indexOf('mutation') >= 0) {
prefix = {
zh_hant: '管理你的',
zh_hans: '管理你的',
en: 'Manage your',
}[lang]
}

Expand Down
14 changes: 8 additions & 6 deletions src/components/Buttons/Share/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { TEXT } from '~/common/enums'
type ShareButtonBaseProps = {
hasIcon?: boolean
iconSize?: Extract<IconSize, 'md-s'>
iconColor?: Extract<IconColor, 'grey' | 'black'>
iconColor?: Extract<IconColor, 'green' | 'grey' | 'black' | 'white'>
inCard: boolean
} & Omit<ShareDialogProps, 'children'>

Expand All @@ -33,11 +33,13 @@ export const ShareButton: React.FC<ShareButtonProps> = ({
...props
}) => {
const isGreen = bgColor === 'green'
const buttonBgActiveColor = isGreen
? undefined
: inCard
? 'grey-lighter-active'
: 'grey-lighter'
const isHalfBlack = bgColor === 'half-black'
const buttonBgActiveColor =
isGreen || isHalfBlack
? undefined
: inCard
? 'grey-lighter-active'
: 'grey-lighter'
const buttonSpacing = spacing || ['xtight', 'xtight']

return (
Expand Down
42 changes: 40 additions & 2 deletions src/components/ClientUpdater/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { useQuery } from '@apollo/react-hooks'
import differenceInDays from 'date-fns/differenceInDays'
import parseISO from 'date-fns/parseISO'
import { Router } from 'next/router'
import { useEffect, useRef } from 'react'

import { useWindowResize } from '~/components'
import { useEventListener, useWindowResize } from '~/components'
import CLIENT_INFO from '~/components/GQL/queries/clientInfo'

import { STORE_KEY_VIEW_MODE } from '~/common/enums'
import {
CHANGE_NEW_USER_HOME_FEED_SORT_BY,
STORE_KEY_VIEW_MODE,
} from '~/common/enums'

import { ClientInfo } from '~/components/GQL/queries/__generated__/ClientInfo'

Expand Down Expand Up @@ -74,5 +79,38 @@ export const ClientUpdater = () => {
})
}, [])

/**
* Change specific new user's home feed.
*/
const changeNewUserHomeFeedSortBy = ({
createdAt,
group,
}: {
createdAt: Date | string | number | null
group: 'a' | 'b' | null
}) => {
if (!createdAt || !group) {
return
}

if (typeof createdAt === 'string') {
createdAt = parseISO(createdAt)
}

if (differenceInDays(new Date(), createdAt) > 7 || group !== 'b') {
return
}

client.writeData({
id: 'ClientPreference:local',
data: { feedSortType: 'icymi' },
})
}

useEventListener(
CHANGE_NEW_USER_HOME_FEED_SORT_BY,
changeNewUserHomeFeedSortBy
)

return null
}
3 changes: 2 additions & 1 deletion src/components/Context/Features/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import React from 'react'

import { FeatureOfficial } from './__generated__/FeatureOfficial'

type FeatureName = 'payment' | 'add_credit' | 'payout'
type FeatureName = 'payment' | 'add_credit' | 'payout' | 'tag_adoption'

export const FeaturesContext = React.createContext({
payment: false,
add_credit: false,
payout: false,
tag_adoption: false,
})

export const FeaturesConsumer = FeaturesContext.Consumer
Expand Down
1 change: 1 addition & 0 deletions src/components/Context/Viewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const ViewerFragments = {
hasPaymentPassword
}
info {
createdAt
email
agreeOn
userNameEditable
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/Footer/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button, ButtonProps, IconSpinner, TextIcon } from '~/components'

type DialogFooterButtonProps = {
textColor?: 'black' | 'white' | 'grey'
bgColor?: 'green' | 'grey-lighter' | 'red' | 'white'
bgColor?: 'green' | 'grey-lighter' | 'red' | 'white' | 'gold'
icon?: React.ReactNode

loading?: boolean
Expand Down
Loading

0 comments on commit b5ff4d3

Please sign in to comment.