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-8569 - Handover of Owner Role #3552

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,10 @@ export default {
"Inhalte erstellen und bearbeiten",
"pages.rooms.members.roleChange.Roomadmin.subText":
"Gleiche Berechtigungen wie „Bearbeiten”, zusätzlich andere Mitglieder hinzufügen, entfernen, deren Raumberechtigungen ändern sowie Raum bearbeiten",
"pages.rooms.members.roleChange.Roomowner.subText":
"Gleiche Berechtigungen wie „Verwalten”, zusätzlich Raum löschen",
"pages.rooms.members.roleChange.Roomowner.subText.warning":
"Achtung: Kann nur eine Person im Raum erhalten!",
"pages.rooms.title": "Räume",
"pages.taskCard.addElement": "Element hinzufügen",
"pages.taskCard.deleteElement.text":
Expand Down
4 changes: 4 additions & 0 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,10 @@ export default {
"Create and edit content",
"pages.rooms.members.roleChange.Roomadmin.subText":
'Same permissions as "Edit", plus add and remove other members, change their room permissions and edit the room',
"pages.rooms.members.roleChange.Roomowner.subText":
"Same authorizations as “ Administer”, additionally delete room",
"pages.rooms.members.roleChange.Roomowner.subText.warning":
"Attention: Only one person in the room can receive this authorization!",
"pages.rooms.title": "Rooms",
"pages.taskCard.addElement": "Add element",
"pages.taskCard.deleteElement.text":
Expand Down
4 changes: 4 additions & 0 deletions src/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1862,6 +1862,10 @@ export default {
"Crear y editar contenido",
"pages.rooms.members.roleChange.Roomadmin.subText":
'Los mismos permisos que "Editar", además de agregar y eliminar otros miembros, cambiar sus permisos de sala y editar la sala',
"pages.rooms.members.roleChange.Roomowner.subText":
"Las mismas autorizaciones que «Administrar», más suprimir la habitación",
"pages.rooms.members.roleChange.Roomowner.subText.warning":
"Achtung: Kann nur eine Person im Raum erhalten!",
"pages.rooms.title": "Salas",
"pages.taskCard.addElement": "Añadir artículo",
"pages.taskCard.deleteElement.text":
Expand Down
4 changes: 4 additions & 0 deletions src/locales/uk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,10 @@ export default {
"Створюйте та редагуйте контент",
"pages.rooms.members.roleChange.Roomadmin.subText":
"Такі самі дозволи, як і «Редагувати», а також додавати та видаляти інших учасників, змінювати їхні дозволи для кімнати та редагувати кімнату",
"pages.rooms.members.roleChange.Roomowner.subText":
"Ті самі повноваження, що й «Керування», плюс видалення кімнати",
"pages.rooms.members.roleChange.Roomowner.subText.warning":
"Увага: Тільки одна людина в кімнаті може отримати ці повноваження!",
"pages.rooms.title": "Кімнати",
"pages.taskCard.addElement": "Додати елемент",
"pages.taskCard.deleteElement.text":
Expand Down
2 changes: 1 addition & 1 deletion src/modules/feature/room/RoomMembers/ChangeRole.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("ChangeRole.vue", () => {
expect(wrapper.text()).toContain("pages.rooms.members.changePermission");

const radioButtons = wrapper.findAllComponents({ name: "v-radio" });
expect(radioButtons.length).toBe(3);
expect(radioButtons.length).toBe(4);

const cancelButton = wrapper.find(
"[data-testid='change-role-cancel-btn']"
Expand Down
126 changes: 95 additions & 31 deletions src/modules/feature/room/RoomMembers/ChangeRole.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,80 @@
<div class="mb-4">
{{ infoText }}
</div>
<v-radio-group v-model="selectedRole" class="ml-n2">
<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") }}
</label>

<v-radio
id="roleChangeEditor"
:label="t('pages.rooms.members.roomPermissions.editor')"
:value="RoleName.Roomeditor"
color="primary"
/>
<label for="roleChangeEditor" class="ml-10 mt-n2 mb-2 radio-label">
{{ t("pages.rooms.members.roleChange.Roomeditor.subText") }}
</label>

<v-radio
id="roleChangeAdmin"
:label="t('pages.rooms.members.roomPermissions.admin')"
:value="RoleName.Roomadmin"
color="primary"
/>
<label for="roleChangeAdmin" class="ml-10 mt-n2 mb-2 radio-label">
{{ t("pages.rooms.members.roleChange.Roomadmin.subText") }}
</label>
</v-radio-group>
<div v-if="isHandOverMode">
<v-alert> handover mode </v-alert>
</div>
<div v-else>
<v-radio-group v-model="selectedRole" hide-details class="ml-n2">
<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") }}
</label>

<v-radio
id="roleChangeEditor"
:label="t('pages.rooms.members.roomPermissions.editor')"
:value="RoleName.Roomeditor"
color="primary"
/>
<label
for="roleChangeEditor"
class="ml-10 mt-n2 mb-2 radio-label"
>
{{ t("pages.rooms.members.roleChange.Roomeditor.subText") }}
</label>

<v-radio
id="roleChangeAdmin"
:label="t('pages.rooms.members.roomPermissions.admin')"
:value="RoleName.Roomadmin"
color="primary"
/>
<label for="roleChangeAdmin" class="ml-10 mt-n2 mb-2 radio-label">
{{ t("pages.rooms.members.roleChange.Roomadmin.subText") }}
</label>

<v-radio
v-if="isChangeRoleOptionVisible"
id="roleChangeOwner"
:label="t('pages.rooms.members.roomPermissions.owner')"
:value="RoleName.Roomowner"
color="primary"
/>
<label
v-if="isChangeRoleOptionVisible"
for="roleChangeOwner"
class="ml-10 mt-n2 mb-2 radio-label"
>
{{ t("pages.rooms.members.roleChange.Roomowner.subText") }}
<br />
{{
t("pages.rooms.members.roleChange.Roomowner.subText.warning")
}}
</label>
</v-radio-group>
<v-alert
dense
type="warning"
:icon="mdiAlert"
class="ml-8"
v-if="selectedRole === RoleName.Roomowner"
>
<span class="alert-text">
Diese Raumberechtigung wird an das ausgewählte Mitglied
übertragen. Cord Carl verliert die Berechtigung „Besitzen” und
erhält die Berechtigung „Verwalten”.
</span>
</v-alert>
</div>
</div>
</div>
</template>
Expand Down Expand Up @@ -82,6 +125,7 @@ import {
import { useFocusTrap } from "@vueuse/integrations/useFocusTrap";
import { VCard, VRadio } from "vuetify/lib/components/index.mjs";
import { RoomMember } from "@data-room";
import { mdiAlert } from "@icons/material";

const props = defineProps({
members: {
Expand All @@ -93,10 +137,21 @@ const props = defineProps({
type: String,
required: true,
},
currentUser: {
type: Object as PropType<RoomMember>,
required: true,
},
});
const { t } = useI18n();
const selectedRole = ref<string | null>(null);
const memberToChangeRole = toRef(props, "members")?.value;
const isChangeRoleOptionVisible = computed(() => {
return (
props.currentUser?.roomRoleName === RoleName.Roomowner &&
memberToChangeRole.length === 1
);
});
const isHandOverMode = ref(false);

if (memberToChangeRole.length > 1) {
const roleNamesInProp = memberToChangeRole.map(
Expand Down Expand Up @@ -130,6 +185,10 @@ const emit = defineEmits<{

const onConfirm = () => {
if (!selectedRole.value) return;
if (selectedRole.value === RoleName.Roomowner) {
isHandOverMode.value = true;
return;
}
emit(
"confirm",
selectedRole.value as RoleEnum,
Expand All @@ -153,4 +212,9 @@ useFocusTrap(changeRoleContent, {
line-height: var(--line-height-lg);
opacity: var(--v-medium-emphasis-opacity);
}

.alert-text {
color: rgba(var(--v-theme-on-background)) !important;
line-height: var(--line-height-lg) !important;
}
</style>
1 change: 1 addition & 0 deletions src/modules/page/room/RoomMembers.page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<ChangeRole
:members="membersToChangeRole"
:room-name="room?.name || ''"
:current-user="currentUser"
@cancel="onDialogClose"
@confirm="onChangeRole"
/>
Expand Down
104 changes: 104 additions & 0 deletions src/serverApi/v3/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6742,6 +6742,19 @@ export interface ParentConsentResponse {
*/
_id: string;
}
/**
*
* @export
* @interface PassOwnershipBodyParams
*/
export interface PassOwnershipBodyParams {
/**
* The IDs of the users
* @type {string}
* @memberof PassOwnershipBodyParams
*/
userId: string;
}
/**
*
* @export
Expand Down Expand Up @@ -20852,6 +20865,50 @@ export const RoomApiAxiosParamCreator = function (configuration?: Configuration)
options: localVarRequestOptions,
};
},
/**
*
* @summary Passes the ownership of the room to another user. Can only be used if you are the owner, and you will loose the ownership and become a roomadmin instead.
* @param {string} roomId
* @param {PassOwnershipBodyParams} passOwnershipBodyParams
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
roomControllerChangeRoomOwner: async (roomId: string, passOwnershipBodyParams: PassOwnershipBodyParams, options: any = {}): Promise<RequestArgs> => {
// verify required parameter 'roomId' is not null or undefined
assertParamExists('roomControllerChangeRoomOwner', 'roomId', roomId)
// verify required parameter 'passOwnershipBodyParams' is not null or undefined
assertParamExists('roomControllerChangeRoomOwner', 'passOwnershipBodyParams', passOwnershipBodyParams)
const localVarPath = `/rooms/{roomId}/members/pass-ownership`
.replace(`{${"roomId"}}`, encodeURIComponent(String(roomId)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'PATCH', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;

// authentication bearer required
// http bearer authentication required
await setBearerAuthToObject(localVarHeaderParameter, configuration)



localVarHeaderParameter['Content-Type'] = 'application/json';

setSearchParams(localVarUrlObj, localVarQueryParameter, options.query);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(passOwnershipBodyParams, localVarRequestOptions, configuration)

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Create a new room
Expand Down Expand Up @@ -21248,6 +21305,18 @@ export const RoomApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.roomControllerChangeRolesOfMembers(roomId, changeRoomRoleBodyParams, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @summary Passes the ownership of the room to another user. Can only be used if you are the owner, and you will loose the ownership and become a roomadmin instead.
* @param {string} roomId
* @param {PassOwnershipBodyParams} passOwnershipBodyParams
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async roomControllerChangeRoomOwner(roomId: string, passOwnershipBodyParams: PassOwnershipBodyParams, options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<string>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.roomControllerChangeRoomOwner(roomId, passOwnershipBodyParams, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @summary Create a new room
Expand Down Expand Up @@ -21382,6 +21451,17 @@ export const RoomApiFactory = function (configuration?: Configuration, basePath?
roomControllerChangeRolesOfMembers(roomId: string, changeRoomRoleBodyParams: ChangeRoomRoleBodyParams, options?: any): AxiosPromise<string> {
return localVarFp.roomControllerChangeRolesOfMembers(roomId, changeRoomRoleBodyParams, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Passes the ownership of the room to another user. Can only be used if you are the owner, and you will loose the ownership and become a roomadmin instead.
* @param {string} roomId
* @param {PassOwnershipBodyParams} passOwnershipBodyParams
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
roomControllerChangeRoomOwner(roomId: string, passOwnershipBodyParams: PassOwnershipBodyParams, options?: any): AxiosPromise<string> {
return localVarFp.roomControllerChangeRoomOwner(roomId, passOwnershipBodyParams, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Create a new room
Expand Down Expand Up @@ -21506,6 +21586,17 @@ export interface RoomApiInterface {
*/
roomControllerChangeRolesOfMembers(roomId: string, changeRoomRoleBodyParams: ChangeRoomRoleBodyParams, options?: any): AxiosPromise<string>;

/**
*
* @summary Passes the ownership of the room to another user. Can only be used if you are the owner, and you will loose the ownership and become a roomadmin instead.
* @param {string} roomId
* @param {PassOwnershipBodyParams} passOwnershipBodyParams
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof RoomApiInterface
*/
roomControllerChangeRoomOwner(roomId: string, passOwnershipBodyParams: PassOwnershipBodyParams, options?: any): AxiosPromise<string>;

/**
*
* @summary Create a new room
Expand Down Expand Up @@ -21634,6 +21725,19 @@ export class RoomApi extends BaseAPI implements RoomApiInterface {
return RoomApiFp(this.configuration).roomControllerChangeRolesOfMembers(roomId, changeRoomRoleBodyParams, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Passes the ownership of the room to another user. Can only be used if you are the owner, and you will loose the ownership and become a roomadmin instead.
* @param {string} roomId
* @param {PassOwnershipBodyParams} passOwnershipBodyParams
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof RoomApi
*/
public roomControllerChangeRoomOwner(roomId: string, passOwnershipBodyParams: PassOwnershipBodyParams, options?: any) {
return RoomApiFp(this.configuration).roomControllerChangeRoomOwner(roomId, passOwnershipBodyParams, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Create a new room
Expand Down
Loading