Use generics to better type TabbedView (#10726)
This commit is contained in:
parent
fcf2fe2c1d
commit
a629ce3a53
12 changed files with 56 additions and 52 deletions
|
@ -40,14 +40,16 @@ import { NonEmptyArray } from "../../../@types/common";
|
|||
import { PollHistoryTab } from "../settings/tabs/room/PollHistoryTab";
|
||||
import ErrorBoundary from "../elements/ErrorBoundary";
|
||||
|
||||
export const ROOM_GENERAL_TAB = "ROOM_GENERAL_TAB";
|
||||
export const ROOM_VOIP_TAB = "ROOM_VOIP_TAB";
|
||||
export const ROOM_SECURITY_TAB = "ROOM_SECURITY_TAB";
|
||||
export const ROOM_ROLES_TAB = "ROOM_ROLES_TAB";
|
||||
export const ROOM_NOTIFICATIONS_TAB = "ROOM_NOTIFICATIONS_TAB";
|
||||
export const ROOM_BRIDGES_TAB = "ROOM_BRIDGES_TAB";
|
||||
export const ROOM_ADVANCED_TAB = "ROOM_ADVANCED_TAB";
|
||||
export const ROOM_POLL_HISTORY_TAB = "ROOM_POLL_HISTORY_TAB";
|
||||
export const enum RoomSettingsTab {
|
||||
General = "ROOM_GENERAL_TAB",
|
||||
Voip = "ROOM_VOIP_TAB",
|
||||
Security = "ROOM_SECURITY_TAB",
|
||||
Roles = "ROOM_ROLES_TAB",
|
||||
Notifications = "ROOM_NOTIFICATIONS_TAB",
|
||||
Bridges = "ROOM_BRIDGES_TAB",
|
||||
Advanced = "ROOM_ADVANCED_TAB",
|
||||
PollHistory = "ROOM_POLL_HISTORY_TAB",
|
||||
}
|
||||
|
||||
interface IProps {
|
||||
roomId: string;
|
||||
|
@ -118,12 +120,12 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
|
|||
this.forceUpdate();
|
||||
};
|
||||
|
||||
private getTabs(): NonEmptyArray<Tab> {
|
||||
const tabs: Tab[] = [];
|
||||
private getTabs(): NonEmptyArray<Tab<RoomSettingsTab>> {
|
||||
const tabs: Tab<RoomSettingsTab>[] = [];
|
||||
|
||||
tabs.push(
|
||||
new Tab(
|
||||
ROOM_GENERAL_TAB,
|
||||
RoomSettingsTab.General,
|
||||
_td("General"),
|
||||
"mx_RoomSettingsDialog_settingsIcon",
|
||||
<GeneralRoomSettingsTab room={this.state.room} />,
|
||||
|
@ -133,7 +135,7 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
|
|||
if (SettingsStore.getValue("feature_group_calls")) {
|
||||
tabs.push(
|
||||
new Tab(
|
||||
ROOM_VOIP_TAB,
|
||||
RoomSettingsTab.Voip,
|
||||
_td("Voice & Video"),
|
||||
"mx_RoomSettingsDialog_voiceIcon",
|
||||
<VoipRoomSettingsTab room={this.state.room} />,
|
||||
|
@ -142,7 +144,7 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
|
|||
}
|
||||
tabs.push(
|
||||
new Tab(
|
||||
ROOM_SECURITY_TAB,
|
||||
RoomSettingsTab.Security,
|
||||
_td("Security & Privacy"),
|
||||
"mx_RoomSettingsDialog_securityIcon",
|
||||
<SecurityRoomSettingsTab room={this.state.room} closeSettingsFn={() => this.props.onFinished(true)} />,
|
||||
|
@ -151,7 +153,7 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
|
|||
);
|
||||
tabs.push(
|
||||
new Tab(
|
||||
ROOM_ROLES_TAB,
|
||||
RoomSettingsTab.Roles,
|
||||
_td("Roles & Permissions"),
|
||||
"mx_RoomSettingsDialog_rolesIcon",
|
||||
<RolesRoomSettingsTab room={this.state.room} />,
|
||||
|
@ -160,7 +162,7 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
|
|||
);
|
||||
tabs.push(
|
||||
new Tab(
|
||||
ROOM_NOTIFICATIONS_TAB,
|
||||
RoomSettingsTab.Notifications,
|
||||
_td("Notifications"),
|
||||
"mx_RoomSettingsDialog_notificationsIcon",
|
||||
(
|
||||
|
@ -176,7 +178,7 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
|
|||
if (SettingsStore.getValue("feature_bridge_state")) {
|
||||
tabs.push(
|
||||
new Tab(
|
||||
ROOM_BRIDGES_TAB,
|
||||
RoomSettingsTab.Bridges,
|
||||
_td("Bridges"),
|
||||
"mx_RoomSettingsDialog_bridgesIcon",
|
||||
<BridgeSettingsTab room={this.state.room} />,
|
||||
|
@ -187,7 +189,7 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
|
|||
|
||||
tabs.push(
|
||||
new Tab(
|
||||
ROOM_POLL_HISTORY_TAB,
|
||||
RoomSettingsTab.PollHistory,
|
||||
_td("Poll history"),
|
||||
"mx_RoomSettingsDialog_pollsIcon",
|
||||
<PollHistoryTab room={this.state.room} onFinished={() => this.props.onFinished(true)} />,
|
||||
|
@ -197,7 +199,7 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
|
|||
if (SettingsStore.getValue(UIFeature.AdvancedSettings)) {
|
||||
tabs.push(
|
||||
new Tab(
|
||||
ROOM_ADVANCED_TAB,
|
||||
RoomSettingsTab.Advanced,
|
||||
_td("Advanced"),
|
||||
"mx_RoomSettingsDialog_warningIcon",
|
||||
(
|
||||
|
@ -211,7 +213,7 @@ class RoomSettingsDialog extends React.Component<IProps, IState> {
|
|||
);
|
||||
}
|
||||
|
||||
return tabs as NonEmptyArray<Tab>;
|
||||
return tabs as NonEmptyArray<Tab<RoomSettingsTab>>;
|
||||
}
|
||||
|
||||
public render(): React.ReactNode {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue