Add developer tools option to room list context menu (#10635)

* Make developer tools more accessible

* Extend tests

* Use settings hook

* Trigger CI
This commit is contained in:
Michael Weimann 2023-04-19 13:34:27 +02:00 committed by GitHub
parent 957945b356
commit 83e6a6057d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 126 additions and 32 deletions

View file

@ -1,5 +1,5 @@
/*
Copyright 2021 The Matrix.org Foundation C.I.C.
Copyright 2021 - 2023 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -40,6 +40,8 @@ import IconizedContextMenu, {
import { ButtonEvent } from "../elements/AccessibleButton";
import { shouldShowComponent } from "../../../customisations/helpers/UIComponents";
import { UIComponent } from "../../../settings/UIFeature";
import { DeveloperToolsOption } from "./DeveloperToolsOption";
import { useSettingValue } from "../../../hooks/useSettings";
export interface RoomGeneralContextMenuProps extends IContextMenuProps {
room: Room;
@ -52,6 +54,9 @@ export interface RoomGeneralContextMenuProps extends IContextMenuProps {
onPostLeaveClick?: (event: ButtonEvent) => void;
}
/**
* Room context menu accessible via the room list.
*/
export const RoomGeneralContextMenu: React.FC<RoomGeneralContextMenuProps> = ({
room,
onFinished,
@ -221,6 +226,11 @@ export const RoomGeneralContextMenu: React.FC<RoomGeneralContextMenuProps> = ({
/>
) : null;
const developerModeEnabled = useSettingValue<boolean>("developerMode");
const developerToolsOption = developerModeEnabled ? (
<DeveloperToolsOption onFinished={onFinished} roomId={room.roomId} />
) : null;
return (
<IconizedContextMenu {...props} onFinished={onFinished} className="mx_RoomGeneralContextMenu" compact>
<IconizedContextMenuOptionList>
@ -234,6 +244,7 @@ export const RoomGeneralContextMenu: React.FC<RoomGeneralContextMenuProps> = ({
{settingsOption}
</>
)}
{developerToolsOption}
</IconizedContextMenuOptionList>
<IconizedContextMenuOptionList red>{leaveOption}</IconizedContextMenuOptionList>
</IconizedContextMenu>