Force authors to use the project status sidebar (#810)

This commit is contained in:
triphora 2022-12-23 14:36:14 -05:00 committed by GitHub
parent c536f7d342
commit 1d9820a7c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,25 +13,11 @@
<CrossIcon /> <CrossIcon />
Cancel Cancel
</nuxt-link> </nuxt-link>
<button
v-if="
project.status === 'rejected' ||
project.status === 'draft' ||
project.status === 'unlisted'
"
title="Submit for review"
class="iconified-button column"
:disabled="!$nuxt.$loading"
@click="saveProjectReview"
>
<CheckIcon />
Submit for review
</button>
<button <button
title="Save" title="Save"
class="iconified-button brand-button column" class="iconified-button brand-button column"
:disabled="!$nuxt.$loading" :disabled="!$nuxt.$loading"
@click="saveProjectNotForReview" @click="saveProject"
> >
<SaveIcon /> <SaveIcon />
Save changes Save changes
@ -47,11 +33,8 @@
<li v-if="newProject.slug === ''"> <li v-if="newProject.slug === ''">
Your project cannot have an empty URL suffix. Your project cannot have an empty URL suffix.
</li> </li>
<li v-if="!savingAsDraft && newProject.body === ''"> <li v-if="newProject.body === ''">
Your project must have a body to submit for review. Your project must have an extended description.
</li>
<li v-if="!savingAsDraft && project.versions.length < 1">
Your project must have at least one version to submit for review.
</li> </li>
<li v-if="license.short === ''">Your project must have a license.</li> <li v-if="license.short === ''">Your project must have a license.</li>
</ul> </ul>
@ -551,7 +534,6 @@
import Multiselect from 'vue-multiselect' import Multiselect from 'vue-multiselect'
import CrossIcon from '~/assets/images/utils/x.svg?inline' import CrossIcon from '~/assets/images/utils/x.svg?inline'
import CheckIcon from '~/assets/images/utils/check.svg?inline'
import PlusIcon from '~/assets/images/utils/plus.svg?inline' import PlusIcon from '~/assets/images/utils/plus.svg?inline'
import SaveIcon from '~/assets/images/utils/save.svg?inline' import SaveIcon from '~/assets/images/utils/save.svg?inline'
import TrashIcon from '~/assets/images/utils/trash.svg?inline' import TrashIcon from '~/assets/images/utils/trash.svg?inline'
@ -571,7 +553,6 @@ export default {
Chips, Chips,
Multiselect, Multiselect,
CrossIcon, CrossIcon,
CheckIcon,
PlusIcon, PlusIcon,
SaveIcon, SaveIcon,
TrashIcon, TrashIcon,
@ -679,7 +660,6 @@ export default {
selectableCategories: [], selectableCategories: [],
selectableAdditionalCategories: [], selectableAdditionalCategories: [],
isProcessing: false,
previewImage: null, previewImage: null,
compiledBody: '', compiledBody: '',
@ -692,7 +672,6 @@ export default {
bodyViewMode: 'source', bodyViewMode: 'source',
showKnownErrors: false, showKnownErrors: false,
savingAsDraft: false,
manualSlug: false, manualSlug: false,
} }
}, },
@ -775,37 +754,23 @@ export default {
.map((it) => it.name) .map((it) => it.name)
}, },
checkFields() { checkFields() {
const reviewConditions =
this.newProject.body !== '' && this.newProject.versions.length > 0
if ( if (
this.newProject.title !== '' && this.newProject.title !== '' &&
this.newProject.description !== '' && this.newProject.description !== '' &&
this.newProject.slug !== '' && this.newProject.slug !== '' &&
this.newProject.body !== '' &&
this.license.short !== '' this.license.short !== ''
) { ) {
if (this.savingAsDraft) { return true
return true
} else if (reviewConditions) {
return true
}
} }
this.showKnownErrors = true this.showKnownErrors = true
return false return false
}, },
async saveProjectReview() {
this.savingAsDraft = false
if (this.checkFields()) {
this.isProcessing = true
await this.saveProject()
}
},
async saveProjectNotForReview() {
this.savingAsDraft = true
if (this.checkFields()) {
await this.saveProject()
}
},
async saveProject() { async saveProject() {
if (!this.checkFields()) {
return
}
this.$nuxt.$loading.start() this.$nuxt.$loading.start()
try { try {
@ -841,10 +806,6 @@ export default {
}), }),
} }
if (this.isProcessing) {
data.status = 'processing'
}
await this.$axios.patch( await this.$axios.patch(
`project/${this.newProject.id}`, `project/${this.newProject.id}`,
data, data,