Skip to content

Commit 9a7e64b

Browse files
authored
Merge pull request #256 from php-school/dont-allow-composer-packages-with-no-version
Don't allow composer packages with no version
2 parents 52dadc8 + c2927e2 commit 9a7e64b

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

assets/components/ExerciseEditor.vue

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ import Confirm from "./Confirm.vue";
2424
import HeaderNav from "./HeaderNav.vue";
2525
import StudentDropdown from "./StudentDropdown.vue";
2626
import toFilePath from "./utils/toFilePath";
27+
import Alert from "./Alert.vue";
2728
2829
export default {
2930
components: {
31+
Alert,
3032
StudentDropdown,
3133
HeaderNav,
3234
Tour,
@@ -104,7 +106,9 @@ export default {
104106
currentExercise: {
105107
workshop: this.workshop,
106108
exercise: this.exercise
107-
}
109+
},
110+
showPackageAddError: false,
111+
showPackageErrorTimerId: null
108112
}
109113
},
110114
computed: {
@@ -367,6 +371,20 @@ export default {
367371
fetch('/cloud/composer-package/add?package=' + encodeURIComponent(this.newDependency), opts)
368372
.then(response => response.json())
369373
.then(json => {
374+
if (json.status === 'error') {
375+
this.loadingComposerAdd = false;
376+
this.$refs.packageSearch.reset();
377+
378+
this.showPackageAddError = true;
379+
380+
if (this.showPackageErrorTimerId) {
381+
clearInterval(this.showPackageErrorTimerId);
382+
}
383+
384+
this.showPackageErrorTimerId = setTimeout(() => this.showPackageAddError = false, 3000);
385+
return;
386+
}
387+
370388
this.composerDeps.push({
371389
name: this.newDependency,
372390
version: json.latest_version,
@@ -426,6 +444,9 @@ export default {
426444
@close="dismissPassNotification">
427445
</pass-notification>
428446

447+
<alert type="error" @close="showPackageAddError= false" v-show="showPackageAddError" message="Package could not be added because it has no tagged version."></alert>
448+
449+
429450
<div class="h-full flex flex-col">
430451
<div class="flex flex-1 h-full relative">
431452
<div class="w-1/5 p-4 min-w-[300px]">

0 commit comments

Comments
 (0)