Browse Source

refactor(gui): i18n mapping

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4134/head
Pranav C 2 years ago
parent
commit
5859e8f5d3
  1. 4
      packages/nc-gui/components/account/License.vue
  2. 16
      packages/nc-gui/components/account/SignupSettings.vue
  3. 6
      packages/nc-gui/components/account/Token.vue
  4. 27
      packages/nc-gui/components/account/UserList.vue
  5. 12
      packages/nc-gui/components/account/UsersModal.vue
  6. 1
      packages/nc-gui/lang/bn_IN.json
  7. 12
      packages/nc-gui/lang/en.json
  8. 32
      packages/nc-gui/pages/account/index/users.vue
  9. 15
      packages/nc-gui/pages/account/index/users/[[tabType]].vue

4
packages/nc-gui/components/account/License.vue

@ -1,9 +1,12 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useNuxtApp } from '#app'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { extractSdkResponseErrorMsg, useApi } from '#imports' import { extractSdkResponseErrorMsg, useApi } from '#imports'
const { api, isLoading } = useApi() const { api, isLoading } = useApi()
const {$e} = useNuxtApp()
let key = $ref('') let key = $ref('')
const loadLicense = async () => { const loadLicense = async () => {
@ -22,6 +25,7 @@ const setLicense = async () => {
} catch (e) { } catch (e) {
message.error(await extractSdkResponseErrorMsg(e)) message.error(await extractSdkResponseErrorMsg(e))
} }
$e('a:account:license')
} }
loadLicense() loadLicense()

16
packages/nc-gui/components/account/SignupSettings.vue

