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

Add right panel chat tab for video rooms #12868

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ interface IRoomProps {

// This defines the content of the mainSplit.
// If the mainSplit does not contain the Timeline, the chat is shown in the right panel.
enum MainSplitContentType {
export enum MainSplitContentType {
Timeline,
MaximisedWidget,
Call,
Expand Down
9 changes: 8 additions & 1 deletion src/components/views/right_panel/ExtensionsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,14 @@ const ExtensionsCard: React.FC<Props> = ({ room, onClose }) => {
}

return (
<BaseCard header={header} className="mx_ExtensionsCard" onClose={onClose} hideHeaderButtons>
<BaseCard
header={header}
className="mx_ExtensionsCard"
onClose={onClose}
hideHeaderButtons
id="extensions-panel"
ariaLabelledBy="extensions-panel-tab"
>
{body}
</BaseCard>
);
Expand Down
24 changes: 22 additions & 2 deletions src/components/views/right_panel/RightPanelTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React, { useRef } from "react";
import React, { useContext, useRef } from "react";
import { NavBar, NavItem } from "@vector-im/compound-web";
import { Room } from "matrix-js-sdk/src/matrix";

Expand All @@ -29,13 +29,16 @@ import SettingsStore from "../../../settings/SettingsStore";
import { UIComponent, UIFeature } from "../../../settings/UIFeature";
import { shouldShowComponent } from "../../../customisations/helpers/UIComponents";
import { useIsVideoRoom } from "../../../utils/video-rooms";
import RoomContext from "../../../contexts/RoomContext";
import { MainSplitContentType } from "../../structures/RoomView";

function shouldShowTabsForPhase(phase?: RightPanelPhases): boolean {
const tabs = [
RightPanelPhases.RoomSummary,
RightPanelPhases.RoomMemberList,
RightPanelPhases.ThreadPanel,
RightPanelPhases.Extensions,
RightPanelPhases.Timeline,
];
return !!phase && tabs.includes(phase);
}
Expand All @@ -47,6 +50,7 @@ type Props = {

export const RightPanelTabs: React.FC<Props> = ({ phase, room }): JSX.Element | null => {
const threadsTabRef = useRef<HTMLButtonElement | null>(null);
const roomContext = useContext(RoomContext);

useDispatcher(dispatcher, (payload) => {
// This actually focuses the threads tab, as its the only interactive element,
Expand All @@ -57,6 +61,10 @@ export const RightPanelTabs: React.FC<Props> = ({ phase, room }): JSX.Element |
});

const isVideoRoom = useIsVideoRoom(room);
const showChatTab =
isVideoRoom ||
roomContext.mainSplitContentType === MainSplitContentType.MaximisedWidget ||
roomContext.mainSplitContentType === MainSplitContentType.Call;

if (!shouldShowTabsForPhase(phase)) return null;

Expand All @@ -72,6 +80,18 @@ export const RightPanelTabs: React.FC<Props> = ({ phase, room }): JSX.Element |
>
{_t("right_panel|info")}
</NavItem>
{showChatTab && (
<NavItem
aria-controls="timeline-panel"
id="timeline-panel-tab"
onClick={() => {
RightPanelStore.instance.pushCard({ phase: RightPanelPhases.Timeline }, true);
}}
active={phase === RightPanelPhases.Timeline}
>
{_t("right_panel|video_room_chat|title")}
</NavItem>
)}
<NavItem
aria-controls="memberlist-panel"
id="memberlist-panel-tab"
Expand All @@ -98,7 +118,7 @@ export const RightPanelTabs: React.FC<Props> = ({ phase, room }): JSX.Element |
!isVideoRoom &&
shouldShowComponent(UIComponent.AddIntegrations) && (
<NavItem
aria-controls="thread-panel"
aria-controls="extensions-panel"
id="extensions-panel-tab"
onClick={() => {
RightPanelStore.instance.pushCard({ phase: RightPanelPhases.Extensions }, true);
Expand Down
17 changes: 3 additions & 14 deletions src/components/views/right_panel/TimelineCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { E2EStatus } from "../../../utils/ShieldUtils";
import EditorStateTransfer from "../../../utils/EditorStateTransfer";
import RoomContext, { TimelineRenderingType } from "../../../contexts/RoomContext";
import dis from "../../../dispatcher/dispatcher";
import { _t } from "../../../languageHandler";
import { ActionPayload } from "../../../dispatcher/payloads";
import { Action } from "../../../dispatcher/actions";
import ContentMessages from "../../../ContentMessages";
Expand All @@ -44,7 +43,6 @@ import SettingsStore from "../../../settings/SettingsStore";
import JumpToBottomButton from "../rooms/JumpToBottomButton";
import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload";
import Measured from "../elements/Measured";
import Heading from "../typography/Heading";
import { UPDATE_EVENT } from "../../../stores/AsyncStore";
import { SdkContextClass } from "../../../contexts/SDKContext";

Expand Down Expand Up @@ -193,16 +191,6 @@ export default class TimelineCard extends React.Component<IProps, IState> {
}
};

private renderTimelineCardHeader = (): JSX.Element => {
return (
<div className="mx_BaseCard_header_title">
<Heading size="4" className="mx_BaseCard_header_title_heading">
{_t("right_panel|video_room_chat|title")}
</Heading>
</div>
);
};

public render(): React.ReactNode {
const highlightedEventId = this.state.isInitialEventHighlighted ? this.state.initialEventId : undefined;

Expand Down Expand Up @@ -232,10 +220,11 @@ export default class TimelineCard extends React.Component<IProps, IState> {
>
<BaseCard
className={this.props.classNames}
onClose={this.props.onClose}
withoutScrollContainer={true}
header={this.renderTimelineCardHeader()}
ref={this.card}
hideHeaderButtons
id="timeline-panel"
ariaLabelledBy="timeline-panel-tab"
>
{this.card.current && <Measured sensor={this.card.current} onMeasurement={this.onMeasurement} />}
<div className="mx_TimelineCard_timeline">
Expand Down
Loading