Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Add a developer mode flag and use it for accessing space timelines (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live authored Oct 20, 2021
1 parent 96bd052 commit d188d32
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/components/structures/LoggedInView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ interface IProps {
currentGroupIsNew?: boolean;
justRegistered?: boolean;
roomJustCreatedOpts?: IOpts;
forceTimeline?: boolean; // see props on MatrixChat
}

interface IUsageLimit {
Expand Down Expand Up @@ -611,6 +612,7 @@ class LoggedInView extends React.Component<IProps, IState> {
key={this.props.currentRoomId || 'roomview'}
resizeNotifier={this.props.resizeNotifier}
justCreatedOpts={this.props.roomJustCreatedOpts}
forceTimeline={this.props.forceTimeline}
/>;
break;

Expand Down
5 changes: 5 additions & 0 deletions src/components/structures/MatrixChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -238,6 +241,7 @@ interface IState {
pendingInitialSync?: boolean;
justRegistered?: boolean;
roomJustCreatedOpts?: IOpts;
forceTimeline?: boolean; // see props
}

@replaceableComponent("structures.MatrixChat")
Expand Down Expand Up @@ -968,6 +972,7 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
page_type: PageType.RoomView,
threepidInvite: roomInfo.threepid_invite,
roomOobData: roomInfo.oob_data,
forceTimeline: roomInfo.forceTimeline,
ready: true,
roomJustCreatedOpts: roomInfo.justCreatedOpts,
}, () => {
Expand Down
4 changes: 3 additions & 1 deletion src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -1911,7 +1913,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
);
}

if (this.state.room?.isSpaceRoom()) {
if (this.state.room?.isSpaceRoom() && !this.props.forceTimeline) {
return <SpaceRoomView
space={this.state.room}
justCreatedOpts={this.props.justCreatedOpts}
Expand Down
25 changes: 25 additions & 0 deletions src/components/views/context_menus/SpaceContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { SetRightPanelPhasePayload } from "../../../dispatcher/payloads/SetRight
import { Action } from "../../../dispatcher/actions";
import { RightPanelPhases } from "../../../stores/RightPanelStorePhases";
import { BetaPill } from "../beta/BetaCard";
import SettingsStore from "../../../settings/SettingsStore";

interface IProps extends IContextMenuProps {
space: Room;
Expand Down Expand Up @@ -105,6 +106,29 @@ const SpaceContextMenu = ({ space, onFinished, ...props }: IProps) => {
</IconizedContextMenuOptionList>;
}

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 = <IconizedContextMenuOptionList first>
<IconizedContextMenuOption
iconClassName="mx_SpacePanel_iconSettings"
label={_t("See room timeline (devtools)")}
onClick={onViewTimelineClick}
/>
</IconizedContextMenuOptionList>;
}

const canAddRooms = space.currentState.maySendStateEvent(EventType.SpaceChild, userId);

let newRoomSection;
Expand Down Expand Up @@ -209,6 +233,7 @@ const SpaceContextMenu = ({ space, onFinished, ...props }: IProps) => {
</IconizedContextMenuOptionList>
{ newRoomSection }
{ leaveSection }
{ devtoolsSection }
</IconizedContextMenu>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default class LabsUserSettingsTab extends React.Component<{}, IState> {
}

labsSection = <div className="mx_SettingsTab_section">
<SettingsFlag name="developerMode" level={SettingLevel.ACCOUNT} />
{ flags }
<SettingsFlag name="enableWidgetScreenshots" level={SettingLevel.ACCOUNT} />
<SettingsFlag name="showHiddenEventsInTimeline" level={SettingLevel.DEVICE} />
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -2701,6 +2702,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",
Expand Down
5 changes: 5 additions & 0 deletions src/settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d188d32

Please sign in to comment.