Browse Source

fix: validation

pull/6420/head
sreehari jayaraj 1 year ago
parent
commit
c1f8c3b701
  1. 26
      packages/nc-gui/components/account/Token.vue

26
packages/nc-gui/components/account/Token.vue

@ -73,6 +73,7 @@ loadTokens()
const isModalOpen = ref(false)
const tokenDesc = ref('')
const tokenToCopy = ref('')
const isTextEmpty = ref(false)
const deleteToken = async (token: string): Promise<void> => {
try {
@ -89,6 +90,12 @@ const deleteToken = async (token: string): Promise<void> => {
}
const generateToken = async () => {
if (!selectedTokenData.value.description?.length) {
isTextEmpty.value = true
} else {
isTextEmpty.value = false
}
if (isTextEmpty.value) return
try {
await api.orgTokens.create(selectedTokenData.value)
showNewTokenModal.value = false
@ -158,6 +165,7 @@ const descriptionInput: VNodeRef = (el) => (el as HTMLInputElement)?.focus()
v-if="showNewTokenModal"
class="flex gap-5 px-3 py-3.5 text-gray-500 font-medium text-3.5 w-full nc-token-generate"
>
<div class="flex flex-col w-full">
<a-input
:ref="descriptionInput"
v-model:value="selectedTokenData.description"
@ -166,14 +174,28 @@ const descriptionInput: VNodeRef = (el) => (el as HTMLInputElement)?.focus()
placeholder="Token Name"
data-testid="nc-token-input"
/>
<span v-if="isTextEmpty" class="text-red-500 text-xs font-light mt-1.5 ml-1">token name should not be empty</span>
</div>
<div class="flex gap-2 justify-start">
<NcButton v-if="!isLoading" type="secondary" size="small" @click="showNewTokenModal = false"> Cancel </NcButton>
<NcButton
v-if="!isLoading"
type="secondary"
size="small"
@click="
() => {
showNewTokenModal = false
isTextEmpty = false
}
"
>
Cancel
</NcButton>
<NcButton type="primary" size="sm" :is-loading="isLoading" data-testid="nc-token-save-btn" @click="generateToken">
Save
</NcButton>
</div>
</div>
<div v-if="!tokens">
<div v-if="!tokens.length">
<a-empty :image="Empty.PRESENTED_IMAGE_SIMPLE" :description="`${$t('general.no')} ${$t('labels.token')}`" />
</div>

Loading…
Cancel
Save