-
-
Notifications
You must be signed in to change notification settings - Fork 822
Allow maintaining a different right panel width for thread panels #11064
Changes from 9 commits
d53ba2d
d9d3b6d
e858785
48d61f3
3ad5e45
02bb437
dd398f6
c6eb1b0
08712e7
2855655
86c5b72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,6 +179,7 @@ export interface IRoomState { | |
showApps: boolean; | ||
isPeeking: boolean; | ||
showRightPanel: boolean; | ||
threadRightPanel: boolean; | ||
t3chguy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// error object, as from the matrix client/server API | ||
// If we failed to load information about the room, | ||
// store the error here. | ||
|
@@ -223,7 +224,6 @@ export interface IRoomState { | |
wasContextSwitch?: boolean; | ||
editState?: EditorStateTransfer; | ||
timelineRenderingType: TimelineRenderingType; | ||
threadId?: string; | ||
liveTimeline?: EventTimeline; | ||
narrow: boolean; | ||
msc3946ProcessDynamicPredecessor: boolean; | ||
|
@@ -402,6 +402,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> { | |
showApps: false, | ||
isPeeking: false, | ||
showRightPanel: false, | ||
threadRightPanel: false, | ||
joining: false, | ||
showTopUnreadMessagesBar: false, | ||
statusBarVisible: false, | ||
|
@@ -623,6 +624,11 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> { | |
mainSplitContentType: room ? this.getMainSplitContentType(room) : undefined, | ||
initialEventId: undefined, // default to clearing this, will get set later in the method if needed | ||
showRightPanel: roomId ? this.context.rightPanelStore.isOpenForRoom(roomId) : false, | ||
threadRightPanel: roomId | ||
t3chguy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
? [RightPanelPhases.ThreadView, RightPanelPhases.ThreadPanel].includes( | ||
this.context.rightPanelStore.currentCardForRoom(roomId).phase!, | ||
) | ||
: false, | ||
activeCall: roomId ? CallStore.instance.getActiveCall(roomId) : null, | ||
}; | ||
|
||
|
@@ -1011,8 +1017,14 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> { | |
} | ||
|
||
private onRightPanelStoreUpdate = (): void => { | ||
const { roomId } = this.state; | ||
this.setState({ | ||
showRightPanel: this.state.roomId ? this.context.rightPanelStore.isOpenForRoom(this.state.roomId) : false, | ||
showRightPanel: roomId ? this.context.rightPanelStore.isOpenForRoom(roomId) : false, | ||
threadRightPanel: roomId | ||
? [RightPanelPhases.ThreadView, RightPanelPhases.ThreadPanel].includes( | ||
this.context.rightPanelStore.currentCardForRoom(roomId).phase!, | ||
) | ||
: false, | ||
}); | ||
}; | ||
|
||
|
@@ -2439,7 +2451,12 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> { | |
viewingCall={viewingCall} | ||
activeCall={this.state.activeCall} | ||
/> | ||
<MainSplit panel={rightPanel} resizeNotifier={this.props.resizeNotifier}> | ||
<MainSplit | ||
panel={rightPanel} | ||
resizeNotifier={this.props.resizeNotifier} | ||
sizeKey={this.state.threadRightPanel ? "thread" : undefined} | ||
defaultSize={this.state.threadRightPanel ? 500 : undefined} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. a comment explaining this logic wouldn't hurt. I think the idea is: for a thread panel we default to 500px, for other panels we default to... something else? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. according to the IProps on MainSplit, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its an optional prop, because of its presence in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I did wonder! |
||
> | ||
<div | ||
className={mainSplitContentClasses} | ||
ref={this.roomViewBody} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
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 { render } from "@testing-library/react"; | ||
|
||
import MainSplit from "../../../src/components/structures/MainSplit"; | ||
import ResizeNotifier from "../../../src/utils/ResizeNotifier"; | ||
|
||
describe("<MainSplit/>", () => { | ||
const resizeNotifier = new ResizeNotifier(); | ||
const children = ( | ||
<div> | ||
Child<span>Foo</span>Bar | ||
</div> | ||
); | ||
const panel = <div>Right panel</div>; | ||
|
||
it("renders", () => { | ||
const { asFragment, container } = render( | ||
<MainSplit resizeNotifier={resizeNotifier} children={children} panel={panel} />, | ||
); | ||
expect(asFragment()).toMatchSnapshot(); | ||
// Assert it matches the default width of 350 | ||
expect(container.querySelector<HTMLElement>(".mx_RightPanel_ResizeWrapper")!.style.width).toBe("350px"); | ||
}); | ||
|
||
it("respects defaultSize prop", () => { | ||
const { asFragment, container } = render( | ||
<MainSplit resizeNotifier={resizeNotifier} children={children} panel={panel} defaultSize={500} />, | ||
); | ||
expect(asFragment()).toMatchSnapshot(); | ||
// Assert it matches the default width of 350 | ||
expect(container.querySelector<HTMLElement>(".mx_RightPanel_ResizeWrapper")!.style.width).toBe("500px"); | ||
}); | ||
|
||
it("prefers size stashed in LocalStorage to the defaultSize prop", () => { | ||
localStorage.setItem("mx_rhs_size_thread", "333"); | ||
const { container } = render( | ||
<MainSplit | ||
resizeNotifier={resizeNotifier} | ||
children={children} | ||
panel={panel} | ||
sizeKey="thread" | ||
defaultSize={400} | ||
/>, | ||
); | ||
expect(container.querySelector<HTMLElement>(".mx_RightPanel_ResizeWrapper")!.style.width).toBe("333px"); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<MainSplit/> renders 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="mx_MainSplit" | ||
> | ||
<div> | ||
Child | ||
<span> | ||
Foo | ||
</span> | ||
Bar | ||
</div> | ||
<div | ||
class="mx_RightPanel_ResizeWrapper" | ||
style="position: relative; user-select: auto; width: 350px; height: 100%; max-width: 50%; min-width: 264px; box-sizing: border-box; flex-shrink: 0;" | ||
> | ||
<div> | ||
Right panel | ||
</div> | ||
<div> | ||
<div | ||
class="mx_ResizeHandle--horizontal" | ||
style="position: absolute; user-select: none; width: 10px; height: 100%; top: 0px; left: -5px; cursor: col-resize;" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</DocumentFragment> | ||
`; | ||
|
||
exports[`<MainSplit/> respects defaultSize prop 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
class="mx_MainSplit" | ||
> | ||
<div> | ||
Child | ||
<span> | ||
Foo | ||
</span> | ||
Bar | ||
</div> | ||
<div | ||
class="mx_RightPanel_ResizeWrapper" | ||
style="position: relative; user-select: auto; width: 500px; height: 100%; max-width: 50%; min-width: 264px; box-sizing: border-box; flex-shrink: 0;" | ||
> | ||
<div> | ||
Right panel | ||
</div> | ||
<div> | ||
<div | ||
class="mx_ResizeHandle--horizontal" | ||
style="position: absolute; user-select: none; width: 10px; height: 100%; top: 0px; left: -5px; cursor: col-resize;" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</DocumentFragment> | ||
`; |
Uh oh!
There was an error while loading. Please reload this page.