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

Commit c87775f

Browse files
committed
refactor(normal-community): add jobsTable
1 parent 92e6076 commit c87775f

File tree

9 files changed

+140
-11
lines changed

9 files changed

+140
-11
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React from 'react'
2+
3+
import { ICON_CMD } from '../../config'
4+
import { Popover, BannerCountBrief } from '../../components'
5+
6+
import {
7+
BannerContentWrapper,
8+
Operation,
9+
OperationItem,
10+
OperationDivider,
11+
OperationTitle,
12+
OperationIcon,
13+
OperationIconChart,
14+
} from './styles/common_banner'
15+
16+
import * as logic from './logic'
17+
18+
const JobsBanner = ({ filteredCount, totalCount }) => (
19+
<BannerContentWrapper>
20+
<BannerCountBrief filteredCount={filteredCount} totalCount={totalCount} />
21+
<Operation>
22+
<OperationItem onClick={console.log}>
23+
<OperationIconChart src={`${ICON_CMD}/refresh.svg`} />
24+
刷新
25+
</OperationItem>
26+
<OperationDivider />
27+
<OperationItem>
28+
<OperationIcon src={`${ICON_CMD}/filter2.svg`} />
29+
<Popover
30+
content={<div>兼容各个页面的 Filter 菜单</div>}
31+
trigger="hover"
32+
>
33+
<OperationTitle>过滤</OperationTitle>
34+
</Popover>
35+
</OperationItem>
36+
<OperationDivider />
37+
<OperationItem onClick={logic.onAdd}>
38+
<OperationIconChart src={`${ICON_CMD}/plus.svg`} />
39+
添加
40+
</OperationItem>
41+
<OperationDivider />
42+
<OperationItem>
43+
<OperationIcon src={`${ICON_CMD}/chart.svg`} />
44+
图表
45+
</OperationItem>
46+
</Operation>
47+
</BannerContentWrapper>
48+
)
49+
50+
export default JobsBanner

