Skip to content

Commit

Permalink
fix(create-config): added check for unique name
Browse files Browse the repository at this point in the history
Closes #133

Signed-off-by: Lukas Mertens <[email protected]>

commit-id:bfa38f6a
  • Loading branch information
lukas-mertens committed Apr 11, 2024
1 parent 59e0f0e commit 442c012
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/CreateConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,22 @@

<script setup lang="ts">
import {computed, ref} from "vue";
import {useEvbcStore} from "@/store/evbc";
import {storeToRefs} from "pinia";

enum ComponentStates {
enum ComponentStates {
DEFAULT,
ASK_USER_FOR_CONFIG_NAME,
}

const evbcStore = useEvbcStore();
const state = ref<ComponentStates>(ComponentStates.DEFAULT);
const configName = ref<string>("");
const configNameValid = computed<boolean>(() => validateConfigName() === true);
const emit = defineEmits<{
createConfig: [name: string],
}>();
const {available_configs} = storeToRefs(evbcStore);

function createConfig() {
if (validateConfigName() === true) {
Expand All @@ -91,6 +96,8 @@ import {computed, ref} from "vue";
return "The name must not contain the file extension";
} else if (!/^[a-zA-Z0-9-_]+$/.test(configName.value)) {
return "The name must only contain letters, numbers, dashes and underscores";
} else if (Object.keys(available_configs.value).includes(configName.value.trim())) {
return "The name must be unique";
} else {
return true;
}
Expand Down

0 comments on commit 442c012

Please sign in to comment.