Skip to content

Commit 10c9ef3

Browse files
authored
fix: Mobx array out of range (#559)
1 parent f130ec0 commit 10c9ef3

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/pages/Dashboard/Apps/Deploy/index.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,18 @@ export default class AppDeploy extends Component {
6565

6666
if (!isK8s) {
6767
appDeployStore.runtimeId = _.get(
68-
appDeployStore.runtimes[0],
69-
'runtime_id'
68+
appDeployStore.runtimes.slice(),
69+
'[0].runtime_id'
7070
);
7171
await appDeployStore.fetchSubnetsByRuntime(appDeployStore.runtimeId);
7272
}
7373

7474
// fetch versions
7575
await appDeployStore.fetchVersions({ app_id: [appId] });
76-
appDeployStore.versionId = _.get(appDeployStore.versions[0], 'version_id');
76+
appDeployStore.versionId = _.get(
77+
appDeployStore.versions.slice(),
78+
'[0].version_id'
79+
);
7780
await appDeployStore.fetchFilesByVersion(appDeployStore.versionId, isK8s);
7881

7982
if (!isK8s && !_.isEmpty(appDeployStore.configJson)) {

src/pages/SSHKeys/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default class SSHKeys extends Component {
4040
sshKeyStore.userId = user.user_id;
4141
await sshKeyStore.fetchKeyPairs();
4242

43-
const nodeIds = get(sshKeyStore.keyPairs[0], 'node_id', '');
43+
const nodeIds = get(sshKeyStore.keyPairs.slice(), '[0].node_id', '');
4444
clusterDetailStore.nodeIds = nodeIds || ['0'];
4545
if (nodeIds) {
4646
await clusterStore.fetchAll({
@@ -92,7 +92,7 @@ export default class SSHKeys extends Component {
9292
const keyPairs = sshKeyStore.keyPairs.filter(
9393
item => item.key_pair_id === currentPairId
9494
);
95-
const nodeIds = get(keyPairs[0], 'node_id', '');
95+
const nodeIds = get(keyPairs.slice(), '[0].node_id', '');
9696
await fetchNodes({ node_id: nodeIds || 0 });
9797
}, 3000);
9898
}

src/stores/key_pair/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export default class KeyPairStore extends Store {
5151
this.keyPairs = _.get(result, 'key_pair_set', []);
5252

5353
if (!this.currentPairId || this.currentPairId === this.pairId) {
54-
this.nodeIds = _.get(this.keyPairs[0], 'node_id', '');
55-
this.currentPairId = _.get(this.keyPairs[0], 'key_pair_id', '');
54+
this.nodeIds = _.get(this.keyPairs.slice(), '[0].node_id', '');
55+
this.currentPairId = _.get(this.keyPairs.slice(), '[0].key_pair_id', '');
5656
}
5757

5858
this.isLoading = false;

0 commit comments

Comments
 (0)