Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Pages show userid change username #447

Merged
merged 2 commits into from
Sep 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/components/DetailCard/AppCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export default class AppCard extends React.Component {
static propTypes = {
appDetail: PropTypes.object.isRequired,
repoName: PropTypes.string,
repoProvider: PropTypes.string
repoProvider: PropTypes.string,
userName: PropTypes.string
};

/*shouldComponentUpdate(nextProps) {
Expand All @@ -26,7 +27,7 @@ export default class AppCard extends React.Component {
}*/

render() {
const { appDetail, repoName, repoProvider, t } = this.props;
const { appDetail, repoName, repoProvider, userName, t } = this.props;

return (
<div className={styles.detailCard}>
Expand Down Expand Up @@ -66,7 +67,7 @@ export default class AppCard extends React.Component {
</li>
<li>
<span className={styles.name}>{t('Developer')}</span>
{appDetail.owner}
{userName}
</li>
<li>
<span className={styles.name}>{t('Date Updated')}</span>
Expand Down
3 changes: 2 additions & 1 deletion src/components/DetailCard/ClusterCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export default class ClusterCard extends Component {
detail: PropTypes.object.isRequired,
appName: PropTypes.string,
runtimeName: PropTypes.string,
provider: PropTypes.string
provider: PropTypes.string,
userName: PropTypes.string
};

render() {
Expand Down
7 changes: 4 additions & 3 deletions src/components/DetailCard/RuntimeCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ export default class RuntimeCard extends Component {
static propTypes = {
detail: PropTypes.object.isRequired,
appCount: PropTypes.number,
clusterCount: PropTypes.number
clusterCount: PropTypes.number,
userName: PropTypes.string
};

render() {
const { detail, appCount, clusterCount, t } = this.props;
const { detail, appCount, clusterCount, userName, t } = this.props;

return (
<div className={styles.detailCard}>
Expand Down Expand Up @@ -61,7 +62,7 @@ export default class RuntimeCard extends Component {
)}
<li>
<span className={styles.name}>{t('Creator')}</span>
{detail.owner}
{userName}
</li>
<li>
<span className={styles.name}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/DetailCard/UserCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export default class UserCard extends React.Component {
return (
<div className={styles.detailCard}>
<div className={styles.title}>
<div className={styles.name} title={userDetail.name}>
{userDetail.name}
<div className={styles.name} title={userDetail.username}>
{userDetail.username}
</div>
<CopyId id={userDetail.user_id} />
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/components/Footer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ export default class Footer extends PureComponent {
<img src="/logo_grey.svg" alt="logo" height="100%" />
</span>
<ul className={styles.terms}>
<li>
<a target="_blank" href="https://docs.openpitrix.io/v1.0/zh-CN/developer-guide/ ">
{t('Document')}
</a>
</li>
<li>
<a target="_blank" href="https://openpitrix.io" rel="noreferrer">
{t('About')}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Layout/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
margin: 56px 20px 32px $menu-width+20px;
width: calc(100% - #{$menu-width} - 40px);
//min-width:calc(#{$content-width} - #{$menu-width} - 40px);
min-width: 900px;
min-width: 950px;
min-height: calc(100vh - 100px);
padding-top: 0;
}
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@

"Back to user": "切换为普通用户",
"Back to developer": "切换为开发者",
"Document": "文档",

"None": "无"
}
8 changes: 7 additions & 1 deletion src/pages/Admin/Apps/Add/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,13 @@ export default class AppAdd extends Component {

<div className={styles.operateWord}>
{t('view_guide_1')}
<span className={styles.link}>{t('view_guide_2')}</span>
<a
className={styles.link}
target="_blank"
href="https://docs.openpitrix.io/v1.0/zh-CN/developer-guide/ "
>
{t('view_guide_2')}
</a>
{t('view_guide_3')}
</div>
{createError && (
Expand Down
21 changes: 14 additions & 7 deletions src/pages/Admin/Apps/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,13 @@ export default class AppDetail extends Component {

<div className={styles.operateWord}>
{t('view_guide_1')}
<span className={styles.link} onClick={() => this.setCreateStep(2)}>
<a
className={styles.link}
target="_blank"
href="https://docs.openpitrix.io/v1.0/zh-CN/developer-guide/ "
>
{t('view_guide_2')}
</span>
</a>
{t('view_guide_3')}
</div>
{createError && (
Expand Down Expand Up @@ -412,7 +416,13 @@ export default class AppDetail extends Component {
)}
<div className={styles.viewGuide}>
{t('view_guide_1')}
<span className={styles.link}>{t('view_guide_2')}</span>
<a
className={styles.link}
target="_blank"
href="https://docs.openpitrix.io/v1.0/zh-CN/developer-guide/ "
>
{t('view_guide_2')}
</a>
{t('view_guide_3')}
</div>
{createError && (
Expand Down Expand Up @@ -570,10 +580,7 @@ export default class AppDetail extends Component {
(createStep === 2 ? this.renderCreateSuccess() : this.renderCreateVersion())}
{!isShowCreate && (
<Fragment>
<TagNav
tags={['Information', 'Clusters', 'Logs']}
changeTag={this.changeDetailTab}
/>
<TagNav tags={['Information', 'Clusters']} changeTag={this.changeDetailTab} />
{detailTab === 'Information' ? (
this.renderInformation()
) : (
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Admin/Apps/Review/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default class Review extends Component {
name={getObjName(apps, 'app_id', item.app_id, 'name')}
description={item.app_id}
image={item.icon || 'appcenter'}
linkUrl={`/dashboard/review/${item.app_id}?versionId=${item.version_id}`}
linkUrl={`/dashboard/review/${item.app_id}/${item.version_id}`}
/>
)
},
Expand Down
20 changes: 11 additions & 9 deletions src/pages/Admin/Apps/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import styles from './index.scss';
appStore: rootStore.appStore,
categoryStore: rootStore.categoryStore,
repoStore: rootStore.repoStore,
userStore: rootStore.userStore,
user: rootStore.user
}))
@observer
Expand All @@ -43,12 +44,13 @@ export default class Apps extends Component {
repoStore.loadPageInit();
}

componentDidMount() {
const { appStore, user } = this.props;
async componentDidMount() {
const { appStore, userStore, user } = this.props;
const { isAdmin } = user;

if (isAdmin) {
appStore.fetchStatistics();
await appStore.fetchStatistics();
await userStore.fetchAll({ noLimit: true });
}
}

Expand Down Expand Up @@ -80,7 +82,6 @@ export default class Apps extends Component {
const { appStore, categoryStore, t } = this.props;
const { isModalOpen, hideModal, handleApp, changeAppCate, modifyCategoryById } = appStore;
const categories = categoryStore.categories.toJSON();

const { selectedCategory } = handleApp;

return (
Expand Down Expand Up @@ -204,9 +205,10 @@ export default class Apps extends Component {
}

render() {
const { appStore, repoStore, user, t } = this.props;
const { appStore, repoStore, userStore, user, t } = this.props;
const { apps, summaryInfo, isLoading, onChangeStatus, selectStatus, viewType } = appStore;
const { repos } = repoStore;
const { users } = userStore;
const { isNormal, isDev, isAdmin } = user;

let navLinkShow = t('My Apps') + ' / ' + t('All');
Expand Down Expand Up @@ -276,9 +278,9 @@ export default class Apps extends Component {
},
{
title: t('Developer'),
key: 'developer',
key: 'owner',
width: '80px',
render: item => item.owner
render: item => getObjName(users, 'user_id', item.owner, 'username') || item.owner
},
{
title: t('Updated At'),
Expand All @@ -302,8 +304,8 @@ export default class Apps extends Component {
}
];

if (isDev) {
columns = columns.filter(item => item.key !== 'developer');
if (!isAdmin) {
columns = columns.filter(item => item.key !== 'owner');
}

const rowSelection = {
Expand Down
15 changes: 13 additions & 2 deletions src/pages/Admin/Clusters/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import styles from './index.scss';
appStore: rootStore.appStore,
appVersionStore: rootStore.appVersionStore,
runtimeStore: rootStore.runtimeStore,
userStore: rootStore.userStore,
user: rootStore.user,
sock
}))
Expand All @@ -37,9 +38,16 @@ export default class ClusterDetail extends Component {
}

componentDidMount() {
const { clusterStore, clusterDetailStore, runtimeStore, appStore, match } = this.props;
const {
clusterStore,
clusterDetailStore,
runtimeStore,
appStore,
userStore,
match
} = this.props;
const clusterId = get(match, 'params.clusterId');
clusterDetailStore.fetchPage({ clusterId, clusterStore, runtimeStore, appStore });
clusterDetailStore.fetchPage({ clusterId, clusterStore, runtimeStore, appStore, userStore });
}

listenToJob = async ({ op, rtype, rid, values = {} }) => {
Expand Down Expand Up @@ -194,6 +202,7 @@ export default class ClusterDetail extends Component {
clusterStore,
clusterDetailStore,
runtimeStore,
userStore,
user,
t
} = this.props;
Expand All @@ -214,6 +223,7 @@ export default class ClusterDetail extends Component {
const appName = _.get(appStore.appDetail, 'name', '');
const runtimeName = _.get(runtimeDetail, 'name', '');
const provider = _.get(runtimeDetail, 'provider', '');
const userName = _.get(userStore.userDetail, 'name', '');

const { isNormal, isDev, isAdmin } = user;

Expand Down Expand Up @@ -265,6 +275,7 @@ export default class ClusterDetail extends Component {
appName={appName}
runtimeName={runtimeName}
provider={provider}
userName={userName}
/>
<Popover
className="operation"
Expand Down
25 changes: 17 additions & 8 deletions src/pages/Admin/Clusters/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import styles from './index.scss';
clusterStore: rootStore.clusterStore,
appStore: rootStore.appStore,
runtimeStore: rootStore.runtimeStore,
userStore: rootStore.userStore,
user: rootStore.user,
sock
}))
Expand Down Expand Up @@ -47,12 +48,13 @@ export default class Clusters extends Component {
this.store = clusterStore;
}

componentDidMount() {
const { clusterStore, user } = this.props;
async componentDidMount() {
const { clusterStore, userStore, user } = this.props;
const { isAdmin } = user;

if (isAdmin) {
clusterStore.fetchStatistics();
await clusterStore.fetchStatistics();
await userStore.fetchAll({ noLimit: true });
}
}

Expand Down Expand Up @@ -210,13 +212,14 @@ export default class Clusters extends Component {
}

render() {
const { clusterStore, user, t } = this.props;
const { clusterStore, appStore, userStore, user, t } = this.props;
const { summaryInfo, clusters, isLoading } = clusterStore;

const runtimes = this.props.runtimeStore.allRuntimes;
const { apps } = this.props.appStore;
const { apps } = appStore;
const { users } = userStore;

const columns = [
let columns = [
{
title: t('Cluster Name'),
key: 'name',
Expand Down Expand Up @@ -257,17 +260,19 @@ export default class Clusters extends Component {
{
title: t('Node Count'),
key: 'node_count',
width: '80px',
render: cl => (cl.cluster_node_set && cl.cluster_node_set.length) || 0
},
{
title: t('User'),
key: 'owner',
render: cl => cl.owner
width: '100px',
render: item => getObjName(users, 'user_id', item.owner, 'username') || item.owner
},
{
title: t('Created At'),
key: 'create_time',
width: '150px',
width: '100px',
sorter: true,
onChangeSort: this.onChangeSort,
render: cl => formatTime(cl.create_time, 'YYYY/MM/DD HH:mm:ss')
Expand All @@ -286,6 +291,10 @@ export default class Clusters extends Component {
}
];

if (!user.isAdmin) {
columns = columns.filter(item => item.key !== 'owner');
}

const rowSelection = {
type: 'checkbox',
selectType: 'onSelect',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Admin/Overview/AppList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class AppList extends PureComponent {
imageSize={24}
name={item.name || app.name}
description={item.description || app.description}
linkUrl={isAdmin ? `/dashboard/app/${item.id}` : `/app/${item.app_id}`}
linkUrl={isAdmin ? `/app/${item.id}` : `/dashboard/app/${item.app_id}`}
noCopy={true}
/>
</li>
Expand Down
7 changes: 6 additions & 1 deletion src/pages/Admin/Overview/RepoList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ export default class RepoList extends PureComponent {
return (
<li key={item.id || item.runtime_id}>
<Link to={link}>
<Icon name={provider} size={24} className={styles.icon} type="dark" />
<Icon
name={provider || 'stateful-set'}
size={24}
className={styles.icon}
type="dark"
/>
<span className={styles.name}>{item.name || repo.name}</span>
<span className={styles.total}>
<span className={styles.number}>{number}</span>
Expand Down
Loading