Skip to content

Commit

Permalink
feat: Add new ISV navigation (#611)
Browse files Browse the repository at this point in the history
  • Loading branch information
dongrui authored Dec 24, 2018
1 parent f747256 commit 9700678
Show file tree
Hide file tree
Showing 8 changed files with 380 additions and 249 deletions.
357 changes: 205 additions & 152 deletions src/components/Layout/SideNav/index.jsx

Large diffs are not rendered by default.

180 changes: 130 additions & 50 deletions src/components/Layout/SideNav/navMap.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,4 @@
export const subNavMap = {
dashboard: {
title: 'Dashboard',
links: [{ name: 'Overview', link: '/dashboard', active: 'dashboard' }]
},
app: {
title: 'Store',
links: [
{ name: 'All Apps', link: '/dashboard/apps', active: '/app' },
{ name: 'App Reviews', link: '/dashboard/app-reviews', active: 'review' },
{ name: 'Categroies', link: '/dashboard/categories', active: 'categor' }
/* { name: 'Appearance', link: '#', active: 'appearance' } */
]
},
user: {
title: 'Users',
links: [
{ name: 'All Users', link: '/dashboard/users', active: 'user' },
{ name: 'Roles', link: '#', active: 'role' },
{ name: 'Permission and Policy', link: '#', active: 'policy' }
]
},
repo: {
title: 'Platform',
links: [
/* { name: 'Tickets', link: '#', active: 'ticket' },
{ name: 'Notifications', link: '#', active: 'notification' }, */
{ name: 'Repos', link: '/dashboard/repos', active: 'repo' },
{ name: 'Runtimes', link: '/dashboard/runtimes', active: 'runtime' },
{ name: 'All Clusters', link: '/dashboard/clusters', active: 'cluster' }
/* { name: 'Service Status', link: '#', active: 'service' } */
]
},
provider: {
title: 'App service provider',
links: [
{ name: '全部服务商', link: '/dashboard/providers', active: 'providers' },
{
name: '入驻申请',
link: '/dashboard/applications',
active: 'applications'
},
{ name: '合约', link: '#', active: '#' },
{ name: '保证金', link: '#', active: '#' }
]
}
};

// First level navigation(top) for admin, isv and developer
export const getNavs = {
global_admin: [
{
Expand Down Expand Up @@ -97,6 +50,50 @@ export const getNavs = {
title: 'Settings'
}
],
isv: [
{
link: '/dashboard/apps',
iconName: 'appcenter',
active: 'app',
title: 'App Manage'
},
{
link: '#',
iconName: 'wrench',
active: 'develop',
title: 'App Develop'
},
{
link: '#',
iconName: 'ticket',
active: '',
title: 'Work list'
},
{
link: '#',
iconName: 'linechart',
active: '',
title: 'Operation Center'
},
{
link: '#',
iconName: 'wallet',
active: '',
title: 'Financial Center'
},
{
link: '#',
iconName: 'group',
active: 'user',
title: 'Team Members'
},
{
link: '#',
iconName: 'shield',
active: '',
title: '服务商详情'
}
],
developer: [
{
link: '/dashboard/app/create',
Expand All @@ -113,8 +110,9 @@ export const getNavs = {
]
};

// First level navigation(bottom) for all roles
export const getBottomNavs = [
{
/* {
link: '#',
iconName: 'magnifier',
active: '',
Expand All @@ -125,7 +123,7 @@ export const getBottomNavs = [
iconName: 'bell',
active: '',
title: 'Alarms'
},
}, */
{
link: '#',
iconName: 'mail',
Expand All @@ -140,6 +138,87 @@ export const getBottomNavs = [
}
];

// Secondary navigation for admin and isv
export const subNavMap = {
global_admin: {
dashboard: {
title: 'Dashboard',
links: [{ name: 'Overview', link: '/dashboard', active: 'dashboard' }]
},
app: {
title: 'App Store',
links: [
{ name: 'All Apps', link: '/dashboard/apps', active: '/apps' },
{
name: 'App Reviews',
link: '/dashboard/app-reviews',
active: 'review'
},
{
name: 'Categroies',
link: '/dashboard/categories',
active: 'categor'
},
{
name: 'Appearance',
link: '#',
active: 'appearance',
isDisabled: true
}
]
},
provider: {
title: 'App service provider',
links: [
{
name: '全部服务商',
link: '/dashboard/providers',
active: 'provider'
},
{
name: '入驻申请',
link: '/dashboard/applications',
active: 'applications'
},
{
name: '合约',
link: '#',
active: '#',
isDisabled: true
},
{
name: '保证金',
link: '#',
active: '#',
isDisabled: true
}
]
},
user: {
title: 'Users and Permission',
links: [
{ name: 'All Users', link: '/dashboard/users', active: 'user' },
{ name: 'Roles', link: '#', active: 'role' },
{ name: 'Permission and Policy', link: '#', active: 'policy' }
]
}
},
isv: {
app: {
title: 'App Manage',
links: [
{ name: 'All Apps', link: '/dashboard/apps', active: '/apps' },
{
name: 'App Reviews',
link: '/dashboard/app-reviews',
active: 'review'
}
]
}
}
};

// Secondary navigation for developer
export const getDevSubNavs = appId => [
{
title: 'Development',
Expand Down Expand Up @@ -177,6 +256,7 @@ export const getDevSubNavs = appId => [
}
];

// User menus layer for all roles
export const userMenus = [
{
name: 'Account Info',
Expand Down
6 changes: 3 additions & 3 deletions src/components/Layout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class Layout extends Component {
hasBack
} = this.props;

const { isNormal, isDev, isAdmin } = this.props.user;
const hasMenu = (isDev || isAdmin) && !isHome;
const { isNormal } = this.props.user;
const hasMenu = !isNormal && !isHome;
const hasSubNav = hasMenu && !noSubMenu && !hasBack;

if (isNormal) {
Expand Down Expand Up @@ -131,7 +131,7 @@ class Layout extends Component {
{hasBack && (
<Icon
onClick={() => this.goBack()}
name="previous"
name="back"
size={24}
type="dark"
className={styles.backIcon}
Expand Down
9 changes: 7 additions & 2 deletions src/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@
"Developer": "开发者",
"Normal User": "普通用户",
"Permission and Policy": "权限与策略",
"Users and Permission": "用户与权限",
"Email": "邮箱",
"delete_user_desc": "您确定要删除该用户吗?",
"Organization": "机构",
Expand Down Expand Up @@ -390,7 +391,11 @@
"QingCloud App Center": "QingCloud 应用中心",
"My dashboard": "我的工作台",
"App service provider": "应用服务商",
"App Manage": "应用管理",
"App Develop": "应用开发",
"Work list": "工单",
"Operation Center": "运维中心",
"Team Members": "团队成员",
"Financial Center": "财务中心",
"Message and monitoring": "消息与监控",
"Settings": "设置",
Expand Down Expand Up @@ -450,7 +455,7 @@
"LINK_STEPPER_FOOTER_CREATE_RUNTIME_1": "《平台服务条款》",
"STEPPER_FOOTER_CREATE_RUNTIME_2": "关于授权信息的保密与安全问题请参看",
"LINK_STEPPER_FOOTER_CREATE_RUNTIME_2": "《平台服务条款》",

"STEPPER_NAME_CREATE_CREDENTIAL_HEADER": "添加授权信息 {{activeStep}}/{{steps}}",
"STEPPER_TITLE_CREATE_CREDENTIAL_1": "提供环境授权信息",
"STEPPER_TITLE_CREATE_CREDENTIAL_2": "设置名称、备注",
Expand All @@ -459,7 +464,7 @@
"LINK_STEPPER_FOOTER_CREATE_CREDENTIAL_1": "《平台服务条款》",
"STEPPER_FOOTER_CREATE_CREDENTIAL_2": "关于授权信息的保密与安全问题请参看",
"LINK_STEPPER_FOOTER_CREATE_CREDENTIAL_2": "《平台服务条款》",

"Verify": "验证",
"How to get these tips?": "如何获得这些信息?",

Expand Down
50 changes: 15 additions & 35 deletions src/pages/Dashboard/Apps/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -383,45 +383,25 @@ export default class Apps extends Component {
noCancel: false
};

const linkPath = isAdmin ? 'Store>All Apps' : 'My Apps>All';

return (
<Layout>
<BreadCrumb linkPath={linkPath} />

{isAdmin && (
<Layout pageTitle={t('All Apps')}>
{/* {isAdmin && (
<Row>
<Statistics {...summaryInfo} objs={repos.slice()} />
</Row>
)}

<Row>
<Grid>
<Section size={12}>
{isDev && this.renderToolbar(true)}

{viewType === 'card' ? (
this.renderCardApps()
) : (
<Card>
{isAdmin && this.renderToolbar()}

<Table
columns={columns}
dataSource={apps.slice(0, 10)}
rowSelection={rowSelection}
filterList={filterList}
pagination={pagination}
isLoading={isLoading}
/>
</Card>
)}

{this.renderOpsModal()}
{this.renderDeleteDialog()}
</Section>
</Grid>
</Row>
)} */}

<Table
columns={columns}
dataSource={apps.slice(0, 10)}
rowSelection={rowSelection}
filterList={filterList}
pagination={pagination}
isLoading={isLoading}
/>

{this.renderOpsModal()}
{this.renderDeleteDialog()}
</Layout>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Login/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class Login extends Component {
if (res && res.user) {
await store.fetchDetail(res.user.sub, true);
}
const defaultUrl = user.isDev ? '/dashboard/my/apps' : '/dashboard';
const defaultUrl = user.isDev ? '/dashboard/my/apps' : '/dashboard/apps';
if (!(res && res.err)) {
history.push(getUrlParam('url') || defaultUrl);
}
Expand Down
19 changes: 13 additions & 6 deletions src/providers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,23 @@ export default class UserProvider {
}

get isDev() {
return this.changedRole !== ROLE_NORMAL && this.role === ROLE_DEV;
return (
this.changedRole === ROLE_DEV
|| (this.changedRole !== ROLE_NORMAL
&& this.role === ROLE_DEV
&& this.username !== 'isv')
);
}

get isNormal() {
return this.changedRole === ROLE_NORMAL || this.role === ROLE_NORMAL;
}

set isAdmin(boolen) {}

set isDev(boolen) {}

set isNormal(boolen) {}
get isISV() {
return (
this.changedRole !== ROLE_DEV
&& this.role === ROLE_DEV
&& this.username === 'isv'
);
}
}
6 changes: 6 additions & 0 deletions src/utils/icons.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9700678

Please sign in to comment.