Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 16618d0

Browse files
committed
chore: Merge branch 'dev'
2 parents 158ab4a + 03a1966 commit 16618d0

File tree

18 files changed

+211
-107
lines changed

18 files changed

+211
-107
lines changed

components/ArticleActionsPanel/EditOption.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
import T from 'prop-types'
33

44
import { ICON_CMD } from '@config'
5+
import { THREAD } from '@utils'
56
import withGuardian from '@components/HOC/withGuardian'
67

78
import { Option, OptionIcon, OptionTitle } from './styles'
@@ -10,7 +11,11 @@ const EditOption = ({ thread, onEdit }) => (
1011
<React.Fragment>
1112
<Option onClick={onEdit.bind(this, thread)}>
1213
<OptionIcon src={`${ICON_CMD}/edit.svg`} />
13-
<OptionTitle>编辑</OptionTitle>
14+
{thread === THREAD.REPO ? (
15+
<OptionTitle>同步仓库信息</OptionTitle>
16+
) : (
17+
<OptionTitle>编辑</OptionTitle>
18+
)}
1419
</Option>
1520
</React.Fragment>
1621
)

components/GithubRepoPage/index.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
ReadmeWrapper,
2323
Footer,
2424
SearchButton,
25-
SyncButton,
2625
PublishButton,
2726
ReadonlyHolder,
2827
} from './styles'
@@ -32,18 +31,17 @@ const log = buildLog('c:GithubRepoPage:index')
3231

