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