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:
parent
957945b356
commit
83e6a6057d
8 changed files with 126 additions and 32 deletions
47
src/components/views/context_menus/DeveloperToolsOption.tsx
Normal file
47
src/components/views/context_menus/DeveloperToolsOption.tsx
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
Copyright 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.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import Modal from "../../../Modal";
|
||||
import DevtoolsDialog from "../dialogs/DevtoolsDialog";
|
||||
import { IconizedContextMenuOption } from "./IconizedContextMenu";
|
||||
import { _t } from "../../../languageHandler";
|
||||
|
||||
interface Props {
|
||||
onFinished: () => void;
|
||||
roomId: string;
|
||||
}
|
||||
|
||||
export const DeveloperToolsOption: React.FC<Props> = ({ onFinished, roomId }) => {
|
||||
return (
|
||||
<IconizedContextMenuOption
|
||||
onClick={() => {
|
||||
Modal.createDialog(
|
||||
DevtoolsDialog,
|
||||
{
|
||||
onFinished: () => {},
|
||||
roomId: roomId,
|
||||
},
|
||||
"mx_DevtoolsDialog_wrapper",
|
||||
);
|
||||
onFinished();
|
||||
}}
|
||||
label={_t("Developer tools")}
|
||||
iconClassName="mx_IconizedContextMenu_developerTools"
|
||||
/>
|
||||
);
|
||||
};
|
|
@ -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.
|
||||
|
@ -48,15 +48,18 @@ import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
|
|||
import { getKeyBindingsManager } from "../../../KeyBindingsManager";
|
||||
import { KeyBindingAction } from "../../../accessibility/KeyboardShortcuts";
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
import DevtoolsDialog from "../dialogs/DevtoolsDialog";
|
||||
import { SdkContextClass } from "../../../contexts/SDKContext";
|
||||
import { shouldShowComponent } from "../../../customisations/helpers/UIComponents";
|
||||
import { UIComponent } from "../../../settings/UIFeature";
|
||||
import { DeveloperToolsOption } from "./DeveloperToolsOption";
|
||||
|
||||
interface IProps extends IContextMenuProps {
|
||||
room: Room;
|
||||
}
|
||||
|
||||
/**
|
||||
* Room context menu accessible via the room header.
|
||||
*/
|
||||
const RoomContextMenu: React.FC<IProps> = ({ room, onFinished, ...props }) => {
|
||||
const cli = useContext(MatrixClientContext);
|
||||
const roomTags = useEventEmitterState(RoomListStore.instance, LISTS_UPDATE_EVENT, () =>
|
||||
|
@ -393,23 +396,7 @@ const RoomContextMenu: React.FC<IProps> = ({ room, onFinished, ...props }) => {
|
|||
{exportChatOption}
|
||||
|
||||
{SettingsStore.getValue("developerMode") && (
|
||||
<IconizedContextMenuOption
|
||||
onClick={(ev: ButtonEvent) => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
|
||||
Modal.createDialog(
|
||||
DevtoolsDialog,
|
||||
{
|
||||
roomId: room.roomId,
|
||||
},
|
||||
"mx_DevtoolsDialog_wrapper",
|
||||
);
|
||||
onFinished();
|
||||
}}
|
||||
label={_t("Developer tools")}
|
||||
iconClassName="mx_RoomTile_iconDeveloperTools"
|
||||
/>
|
||||
<DeveloperToolsOption onFinished={onFinished} roomId={room.roomId} />
|
||||
)}
|
||||
|
||||
{leaveOption}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2019 - 2022 The Matrix.org Foundation C.I.C.
|
||||
Copyright 2019 - 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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue