Browse Source

fix: refactor token page

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

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

@ -73,7 +73,7 @@ loadTokens()
const isModalOpen = ref(false) const isModalOpen = ref(false)
const tokenDesc = ref('') const tokenDesc = ref('')
const tokenToCopy = ref('') const tokenToCopy = ref('')
const isTokenNameIsEmpty = ref(false) const isTokenNameEmpty = ref(false)
const deleteToken = async (token: string): Promise<void> => { const deleteToken = async (token: string): Promise<void> => {
try { try {
@ -90,12 +90,9 @@ const deleteToken = async (token: string): Promise<void> => {
} }
const generateToken = async () => { const generateToken = async () => {
if (!selectedTokenData.value.description?.length) { isTokenNameEmpty.value = !selectedTokenData.value.description?.length
isTokenNameIsEmpty.value = true
} else { if (isTokenNameEmpty.value) return
isTokenNameIsEmpty.value = false
}
if (isTokenNameIsEmpty.value) return
try { try {
await api.orgTokens.create(selectedTokenData.value) await api.orgTokens.create(selectedTokenData.value)
showNewTokenModal.value = false showNewTokenModal.value = false
@ -133,7 +130,7 @@ const descriptionInput: VNodeRef = (el) => (el as HTMLInputElement)?.focus()
const handleCancel = () => { const handleCancel = () => {
showNewTokenModal.value = false showNewTokenModal.value = false
isTokenNameIsEmpty.value = false isTokenNameEmpty.value = false
} }
</script> </script>
@ -179,7 +176,7 @@ const handleCancel = () => {
placeholder="Token Name" placeholder="Token Name"
data-testid="nc-token-input" data-testid="nc-token-input"
/> />
<span v-if="isTokenNameIsEmpty" class="text-red-500 text-xs font-light mt-1.5 ml-1" <span v-if="isTokenNameEmpty" class="text-red-500 text-xs font-light mt-1.5 ml-1"
>token name should not be empty</span >token name should not be empty</span
> >
</div> </div>

Loading…
Cancel
Save