Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BC-8519 - add room owner role #3473

Merged
merged 11 commits into from
Dec 16, 2024
11 changes: 10 additions & 1 deletion src/modules/data/room/roomMembers/roomMembers.composable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import { $axios } from "@/utils/api";
import { useI18n } from "vue-i18n";
import { useBoardNotifier } from "@util-board";
import { schoolsModule } from "@/store";
import { authModule } from "@/store/store-accessor";

export const useRoomMembers = (roomId: string) => {
const roomMembers: Ref<RoomMemberResponse[]> = ref([]);
const roomMembers: Ref<RoomMemberResponse[] | any[]> = ref([]);
muratmerdoglu-dp marked this conversation as resolved.
Show resolved Hide resolved
const potentialRoomMembers: Ref<RoomMember[]> = ref([]);
const schools: Ref<SchoolForExternalInviteResponse[]> = ref([]);
const isLoading = ref(false);
Expand All @@ -25,9 +26,13 @@ export const useRoomMembers = (roomId: string) => {
id: schoolsModule.getSchool.id,
name: schoolsModule.getSchool.name,
};
const currentUserId = authModule.getUser?.id ?? "";

const userRoles: Record<string, string> = {
[RoleName.Roomowner]: t("common.labels.teacher"),
[RoleName.Roomadmin]: t("common.labels.teacher"),
[RoleName.Roomeditor]: t("common.labels.teacher"),
[RoleName.Roomviewer]: t("common.labels.teacher"),
};

const roomApi = RoomApiFactory(undefined, "/v3", $axios);
Expand All @@ -42,6 +47,10 @@ export const useRoomMembers = (roomId: string) => {
return {
...member,
displayRoleName: userRoles[member.roleName],
isSelectable: !(
member.userId === currentUserId ||
member.roleName === RoleName.Roomowner
),
};
});
isLoading.value = false;
Expand Down
muratmerdoglu-dp marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ describe("useRoomMembers", () => {
membersMock.map((member) => ({
...member,
displayRoleName: "common.labels.teacher",
isSelectable: true,
}))
);
});
Expand Down
8 changes: 7 additions & 1 deletion src/modules/feature/room/RoomMembers/MembersTable.vue
muratmerdoglu-dp marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
item-value="userId"
mobile-breakpoint="sm"
:items="memberList"
item-selectable="isSelectable"
:headers="tableHeader"
:items-per-page-options="[5, 10, 25, 50, 100]"
:items-per-page="50"
Expand All @@ -69,6 +70,7 @@
<template #[`item.actions`]="{ item, index }">
<v-btn
:data-testid="`remove-member-${index}`"
v-if="item.roleName !== RoleName.Roomowner"
size="x-small"
variant="text"
:aria-label="getRemoveAriaLabel(item)"
Expand All @@ -90,7 +92,7 @@ import {
mdiMagnify,
mdiTrashCanOutline,
} from "@icons/material";
import { RoomMemberResponse } from "@/serverApi/v3";
import { RoleName, RoomMemberResponse } from "@/serverApi/v3";
import {
ConfirmationDialog,
useConfirmationDialog,
Expand Down Expand Up @@ -189,6 +191,10 @@ const tableHeader = [
font-weight: bold;
}

:deep(.v-data-table__td .v-selection-control--disabled) {
color: rgba(var(--v-theme-on-surface), var(--v-disabled-opacity));
}

.table-title-header {
min-height: 50px;
}
Expand Down
10 changes: 10 additions & 0 deletions src/serverApi/v3/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ export enum AuthorizationContextParamsRequiredPermissionsEnum {
RoomEdit = 'ROOM_EDIT',
RoomView = 'ROOM_VIEW',
RoomDelete = 'ROOM_DELETE',
RoomMembersAdd = 'ROOM_MEMBERS_ADD',
RoomMembersRemove = 'ROOM_MEMBERS_REMOVE',
RoomChangeOwner = 'ROOM_CHANGE_OWNER',
SchoolChatManage = 'SCHOOL_CHAT_MANAGE',
SchoolCreate = 'SCHOOL_CREATE',
SchoolEdit = 'SCHOOL_EDIT',
Expand Down Expand Up @@ -6887,6 +6890,9 @@ export enum Permission {
RoomEdit = 'ROOM_EDIT',
RoomView = 'ROOM_VIEW',
RoomDelete = 'ROOM_DELETE',
RoomMembersAdd = 'ROOM_MEMBERS_ADD',
RoomMembersRemove = 'ROOM_MEMBERS_REMOVE',
RoomChangeOwner = 'ROOM_CHANGE_OWNER',
SchoolChatManage = 'SCHOOL_CHAT_MANAGE',
SchoolCreate = 'SCHOOL_CREATE',
SchoolEdit = 'SCHOOL_EDIT',
Expand Down Expand Up @@ -7309,6 +7315,8 @@ export enum RoleName {
Helpdesk = 'helpdesk',
Roomviewer = 'roomviewer',
Roomeditor = 'roomeditor',
Roomadmin = 'roomadmin',
Roomowner = 'roomowner',
Student = 'student',
Superhero = 'superhero',
Teacher = 'teacher',
Expand Down Expand Up @@ -9480,6 +9488,8 @@ export interface UserIdAndRole {
* @enum {string}
*/
export enum UserIdAndRoleRoleNameEnum {
Roomowner = 'roomowner',
Roomadmin = 'roomadmin',
Roomeditor = 'roomeditor',
Roomviewer = 'roomviewer'
}
Expand Down
Loading