Reset version page state when currently selected version changes (#543)

* reset versions state on current version change

* 'mode' should not be reset
This commit is contained in:
John Paul 2022-06-18 01:19:15 -04:00 committed by GitHub
parent 76ed8d58fa
commit 2bda7566b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -616,7 +616,6 @@ export default {
mode: 'version',
primaryFile: {},
version: {},
popup_data: null,
changelogViewMode: 'source',
@ -652,7 +651,19 @@ export default {
}
},
methods: {
reset() {
this.changelogViewMode = 'source'
this.dependencyAddMode = 'project'
this.newDependencyId = ''
this.newDependencyType = 'required'
this.primaryFile = {}
this.version = {}
this.newFiles = []
this.deleteFiles = []
},
async setVersion() {
this.reset()
const path = this.$route.name.split('-')
this.mode = path[path.length - 1]
@ -687,11 +698,8 @@ export default {
)
this.version = JSON.parse(JSON.stringify(this.version))
this.primaryFile = this.version.files.find((file) => file.primary)
if (!this.primaryFile) {
this.primaryFile = this.version.files[0]
}
this.primaryFile =
this.version.files.find((file) => file.primary) ?? this.version.files[0]
if (!this.version.changelog && this.version.changelog_url) {
this.version.changelog = (
@ -845,10 +853,7 @@ export default {
const formData = new FormData()
const fileParts = []
for (let i = 0; i < this.newFiles.length; i++) {
fileParts.push(this.newFiles[i].name.concat('-' + i))
}
const fileParts = this.newFiles.map((f, idx) => `${f.name}-${idx}`)
const newVersion = {
project_id: this.version.project_id,