-
Notifications
You must be signed in to change notification settings - Fork 14
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-8569 - Handover of Owner Role #3552
base: main
Are you sure you want to change the base?
Conversation
} | ||
}; | ||
|
||
const swapOwnershipInState = (userId: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about renaming the "swapOwnershipInState" to "setRoomOwner"?
And maybe we can extract duplicate lines(213-219) into a function:
const setRoomOwner = (userId: string) => {
const currentOwner = roomMembers.value.find(
(member) => member.roomRoleName === RoleName.Roomowner
);
const memberToBeOwner = roomMembers.value.find(
(member) => member.userId === userId
);
if (!currentOwner || !memberToBeOwner) {
return;
}
updateMemberRole(memberToBeOwner, RoleName.Roomowner);
updateMemberRole(currentOwner, RoleName.Roomadmin);
};
const updateMemberRole = (member: RoomMember, roleName: RoleName) => {
member.roomRoleName = roleName;
member.displayRoomRole = roomRole[roleName];
member.isSelectable = false;
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea - I'd recommend to also add throwing an exception
if (!currentOwner || !memberToBeOwner) {
throw new Error('setting new owner failed');
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think throwing any Error is redirected to the error
page / or logs the error!
- What about calling
fetchMembers()
to get fresh members' data? - or calling
showFailure()
notification?
</template> | ||
|
||
<template v-slot:default> | ||
<div class="ml-6 mr-6 mt-2"> | ||
<div v-if="!isHandOverMode" class="mb-4"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could think about renaming 'isHandOverMode" to something like "isOwnerHandOverMode" to make it clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
longer but maybe something like "inOwnershipHandoverMode"
<v-radio | ||
id="roleChangeViewer" | ||
:label="t('pages.rooms.members.roomPermissions.viewer')" | ||
:value="RoleName.Roomviewer" | ||
color="primary" | ||
/> | ||
<label for="roleChangeViewer" class="ml-10 mt-n2 mb-2 radio-label"> | ||
{{ t("pages.rooms.members.roleChange.Roomviewer.subText") }} | ||
{{ t("pages.rooms.members.roleChange.Roomviewer.label") }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's confusing ro me that we use the label
from the VRadio
and then use an extra <label>
. That causes e.g. that the screenreader user just reads out the label from the VRadio
.
We should use the label slot from the VRadio
like :
<v-radio>
<template #label>
// first key t('pages.rooms.members.roomPermissions.viewer')
// second key t("pages.rooms.members.roleChange.Roomviewer.label"
// in this slot we can e.g. spans to style them as needed :)
</template>
</v-radio>
So the Screenreader will read out the whole label and its clear what the label is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestion would be:
<v-radio
id="roleChangeViewer"
:value="RoleName.Roomviewer"
color="primary"
class="align-start mb-2"
>
<template #label>
<div class="d-flex flex-column mt-2">
{{ t("pages.rooms.members.roomPermissions.viewer") }}
<span class="radio-label">
{{ t("pages.rooms.members.roleChange.Roomviewer.label") }}
</span>
</div>
</template>
</v-radio>
So we can also avoid negative margins like "mt-n2" and double labels.
We could even think about using v-for for the radio buttons, to avoid code duplication:
In the template:
<v-radio
v-for="roomRole in roomRoles"
:key="roomRole.role"
:value="roomRole.role"
color="primary"
class="align-start mb-2"
>
<template #label>
<div class="d-flex flex-column mt-2">
{{ roomRole.labelHeader }}
<span
v-for="labelDescription in roomRole.labelDescriptions"
:key="labelDescription"
class="radio-label"
>
{{ t(labelDescription) }}
</span>
</div>
</template>
</v-radio>
in the script (maybe with a better var naming e.g. radioOptions)
const roomRoles = computed(() => {
const baseRoles = [
{
role: RoleName.Roomviewer,
labelHeader: t("pages.rooms.members.roomPermissions.viewer"),
labelDescriptions: ["pages.rooms.members.roleChange.Roomviewer.label"],
},
{
role: RoleName.Roomeditor,
labelHeader: t("pages.rooms.members.roomPermissions.editor"),
labelDescriptions: ["pages.rooms.members.roleChange.Roomeditor.label"],
},
{
role: RoleName.Roomadmin,
labelHeader: t("pages.rooms.members.roomPermissions.admin"),
labelDescriptions: ["pages.rooms.members.roleChange.Roomadmin.label"],
},
];
if (isChangeRoleOptionVisible.value) {
baseRoles.push({
role: RoleName.Roomowner,
labelHeader: t("pages.rooms.members.roomPermissions.owner"),
labelDescriptions: [
"pages.rooms.members.roleChange.Roomowner.label",
"pages.rooms.members.roleChange.Roomowner.label.subText",
],
});
}
return baseRoles;
});
const tableSelectedUserIds = computed(() => props.selectedUserIds); | ||
const tableSelectedUserIds = ref<string[]>([]); | ||
|
||
watch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine for now, like discussed this will be changed in BC-8549 to use defineModel
src/modules/data/room/roomMembers/roomMembers.composable.unit.ts
Outdated
Show resolved
Hide resolved
|
Short Description
Links to Ticket and related Pull-Requests
Changes
Data-security
Deployment
New Repos, NPM packages or vendor scripts
Screenshots of UI changes
Checklist before merging