From 99162c71838702e9c71d8e722acfb445f4ffbbff Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 26 Oct 2017 17:17:51 +0800 Subject: [PATCH] update activities data --- mock/api.js | 56 ++++++++++++++++++++++++--- src/routes/Dashboard/Workplace.js | 59 +++++++++++++++++------------ src/routes/Dashboard/Workplace.less | 2 +- 3 files changed, 86 insertions(+), 31 deletions(-) diff --git a/mock/api.js b/mock/api.js index ddbf3bc0..b444b47c 100644 --- a/mock/api.js +++ b/mock/api.js @@ -176,7 +176,15 @@ export const getActivities = [ name: '林东东', avatar: imgMap.a, }, - action: '在 [高逼格设计天团](http://github.com/) 新建项目 [六月迭代](http://github.com/)', + group: { + name: '高逼格设计天团', + link: 'http://github.com/', + }, + project: { + name: '六月迭代', + link: 'http://github.com/', + }, + template: '在 @{group} 新建项目 @{project}', }, { id: 'trend-2', @@ -185,7 +193,15 @@ export const getActivities = [ name: '付小小', avatar: imgMap.c, }, - action: '在 [高逼格设计天团](http://github.com/) 新建项目 [六月迭代](http://github.com/)', + group: { + name: '高逼格设计天团', + link: 'http://github.com/', + }, + project: { + name: '六月迭代', + link: 'http://github.com/', + }, + template: '在 @{group} 新建项目 @{project}', }, { id: 'trend-3', @@ -194,7 +210,15 @@ export const getActivities = [ name: '曲丽丽', avatar: imgMap.b, }, - action: '在 [中二少女团](http://github.com/) 新建项目 [六月迭代](http://github.com/)', + group: { + name: '中二少女团', + link: 'http://github.com/', + }, + project: { + name: '六月迭代', + link: 'http://github.com/', + }, + template: '在 @{group} 新建项目 @{project}', }, { id: 'trend-4', @@ -203,7 +227,11 @@ export const getActivities = [ name: '周星星', avatar: imgMap.c, }, - action: '在 [5 月日常迭代](http://github.com/) 更新至已发布状态', + project: { + name: '5 月日常迭代', + link: 'http://github.com/', + }, + template: '将 @{project} 更新至已发布状态', }, { id: 'trend-5', @@ -212,7 +240,15 @@ export const getActivities = [ name: '朱偏右', avatar: imgMap.a, }, - action: '在 [工程效能](http://github.com/) 发布了 [留言](http://github.com/)', + project: { + name: '工程效能', + link: 'http://github.com/', + }, + comment: { + name: '留言', + link: 'http://github.com/', + }, + template: '在 @{project} 发布了 @{comment}', }, { id: 'trend-6', @@ -221,7 +257,15 @@ export const getActivities = [ name: '乐哥', avatar: imgMap.d, }, - action: '在 [程序员日常](http://github.com/) 新建项目 [品牌迭代](http://github.com/)', + group: { + name: '程序员日常', + link: 'http://github.com/', + }, + project: { + name: '品牌迭代', + link: 'http://github.com/', + }, + template: '在 @{group} 新建项目 @{project}', }, ]; diff --git a/src/routes/Dashboard/Workplace.js b/src/routes/Dashboard/Workplace.js index 935a3a58..ba1bd086 100644 --- a/src/routes/Dashboard/Workplace.js +++ b/src/routes/Dashboard/Workplace.js @@ -96,10 +96,43 @@ export default class Workplace extends PureComponent { }); } + renderActivities() { + const { + activities: { list }, + } = this.props; + return list.map((item) => { + const events = item.template.split(/@\{([^{}]*)\}/gi).map((key) => { + if (item[key]) { + return {item[key].name}; + } + return key; + }); + return ( + + } + title={ + + {item.user.name} +   + {events} + + } + description={ + + {moment(item.updatedAt).fromNow()} + + } + /> + + ); + }); + } + render() { const { project: { loading: projectLoading, notice }, - activities: { loading: activitiesLoading, list: activitiesList }, + activities: { loading: activitiesLoading }, chart: { radarData }, } = this.props; @@ -183,29 +216,7 @@ export default class Workplace extends PureComponent { >
- { - activitiesList.map(item => ( - - } - title={ - - {item.user.name} -   - - 在 xx 新建了项目 xxxx - - - } - description={ - - {moment(item.updatedAt).fromNow()} - - } - /> - - )) - } + {this.renderActivities()}
diff --git a/src/routes/Dashboard/Workplace.less b/src/routes/Dashboard/Workplace.less index 0174a317..7889bd6d 100644 --- a/src/routes/Dashboard/Workplace.less +++ b/src/routes/Dashboard/Workplace.less @@ -6,7 +6,7 @@ .username { color: @text-color; } - .operation { + .event { font-weight: normal; } } -- GitLab