1+ import './ApplicationTable.css' ;
12import React , { Component } from 'react' ;
23
34import {
45 Confirm ,
5- TableActionCell ,
66 Table ,
77 TableCell ,
8- TableRouteCell ,
98 TableBody ,
10- TableTextCell ,
11- TableHeader ,
12- TableColumn ,
139 TableRow
1410} from '../Dashboard' ;
1511import { Link } from 'react-router' ;
@@ -21,6 +17,7 @@ export default class ApplicationsTable extends Component {
2117 React . PropTypes . array
2218 ] ) . isRequired ,
2319 loading : React . PropTypes . bool . isRequired ,
20+ moveApplication : React . PropTypes . func . isRequired ,
2421 deleteApplication : React . PropTypes . func . isRequired ,
2522 updateApplication : React . PropTypes . func . isRequired ,
2623 fetchApplications : React . PropTypes . func . isRequired ,
@@ -43,8 +40,28 @@ export default class ApplicationsTable extends Component {
4340 }
4441 }
4542
43+ renderMoveButton ( id , direction , row , total ) {
44+ const icon = direction === 'up' ? 'icon-budicon-462' : 'icon-budicon-460' ;
45+ const enabled = ( direction === 'up' && row > 1 ) || ( direction === 'down' && row < total ) ;
46+ return (
47+ < li title = { direction } data-toggle = "tooltip" >
48+ < a
49+ href = "#" onClick = { ( e ) => {
50+ if ( enabled ) {
51+ this . props . moveApplication ( id , direction ) ;
52+ }
53+ } } className = { `move-app ${ ! enabled ? 'disabled' : '' } ` }
54+ >
55+ < i className = { icon } />
56+ </ a >
57+ </ li >
58+ ) ;
59+ }
60+
4661 render ( ) {
47- const { applications, renderActions, appId } = this . props ;
62+ const { applications, appId } = this . props ;
63+ const rowsTotal = Object . keys ( applications ) . length ;
64+ let rowIndex = 0 ;
4865 return (
4966 < div >
5067 < Confirm
@@ -63,12 +80,12 @@ export default class ApplicationsTable extends Component {
6380 const application = applications [ key ] ;
6481 const logo = application . logo || 'https://cdn.auth0.com/manage/v0.3.1866/img/badge-grey.svg' ;
6582 const type = application . type ;
66- const callback = application . callback ;
6783 const enabled = application . enabled ;
6884 const appClassName = `btn btn-publish-app ${ enabled ? 'btn-transparent' : 'btn-success' } ` ;
6985 const appButtonText = enabled ? 'UNPUBLISH' : 'PUBLISH' ;
7086 const name = application . name || application . client ;
7187 const loginUrl = application . loginUrl ;
88+ rowIndex ++ ;
7289 return (
7390 < TableRow key = { key } >
7491 < TableCell >
@@ -97,6 +114,8 @@ export default class ApplicationsTable extends Component {
97114 < i className = "icon-budicon-187" />
98115 </ a >
99116 </ li >
117+ { this . renderMoveButton ( key , 'up' , rowIndex , rowsTotal ) }
118+ { this . renderMoveButton ( key , 'down' , rowIndex , rowsTotal ) }
100119 < li title = "Edit" data-toggle = "tooltip" >
101120 < Link to = { `/applications/${ key } ` } >
102121 < i className = "icon-budicon-329" />
0 commit comments