-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
…d revoke
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
previewFeatures = ["multiSchema", "views"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,13 @@ import { onMounted, ref } from 'vue'; | |
import { Dropdown } from '@/components/form'; | ||
import { Spinner } from '@/components/layout'; | ||
import { Button, Column, DataTable, Dialog, IconField, InputIcon, InputText, useToast } from '@/lib/primevue'; | ||
import { ssoService } from '@/services'; | ||
import { ssoService, yarsService } from '@/services'; | ||
import { useAuthZStore } from '@/store'; | ||
import { GroupName } from '@/utils/enums/application'; | ||
import type { DropdownChangeEvent } from 'primevue/dropdown'; | ||
import type { Ref } from 'vue'; | ||
import type { User } from '@/types'; | ||
import type { Group, User } from '@/types'; | ||
// Constants | ||
const USER_SEARCH_PARAMS: { [key: string]: string } = { | ||
|
@@ -29,12 +29,13 @@ const authzStore = useAuthZStore(); | |
// State | ||
const loading: Ref<boolean> = ref(false); | ||
const searchTag: Ref<string> = ref(''); | ||
const selectableGroups: Ref<Array<GroupName>> = ref([]); | ||
const selectableGroups: Ref<Map<string, GroupName>> = ref(new Map()); | ||
const selectedGroup: Ref<GroupName | undefined> = ref(undefined); | ||
const selectedParam: Ref<string | undefined> = ref(undefined); | ||
const selectedParam: Ref<string | undefined> = ref('Last name'); | ||
const selectedUser: Ref<User | undefined> = ref(undefined); | ||
const users: Ref<Array<User>> = ref([]); | ||
const visible = defineModel<boolean>('visible'); | ||
const yarsGroups: Ref<Array<Group>> = ref([]); | ||
// Actions | ||
let cancelTokenSource: any = null; | ||
|
@@ -86,12 +87,20 @@ async function searchIdirUsers() { | |
} | ||
} | ||
onMounted(() => { | ||
// TODO: Map rbac groups to radio list to get cleaner labels | ||
selectableGroups.value = [GroupName.NAVIGATOR, GroupName.NAVIGATOR_READ_ONLY]; | ||
onMounted(async () => { | ||
yarsGroups.value = (await yarsService.getGroups()).data; | ||
const allowedGroups: Array<GroupName> = [GroupName.NAVIGATOR, GroupName.NAVIGATOR_READ_ONLY]; | ||
if (authzStore.isInGroup([GroupName.ADMIN, GroupName.DEVELOPER])) { | ||
selectableGroups.value.unshift(GroupName.ADMIN, GroupName.SUPERVISOR); | ||
allowedGroups.unshift(GroupName.ADMIN, GroupName.SUPERVISOR); | ||
} | ||
selectableGroups.value = new Map( | ||
allowedGroups.map((groupName) => { | ||
const group = yarsGroups.value.find((group) => group.name === groupName); | ||
return [group?.label ?? groupName.toLowerCase(), groupName]; | ||
}) | ||
); | ||
}); | ||
</script> | ||
|
||
|
@@ -106,6 +115,18 @@ onMounted(() => { | |
<span class="p-dialog-title">Create new user</span> | ||
</template> | ||
<div class="flex justify-content-between align-items-center"> | ||
<Dropdown | ||
class="col-3 m-0" | ||
name="searchParam" | ||
placeholder="Last name" | ||
:options="Object.values(USER_SEARCH_PARAMS)" | ||
@on-change=" | ||
(param: DropdownChangeEvent) => { | ||
selectedParam = param.value; | ||
searchIdirUsers(); | ||
} | ||
" | ||
/> | ||
<div class="col-9 mb-2"> | ||
<IconField icon-position="left"> | ||
<InputIcon class="pi pi-search" /> | ||
|
@@ -114,21 +135,10 @@ onMounted(() => { | |
placeholder="Search by first name, last name, or email" | ||
class="col-12 pl-5" | ||
@update:model-value="searchIdirUsers" | ||
autofocus | ||
Check warning on line 138 in frontend/src/components/user/UserCreateModal.vue GitHub Actions / Unit Tests (Frontend) (16.x)
Check warning on line 138 in frontend/src/components/user/UserCreateModal.vue GitHub Actions / Unit Tests (Frontend) (18.x)
Check warning on line 138 in frontend/src/components/user/UserCreateModal.vue GitHub Actions / Unit Tests (Frontend) (20.x)
Check warning on line 138 in frontend/src/components/user/UserCreateModal.vue GitHub Actions / Unit Tests (Frontend) (16.x)
Check warning on line 138 in frontend/src/components/user/UserCreateModal.vue GitHub Actions / Unit Tests (Frontend) (18.x)
Check warning on line 138 in frontend/src/components/user/UserCreateModal.vue GitHub Actions / Unit Tests (Frontend) (20.x)
|
||
/> | ||
</IconField> | ||
</div> | ||
<Dropdown | ||
class="col-3 m-0" | ||
name="assignRole" | ||
placeholder="First name" | ||
:options="Object.values(USER_SEARCH_PARAMS)" | ||
@on-change=" | ||
(param: DropdownChangeEvent) => { | ||
selectedParam = param.value; | ||
searchIdirUsers(); | ||
} | ||
" | ||
/> | ||
</div> | ||
<DataTable | ||
v-model:selection="selectedUser" | ||
|
@@ -149,7 +159,6 @@ onMounted(() => { | |
<template #loading> | ||
<Spinner /> | ||
</template> | ||
|
||
<Column | ||
field="fullName" | ||
header="Username" | ||
|
@@ -175,9 +184,9 @@ onMounted(() => { | |
class="col-12" | ||
name="assignRole" | ||
label="Assign role" | ||
:options="selectableGroups" | ||
:options="[...selectableGroups.keys()]" | ||
:disabled="!selectedUser" | ||
@on-change="(e: DropdownChangeEvent) => (selectedGroup = e.value)" | ||
@on-change="(e: DropdownChangeEvent) => (selectedGroup = selectableGroups.get(e.value))" | ||
/> | ||
<div class="flex-auto pl-2"> | ||
<Button | ||
|