Prevent user from adding the same dependency multiple times (#859)
This commit is contained in:
parent
de212322e2
commit
61a4f15e53
@ -1176,6 +1176,18 @@ export default {
|
|||||||
const project = (await this.$axios.get(`project/${newDependencyId}`))
|
const project = (await this.$axios.get(`project/${newDependencyId}`))
|
||||||
.data
|
.data
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.version.dependencies.some(
|
||||||
|
(dep) => project.id === dep.project_id
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
this.$notify({
|
||||||
|
group: 'main',
|
||||||
|
title: 'Dependency already added',
|
||||||
|
text: 'You cannot add the same dependency twice.',
|
||||||
|
type: 'error',
|
||||||
|
})
|
||||||
|
} else {
|
||||||
this.version.dependencies.push({
|
this.version.dependencies.push({
|
||||||
project,
|
project,
|
||||||
project_id: project.id,
|
project_id: project.id,
|
||||||
@ -1187,6 +1199,7 @@ export default {
|
|||||||
projects: this.dependencies.projects.concat([project]),
|
projects: this.dependencies.projects.concat([project]),
|
||||||
versions: this.dependencies.versions,
|
versions: this.dependencies.versions,
|
||||||
})
|
})
|
||||||
|
}
|
||||||
} else if (dependencyAddMode === 'version') {
|
} else if (dependencyAddMode === 'version') {
|
||||||
const version = (
|
const version = (
|
||||||
await this.$axios.get(`version/${this.newDependencyId}`)
|
await this.$axios.get(`version/${this.newDependencyId}`)
|
||||||
@ -1196,6 +1209,18 @@ export default {
|
|||||||
await this.$axios.get(`project/${version.project_id}`)
|
await this.$axios.get(`project/${version.project_id}`)
|
||||||
).data
|
).data
|
||||||
|
|
||||||
|
if (
|
||||||
|
this.version.dependencies.some(
|
||||||
|
(dep) => version.id === dep.version_id
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
this.$notify({
|
||||||
|
group: 'main',
|
||||||
|
title: 'Dependency already added',
|
||||||
|
text: 'You cannot add the same dependency twice.',
|
||||||
|
type: 'error',
|
||||||
|
})
|
||||||
|
} else {
|
||||||
this.version.dependencies.push({
|
this.version.dependencies.push({
|
||||||
version,
|
version,
|
||||||
project,
|
project,
|
||||||
@ -1212,6 +1237,7 @@ export default {
|
|||||||
versions: this.dependencies.versions.concat([version]),
|
versions: this.dependencies.versions.concat([version]),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.newDependencyId = ''
|
this.newDependencyId = ''
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user