Skip to content

Commit

Permalink
Update CloudCode.react.js
Browse files Browse the repository at this point in the history
  • Loading branch information
dblythy committed Sep 4, 2021
1 parent 206b3f1 commit 44eea2a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/dashboard/Data/CloudCode/CloudCode.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import styles from 'dashboard/Data/CloudCode/CloudCode.scss';
import Toolbar from 'components/Toolbar/Toolbar.react';

function getPath(params) {
return params.splat;
const last = params.location.pathname.split('cloud_code/')[1]
return last;
}

export default class CloudCode extends DashboardView {
Expand All @@ -31,12 +32,12 @@ export default class CloudCode extends DashboardView {
}

componentWillMount() {
this.fetchSource(this.context.currentApp, getPath(this.props.params));
this.fetchSource(this.context.currentApp, getPath(this.props));
}

componentWillReceiveProps(nextProps, nextContext) {
if (this.context !== nextContext) {
this.fetchSource(nextContext.currentApp, getPath(nextProps.params));
this.fetchSource(nextContext.currentApp, getPath(nextProps));
}
}

Expand All @@ -52,7 +53,7 @@ export default class CloudCode extends DashboardView {

if (!fileName || release.files[fileName] === undefined) {
// Means we're still in /cloud_code/. Let's redirect to /cloud_code/main.js
history.replace(this.context.generatePath('cloud_code/main.js'))
history.replace(this.context.generatePath(`cloud_code/${Object.keys(release.files)[0]}`))
} else {
// Means we can load /cloud_code/<fileName>
app.getSource(fileName).then(
Expand All @@ -66,7 +67,7 @@ export default class CloudCode extends DashboardView {
}

renderSidebar() {
let current = getPath(this.props.params) || '';
let current = getPath(this.props) || '';
let files = this.state.files;
if (!files) {
return null;
Expand All @@ -90,7 +91,7 @@ export default class CloudCode extends DashboardView {
renderContent() {
let toolbar = null;
let content = null;
let fileName = getPath(this.props.params);
let fileName = getPath(this.props);

if (!this.state.files || Object.keys(this.state.files).length === 0) {
content = (
Expand Down

0 comments on commit 44eea2a

Please sign in to comment.