diff --git a/src/index.js b/src/index.js
index 3c9d159a..aaa0f4cf 100644
--- a/src/index.js
+++ b/src/index.js
@@ -18,6 +18,9 @@ store.registerStores();
if (typeof window !== 'undefined') {
const AppWithRouter = withRouter(App);
+ try {
+ store.loginUser = JSON.parse(getCookie('loginUser') || '{}');
+ } catch (err) {}
import('./routes').then(({ default: routes }) => {
let sc = null;
diff --git a/src/pages/Admin/Apps/Add/RepoList/index.jsx b/src/pages/Admin/Apps/Add/RepoList/index.jsx
index fb3f2bac..13877586 100644
--- a/src/pages/Admin/Apps/Add/RepoList/index.jsx
+++ b/src/pages/Admin/Apps/Add/RepoList/index.jsx
@@ -27,7 +27,7 @@ export default class RepoList extends PureComponent {
return (
-
{capitalize(type)}
+
{t(capitalize(type))}
{repos.map(repo => (
-
-
-
+
+
this.selectRepoNext(selectRepos.length)}
diff --git a/src/pages/Admin/Apps/Detail/DetailBlock/index.jsx b/src/pages/Admin/Apps/Detail/DetailBlock/index.jsx
index 73bb9e1d..06417fc4 100644
--- a/src/pages/Admin/Apps/Detail/DetailBlock/index.jsx
+++ b/src/pages/Admin/Apps/Detail/DetailBlock/index.jsx
@@ -40,7 +40,7 @@ export default class DetailBlock extends React.Component {
- {t('Status')}
-
-
+
diff --git a/src/pages/Admin/Apps/Review/index.jsx b/src/pages/Admin/Apps/Review/index.jsx
index 46f10a17..e50d5dd7 100644
--- a/src/pages/Admin/Apps/Review/index.jsx
+++ b/src/pages/Admin/Apps/Review/index.jsx
@@ -66,6 +66,12 @@ export default class Review extends Component {
const { repos } = repoStore;
let columns = [
+ {
+ title: t('Status'),
+ key: 'status',
+ width: '110px',
+ render: item =>
+ },
{
title: t('App Name'),
key: 'name',
@@ -85,12 +91,6 @@ export default class Review extends Component {
width: '120px',
render: item => get(item, 'latest_app_version.name', '')
},
- {
- title: t('Status'),
- key: 'status',
- width: '90px',
- render: item =>
- },
{
title: t('Categories'),
key: 'category',
@@ -103,12 +103,6 @@ export default class Review extends Component {
.join(', ')
)
},
- {
- title: t('Visibility'),
- key: 'visibility',
- width: '65px',
- render: item => t(getObjName(repos, 'repo_id', item.repo_id, 'visibility'))
- },
{
title: t('Repo'),
key: 'repo_id',
@@ -132,7 +126,7 @@ export default class Review extends Component {
{
title: t('Updated At'),
key: 'status_time',
- width: '112px',
+ width: '92px',
sorter: this.role === 'global_admin',
onChangeSort: this.onChangeSort,
render: item =>
diff --git a/src/pages/Admin/Apps/index.jsx b/src/pages/Admin/Apps/index.jsx
index 4d53f14d..8aeeebde 100644
--- a/src/pages/Admin/Apps/index.jsx
+++ b/src/pages/Admin/Apps/index.jsx
@@ -26,11 +26,12 @@ import styles from './index.scss';
}))
@observer
export default class Apps extends Component {
- static async onEnter({ appStore, categoryStore, repoStore, sessInfo }) {
+ static async onEnter({ appStore, categoryStore, repoStore, loginUser }) {
await appStore.fetchAll();
await repoStore.fetchAll({
status: ['active', 'deleted'],
- noLimit: true
+ noLimit: true,
+ isQueryPublic: loginUser.isDev
});
await categoryStore.fetchAll();
}
@@ -205,9 +206,15 @@ export default class Apps extends Component {
render() {
const { appStore, repoStore, t } = this.props;
const { apps, summaryInfo, isLoading, onChangeStatus, selectStatus, viewType } = appStore;
-
const { repos } = repoStore;
+ let navLinkShow = t('My Apps') + ' / ' + t('All');
+ let urlFront = '/dashboard/app/';
+ if (this.role === 'global_admin') {
+ navLinkShow = t('Store') + ' / ' + t('All Apps');
+ urlFront = '/store/';
+ }
+
let columns = [
{
title: t('App Name'),
@@ -218,7 +225,7 @@ export default class Apps extends Component {
name={item.name}
description={item.app_id}
image={item.icon || 'appcenter'}
- linkUrl={`/dashboard/app/${item.app_id}`}
+ linkUrl={urlFront + item.app_id}
/>
)
},
@@ -326,11 +333,6 @@ export default class Apps extends Component {
noCancel: false
};
- let navLinkShow = t('My Apps') + ' / ' + t('All');
- if (this.role === 'global_admin') {
- navLinkShow = t('Store') + ' / ' + t('All Apps');
- }
-
return (
{navLinkShow}
diff --git a/src/pages/Admin/Categories/Detail/index.jsx b/src/pages/Admin/Categories/Detail/index.jsx
index c44bbf87..0f8c90d0 100644
--- a/src/pages/Admin/Categories/Detail/index.jsx
+++ b/src/pages/Admin/Categories/Detail/index.jsx
@@ -56,7 +56,7 @@ export default class CategoryDetail extends Component {
return (
showModifyCategory(category)}>{t('Modify Category')}
- showDeleteCategory(category)}>{t('Delete Category')}
+ showDeleteCategory(category)}>{t('Delete')}
);
};
diff --git a/src/pages/Admin/Repos/Add/index.jsx b/src/pages/Admin/Repos/Add/index.jsx
index 7cd0bd7c..525bd1e8 100644
--- a/src/pages/Admin/Repos/Add/index.jsx
+++ b/src/pages/Admin/Repos/Add/index.jsx
@@ -130,9 +130,9 @@ export default class RepoAdd extends Component {
className={styles.input}
placeholder="www.example.com/path/point/"
maxLength="100"
- required
name="url"
title={url}
+ required={!Boolean(repoId)}
disabled={Boolean(repoId)}
/>
@@ -144,13 +144,13 @@ export default class RepoAdd extends Component {
diff --git a/src/pages/Admin/Repos/index.jsx b/src/pages/Admin/Repos/index.jsx
index 7d9c486f..a295c6da 100644
--- a/src/pages/Admin/Repos/index.jsx
+++ b/src/pages/Admin/Repos/index.jsx
@@ -14,16 +14,21 @@ import styles from './index.scss';
@translate()
@inject(({ rootStore, sessInfo }) => ({
- rootStore,
repoStore: rootStore.repoStore,
appStore: rootStore.appStore,
sessInfo
}))
@observer
export default class Repos extends Component {
- static async onEnter({ repoStore, appStore }) {
+ static async onEnter({ repoStore, appStore, loginUser }) {
repoStore.appStore = appStore;
- await repoStore.fetchAll({ noLimit: true }, appStore);
+ await repoStore.fetchAll(
+ {
+ noLimit: true,
+ isQueryPublic: loginUser.isDev
+ },
+ appStore
+ );
}
constructor(props) {
diff --git a/src/pages/AppDetail/index.jsx b/src/pages/AppDetail/index.jsx
index ecfc1e99..4cbf6ab8 100644
--- a/src/pages/AppDetail/index.jsx
+++ b/src/pages/AppDetail/index.jsx
@@ -235,6 +235,8 @@ export default class AppDetail extends Component {
const appDetail = appStore.appDetail;
const role = getSessInfo('role', sessInfo);
const isNormal = role === 'user';
+ const { path } = this.props.match;
+ const isShowReview = role === 'global_admin' && path.indexOf('review') > -1;
return (
- {role === 'global_admin' && this.renderAdminReview()}
+ {isShowReview && this.renderAdminReview()}
{this.renderReasonDialog()}
);
diff --git a/src/pages/Profile/index.jsx b/src/pages/Profile/index.jsx
index ff375327..2a58fc6e 100644
--- a/src/pages/Profile/index.jsx
+++ b/src/pages/Profile/index.jsx
@@ -57,7 +57,7 @@ export default class Profile extends Component {
{
diff --git a/src/stores/RootStore.js b/src/stores/RootStore.js
index 2a8dcaf7..2adc129b 100644
--- a/src/stores/RootStore.js
+++ b/src/stores/RootStore.js
@@ -18,6 +18,7 @@ const defaultNotifyOption = { title: '', message: '', type: 'info' };
export default class RootStore extends Store {
@observable fixNav = false;
@observable notifications = [];
+ @observable loginUser = {};
constructor(initialState) {
super(initialState);
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js
index d0e84477..6c1eb459 100644
--- a/src/stores/UserStore.js
+++ b/src/stores/UserStore.js
@@ -92,9 +92,19 @@ export default class UserStore extends Store {
this.isLoading = true;
const result = await this.request.get(`users`, { user_id: userId });
this.userDetail = get(result, 'user_set[0]', {});
+
if (isLogin) {
+ const userInfo = pick({ ...this.userDetail }, ['user_id', 'username', 'email', 'role']);
+ const loginUser = {
+ ...userInfo,
+ isAdmin: userInfo.role === 'global_admin',
+ isDev: userInfo.role === 'developer',
+ isUser: userInfo.role === 'user'
+ };
setCookie('user', this.userDetail.username, this.cookieTime);
+ setCookie('loginUser', JSON.stringify(loginUser), this.cookieTime);
}
+
this.isLoading = false;
};
diff --git a/src/stores/repo/create.js b/src/stores/repo/create.js
index 0edfebaf..da2710d7 100644
--- a/src/stores/repo/create.js
+++ b/src/stores/repo/create.js
@@ -169,17 +169,8 @@ export default class RepoCreateStore extends Store {
return this.info('Labels missing key');
}
}
- /* if (_.isEmpty(selectors)) {
- this.isLoading = false;
- return this.info('missing selectors');
- }
-
- if (_.isEmpty(labels)) {
- this.isLoading = false;
- return this.info('missing labels');
- }*/
- if (protocolType === 's3') {
+ if (data.url && protocolType === 's3') {
data.credential = JSON.stringify({
access_key_id: accessKey,
secret_access_key: secretKey
@@ -205,21 +196,11 @@ export default class RepoCreateStore extends Store {
data.credential = '{}';
}
- // fixme: both labels and selectors pass as queryString
- /* data.selectors = selectors.map(selector => ({
- selector_key: selector.label_key,
- selector_value: selector.label_value
- }));
-
- data.labels = labels.map(label => ({
- label_key: label.label_key,
- label_value: label.label_value
- }));*/
-
+ // fixed: both labels and selectors pass as queryString
data.selectors = this.toQueryString(selectors);
data.labels = this.toQueryString(labels);
- // fix: provider is mobx array
+ // fixed: provider is mobx array
let flatProviders = providers.toJSON();
if (typeof flatProviders[0] !== 'string' && flatProviders[0].toJSON) {
flatProviders = flatProviders[0].toJSON();
@@ -234,6 +215,9 @@ export default class RepoCreateStore extends Store {
this.isLoading = true;
if (this.repoId) {
delete data.url;
+ if (!accessKey) {
+ delete data.credential;
+ }
_.extend(data, { repo_id: this.repoId });
await this.modifyRepo(data);
} else {
@@ -246,7 +230,7 @@ export default class RepoCreateStore extends Store {
this.success('Create repo successfully');
}
- // disable re-submit form in 2 sec
+ // disable re-submit form in 1 sec
setTimeout(() => {
this.isLoading = false;
}, 1000);
diff --git a/src/stores/repo/index.js b/src/stores/repo/index.js
index 55c22853..afefad4f 100644
--- a/src/stores/repo/index.js
+++ b/src/stores/repo/index.js
@@ -58,12 +58,22 @@ export default class RepoStore extends Store {
const result = await this.request.get('repos', assign(defaultParams, params));
this.repos = get(result, 'repo_set', []);
this.totalCount = get(result, 'total_count', 0);
+
+ if (params.isQueryPublic) {
+ delete params.isQueryPublic;
+ params.visibility = ['public'];
+ const pubResult = await this.request.get('repos', assign(defaultParams, params));
+ const pubRepos = get(pubResult, 'repo_set', []);
+ this.repos = [...pubRepos, ...this.repos];
+ }
+
if (appStore) {
for (let i = 0; i < this.initLoadNumber && i < this.repos.length; i++) {
await appStore.fetchAll({ repo_id: this.repos[i].repo_id });
this.repos[i] = { total: appStore.totalCount, apps: appStore.apps, ...this.repos[i] };
}
}
+
this.isLoading = false;
};
@@ -202,10 +212,11 @@ export default class RepoStore extends Store {
}
const itemKey = type === 'selectors' ? 'selector_key' : 'label_key';
+ const itemValue = type === 'selectors' ? 'selector_value' : 'label_value';
return get(this.repoDetail, type, [])
.filter(item => Boolean(item[itemKey]))
- .map(item => values(item).join('='))
+ .map(item => item[itemKey] + '=' + item[itemValue])
.join('&');
};
}
diff --git a/src/stores/runtime/create.js b/src/stores/runtime/create.js
index 0e20f794..79885b2d 100644
--- a/src/stores/runtime/create.js
+++ b/src/stores/runtime/create.js
@@ -70,11 +70,7 @@ export default class RuntimeCreateStore extends Store {
@action
handleValidateCredential = () => {
- if (this.runtimeUrl && this.accessKey && this.secretKey) {
- this.getRuntimeZone();
- } else {
- this.error('Incomplete credential information!');
- }
+ this.getRuntimeZone();
};
@action
@@ -239,8 +235,6 @@ export default class RuntimeCreateStore extends Store {
this.runtimeZones = _.get(result, 'zone', []);
if (this.runtimeZones.length > 0) {
this.success('Get zone data success!');
- } else {
- this.error('Get zone data fail!');
}
}