@@ -15,7 +15,8 @@ import styles from 'dashboard/Data/CloudCode/CloudCode.scss';
1515import Toolbar from 'components/Toolbar/Toolbar.react' ;
1616
1717function getPath ( params ) {
18- return params . splat ;
18+ const last = params . location . pathname . split ( 'cloud_code/' ) [ 1 ]
19+ return last ;
1920}
2021
2122export default class CloudCode extends DashboardView {
@@ -31,12 +32,12 @@ export default class CloudCode extends DashboardView {
3132 }
3233
3334 componentWillMount ( ) {
34- this . fetchSource ( this . context . currentApp , getPath ( this . props . params ) ) ;
35+ this . fetchSource ( this . context . currentApp , getPath ( this . props ) ) ;
3536 }
3637
3738 componentWillReceiveProps ( nextProps , nextContext ) {
3839 if ( this . context !== nextContext ) {
39- this . fetchSource ( nextContext . currentApp , getPath ( nextProps . params ) ) ;
40+ this . fetchSource ( nextContext . currentApp , getPath ( nextProps ) ) ;
4041 }
4142 }
4243
@@ -52,7 +53,7 @@ export default class CloudCode extends DashboardView {
5253
5354 if ( ! fileName || release . files [ fileName ] === undefined ) {
5455 // Means we're still in /cloud_code/. Let's redirect to /cloud_code/main.js
55- history . replace ( this . context . generatePath ( ' cloud_code/main.js' ) )
56+ history . replace ( this . context . generatePath ( ` cloud_code/${ Object . keys ( release . files ) [ 0 ] } ` ) )
5657 } else {
5758 // Means we can load /cloud_code/<fileName>
5859 app . getSource ( fileName ) . then (
@@ -66,7 +67,7 @@ export default class CloudCode extends DashboardView {
6667 }
6768
6869 renderSidebar ( ) {
69- let current = getPath ( this . props . params ) || '' ;
70+ let current = getPath ( this . props ) || '' ;
7071 let files = this . state . files ;
7172 if ( ! files ) {
7273 return null ;
@@ -90,7 +91,7 @@ export default class CloudCode extends DashboardView {
9091 renderContent ( ) {
9192 let toolbar = null ;
9293 let content = null ;
93- let fileName = getPath ( this . props . params ) ;
94+ let fileName = getPath ( this . props ) ;
9495
9596 if ( ! this . state . files || Object . keys ( this . state . files ) . length === 0 ) {
9697 content = (
0 commit comments