@@ -2,6 +2,7 @@ import React, { Component, Fragment } from 'react';
22import PropTypes from 'prop-types' ;
33import { observer , inject } from 'mobx-react' ;
44import { Link } from 'react-router-dom' ;
5+ import classnames from 'classnames' ;
56import _ , { capitalize } from 'lodash' ;
67import { withTranslation } from 'react-i18next' ;
78
@@ -19,6 +20,8 @@ import { CLUSTER_TYPE, runtimeTabs } from 'config/runtimes';
1920import columns from './columns' ;
2021import styles from './index.scss' ;
2122
23+ const appTabs = [ { name : 'Agent' , value : 1 } ] ;
24+
2225@withTranslation ( )
2326@inject ( ( { rootStore } ) => ( {
2427 rootStore,
@@ -33,6 +36,7 @@ import styles from './index.scss';
3336@observer
3437export default class Clusters extends Component {
3538 static propTypes = {
39+ appId : PropTypes . string ,
3640 fetchData : PropTypes . func ,
3741 isK8S : PropTypes . bool ,
3842 runtimeId : PropTypes . string ,
@@ -41,6 +45,7 @@ export default class Clusters extends Component {
4145
4246 static defaultProps = {
4347 runtimeId : '' ,
48+ appId : '' ,
4449 isK8S : false ,
4550 title : ''
4651 } ;
@@ -52,6 +57,7 @@ export default class Clusters extends Component {
5257 runtimeStore,
5358 user,
5459 runtimeId,
60+ appId,
5561 fetchData
5662 } = this . props ;
5763
@@ -62,9 +68,10 @@ export default class Clusters extends Component {
6268
6369 Object . assign ( clusterStore , {
6470 runtimeId,
71+ appId,
6572 attachUsers : ! user . isUserPortal ,
6673 attachVersions : cluster_type === CLUSTER_TYPE . instance ,
67- attachApps : ! user . isDevPortal || runtimeId ,
74+ attachApps : ( ! user . isDevPortal || runtimeId ) && ! appId ,
6875 with_detail : true ,
6976 cluster_type : CLUSTER_TYPE . instance , // default fetch instance
7077 userId : ( user . isUserPortal || user . isAdminPortal ) && user . user_id
@@ -219,11 +226,12 @@ export default class Clusters extends Component {
219226 } = this . props ;
220227 const { apps } = appStore ;
221228 const { versions } = appVersionStore ;
229+ const isAppDetail = this . props . appId ;
222230
223231 const app = _ . find ( apps , { app_id : appId } ) || { } ;
224232 const version = _ . find ( versions , { version_id : versionId } ) || { } ;
225233
226- if ( user . isUserPortal || user . isAdmin || runtimeId ) {
234+ if ( ( user . isUserPortal || user . isAdmin || runtimeId ) && ! isAppDetail ) {
227235 return (
228236 < div className = { styles . appTdShow } >
229237 < label className = { styles . appImage } >
@@ -269,7 +277,7 @@ export default class Clusters extends Component {
269277
270278 renderToolbar ( ) {
271279 const {
272- clusterStore, user, match, t
280+ clusterStore, user, appId , match, t
273281 } = this . props ;
274282 const {
275283 searchWord,
@@ -280,7 +288,8 @@ export default class Clusters extends Component {
280288 onlyView,
281289 isAgent
282290 } = clusterStore ;
283- const { appId } = match . params ;
291+ const hasDeployButton = ( user . isDevPortal && ! onlyView ) || appId ;
292+ const app_id = appId || _ . get ( match , 'params.appId' , '' ) ;
284293
285294 if ( ! ( onlyView || isAgent ) && clusterIds . length ) {
286295 return (
@@ -309,9 +318,10 @@ export default class Clusters extends Component {
309318 onRefresh = { onRefresh }
310319 noRefreshBtn
311320 >
312- { user . isDevPortal && ! onlyView && (
313- < Link to = { toRoute ( routes . portal . deploy , { appId } ) } >
321+ { hasDeployButton && (
322+ < Link to = { toRoute ( routes . portal . deploy , { appId : app_id } ) } >
314323 < Button type = "primary" className = "pull-right" >
324+ < Icon name = "add" type = "white" className = { styles . icon } />
315325 { t ( 'Deploy' ) }
316326 </ Button >
317327 </ Link >
@@ -322,7 +332,13 @@ export default class Clusters extends Component {
322332
323333 renderMain ( ) {
324334 const {
325- clusterStore, userStore, user, runtimeId, isK8S, t
335+ clusterStore,
336+ userStore,
337+ user,
338+ runtimeId,
339+ appId,
340+ isK8S,
341+ t
326342 } = this . props ;
327343 const { isLoading, onlyView, isAgent } = clusterStore ;
328344
@@ -333,8 +349,8 @@ export default class Clusters extends Component {
333349 < Fragment >
334350 { ! isK8S && (
335351 < Tabs
336- tabs = { runtimeTabs }
337- className = { styles . tabs }
352+ tabs = { appId ? appTabs : runtimeTabs }
353+ className = { classnames ( styles . tabs , { [ styles . appTabs ] : appId } ) }
338354 changeTab = { this . handleChangeTab }
339355 noFirstChange
340356 isCardTab
@@ -377,6 +393,7 @@ export default class Clusters extends Component {
377393 renderAppTdShow : this . renderAppTdShow ,
378394 renderHandleMenu : this . renderHandleMenu ,
379395 isRuntimeDetail : Boolean ( runtimeId ) ,
396+ isAppDetail : Boolean ( appId ) ,
380397 users,
381398 user,
382399 runtimes,
@@ -393,10 +410,10 @@ export default class Clusters extends Component {
393410
394411 render ( ) {
395412 const {
396- user, title, runtimeId, t
413+ user, title, runtimeId, appId , t
397414 } = this . props ;
398415
399- if ( user . isUserPortal || runtimeId ) {
416+ if ( user . isUserPortal || runtimeId || appId ) {
400417 return this . renderMain ( ) ;
401418 }
402419
0 commit comments