3332
const GithubRepoPage = ({
3433
repo,
34+
updating,
3535
onSearch,
3636
onPublish,
37-
onSync,
3837
showPublishBtn,
3938
showSearchBtn,
40-
showSyncBtn,
4139
viewerHeader,
4240
bodyHeader,
4341
publishing,
4442
readOnly,
4543
}) => (
46-
<Wrapper>
44+
<Wrapper updating={updating}>
4745
{!readOnly ? (
4846
<React.Fragment>{viewerHeader}</React.Fragment>
4947
) : (
@@ -61,17 +59,12 @@ const GithubRepoPage = ({
6159
<MarkDownRender body={repo.readme || ''} />
6260
</ReadmeWrapper>
6361
</BodyWrapper>
64-
<Footer show={showSearchBtn || showSyncBtn || showPublishBtn}>
62+
<Footer show={showSearchBtn || showPublishBtn}>
6563
<Maybe test={showSearchBtn}>
6664
<SearchButton type="primary" ghost onClick={onSearch}>
6765
重新搜索
6866
</SearchButton>
6967
</Maybe>
70-
<Maybe test={showSyncBtn}>
71-
<SyncButton type="primary" ghost onClick={onSync}>
72-
同步仓库
73-
</SyncButton>
74-
</Maybe>
7568
<Maybe test={showPublishBtn}>
7669
{publishing ? (
7770
<PublishButton type="primary">发布中...</PublishButton>
@@ -87,13 +80,12 @@ const GithubRepoPage = ({
8780

8881
GithubRepoPage.propTypes = {
8982
repo: T.object.isRequired,
83+
updating: T.bool,
9084
onPublish: T.func,
9185
onSearch: T.func,
92-
onSync: T.func,
9386

9487
showPublishBtn: T.bool,
9588
showSearchBtn: T.bool,
96-
showSyncBtn: T.bool,
9789

9890
viewerHeader: T.node,
9991
bodyHeader: T.node,
@@ -103,13 +95,12 @@ GithubRepoPage.propTypes = {
10395
}
10496

10597
GithubRepoPage.defaultProps = {
98+
updating: false,
10699
onPublish: log,
107100
onSearch: log,
108-
onSync: log,
109101

110102
showPublishBtn: false,
111103
showSearchBtn: false,
112-
showSyncBtn: false,
113104
viewerHeader: <div />,
114105
bodyHeader: <div />,
115106

components/GithubRepoPage/sch

Whitespace-only changes.

components/GithubRepoPage/styles/index.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import styled from 'styled-components'
22
import { Button } from 'antd'
33

44
// import Img from '@Img'
5-
import { theme, cs } from '@utils'
5+
import { theme, cs, animate } from '@utils'
66

7-
export const Wrapper = styled.div``
7+
export const Wrapper = styled.div`
8+
animation: ${({ updating }) => (updating ? animate.updatingRule : '')};
9+
`
810

911
export const BodyWrapper = styled.div`
1012
${cs.flexColumn('align-center')};
@@ -45,9 +47,6 @@ export const Footer = styled.div`
4547
export const SearchButton = styled(Button)`
4648
margin-right: 10px;
4749
`
48-
export const SyncButton = styled(Button)`
49-
margin-right: 10px;
50-
`
5150
export const PublishButton = styled(Button)``
5251

5352
export const ReadonlyHolder = styled.div`

components/Tooltip/styles/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ export const Wrapper = styled(Tippy)`
1616
}
1717
&[x-placement^='bottom'] {
1818
.tippy-arrow {
19-
border-top-color: ${theme('tooltip.bg')};
19+
border-bottom-color: ${theme('tooltip.bg')};
2020
}
2121
}
2222
&[x-placement^='left'] {
2323
.tippy-arrow {
24-
border-top-color: ${theme('tooltip.bg')};
24+
border-left-color: ${theme('tooltip.bg')};
2525
}
2626
}
2727
&[x-placement^='right'] {
2828
.tippy-arrow {
29-
border-top-color: ${theme('tooltip.bg')};
29+
border-right-color: ${theme('tooltip.bg')};
3030
}
3131
}
3232
`

components/UserBrief/SocialIcons.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import React from 'react'
22
import R from 'ramda'
3-
import ReactTooltip from 'react-tooltip'
43

54
import { ICON_CMD } from '@config'
6-
75
import { nilOrEmpty, SOCIAL_LISTS } from '@utils'
8-
import { Wrapper, Linker, SocialIcon } from './styles/social_icons'
96

10-
const tooltipOffset = JSON.stringify({ left: 3 })
7+
import Tooltip from '@components/Tooltip'
8+
import { Wrapper, Linker, SocialIcon } from './styles/social_icons'
119

1210
const DisplayIcon = ({ user, social }) => {
1311
if (user[social.key] && !R.contains(social.key, ['qq', 'weichat'])) {
@@ -25,17 +23,18 @@ const DisplayIcon = ({ user, social }) => {
2523
)
2624
}
2725
return (
28-
<div
26+
<Tooltip
2927
key={social.key}
30-
data-tip={user.social[social.key]}
31-
data-for="social_icons"
32-
data-offset={tooltipOffset}
28+
content={user.social[social.key]}
29+
placement="bottom"
3330
>
34-
<SocialIcon
35-
src={`${ICON_CMD}/${social.key}.svg`}
36-
active={!nilOrEmpty(user.social[social.key])}
37-
/>
38-
</div>
31+
<div>
32+
<SocialIcon
33+
src={`${ICON_CMD}/${social.key}.svg`}
34+
active={!nilOrEmpty(user.social[social.key])}
35+
/>
36+
</div>
37+
</Tooltip>
3938
)
4039
}
4140

@@ -44,7 +43,6 @@ const SocialIcons = ({ user }) => (
4443
{SOCIAL_LISTS.map(social => (
4544
<DisplayIcon key={social.key} user={user} social={social} />
4645
))}
47-
<ReactTooltip effect="solid" place="bottom" id="social_icons" />
4846
</Wrapper>
4947
)
5048

containers/AccountViewer/Planets.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from 'react'
2-
import ReactTooltip from 'react-tooltip'
32
import R from 'ramda'
43

54
import { sortByIndex } from '@utils'
5+
import Tooltip from '@components/Tooltip'
6+
67
import {
78
Wrapper,
89
HeaderWrapper,
@@ -12,7 +13,6 @@ import {
1213
PlanetsIcon,
1314
} from './styles/planets'
1415

15-
const tooltipOffset = JSON.stringify({ top: 10, left: 5 })
1616
const Planets = ({ subscribedCommunities, viewingType }) => {
1717
if (!subscribedCommunities) return null
1818

@@ -38,17 +38,17 @@ const Planets = ({ subscribedCommunities, viewingType }) => {
3838
</HeaderWrapper>
3939
<IconList>
4040
{sortedCommunities.map(community => (
41-
<div
41+
<Tooltip
4242
key={community.raw}
43-
data-tip={community.title}
44-
data-for="planet_icon"
45-
data-offset={tooltipOffset}
43+
content={community.title}
44+
placement="top"
4645
>
47-
<PlanetsIcon src={community.logo} />
48-
</div>
46+
<div>
47+
<PlanetsIcon src={community.logo} />
48+
</div>
49+
</Tooltip>
4950
))}
5051
</IconList>
51-
<ReactTooltip effect="solid" place="bottom" id="planet_icon" />
5252
</Wrapper>
5353
)
5454
}

containers/AccountViewer/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import React from 'react'
88
import R from 'ramda'
9-
import ReactTooltip from 'react-tooltip'
109

1110
import { connectStore, buildLog } from '@utils'
1211

@@ -41,7 +40,6 @@ const AccountViewerContainer = ({ accountViewer, user }) => {
4140
<AccountWrapper>
4241
{!R.isEmpty(userInfoData.id) && (
4342
<React.Fragment>
44-
<ReactTooltip effect="solid" place="bottom" />
4543
<AccountContent>
4644
<UserBrief
4745
user={userInfoData}

containers/ArticleBodyHeader/logic.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ export const onEdit = thread => {
3939
break
4040

4141
case THREAD.REPO:
42-
type = TYPE.PREVIEW_REPO_EDIT
43-
break
42+
return dispatchEvent(EVENT.SYNC_REPO)
4443

4544
default: {
4645
type = TYPE.PREVIEW_POST_EDIT
@@ -268,18 +267,15 @@ const ErrSolver = [
268267
// init & uninit
269268
// ###############################
270269
export const useInit = _store => {
271-
useEffect(
272-
() => {
273-
store = _store
274-
// log('effect init')
275-
sub$ = sr71$.data().subscribe($solver(DataSolver, ErrSolver))
276-
277-
return () => {
278-
// log('effect uninit')
279-
sr71$.stop()
280-
sub$.unsubscribe()
281-
}
282-
},
283-
[_store]
284-
)
270+
useEffect(() => {
271+
store = _store
272+
// log('effect init')
273+
sub$ = sr71$.data().subscribe($solver(DataSolver, ErrSolver))
274+
275+
return () => {
276+
// log('effect uninit')
277+
sr71$.stop()
278+
sub$.unsubscribe()
279+
}
280+
}, [_store])
285281
}

containers/ArticleViewerHeader/LastSyncInfo.js

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,33 @@ import {
1414
Divider,
1515
} from './styles/reaction'
1616

17-
const LastSyncInfo = ({ show, data }) => (
18-
<Maybe test={show}>
19-
<Popover
20-
placement="bottomLeft"
21-
trigger="hover"
22-
content={<PopInfo>上次与该 Github repo 同步的时间</PopInfo>}
23-
>
24-
<Reaction>
25-
<Divider />
26-
<PlainAction>
27-
<ReactionName>同步于:</ReactionName>
28-
</PlainAction>
29-
<SyncTime>
30-
{data.lastSync ? (
31-
<TimeAgo datetime={data.lastSync} locale="zh_CN" />
32-
) : (
33-
'--'
34-
)}
35-
</SyncTime>
36-
</Reaction>
37-
</Popover>
38-
</Maybe>
39-
)
17+
const LastSyncInfo = ({ show, data }) => {
18+
const lastSyncTime = data.lastSync || data.updatedAt || null
19+
20+
return (
21+
<Maybe test={show}>
22+
<Popover
23+
placement="bottomLeft"
24+
trigger="hover"
25+
content={<PopInfo>上次与该 Github repo 同步的时间</PopInfo>}
26+
>
27+
<Reaction>
28+
<Divider />
29+
<PlainAction>
30+
<ReactionName>同步于:</ReactionName>
31+
</PlainAction>
32+
<SyncTime>
33+
{lastSyncTime ? (
34+
<TimeAgo datetime={lastSyncTime} locale="zh_CN" />
35+
) : (
36+
'--'
37+
)}
38+
</SyncTime>
39+
</Reaction>
40+
</Popover>
41+
</Maybe>
42+
)
43+
}
4044

4145
LastSyncInfo.propTypes = {
4246
data: T.shape({

0 commit comments

Comments
 (0)