Prevent user from adding the same dependency multiple times (#859)
This commit is contained in:
parent
de212322e2
commit
61a4f15e53
@ -1176,17 +1176,30 @@ export default {
|
|||||||
const project = (await this.$axios.get(`project/${newDependencyId}`))
|
const project = (await this.$axios.get(`project/${newDependencyId}`))
|
||||||
.data
|
.data
|
||||||
|
|
||||||
this.version.dependencies.push({
|
if (
|
||||||
project,
|
this.version.dependencies.some(
|
||||||
project_id: project.id,
|
(dep) => project.id === dep.project_id
|
||||||
dependency_type: newDependencyType,
|
)
|
||||||
link: `/${project.project_type}/${project.slug ?? 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({
|
||||||
|
project,
|
||||||
|
project_id: project.id,
|
||||||
|
dependency_type: newDependencyType,
|
||||||
|
link: `/${project.project_type}/${project.slug ?? project.id}`,
|
||||||
|
})
|
||||||
|
|
||||||
this.$emit('update:dependencies', {
|
this.$emit('update:dependencies', {
|
||||||
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,21 +1209,34 @@ export default {
|
|||||||
await this.$axios.get(`project/${version.project_id}`)
|
await this.$axios.get(`project/${version.project_id}`)
|
||||||
).data
|
).data
|
||||||
|
|
||||||
this.version.dependencies.push({
|
if (
|
||||||
version,
|
this.version.dependencies.some(
|
||||||
project,
|
(dep) => version.id === dep.version_id
|
||||||
version_id: version.id,
|
)
|
||||||
project_id: project.id,
|
) {
|
||||||
dependency_type: this.newDependencyType,
|
this.$notify({
|
||||||
link: `/${project.project_type}/${
|
group: 'main',
|
||||||
project.slug ?? project.id
|
title: 'Dependency already added',
|
||||||
}/version/${encodeURI(version.version_number)}`,
|
text: 'You cannot add the same dependency twice.',
|
||||||
})
|
type: 'error',
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.version.dependencies.push({
|
||||||
|
version,
|
||||||
|
project,
|
||||||
|
version_id: version.id,
|
||||||
|
project_id: project.id,
|
||||||
|
dependency_type: this.newDependencyType,
|
||||||
|
link: `/${project.project_type}/${
|
||||||
|
project.slug ?? project.id
|
||||||
|
}/version/${encodeURI(version.version_number)}`,
|
||||||
|
})
|
||||||
|
|
||||||
this.$emit('update:dependencies', {
|
this.$emit('update:dependencies', {
|
||||||
projects: this.dependencies.projects.concat([project]),
|
projects: this.dependencies.projects.concat([project]),
|
||||||
versions: this.dependencies.versions.concat([version]),
|
versions: this.dependencies.versions.concat([version]),
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.newDependencyId = ''
|
this.newDependencyId = ''
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user