Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(create-config): added check for unique name #134

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading