diff --git a/pkg/epinio/detail/applications.vue b/pkg/epinio/detail/applications.vue index 4d5f0c00f6..dcabd0b576 100644 --- a/pkg/epinio/detail/applications.vue +++ b/pkg/epinio/detail/applications.vue @@ -51,12 +51,14 @@ export default Vue.extend({ required: true }, }, - fetch() { + async fetch() { this.$store.dispatch(`epinio/findAll`, { type: EPINIO_TYPES.SERVICE_INSTANCE }); this.$store.dispatch(`epinio/findAll`, { type: EPINIO_TYPES.CONFIGURATION }); if (this.value.appSource.git) { - this.fetchRepoDetails(); + await this.fetchRepoDetails(); + + this.setCommitDetails(); } }, data() { @@ -119,23 +121,25 @@ export default Vue.extend({ this.gitSource = GitUtils[this.gitType].normalize.repo(res); - const commit = this.value.appSourceInfo?.details.filter((ele: { label: string; }) => ele.label === 'Revision')[0]?.value; - - if (commit) { - this.gitDeployment.deployedCommit = { - short: commit?.slice(0, 7), - long: commit - }; - } - await this.fetchCommits(); }, async fetchCommits() { const { usernameOrOrg, repo, branch } = this.value.appSource.git; - this.gitDeployment.commits = await this.$store.dispatch(`${ this.gitType }/fetchCommits`, { - username: usernameOrOrg, repo, branch - }); + if (branch?.name) { + this.gitDeployment.commits = await this.$store.dispatch(`${ this.gitType }/fetchCommits`, { + username: usernameOrOrg, repo, branch + }); + } + }, + setCommitDetails() { + const { commit } = this.value.appSource.git; + const selectedCommit = this.preparedCommits.find((c: { commitId?: string }) => c.commitId === commit) || this.orderedCommits[0]; + + this.gitDeployment.deployedCommit = { + short: selectedCommit?.commitId?.slice(0, 7), + long: selectedCommit.commitId + }; }, formatDate(date: string, from: boolean) { day.extend(relativeTime); @@ -431,7 +435,7 @@ export default Vue.extend({ ({ }) .then(() => { if (this.branches.length && !this.hasError.branch) { - this.selectedBranch = branch; + if (branch?.name) { + this.selectedBranch = branch; - return this.fetchCommits(); + return this.fetchCommits(); + } } }); - const selectedCommit = this.commits.find((c: commit) => { + const selectedCommit = this.commits?.find((c: commit) => { // Github has sha's // Gitlab has id's as sha's const sha = c.sha || c.id;