@ -4,6 +4,8 @@ import { extractSdkResponseErrorMsg, useApi } from '#imports'
const { api } = useApi() const { api } = useApi()
const { t } = useI18n()
let settings = $ref<{ enable_user_signup?: boolean }>({ enable_user_signup: false }) let settings = $ref<{ enable_user_signup?: boolean }>({ enable_user_signup: false })
const loadSettings = async () => { const loadSettings = async () => {
@ -18,7 +20,7 @@ const loadSettings = async () => {
const saveSettings = async () => { const saveSettings = async () => {
try { try {
await api.orgAppSettings.set(settings) await api.orgAppSettings.set(settings)
message.success('Settings ky updated') message.success(t('msg.success.settingsSaved'))
} catch (e) { } catch (e) {
message.error(await extractSdkResponseErrorMsg(e)) message.error(await extractSdkResponseErrorMsg(e))
} }
@ -31,12 +33,20 @@ loadSettings()
<div> <div>
<div class="text-xl">Settings</div> <div class="text-xl">Settings</div>
<a-divider class="!my-3" /> <a-divider class="!my-3" />
<div class="-ml-6">
<a-form-item> <a-form-item>
<a-checkbox v-model:checked="settings.enable_user_signup" class="nc-checkbox" name="virtual" @change="saveSettings"> <a-checkbox
Enable user signup v-model:checked="settings.enable_user_signup"
v-e="['c:account:enable-signup']"
class="nc-checkbox"
name="virtual"
@change="saveSettings"
>
{{ $t('labels.enableSignup') }}
</a-checkbox> </a-checkbox>
</a-form-item> </a-form-item>
</div> </div>
</div>
</template> </template>
<style scoped> <style scoped>

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

@ -51,17 +51,18 @@ loadTokens()
const deleteToken = async (token: string) => { const deleteToken = async (token: string) => {
Modal.confirm({ Modal.confirm({
title: 'Are you sure you want to delete this token?', title: t('msg.info.deleteTokenConfirmation'),
type: 'warn', type: 'warn',
onOk: async () => { onOk: async () => {
try { try {
// todo: delete token // todo: delete token
await api.orgTokens.delete(token) await api.orgTokens.delete(token)
message.success('Token deleted successfully') message.success(t('msg.success.tokenDeleted'))
await loadTokens() await loadTokens()
} catch (e) { } catch (e) {
message.error(await extractSdkResponseErrorMsg(e)) message.error(await extractSdkResponseErrorMsg(e))
} }
$e('a:account:token:delete')
}, },
}) })
} }
@ -77,7 +78,6 @@ const generateToken = async () => {
} catch (e) { } catch (e) {
message.error(await extractSdkResponseErrorMsg(e)) message.error(await extractSdkResponseErrorMsg(e))
} }
$e('a:api-token:generate') $e('a:api-token:generate')
} }

27
packages/nc-gui/components/account/UserList.vue

@ -44,7 +44,7 @@ const loadUsers = async (page = currentPage, limit = currentLimit) => {
pagination.pageSize = 10 pagination.pageSize = 10
users = response.list as UserType[] users = response.list as UserType[]
} catch (e: any) { } catch (e) {
message.error(await extractSdkResponseErrorMsg(e)) message.error(await extractSdkResponseErrorMsg(e))
} }
} }
@ -56,8 +56,10 @@ const updateRole = async (userId: string, roles: Role) => {
await api.orgUsers.update(userId, { await api.orgUsers.update(userId, {
roles, roles,
} as unknown as UserType) } as unknown as UserType)
message.success('Role updated successfully') message.success(t('msg.success.roleUpdated'))
} catch (e: any) {
$e('a:org-user:role-updated', { role: roles })
} catch (e) {
message.error(await extractSdkResponseErrorMsg(e)) message.error(await extractSdkResponseErrorMsg(e))
} }
} }
@ -70,9 +72,10 @@ const deleteUser = async (userId: string) => {
onOk: async () => { onOk: async () => {
try { try {
await api.orgUsers.delete(userId) await api.orgUsers.delete(userId)
message.success('User deleted successfully') message.success(t('msg.success.userDeleted'))
await loadUsers() await loadUsers()
} catch (e: any) { $e('a:org-user:user-deleted')
} catch (e) {
message.error(await extractSdkResponseErrorMsg(e)) message.error(await extractSdkResponseErrorMsg(e))
} }
}, },
@ -86,7 +89,7 @@ const resendInvite = async (user: User) => {
// Invite email sent successfully // Invite email sent successfully
message.success(t('msg.success.inviteEmailSent')) message.success(t('msg.success.inviteEmailSent'))
await loadUsers() await loadUsers()
} catch (e: any) { } catch (e) {
message.error(await extractSdkResponseErrorMsg(e)) message.error(await extractSdkResponseErrorMsg(e))
} }
@ -177,16 +180,16 @@ const copyPasswordResetUrl = async (user: User) => {
> >
<a-select-option :value="Role.OrgLevelCreator" :label="$t(`objects.roleType.orgLevelCreator`)"> <a-select-option :value="Role.OrgLevelCreator" :label="$t(`objects.roleType.orgLevelCreator`)">
<div>{{ $t(`objects.roleType.orgLevelCreator`) }}</div> <div>{{ $t(`objects.roleType.orgLevelCreator`) }}</div>
<span class="text-gray-500 text-xs whitespace-normal" <span class="text-gray-500 text-xs whitespace-normal">
>Creator can create new projects and access any invited project.</span {{ $t('msg.info.roles.orgCreator') }}
> </span>
</a-select-option> </a-select-option>
<a-select-option :value="Role.OrgLevelViewer" :label="$t(`objects.roleType.orgLevelViewer`)"> <a-select-option :value="Role.OrgLevelViewer" :label="$t(`objects.roleType.orgLevelViewer`)">
<div>{{ $t(`objects.roleType.orgLevelViewer`) }}</div> <div>{{ $t(`objects.roleType.orgLevelViewer`) }}</div>
<span class="text-gray-500 text-xs whitespace-normal" <span class="text-gray-500 text-xs whitespace-normal">
>Viewer is not allowed to create new projects but they can access any invited project.</span {{ $t('msg.info.roles.orgViewer') }}
> </span>
</a-select-option> </a-select-option>
</a-select> </a-select>
</div> </div>

12
packages/nc-gui/components/account/UsersModal.vue

@ -215,16 +215,16 @@ const emailInput = ref((el) => {
<a-select v-model:value="usersData.role" class="nc-user-roles" dropdown-class-name="nc-dropdown-user-role"> <a-select v-model:value="usersData.role" class="nc-user-roles" dropdown-class-name="nc-dropdown-user-role">
<a-select-option :value="Role.OrgLevelCreator" :label="$t(`objects.roleType.orgLevelCreator`)"> <a-select-option :value="Role.OrgLevelCreator" :label="$t(`objects.roleType.orgLevelCreator`)">
<div>{{ $t(`objects.roleType.orgLevelCreator`) }}</div> <div>{{ $t(`objects.roleType.orgLevelCreator`) }}</div>
<span class="text-gray-500 text-xs whitespace-normal" <span class="text-gray-500 text-xs whitespace-normal">
>Creator can create new projects and access any invited project.</span {{ $t('msg.info.roles.orgCreator') }}
> </span>
</a-select-option> </a-select-option>
<a-select-option :value="Role.OrgLevelViewer" :label="$t(`objects.roleType.orgLevelViewer`)"> <a-select-option :value="Role.OrgLevelViewer" :label="$t(`objects.roleType.orgLevelViewer`)">
<div>{{ $t(`objects.roleType.orgLevelViewer`) }}</div> <div>{{ $t(`objects.roleType.orgLevelViewer`) }}</div>
<span class="text-gray-500 text-xs whitespace-normal" <span class="text-gray-500 text-xs whitespace-normal">
>Viewer is not allowed to create new projects but they can access any invited project.</span {{ $t('msg.info.roles.orgViewer') }}
> </span>
</a-select-option> </a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>

1
packages/nc-gui/lang/bn_IN.json

@ -591,6 +591,7 @@
"tableDeleted": "Deleted table successfully", "tableDeleted": "Deleted table successfully",
"generatePublicShareableReadonlyBase": "Generate publicly shareable readonly base", "generatePublicShareableReadonlyBase": "Generate publicly shareable readonly base",
"deleteViewConfirmation": "Are you sure you want to delete this view?", "deleteViewConfirmation": "Are you sure you want to delete this view?",
"deleteTokenConfirmation": "Are you sure you want to delete this token?",
"deleteTableConfirmation": "Do you want to delete the table", "deleteTableConfirmation": "Do you want to delete the table",
"showM2mTables": "Show M2M Tables", "showM2mTables": "Show M2M Tables",
"deleteKanbanStackConfirmation": "Deleting this stack will also remove the select option `{stackToBeDeleted}` from the `{groupingField}`. The records will move to the uncategorized stack." "deleteKanbanStackConfirmation": "Deleting this stack will also remove the select option `{stackToBeDeleted}` from the `{groupingField}`. The records will move to the uncategorized stack."

12
packages/nc-gui/lang/en.json

@ -299,7 +299,8 @@
"signUpWithGoogle": "Sign up with Google", "signUpWithGoogle": "Sign up with Google",
"signInWithGoogle": "Sign in with Google", "signInWithGoogle": "Sign in with Google",
"agreeToTos": "By signing up, you agree to the Terms of Service", "agreeToTos": "By signing up, you agree to the Terms of Service",
"welcomeToNc": "Welcome to NocoDB!" "welcomeToNc": "Welcome to NocoDB!",
"enableSignup": "Enable user signup"
}, },
"activity": { "activity": {
"createProject": "Create Project", "createProject": "Create Project",
@ -485,6 +486,10 @@
}, },
"msg": { "msg": {
"info": { "info": {
"roles": {
"orgCreator": "Creator can create new projects and access any invited project.",
"orgViewer": "Viewer is not allowed to create new projects but they can access any invited project."
},
"footerInfo": "Rows per page", "footerInfo": "Rows per page",
"upload": "Select file to Upload", "upload": "Select file to Upload",
"upload_sub": "or drag and drop file", "upload_sub": "or drag and drop file",
@ -688,6 +693,7 @@
"tableDataExported": "Successfully exported all table data", "tableDataExported": "Successfully exported all table data",
"updated": "Successfully updated", "updated": "Successfully updated",
"sharedViewDeleted": "Deleted shared view successfully", "sharedViewDeleted": "Deleted shared view successfully",
"userDeleted": "User deleted successfully",
"viewRenamed": "View renamed successfully", "viewRenamed": "View renamed successfully",
"tokenGenerated": "Token generated successfully", "tokenGenerated": "Token generated successfully",
"tokenDeleted": "Token deleted successfully", "tokenDeleted": "Token deleted successfully",
@ -705,7 +711,9 @@
"webhookTested": "Webhook tested successfully", "webhookTested": "Webhook tested successfully",
"columnUpdated": "Column updated", "columnUpdated": "Column updated",
"columnCreated": "Column created", "columnCreated": "Column created",
"passwordChanged": "Password changed successfully. Please login again." "passwordChanged": "Password changed successfully. Please login again.",
"settingsSaved": "Settings saved successfully",
"roleUpdated": "Role updated successfully"
} }
} }
} }

