From e3e76d473c54b216533f53acabb2ec4d39c6ade0 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 19 Oct 2021 22:30:50 -0600 Subject: [PATCH] Add a developer mode flag and use it for accessing space timelines Fixes https://github.com/vector-im/element-web/issues/19416 --- src/components/structures/LoggedInView.tsx | 2 ++ src/components/structures/MatrixChat.tsx | 5 ++++ src/components/structures/RoomView.tsx | 4 ++- .../views/context_menus/SpaceContextMenu.tsx | 25 +++++++++++++++++++ .../tabs/user/LabsUserSettingsTab.tsx | 1 + src/i18n/strings/en_EN.json | 2 ++ src/settings/Settings.tsx | 5 ++++ 7 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/components/structures/LoggedInView.tsx b/src/components/structures/LoggedInView.tsx index 84e0b446f56..566e14e6337 100644 --- a/src/components/structures/LoggedInView.tsx +++ b/src/components/structures/LoggedInView.tsx @@ -108,6 +108,7 @@ interface IProps { currentGroupIsNew?: boolean; justRegistered?: boolean; roomJustCreatedOpts?: IOpts; + forceTimeline?: boolean; // see props on MatrixChat } interface IUsageLimit { @@ -611,6 +612,7 @@ class LoggedInView extends React.Component { key={this.props.currentRoomId || 'roomview'} resizeNotifier={this.props.resizeNotifier} justCreatedOpts={this.props.roomJustCreatedOpts} + forceTimeline={this.props.forceTimeline} />; break; diff --git a/src/components/structures/MatrixChat.tsx b/src/components/structures/MatrixChat.tsx index f0a7e634b04..0c68f2013cb 100644 --- a/src/components/structures/MatrixChat.tsx +++ b/src/components/structures/MatrixChat.tsx @@ -176,6 +176,9 @@ interface IRoomInfo { threepid_invite?: IThreepidInvite; justCreatedOpts?: IOpts; + + // Whether or not to override default behaviour to end up at a timeline + forceTimeline?: boolean; } /* eslint-enable camelcase */ @@ -238,6 +241,7 @@ interface IState { pendingInitialSync?: boolean; justRegistered?: boolean; roomJustCreatedOpts?: IOpts; + forceTimeline?: boolean; // see props } @replaceableComponent("structures.MatrixChat") @@ -968,6 +972,7 @@ export default class MatrixChat extends React.PureComponent { page_type: PageType.RoomView, threepidInvite: roomInfo.threepid_invite, roomOobData: roomInfo.oob_data, + forceTimeline: roomInfo.forceTimeline, ready: true, roomJustCreatedOpts: roomInfo.justCreatedOpts, }, () => { diff --git a/src/components/structures/RoomView.tsx b/src/components/structures/RoomView.tsx index c2e071b8362..7af67a82676 100644 --- a/src/components/structures/RoomView.tsx +++ b/src/components/structures/RoomView.tsx @@ -110,6 +110,8 @@ interface IRoomProps extends MatrixClientProps { resizeNotifier: ResizeNotifier; justCreatedOpts?: IOpts; + forceTimeline?: boolean; // should we force access to the timeline, overriding (for eg) spaces + // Called with the credentials of a registered user (if they were a ROU that transitioned to PWLU) onRegistered?(credentials: IMatrixClientCreds): void; } @@ -1911,7 +1913,7 @@ export class RoomView extends React.Component { ); } - if (this.state.room?.isSpaceRoom()) { + if (this.state.room?.isSpaceRoom() && !this.props.forceTimeline) { return { ; } + let devtoolsSection; + if (SettingsStore.getValue("developerMode")) { + const onViewTimelineClick = (ev: ButtonEvent) => { + ev.preventDefault(); + ev.stopPropagation(); + + defaultDispatcher.dispatch({ + action: 'view_room', + room_id: space.roomId, + forceTimeline: true, + }); + onFinished(); + }; + + devtoolsSection = + + ; + } + const canAddRooms = space.currentState.maySendStateEvent(EventType.SpaceChild, userId); let newRoomSection; @@ -209,6 +233,7 @@ const SpaceContextMenu = ({ space, onFinished, ...props }: IProps) => { { newRoomSection } { leaveSection } + { devtoolsSection } ; }; diff --git a/src/components/views/settings/tabs/user/LabsUserSettingsTab.tsx b/src/components/views/settings/tabs/user/LabsUserSettingsTab.tsx index 60461a114c3..d05a11483c5 100644 --- a/src/components/views/settings/tabs/user/LabsUserSettingsTab.tsx +++ b/src/components/views/settings/tabs/user/LabsUserSettingsTab.tsx @@ -87,6 +87,7 @@ export default class LabsUserSettingsTab extends React.Component<{}, IState> { } labsSection =
+ { flags } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index cfe87263254..8be30e4586b 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -886,6 +886,7 @@ "All rooms you're in will appear in Home.": "All rooms you're in will appear in Home.", "Display Communities instead of Spaces": "Display Communities instead of Spaces", "Temporarily show communities instead of Spaces for this session. Support for this will be removed in the near future. This will reload Element.": "Temporarily show communities instead of Spaces for this session. Support for this will be removed in the near future. This will reload Element.", + "Developer mode": "Developer mode", "Collecting app version information": "Collecting app version information", "Collecting logs": "Collecting logs", "Uploading logs": "Uploading logs", @@ -2703,6 +2704,7 @@ "Collapse reply thread": "Collapse reply thread", "Report": "Report", "View in room": "View in room", + "See room timeline (devtools)": "See room timeline (devtools)", "Add space": "Add space", "Manage & explore rooms": "Manage & explore rooms", "Clear status": "Clear status", diff --git a/src/settings/Settings.tsx b/src/settings/Settings.tsx index d36ea2ac94c..ab3b164517b 100644 --- a/src/settings/Settings.tsx +++ b/src/settings/Settings.tsx @@ -757,6 +757,11 @@ export const SETTINGS: {[setting: string]: ISetting} = { default: false, controller: new ReloadOnChangeController(), }, + "developerMode": { + displayName: _td("Developer mode"), + supportedLevels: LEVELS_ACCOUNT_SETTINGS, + default: false, + }, [UIFeature.RoomHistorySettings]: { supportedLevels: LEVELS_UI_FEATURE, default: true,