feat(api tokens): format permissions and groups human-readable
This commit is contained in:
parent
bd7b973559
commit
984978fe6d
@ -11,6 +11,7 @@ import flatPickr from 'vue-flatpickr-component'
|
|||||||
import 'flatpickr/dist/flatpickr.css'
|
import 'flatpickr/dist/flatpickr.css'
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
import {useAuthStore} from '@/stores/auth'
|
import {useAuthStore} from '@/stores/auth'
|
||||||
|
import {camelCase} from 'camel-case'
|
||||||
|
|
||||||
const service = new ApiTokenService()
|
const service = new ApiTokenService()
|
||||||
const tokens = ref([])
|
const tokens = ref([])
|
||||||
@ -104,6 +105,10 @@ async function createToken() {
|
|||||||
tokens.value.push(token)
|
tokens.value.push(token)
|
||||||
showCreateForm.value = false
|
showCreateForm.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function formatPermissionTitle(title: string): string {
|
||||||
|
return title.replaceAll('_', ' ')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -127,10 +132,10 @@ async function createToken() {
|
|||||||
<tr v-for="tk in tokens" :key="tk.id">
|
<tr v-for="tk in tokens" :key="tk.id">
|
||||||
<td>{{ tk.id }}</td>
|
<td>{{ tk.id }}</td>
|
||||||
<td>{{ tk.title }}</td>
|
<td>{{ tk.title }}</td>
|
||||||
<td>
|
<td class="is-capitalized">
|
||||||
<template v-for="(v, p) in tk.permissions" :key="'permission-' + p">
|
<template v-for="(v, p) in tk.permissions" :key="'permission-' + p">
|
||||||
<strong>{{ p }}:</strong>
|
<strong>{{ formatPermissionTitle(p) }}:</strong>
|
||||||
{{ v.join(', ') }}
|
{{ v.map(formatPermissionTitle).join(', ') }}
|
||||||
<br/>
|
<br/>
|
||||||
</template>
|
</template>
|
||||||
</td>
|
</td>
|
||||||
@ -197,14 +202,14 @@ async function createToken() {
|
|||||||
<label class="label">{{ $t('user.settings.apiTokens.attributes.permissions') }}</label>
|
<label class="label">{{ $t('user.settings.apiTokens.attributes.permissions') }}</label>
|
||||||
<p>{{ $t('user.settings.apiTokens.permissionExplanation') }}</p>
|
<p>{{ $t('user.settings.apiTokens.permissionExplanation') }}</p>
|
||||||
<div v-for="(routes, group) in availableRoutes" class="mb-2" :key="group">
|
<div v-for="(routes, group) in availableRoutes" class="mb-2" :key="group">
|
||||||
<strong>{{ group }}</strong><br/>
|
<strong class="is-capitalized">{{ formatPermissionTitle(group) }}</strong><br/>
|
||||||
<fancycheckbox
|
<fancycheckbox
|
||||||
v-for="(paths, route) in routes"
|
v-for="(paths, route) in routes"
|
||||||
:key="group+'-'+route"
|
:key="group+'-'+route"
|
||||||
class="mr-2"
|
class="mr-2 is-capitalized"
|
||||||
v-model="newTokenPermissions[group][route]"
|
v-model="newTokenPermissions[group][route]"
|
||||||
>
|
>
|
||||||
{{ route }}
|
{{ formatPermissionTitle(route) }}
|
||||||
</fancycheckbox>
|
</fancycheckbox>
|
||||||
<br/>
|
<br/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user