Skip to content

Commit

Permalink
feat: simplified and adjusted permission usage across codespace
Browse files Browse the repository at this point in the history
  • Loading branch information
tada5hi committed Jul 1, 2024
1 parent 3410786 commit 1839f5e
Show file tree
Hide file tree
Showing 105 changed files with 337 additions and 477 deletions.
133 changes: 67 additions & 66 deletions packages/client-ui/config/layout/contants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*/

import type { NavigationItem } from '@vuecs/navigation';
import { PermissionID } from '@privateaim/core-kit';
import { PermissionName } from '@privateaim/kit';
import { PermissionName as AuthupPermissionName } from '@authup/core-kit';

export enum LayoutKey {
NAVIGATION_ID = 'navigationId',
Expand Down Expand Up @@ -55,19 +56,19 @@ export const LayoutSideDefaultNavigation: NavigationItem[] = [
icon: 'fas fa-tasks',
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionID.PROJECT_ADD,
PermissionID.PROJECT_DROP,
PermissionID.PROJECT_EDIT,
PermissionID.PROJECT_APPROVE,
PermissionName.PROJECT_CREATE,
PermissionName.PROJECT_DELETE,
PermissionName.PROJECT_UPDATE,
PermissionName.PROJECT_APPROVE,

PermissionID.ANALYSIS_ADD,
PermissionID.ANALYSIS_DROP,
PermissionID.ANALYSIS_EDIT,
PermissionID.ANALYSIS_APPROVE,
PermissionName.ANALYSIS_CREATE,
PermissionName.ANALYSIS_DELETE,
PermissionName.ANALYSIS_UPDATE,
PermissionName.ANALYSIS_APPROVE,

PermissionID.ANALYSIS_RESULT_READ,
PermissionID.ANALYSIS_EXECUTION_START,
PermissionID.ANALYSIS_EXECUTION_STOP,
PermissionName.ANALYSIS_RESULT_READ,
PermissionName.ANALYSIS_EXECUTION_START,
PermissionName.ANALYSIS_EXECUTION_STOP,
],
},
{
Expand All @@ -77,13 +78,13 @@ export const LayoutSideDefaultNavigation: NavigationItem[] = [
icon: 'fa fa-bar-chart',
requireLoggedIn: true,
requirePermissions: [
PermissionID.ANALYSIS_ADD,
PermissionID.ANALYSIS_DROP,
PermissionID.ANALYSIS_EDIT,
PermissionID.ANALYSIS_APPROVE,
PermissionName.ANALYSIS_CREATE,
PermissionName.ANALYSIS_DELETE,
PermissionName.ANALYSIS_UPDATE,
PermissionName.ANALYSIS_APPROVE,

PermissionID.ANALYSIS_EXECUTION_START,
PermissionID.ANALYSIS_EXECUTION_STOP,
PermissionName.ANALYSIS_EXECUTION_START,
PermissionName.ANALYSIS_EXECUTION_STOP,
],
},
{
Expand Down Expand Up @@ -112,27 +113,27 @@ export const LayoutSideAdminNavigation: NavigationItem[] = [
icon: 'fas fa-lock',
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionID.REALM_ADD,
PermissionID.REALM_EDIT,
PermissionID.REALM_DROP,
AuthupPermissionName.REALM_CREATE,
AuthupPermissionName.REALM_UPDATE,
AuthupPermissionName.REALM_DELETE,

PermissionID.PROVIDER_ADD,
PermissionID.PROVIDER_EDIT,
PermissionID.PROVIDER_DROP,
AuthupPermissionName.IDENTITY_PROVIDER_CREATE,
AuthupPermissionName.IDENTITY_PROVIDER_UPDATE,
AuthupPermissionName.IDENTITY_PROVIDER_DELETE,

PermissionID.USER_ADD,
PermissionID.USER_EDIT,
PermissionID.USER_DROP,
AuthupPermissionName.USER_CREATE,
AuthupPermissionName.USER_UPDATE,
AuthupPermissionName.USER_DELETE,

PermissionID.ROLE_ADD,
PermissionID.ROLE_EDIT,
PermissionID.ROLE_DROP,
PermissionID.ROLE_PERMISSION_ADD,
PermissionID.ROLE_PERMISSION_DROP,
AuthupPermissionName.ROLE_CREATE,
AuthupPermissionName.ROLE_UPDATE,
AuthupPermissionName.ROLE_DELETE,
AuthupPermissionName.ROLE_PERMISSION_CREATE,
AuthupPermissionName.ROLE_PERMISSION_DELETE,

PermissionID.PERMISSION_ADD,
PermissionID.PERMISSION_EDIT,
PermissionID.PERMISSION_DROP,
AuthupPermissionName.PERMISSION_CREATE,
AuthupPermissionName.PERMISSION_UPDATE,
AuthupPermissionName.PERMISSION_DELETE,
],
children: [
{
Expand All @@ -142,13 +143,13 @@ export const LayoutSideAdminNavigation: NavigationItem[] = [
icon: 'fas fa-university',
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionID.REALM_ADD,
PermissionID.REALM_EDIT,
PermissionID.REALM_DROP,
AuthupPermissionName.REALM_CREATE,
AuthupPermissionName.REALM_UPDATE,
AuthupPermissionName.REALM_DELETE,

PermissionID.PROVIDER_ADD,
PermissionID.PROVIDER_DROP,
PermissionID.PROJECT_EDIT,
AuthupPermissionName.IDENTITY_PROVIDER_CREATE,
AuthupPermissionName.IDENTITY_PROVIDER_DELETE,
PermissionName.PROJECT_UPDATE,
],
},
{
Expand All @@ -158,9 +159,9 @@ export const LayoutSideAdminNavigation: NavigationItem[] = [
icon: 'fas fa-atom',
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionID.PROVIDER_ADD,
PermissionID.PROVIDER_EDIT,
PermissionID.PROVIDER_DROP,
AuthupPermissionName.IDENTITY_PROVIDER_CREATE,
AuthupPermissionName.IDENTITY_PROVIDER_UPDATE,
AuthupPermissionName.IDENTITY_PROVIDER_DELETE,
],
},
{
Expand All @@ -170,9 +171,9 @@ export const LayoutSideAdminNavigation: NavigationItem[] = [
icon: 'fas fa-robot',
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionID.ROBOT_ADD,
PermissionID.ROBOT_EDIT,
PermissionID.ROBOT_DROP,
AuthupPermissionName.ROBOT_CREATE,
AuthupPermissionName.ROBOT_UPDATE,
AuthupPermissionName.ROBOT_DELETE,
],
},
{
Expand All @@ -182,9 +183,9 @@ export const LayoutSideAdminNavigation: NavigationItem[] = [
icon: 'fas fa-user',
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionID.USER_ADD,
PermissionID.USER_EDIT,
PermissionID.USER_DROP,
AuthupPermissionName.USER_CREATE,
AuthupPermissionName.USER_UPDATE,
AuthupPermissionName.USER_DELETE,
],
},
{
Expand All @@ -194,12 +195,12 @@ export const LayoutSideAdminNavigation: NavigationItem[] = [
icon: 'fas fa-users',
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionID.ROLE_ADD,
PermissionID.ROLE_EDIT,
PermissionID.ROLE_DROP,
AuthupPermissionName.ROLE_CREATE,
AuthupPermissionName.ROLE_UPDATE,
AuthupPermissionName.ROLE_DELETE,

PermissionID.ROLE_PERMISSION_ADD,
PermissionID.ROLE_PERMISSION_DROP,
AuthupPermissionName.ROLE_PERMISSION_CREATE,
AuthupPermissionName.ROLE_PERMISSION_DELETE,
],
},
{
Expand All @@ -209,9 +210,9 @@ export const LayoutSideAdminNavigation: NavigationItem[] = [
icon: 'fas fa-key',
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionID.PERMISSION_ADD,
PermissionID.PERMISSION_EDIT,
PermissionID.PERMISSION_DROP,
AuthupPermissionName.PERMISSION_CREATE,
AuthupPermissionName.PERMISSION_UPDATE,
AuthupPermissionName.PERMISSION_DELETE,
],
},
],
Expand All @@ -222,11 +223,11 @@ export const LayoutSideAdminNavigation: NavigationItem[] = [
icon: 'fas fa-globe',
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionID.NODE_ADD,
PermissionID.NODE_DROP,
PermissionID.NODE_EDIT,
PermissionName.NODE_CREATE,
PermissionName.NODE_DELETE,
PermissionName.NODE_UPDATE,

PermissionID.SERVICE_MANAGE,
PermissionName.SERVICE_MANAGE,
],
children: [
{
Expand All @@ -236,9 +237,9 @@ export const LayoutSideAdminNavigation: NavigationItem[] = [
icon: 'fa-solid fa-server',
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionID.NODE_ADD,
PermissionID.NODE_DROP,
PermissionID.NODE_EDIT,
PermissionName.NODE_CREATE,
PermissionName.NODE_DELETE,
PermissionName.NODE_UPDATE,
],
},
{
Expand All @@ -248,7 +249,7 @@ export const LayoutSideAdminNavigation: NavigationItem[] = [
icon: 'fa fa-map-signs',
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionID.SERVICE_MANAGE,
PermissionName.SERVICE_MANAGE,
],
},
],
Expand Down
3 changes: 2 additions & 1 deletion packages/client-ui/pages/admin/identity-providers/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export default defineNuxtComponent({
[LayoutKey.NAVIGATION_ID]: LayoutNavigationID.ADMIN,
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionName.REALM_EDIT,
PermissionName.IDENTITY_PROVIDER_UPDATE,
PermissionName.IDENTITY_PROVIDER_READ,
],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default defineNuxtComponent({
definePageMeta({
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionName.REALM_EDIT,
PermissionName.IDENTITY_PROVIDER_UPDATE,
],
});

Expand Down
7 changes: 4 additions & 3 deletions packages/client-ui/pages/admin/identity-providers/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ export default defineNuxtComponent({
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.NAVIGATION_ID]: LayoutNavigationID.ADMIN,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionName.PROVIDER_EDIT,
PermissionName.PROVIDER_DROP,
PermissionName.PROVIDER_ADD,
PermissionName.IDENTITY_PROVIDER_UPDATE,
PermissionName.IDENTITY_PROVIDER_DELETE,
PermissionName.IDENTITY_PROVIDER_CREATE,
PermissionName.IDENTITY_PROVIDER_READ,
],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default defineNuxtComponent({
[LayoutKey.NAVIGATION_ID]: LayoutNavigationID.ADMIN,
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionName.REALM_ADD,
PermissionName.IDENTITY_PROVIDER_CREATE,
],
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ export default defineNuxtComponent({
resource: IdentityProvider,
) => isRealmResourceWritable(realm.value, resource.realm_id);

const hasEditPermission = useAbilityCheck(PermissionName.PROVIDER_EDIT);
const hasDropPermission = useAbilityCheck(PermissionName.PROVIDER_DROP);
const hasEditPermission = useAbilityCheck(PermissionName.IDENTITY_PROVIDER_UPDATE);
const hasDropPermission = useAbilityCheck(PermissionName.IDENTITY_PROVIDER_DELETE);

const fields = [
{
Expand Down
1 change: 0 additions & 1 deletion packages/client-ui/pages/admin/nodes/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export default defineNuxtComponent({
fields: [
'+registry_id',
'+registry_project_id',
'+email',
'+external_name',
],
},
Expand Down
8 changes: 4 additions & 4 deletions packages/client-ui/pages/admin/nodes/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<script lang="ts">
import type { Node } from '@privateaim/core-kit';
import { PermissionID } from '@privateaim/core-kit';
import { PermissionName } from '@privateaim/kit';
import { definePageMeta, useToast } from '#imports';
import { defineNuxtComponent, navigateTo } from '#app';
import { LayoutKey, LayoutNavigationID } from '../../../config/layout';
Expand All @@ -18,9 +18,9 @@ export default defineNuxtComponent({
[LayoutKey.NAVIGATION_ID]: LayoutNavigationID.ADMIN,
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionID.NODE_EDIT,
PermissionID.NODE_DROP,
PermissionID.NODE_ADD,
PermissionName.NODE_UPDATE,
PermissionName.NODE_DELETE,
PermissionName.NODE_CREATE,
],
});

Expand Down
4 changes: 2 additions & 2 deletions packages/client-ui/pages/admin/nodes/index/add.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<script lang="ts">
import { useStore } from '@authup/client-web-kit';
import type { Node } from '@privateaim/core-kit';
import { PermissionID } from '@privateaim/core-kit';
import { PermissionName } from '@privateaim/kit';
import { storeToRefs } from 'pinia';
import { FNodeForm } from '@privateaim/client-vue';
import { defineNuxtComponent } from '#app';
Expand All @@ -22,7 +22,7 @@ export default defineNuxtComponent({
[LayoutKey.NAVIGATION_ID]: LayoutNavigationID.ADMIN,
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionID.NODE_ADD,
PermissionName.NODE_CREATE,
],
});

Expand Down
6 changes: 3 additions & 3 deletions packages/client-ui/pages/admin/nodes/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
-->
<script lang="ts">
import { useAbilityCheck, useStore } from '@authup/client-web-kit';
import { PermissionName } from '@privateaim/kit';
import { VCTimeago } from '@vuecs/timeago';
import type { Node } from '@privateaim/core-kit';
import { PermissionID } from '@privateaim/core-kit';
import { BTable } from 'bootstrap-vue-next';
import { storeToRefs } from 'pinia';
import type { BuildInput } from 'rapiq';
Expand Down Expand Up @@ -58,8 +58,8 @@ export default defineNuxtComponent({
const store = useStore();
const { realmManagementId } = storeToRefs(store);

const canEdit = useAbilityCheck(PermissionID.NODE_EDIT);
const canDrop = useAbilityCheck(PermissionID.NODE_DROP);
const canEdit = useAbilityCheck(PermissionName.NODE_UPDATE);
const canDrop = useAbilityCheck(PermissionName.NODE_DELETE);
const canView = computed(() => canEdit.value || canDrop.value);

const query = computed<BuildInput<Node>>(() => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/client-ui/pages/admin/permissions/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default defineNuxtComponent({
[LayoutKey.NAVIGATION_ID]: LayoutNavigationID.ADMIN,
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionName.PERMISSION_EDIT,
PermissionName.PERMISSION_UPDATE,
],
});

Expand Down
6 changes: 3 additions & 3 deletions packages/client-ui/pages/admin/permissions/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export default defineNuxtComponent({
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.NAVIGATION_ID]: LayoutNavigationID.ADMIN,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionName.PERMISSION_EDIT,
PermissionName.PERMISSION_DROP,
PermissionName.PERMISSION_ADD,
PermissionName.PERMISSION_UPDATE,
PermissionName.PERMISSION_DELETE,
PermissionName.PERMISSION_CREATE,
],
});

Expand Down
2 changes: 1 addition & 1 deletion packages/client-ui/pages/admin/permissions/index/add.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default defineNuxtComponent({
[LayoutKey.NAVIGATION_ID]: LayoutNavigationID.ADMIN,
[LayoutKey.REQUIRED_LOGGED_IN]: true,
[LayoutKey.REQUIRED_PERMISSIONS]: [
PermissionName.PERMISSION_ADD,
PermissionName.PERMISSION_CREATE,
],
});

Expand Down
4 changes: 2 additions & 2 deletions packages/client-ui/pages/admin/permissions/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export default defineNuxtComponent({
resource: Permission,
) => isRealmResourceWritable(realm.value, resource.realm_id);

const hasEditPermission = useAbilityCheck(PermissionName.PERMISSION_EDIT);
const hasDropPermission = useAbilityCheck(PermissionName.PERMISSION_DROP);
const hasEditPermission = useAbilityCheck(PermissionName.PERMISSION_UPDATE);
const hasDropPermission = useAbilityCheck(PermissionName.PERMISSION_DELETE);

const fields = [
{
Expand Down
Loading

0 comments on commit 1839f5e

Please sign in to comment.