32
packages/nc-gui/pages/account/index/users.vue

@ -1,18 +1,3 @@
<template>
<div class="h-full overflow-y-scroll scrollbar-thin-dull pt-4">
<a-tabs v-model:active-key="selectedTabKey" :open-keys="[]" mode="horizontal" class="nc-auth-tabs">
<a-tab-pane v-for="tab of tabs" :key="tab.key" class="select-none">
<template #tab>
<span>
{{ tab.label }}
</span>
</template>
</a-tab-pane>
</a-tabs>
<NuxtPage :tab-key="selectedTabKey"/>
</div>
</template>
<script setup lang="ts"> <script setup lang="ts">
import { useUIPermission } from '~/composables/useUIPermission' import { useUIPermission } from '~/composables/useUIPermission'
@ -32,10 +17,25 @@ const $route = useRoute()
const selectedTabKey = computed({ const selectedTabKey = computed({
get() { get() {
return tabs.find(t => t.key === $route.params.tabType)?.key ?? tabs[0].key return tabs.find((t) => t.key === $route.params.tabType)?.key ?? tabs[0].key
}, },
set(val) { set(val) {
navigateTo(`/account/users/${val}`) navigateTo(`/account/users/${val}`)
}, },
}) })
</script> </script>
<template>
<div class="h-full overflow-y-scroll scrollbar-thin-dull pt-4">
<a-tabs v-model:active-key="selectedTabKey" :open-keys="[]" mode="horizontal" class="nc-auth-tabs">
<a-tab-pane v-for="tab of tabs" :key="tab.key" class="select-none">
<template #tab>
<span>
{{ tab.label }}
</span>
</template>
</a-tab-pane>
</a-tabs>
<NuxtPage :tab-key="selectedTabKey" />
</div>
</template>

15
packages/nc-gui/pages/account/index/users/[[tabType]].vue

@ -1,3 +1,11 @@
<script setup lang="ts">
import { defineProps } from '#imports'
const props = defineProps<{
tabKey: string
}>()
</script>
<template> <template>
<template v-if="props.tabKey === 'list'"> <template v-if="props.tabKey === 'list'">
<LazyAccountUserList /> <LazyAccountUserList />
@ -9,10 +17,3 @@
<LazyAccountResetPassword /> <LazyAccountResetPassword />
</template> </template>
</template> </template>
<script setup lang="ts">
import { defineProps } from '#imports'
const props = defineProps<{
tabKey: string
}>()
</script>

Loading…
Cancel
Save