opnform-host-nginx/client/pages/settings.vue

107 lines
2.5 KiB
Vue
Raw Normal View History

<template>
<div class="bg-white">
<div class="flex bg-gray-50">
<div class="w-full md:w-4/5 md:mx-auto md:max-w-4xl px-4">
<div class="pt-4 pb-0">
<div class="flex">
<h2 class="flex-grow text-gray-900">
My Account
</h2>
</div>
<ul class="flex text-gray-500">
<li>{{ user.email }}</li>
</ul>
<div class="mt-4 border-gray-200 dark:border-gray-700">
<ul class="flex flex-wrap -mb-px text-sm font-medium text-center">
<li
v-for="(tab, i) in tabsList"
:key="i + 1"
class="mr-6"
>
<nuxt-link
:to="{ name: tab.route }"
class="hover:no-underline inline-block py-4 rounded-t-lg border-b-2 text-gray-500 hover:text-gray-600"
active-class="text-blue-600 hover:text-blue-900 dark:text-blue-500 dark:hover:text-blue-500 border-blue-600 dark:border-blue-500"
>
{{ tab.name }}
</nuxt-link>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="flex bg-white">
<div class="w-full md:w-4/5 md:mx-auto md:max-w-4xl px-4">
<div class="mt-4 pb-0">
<NuxtPage />
</div>
</div>
</div>
</div>
</template>
<script setup>
import { computed } from "vue"
import { useAuthStore } from "../stores/auth"
definePageMeta({
middleware: ["auth", "self-hosted-credentials"],
})
useOpnSeoMeta({
title: "Settings",
})
const authStore = useAuthStore()
const user = computed(() => authStore.user)
Readonly User (#637) * Readonly User * Refactor FormPolicy and TemplatePolicy to centralize write operation logic - Introduced a private method `canPerformWriteOperation` in both FormPolicy and TemplatePolicy to encapsulate the logic for determining if a user can perform write operations on the respective models. - Updated the `update`, `delete`, `restore`, and `forceDelete` methods in FormPolicy to use the new method for improved readability and maintainability. - Simplified the `update` and `delete` methods in TemplatePolicy to leverage the centralized write operation logic. This refactoring enhances code clarity and reduces duplication across policy classes. * Refactor user and workspace permissions handling - Updated FormController to authorize form creation based on workspace context. - Removed the `is_readonly` attribute from UserResource and integrated it into WorkspaceResource for better encapsulation. - Refactored User model to eliminate the `getIsReadonlyAttribute` method, shifting readonly logic to the Workspace model. - Adjusted FormPolicy and TemplatePolicy to utilize workspace readonly checks for user permissions. - Updated various frontend components to reference workspace readonly status instead of user readonly status, enhancing clarity and consistency in permission handling. These changes improve the management of user permissions in relation to workspaces, ensuring a more robust and maintainable authorization system. * Fix isReadonlyUser * fix pint --------- Co-authored-by: Julien Nahum <julien@nahum.net>
2024-12-30 14:35:23 +01:00
const workspace = computed(() => useWorkspacesStore().getCurrent)
const tabsList = computed(() => {
const tabs = [
{
name: "Profile",
route: "settings-profile",
},
{
name: "Workspace Settings",
route: "settings-workspace",
},
Readonly User (#637) * Readonly User * Refactor FormPolicy and TemplatePolicy to centralize write operation logic - Introduced a private method `canPerformWriteOperation` in both FormPolicy and TemplatePolicy to encapsulate the logic for determining if a user can perform write operations on the respective models. - Updated the `update`, `delete`, `restore`, and `forceDelete` methods in FormPolicy to use the new method for improved readability and maintainability. - Simplified the `update` and `delete` methods in TemplatePolicy to leverage the centralized write operation logic. This refactoring enhances code clarity and reduces duplication across policy classes. * Refactor user and workspace permissions handling - Updated FormController to authorize form creation based on workspace context. - Removed the `is_readonly` attribute from UserResource and integrated it into WorkspaceResource for better encapsulation. - Refactored User model to eliminate the `getIsReadonlyAttribute` method, shifting readonly logic to the Workspace model. - Adjusted FormPolicy and TemplatePolicy to utilize workspace readonly checks for user permissions. - Updated various frontend components to reference workspace readonly status instead of user readonly status, enhancing clarity and consistency in permission handling. These changes improve the management of user permissions in relation to workspaces, ensuring a more robust and maintainable authorization system. * Fix isReadonlyUser * fix pint --------- Co-authored-by: Julien Nahum <julien@nahum.net>
2024-12-30 14:35:23 +01:00
...workspace.value.is_readonly ? [] : [
{
name: "Access Tokens",
route: "settings-access-tokens",
},
{
name: "Connections",
route: "settings-connections",
},
],
{
name: "Password",
route: "settings-password",
},
{
name: "Delete Account",
route: "settings-account",
},
]
if (user?.value?.is_subscribed) {
tabs.splice(1, 0, {
name: "Billing",
route: "settings-billing",
})
}
if (user?.value?.admin) {
tabs.push({
name: "Admin",
route: "settings-admin",
})
}
return tabs
})
</script>