Skip to content

Commit

Permalink
fix: App detail page userId transfer name (#626)
Browse files Browse the repository at this point in the history
* fix: Pages time format show

* fix: Modal footer button style
  • Loading branch information
dongrui authored Jan 2, 2019
1 parent fd2a35c commit de8b597
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/components/Base/Modal/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ $padding-left: 24px;
.footer {
padding: 32px $padding-left;
//border-top: 1px solid $N10;
//text-align: right;
text-align: right;
.operationBtn{
margin-left: 192px;
text-align: left;
Expand Down
7 changes: 6 additions & 1 deletion src/locales/zh/apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,10 @@
"STEPPER_TITLE_VERSION_SUBMIT_CHECK_2": "检查版本信息",
"STEPPER_FOOTER_VERSION_SUBMIT_CHECK_2": "版本号以及版本的更新日志都是重要的信息。",
"STEPPER_HEADER_VERSION_SUBMIT_CHECK_2": "「检查应用信息」",
"": ""

"Please input the reason for reject": "请您填写拒绝原因",

"ISV_REVIEW_PASS": "应用服务商审核通过了该应用版本",
"BUSINESS_ADMIN_REVIEW_PASS": "平台商务审核通过了该应用版本",
"DEVELOP_ADMIN_REVIEW_PASS": "平台技术审核审核通过了该应用版本"
}
61 changes: 43 additions & 18 deletions src/pages/Dashboard/Apps/Detail/index.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, { Component, Fragment } from 'react';
import React, { Component } from 'react';
import { observer, inject } from 'mobx-react';
import { Link } from 'react-router-dom';
import { translate } from 'react-i18next';
import _ from 'lodash';
import classNames from 'classnames';

import {
Icon, Input, Table, Button, Image
Expand All @@ -15,6 +14,7 @@ import TdName from 'components/TdName';
import TimeShow from 'components/TimeShow';
import AppStatistics from 'components/AppStatistics';
import versionTypes from 'config/version-types';
import { formatTime } from 'utils';
import Versions from '../../Versions';

import styles from './index.scss';
Expand All @@ -37,31 +37,48 @@ const tags = [
export default class AppDetail extends Component {
async componentDidMount() {
const {
appStore, appVersionStore, clusterStore, match
appStore,
appVersionStore,
clusterStore,
userStore,
match
} = this.props;
const { appId } = match.params;

await appStore.fetch(appId);

await appVersionStore.fetchActiveVersions({ app_id: appId, noLimit: true });

clusterStore.appId = appId;
// get month deploy total
await clusterStore.fetchAll({ app_id: appId, created_date: 30, limit: 1 });
// get deploy total and user instance
await clusterStore.fetchAll({ app_id: appId });

await appVersionStore.fetchAll({ app_id: appId, noLimit: true });
const { appDetail } = appStore;
await userStore.fetchDetail({ user_id: appDetail.owner });
}

changeTab = async tab => {
const { appStore, appVersionStore, match } = this.props;
const {
appStore, appVersionStore, userStore, match
} = this.props;

if (tab !== appStore.detailTab) {
appStore.detailTab = tab;

if (tab === 'online') {
const { appId } = match.params;
await appVersionStore.fetchTypeVersions(appId);
await appVersionStore.fetchTypeVersions(appId, true);
} else if (tab === 'record') {
const { appDetail } = appStore;
const versoinId = _.get(appDetail, 'latest_app_version.version_id', '');
await appVersionStore.fetchAudits(appDetail.app_id, versoinId);
const versionId = _.get(appDetail, 'latest_app_version.version_id', '');
await appVersionStore.fetchAudits(appDetail.app_id, versionId);
// query record relative operators name
const userIds = _.get(appVersionStore.audits, versionId, []).map(
item => item.operator
);
await userStore.fetchAll({ user_id: _.uniq(userIds) });
}
}
};
Expand All @@ -87,8 +104,8 @@ export default class AppDetail extends Component {
const { appDetail } = appStore;
const { users } = userStore;
const { audits } = appVersionStore;
const versoinId = _.get(appDetail, 'latest_app_version.version_id', '');
const records = audits[versoinId] || [];
const versionId = _.get(appDetail, 'latest_app_version.version_id', '');
const records = audits[versionId] || [];

const columns = [
{
Expand All @@ -101,7 +118,7 @@ export default class AppDetail extends Component {
title: t('申请类型'),
key: 'type',
width: '60px',
render: item => item.type
render: item => item.type || t('应用上架')
},
{
title: t('Status'),
Expand All @@ -115,13 +132,13 @@ export default class AppDetail extends Component {
title: t('Update time'),
key: 'status_time',
width: '100px',
render: item => item.status_time
render: item => formatTime(item.status_time, 'YYYY/MM/DD HH:mm:ss')
},
{
title: t('审核人员'),
key: 'operator',
width: '80px',
render: item => item.operator
render: item => (_.find(users, { user_id: item.operator }) || {}).username
}
];

Expand Down Expand Up @@ -217,8 +234,9 @@ export default class AppDetail extends Component {
}

renderAppBase() {
const { appStore, t } = this.props;
const { appStore, userStore, t } = this.props;
const { appDetail } = appStore;
const { userDetail } = userStore;
const categories = _.get(appDetail, 'category_set', []);

return (
Expand Down Expand Up @@ -256,11 +274,11 @@ export default class AppDetail extends Component {
</dl>
<dl>
<dt>{t('开发者')}</dt>
<dd>{appDetail.owner}</dd>
<dd>{userDetail.username}</dd>
</dl>
<dl>
<dt>{t('上架时间')}</dt>
<dd>{appDetail.status_time}</dd>
<dd>{formatTime(appDetail.status_time, 'YYYY/MM/DD HH:mm:ss')}</dd>
</dl>
<Link to="/" className={styles.link}>
{t('去商店中查看')}
Expand All @@ -271,7 +289,9 @@ export default class AppDetail extends Component {
}

render() {
const { appVersionStore, appStore, t } = this.props;
const {
appVersionStore, appStore, clusterStore, t
} = this.props;
const { detailTab } = appStore;
const { versions } = appVersionStore;

Expand All @@ -280,7 +300,12 @@ export default class AppDetail extends Component {
<Grid>
<Section size={4}>{this.renderAppBase()}</Section>
<Section size={8}>
<AppStatistics isAppDetail appTotal={versions.length} />
<AppStatistics
isAppDetail
versionTotal={versions.length}
totalDepoly={clusterStore.totalCount}
monthDepoly={clusterStore.monthCount}
/>
<DetailTabs tabs={tags} changeTab={this.changeTab} />
{detailTab === 'instance' && this.renderInstance()}
{detailTab === 'online' && <Versions />}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Dashboard/Apps/Info/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export default class Info extends Component {

// judge you can edit app info
const { versions } = appVersionStore;
appStore.isEdit = !_.find(versions, { status: 'submitted' });
const { appDetail } = appStore;
appStore.isEdit = !_.find(versions, { status: 'in-view' })
&& appDetail.status !== 'deleted';

// query categories data for category select
await categoryStore.fetchAll();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/Apps/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export default class Apps extends Component {
} = appStore;
const { users } = userStore;
const { isAdmin } = user;
const urlPrefix = isAdmin ? '/store/' : '/dashboard/versions/';
const urlPrefix = '/dashboard/app/';
const columnsFilter = columns => {
const excludeKeys = isAdmin ? 'owner' : 'maintainers';
return columns.filter(item => item.key !== excludeKeys);
Expand Down
1 change: 1 addition & 0 deletions src/pages/Dashboard/Categories/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,5 @@

.dialogFooter{
margin-left: 75px;
text-align: left !important;
}
34 changes: 30 additions & 4 deletions src/pages/Dashboard/Reviews/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ const reviewStatus = {
business_admin: ['isv-passed', 'business-in-review'],
develop_admin: ['business-passed', 'dev-in-review']
};
const rejectStatus = {
isv: 'isv-rejected',
business_admin: 'business-rejected',
develop_admin: 'dev-rejected'
};
const reviewTitle = {
isv: '应用服务商审核',
business_admin: '平台商务审核',
Expand All @@ -48,6 +53,7 @@ const reviewPassNote = {
appVersionStore: rootStore.appVersionStore,
appStore: rootStore.appStore,
categoryStore: rootStore.categoryStore,
userStore: rootStore.userStore,
user: rootStore.user
}))
@observer
Expand Down Expand Up @@ -136,6 +142,21 @@ export default class ReviewDetail extends Component {
);
};

renderOperator(operatorId) {
const {
appVersionStore, userStore, user, t
} = this.props;
const { users } = userStore;
const operator = _.find(users, { user_id: operatorId }) || user;

return (
<div className={styles.operator}>
<label className={styles.name}>{operator.username}</label>{' '}
{operator.email}
</div>
);
}

renderReviewCard(role) {
const { appVersionStore, user, t } = this.props;
const { reviewDetail } = appVersionStore;
Expand Down Expand Up @@ -174,14 +195,19 @@ export default class ReviewDetail extends Component {
<div className={styles.reviewInfo}>
<dl>
<dt>{t('审核人员')}:</dt>
<dd>{record.operator}</dd>
<dd>{this.renderOperator(record.operator)}</dd>
</dl>
<dl>
<dt>{t('开始时间')}:</dt>
<dd>{formatTime(record.review_time, 'YYYY/MM/DD HH:mm:ss')}</dd>
</dl>
</div>
<div className={styles.opreateButtons}>
{user.username === 'develop_admin' && (
<Link to={`/dashboard/app/${reviewDetail.app_id}/deploy`}>
<Button>{t('Deploy Test')}</Button>
</Link>
)}
<Button type="primary" onClick={() => this.handleReview('review')}>
{t('Pass')}
</Button>
Expand All @@ -193,9 +219,9 @@ export default class ReviewDetail extends Component {
);
}

// passed
// passed, rejectd
if (phaseKeys.includes(role) && !reviewStatus[role].includes(status)) {
const isReject = status.indexOf('reject') > -1;
const isReject = status === rejectStatus[role];

return (
<Card
Expand All @@ -210,7 +236,7 @@ export default class ReviewDetail extends Component {
<div className={styles.reviewInfo}>
<dl>
<dt>{t('审核人员')}:</dt>
<dd>{record.operator}</dd>
<dd>{this.renderOperator(record.operator)}</dd>
</dl>
<dl>
<dt>{t('开始时间')}:</dt>
Expand Down
9 changes: 9 additions & 0 deletions src/pages/Dashboard/Reviews/Detail/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,15 @@
float: right;
}
}

.operator {
@include note-font;

.name {
color: $N500;
font-weight: 500;
}
}
}

.rejectMessage {
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Dashboard/Versions/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ export default class VersionDetail extends Component {
/>
<div className={styles.record}>
<div className={styles.operator}>
{t(audit.role)}:&nbsp;{
(_.find(users, { user_id: audit.operator }) || {}).username
}
{t(audit.role)}:&nbsp;{(
_.find(users, { user_id: audit.operator }) || {}
).username || audit.operator}
</div>
{this.renderReason(audit)}
<div className={styles.time}>
Expand Down
8 changes: 6 additions & 2 deletions src/pages/Dashboard/Versions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ export default class Versions extends Component {
}

componentWillUnmount() {
const { appVersionStore } = this.props;
appVersionStore.reset();
const { appVersionStore, match } = this.props;
const appId = _.get(match, 'params.appId', '');

if (appId) {
appVersionStore.reset();
}
}

toggleHistoryVersions(typeVersion) {
Expand Down
5 changes: 5 additions & 0 deletions src/stores/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ class AppStore extends Store {
} else {
await this.fetch(appId);

// if can't get app, should not storage app info
if (!this.appDetail.app_id) {
return;
}

if (appDetail) {
const index = _.findIndex(apps, { app_id: appId });
apps.splice(index, 1, this.appDetail);
Expand Down
Loading

0 comments on commit de8b597

Please sign in to comment.