* refactor(room list item): rename `RoomListCell` into `RoomListItemView` * refactor(room list item): move open room action to new room list item view model * feat(hover menu): add `hasAccessToOptionsMenu` * feat(hover menu): add to `RoomListItemViewModel` the condition to display or not the hover menu * feat(hover menu): add view model for the hover menu * feat(hover menu): add hover menu view * feat(hover menu): add hover menu to room list item * feat(hover menu): update i18n * test(view model list item): update test and add test to `showHoverMenu` * test(room list): update snapshot * test(room list item menu): add tests for view model * test(room list item menu): add tests for view * test(room list item): add tests * test(e2e): add tests for more options menu * chore: update compound web * test(e2e): fix typo
26 lines
860 B
TypeScript
26 lines
860 B
TypeScript
/*
|
|
* Copyright 2025 New Vector Ltd.
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
* Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import { type Room, KnownMembership } from "matrix-js-sdk/src/matrix";
|
|
|
|
import { isKnockDenied } from "../../../utils/membership";
|
|
import { shouldShowComponent } from "../../../customisations/helpers/UIComponents";
|
|
import { UIComponent } from "../../../settings/UIFeature";
|
|
|
|
/**
|
|
* Check if the user has access to the options menu.
|
|
* @param room
|
|
*/
|
|
export function hasAccessToOptionsMenu(room: Room): boolean {
|
|
return (
|
|
room.getMyMembership() === KnownMembership.Invite ||
|
|
(room.getMyMembership() !== KnownMembership.Knock &&
|
|
!isKnockDenied(room) &&
|
|
shouldShowComponent(UIComponent.RoomOptionsMenu))
|
|
);
|
|
}
|