Skip to content

Commit

Permalink
fix: Mobx array out of range (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnywx authored Nov 29, 2018
1 parent f130ec0 commit 10c9ef3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/pages/Dashboard/Apps/Deploy/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,18 @@ export default class AppDeploy extends Component {

if (!isK8s) {
appDeployStore.runtimeId = _.get(
appDeployStore.runtimes[0],
'runtime_id'
appDeployStore.runtimes.slice(),
'[0].runtime_id'
);
await appDeployStore.fetchSubnetsByRuntime(appDeployStore.runtimeId);
}

// fetch versions
await appDeployStore.fetchVersions({ app_id: [appId] });
appDeployStore.versionId = _.get(appDeployStore.versions[0], 'version_id');
appDeployStore.versionId = _.get(
appDeployStore.versions.slice(),
'[0].version_id'
);
await appDeployStore.fetchFilesByVersion(appDeployStore.versionId, isK8s);

if (!isK8s && !_.isEmpty(appDeployStore.configJson)) {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/SSHKeys/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class SSHKeys extends Component {
sshKeyStore.userId = user.user_id;
await sshKeyStore.fetchKeyPairs();

const nodeIds = get(sshKeyStore.keyPairs[0], 'node_id', '');
const nodeIds = get(sshKeyStore.keyPairs.slice(), '[0].node_id', '');
clusterDetailStore.nodeIds = nodeIds || ['0'];
if (nodeIds) {
await clusterStore.fetchAll({
Expand Down Expand Up @@ -92,7 +92,7 @@ export default class SSHKeys extends Component {
const keyPairs = sshKeyStore.keyPairs.filter(
item => item.key_pair_id === currentPairId
);
const nodeIds = get(keyPairs[0], 'node_id', '');
const nodeIds = get(keyPairs.slice(), '[0].node_id', '');
await fetchNodes({ node_id: nodeIds || 0 });
}, 3000);
}
Expand Down
4 changes: 2 additions & 2 deletions src/stores/key_pair/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export default class KeyPairStore extends Store {
this.keyPairs = _.get(result, 'key_pair_set', []);

if (!this.currentPairId || this.currentPairId === this.pairId) {
this.nodeIds = _.get(this.keyPairs[0], 'node_id', '');
this.currentPairId = _.get(this.keyPairs[0], 'key_pair_id', '');
this.nodeIds = _.get(this.keyPairs.slice(), '[0].node_id', '');
this.currentPairId = _.get(this.keyPairs.slice(), '[0].key_pair_id', '');
}

this.isLoading = false;
Expand Down

0 comments on commit 10c9ef3

Please sign in to comment.