@@ -15,7 +15,8 @@ import styles from 'dashboard/Data/CloudCode/CloudCode.scss';
15
15
import Toolbar from 'components/Toolbar/Toolbar.react' ;
16
16
17
17
function getPath ( params ) {
18
- return params . splat ;
18
+ const last = params . location . pathname . split ( 'cloud_code/' ) [ 1 ]
19
+ return last ;
19
20
}
20
21
21
22
export default class CloudCode extends DashboardView {
@@ -31,12 +32,12 @@ export default class CloudCode extends DashboardView {
31
32
}
32
33
33
34
componentWillMount ( ) {
34
- this . fetchSource ( this . context . currentApp , getPath ( this . props . params ) ) ;
35
+ this . fetchSource ( this . context . currentApp , getPath ( this . props ) ) ;
35
36
}
36
37
37
38
componentWillReceiveProps ( nextProps , nextContext ) {
38
39
if ( this . context !== nextContext ) {
39
- this . fetchSource ( nextContext . currentApp , getPath ( nextProps . params ) ) ;
40
+ this . fetchSource ( nextContext . currentApp , getPath ( nextProps ) ) ;
40
41
}
41
42
}
42
43
@@ -52,7 +53,7 @@ export default class CloudCode extends DashboardView {
52
53
53
54
if ( ! fileName || release . files [ fileName ] === undefined ) {
54
55
// 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 ] } ` ) )
56
57
} else {
57
58
// Means we can load /cloud_code/<fileName>
58
59
app . getSource ( fileName ) . then (
@@ -66,7 +67,7 @@ export default class CloudCode extends DashboardView {
66
67
}
67
68
68
69
renderSidebar ( ) {
69
- let current = getPath ( this . props . params ) || '' ;
70
+ let current = getPath ( this . props ) || '' ;
70
71
let files = this . state . files ;
71
72
if ( ! files ) {
72
73
return null ;
@@ -90,7 +91,7 @@ export default class CloudCode extends DashboardView {
90
91
renderContent ( ) {
91
92
let toolbar = null ;
92
93
let content = null ;
93
- let fileName = getPath ( this . props . params ) ;
94
+ let fileName = getPath ( this . props ) ;
94
95
95
96
if ( ! this . state . files || Object . keys ( this . state . files ) . length === 0 ) {
96
97
content = (
0 commit comments