containers/CommunityBanner/PostsBanner.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ class PostsBanner extends React.Component {
3030
totalCount={totalCount}
3131
/>
3232
<Operation>
33+
<OperationItem onClick={console.log}>
34+
<OperationIconChart src={`${ICON_CMD}/refresh.svg`} />
35+
刷新
36+
</OperationItem>
37+
<OperationDivider />
3338
<OperationItem>
3439
<OperationIcon src={`${ICON_CMD}/filter2.svg`} />
3540
<Popover

containers/CommunityBanner/index.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { makeDebugger, storePlug, stripMobx, ROUTE } from '../../utils'
1313
import * as logic from './logic'
1414

1515
import PostsBanner from './PostsBanner'
16+
import JobsBanner from './JobsBanner'
1617
import TagsBanner from './TagsBanner'
1718
import ThreadsBanner from './ThreadsBanner'
1819
import SubscribersBanner from './SubscribersBanner'
@@ -26,10 +27,11 @@ const debug = makeDebugger('C:CommunityBanner')
2627
const ChildBanner = ({
2728
curRoute,
2829
postsTotalCount,
30+
jobsTotalCount,
2931
tagsTotalCount,
3032
restProps,
3133
}) => {
32-
const { filteredPostsCount } = restProps
34+
const { filteredPostsCount, filteredJobsCount } = restProps
3335

3436
switch (curRoute.subPath) {
3537
case ROUTE.POSTS: {
@@ -40,6 +42,14 @@ const ChildBanner = ({
4042
/>
4143
)
4244
}
45+
case ROUTE.JOBS: {
46+
return (
47+
<JobsBanner
48+
totalCount={jobsTotalCount}
49+
filteredCount={filteredJobsCount}
50+
/>
51+
)
52+
}
4353
case ROUTE.SUBSCRIBERS: {
4454
return <SubscribersBanner totalCount={100} filteredCount={10} />
4555
}
@@ -68,13 +78,19 @@ class CommunityBannerContainer extends React.Component {
6878

6979
render() {
7080
const { communityBanner } = this.props
71-
const { route, postsTotalCount, tagsTotalCount } = communityBanner
81+
const {
82+
curRoute,
83+
postsTotalCount,
84+
jobsTotalCount,
85+
tagsTotalCount,
86+
} = communityBanner
7287

7388
return (
7489
<BannerContainer>
7590
<ChildBanner
76-
curRoute={route}
91+
curRoute={curRoute}
7792
postsTotalCount={postsTotalCount}
93+
jobsTotalCount={jobsTotalCount}
7894
tagsTotalCount={tagsTotalCount}
7995
restProps={stripMobx(communityBanner)}
8096
/>

containers/CommunityBanner/store.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const CommunityBannerStore = t
1515
.model('CommunityBannerStore', {
1616
// postsTotalCount: t.optional(t.number, 0),
1717
filteredPostsCount: t.maybeNull(t.number),
18+
filteredJobsCount: t.maybeNull(t.number),
1819
// tagsTotalCount: t.optional(t.number, 0),
1920
})
2021
.views(self => ({
@@ -24,10 +25,13 @@ const CommunityBannerStore = t
2425
get postsTotalCount() {
2526
return self.root.communityContent.pagedPosts.totalCount
2627
},
28+
get jobsTotalCount() {
29+
return self.root.communityContent.pagedJobs.totalCount
30+
},
2731
get tagsTotalCount() {
2832
return self.root.communityContent.pagedTags.length
2933
},
30-
get route() {
34+
get curRoute() {
3135
const { mainPath, subPath } = self.root.route
3236
return {
3337
mainPath,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react'
2+
3+
import JobsTable from '../../components/JobsTable'
4+
import * as logic from './logic'
5+
6+
const JobsContent = ({ data, restProps: { jobsLoading } }) => (
7+
<JobsTable
8+
data={data}
9+
loading={jobsLoading}
10+
onDelete={logic.onDelete}
11+
onEdit={logic.onEdit}
12+
/>
13+
)
14+
15+
export default JobsContent

containers/CommunityContent/index.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { inject, observer } from 'mobx-react'
1212
import { makeDebugger, storePlug, ROUTE } from '../../utils'
1313

1414
import PostsContent from './PostsContent'
15+
import JobsContent from './JobsContent'
1516
import TagsContent from './TagsContent'
1617

1718
import { Wrapper } from './styles'
@@ -21,15 +22,19 @@ import * as logic from './logic'
2122
const debug = makeDebugger('C:CommunityContent')
2223
/* eslint-enable no-unused-vars */
2324

24-
const renderChildContent = (curRoute, store, restProps) => {
25-
const { pagedPostsData, pagedTagsData } = store
26-
25+
const ChildContent = ({
26+
curRoute,
27+
pagedPostsData,
28+
pagedJobsData,
29+
pagedTagsData,
30+
restProps,
31+
}) => {
2732
switch (curRoute.subPath) {
2833
case ROUTE.POSTS: {
2934
return <PostsContent data={pagedPostsData} restProps={restProps} />
3035
}
3136
case ROUTE.JOBS: {
32-
return <h3>ROUTE.JOBS</h3>
37+
return <JobsContent data={pagedJobsData} restProps={restProps} />
3338
}
3439
case ROUTE.REPOS: {
3540
return <h3>ROUTE.REPOS</h3>
@@ -61,12 +66,23 @@ class CommunityContentContainer extends React.Component {
6166

6267
render() {
6368
const { communityContent } = this.props
64-
const { curRoute } = communityContent
69+
const {
70+
curRoute,
71+
pagedPostsData,
72+
pagedJobsData,
73+
pagedTagsData,
74+
} = communityContent
6575
const restProps = { ...communityContent }
6676

6777
return (
6878
<Wrapper>
69-
{renderChildContent(curRoute, communityContent, restProps)}
79+
<ChildContent
80+
curRoute={curRoute}
81+
pagedPostsData={pagedPostsData}
82+
pagedJobsData={pagedJobsData}
83+
pagedTagsData={pagedTagsData}
84+
restProps={restProps}
85+
/>
7086
</Wrapper>
7187
)
7288
}

containers/CommunityContent/logic.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ export function loadPosts(page = 1) {
4343
sr71$.query(S.pagedPosts, commonFilter(page, community))
4444
}
4545

46+
export function loadJobs(page = 1) {
47+
scrollIntoEle(TYPE.APP_HEADER_ID)
48+
store.markState({ jobsLoading: true })
49+
const { mainPath: community } = store.curRoute
50+
sr71$.query(S.pagedJobs, commonFilter(page, community))
51+
}
52+
4653
export function loadTags() {
4754
scrollIntoEle(TYPE.APP_HEADER_ID)
4855
store.markState({ tagsLoading: true })
@@ -61,6 +68,7 @@ const cancleLoading = () => {
6168
store.markState({
6269
// communitiesLoading: false,
6370
postsLoading: false,
71+
jobsLoading: false,
6472
tagsLoading: false,
6573
})
6674
}
@@ -73,6 +81,13 @@ const DataSolver = [
7381
store.markState({ pagedPosts })
7482
},
7583
},
84+
{
85+
match: asyncRes('pagedJobs'),
86+
action: ({ pagedJobs }) => {
87+
cancleLoading()
88+
store.markState({ pagedJobs })
89+
},
90+
},
7691
{
7792
match: asyncRes('partialTags'),
7893
action: ({ partialTags }) => {
@@ -100,7 +115,7 @@ const DataSolver = [
100115
return loadPosts()
101116
}
102117
case ROUTE.JOBS: {
103-
return console.log('todo')
118+
return loadJobs()
104119
}
105120
case ROUTE.REPOS: {
106121
return console.log('todo')

containers/CommunityContent/store.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ const CommunityContentStore = t
5454
get pagedPostsData() {
5555
return stripMobx(self.pagedPosts)
5656
},
57+
get pagedJobsData() {
58+
return stripMobx(self.pagedJobs)
59+
},
5760
get pagedTagsData() {
5861
return { entries: stripMobx(self.pagedTags) }
5962
},

utils/ssr_helper.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ const ssrCommunityContents = (subPath, resp) => {
5454
communityContent: { pagedPosts: resp.pagedPosts },
5555
}
5656
}
57+
case ROUTE.JOBS: {
58+
return {
59+
communityContent: { pagedJobs: resp.pagedJobs },
60+
}
61+
}
5762
case ROUTE.TAGS: {
5863
return {
5964
communityContent: { pagedTags: resp.partialTags },

0 commit comments

Comments
 (0)