Simplifications in InviteDialog (#33156)
* InviteDialog: simplify users section for CallTransferDialog The majority of `renderMainTab` is enpty for the call transfer dialog, so we may as well inkine the bits that aren't. * Simplify `renderMainTab` Now that this is unused for CallTransfer, we can simplify * Remove redundant eslint-disable eslint seems happy without this, and we shouldn't be disabling lints for a whole file anyway
This commit is contained in:
@@ -65,9 +65,6 @@ import { type UserProfilesStore } from "../../../stores/UserProfilesStore";
|
|||||||
import InviteProgressBody from "./InviteProgressBody.tsx";
|
import InviteProgressBody from "./InviteProgressBody.tsx";
|
||||||
import MultiInviter, { type CompletionStates as MultiInviterCompletionStates } from "../../../utils/MultiInviter.ts";
|
import MultiInviter, { type CompletionStates as MultiInviterCompletionStates } from "../../../utils/MultiInviter.ts";
|
||||||
|
|
||||||
// we have a number of types defined from the Matrix spec which can't reasonably be altered here.
|
|
||||||
/* eslint-disable camelcase */
|
|
||||||
|
|
||||||
interface Result {
|
interface Result {
|
||||||
userId: string;
|
userId: string;
|
||||||
user: Member;
|
user: Member;
|
||||||
@@ -1186,8 +1183,7 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render content of the common "users" tab that is shown whether we have a regular invite dialog or a
|
* Render content of the "users" that is used for both invites and "start chat".
|
||||||
* "CallTransfer" one.
|
|
||||||
*/
|
*/
|
||||||
private renderMainTab(): JSX.Element {
|
private renderMainTab(): JSX.Element {
|
||||||
let helpText;
|
let helpText;
|
||||||
@@ -1275,26 +1271,23 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||||||
|
|
||||||
buttonText = _t("action|invite");
|
buttonText = _t("action|invite");
|
||||||
goButtonFn = this.inviteUsers;
|
goButtonFn = this.inviteUsers;
|
||||||
|
} else {
|
||||||
|
throw new Error("Unknown InviteDialog kind: " + this.props.kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
const goButton =
|
|
||||||
this.props.kind == InviteKind.CallTransfer ? null : (
|
|
||||||
<AccessibleButton
|
|
||||||
kind="primary"
|
|
||||||
onClick={goButtonFn}
|
|
||||||
className="mx_InviteDialog_goButton"
|
|
||||||
disabled={this.state.busy || !this.hasSelection()}
|
|
||||||
>
|
|
||||||
{buttonText}
|
|
||||||
</AccessibleButton>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<p className="mx_InviteDialog_helpText">{helpText}</p>
|
<p className="mx_InviteDialog_helpText">{helpText}</p>
|
||||||
<div className="mx_InviteDialog_addressBar">
|
<div className="mx_InviteDialog_addressBar">
|
||||||
{this.renderEditor()}
|
{this.renderEditor()}
|
||||||
{goButton}
|
<AccessibleButton
|
||||||
|
kind="primary"
|
||||||
|
onClick={goButtonFn}
|
||||||
|
className="mx_InviteDialog_goButton"
|
||||||
|
disabled={this.state.busy || !this.hasSelection()}
|
||||||
|
>
|
||||||
|
{buttonText}
|
||||||
|
</AccessibleButton>
|
||||||
</div>
|
</div>
|
||||||
{this.state.busy ? <InviteProgressBody /> : this.renderSuggestions()}
|
{this.state.busy ? <InviteProgressBody /> : this.renderSuggestions()}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
@@ -1342,7 +1335,12 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
|
|||||||
* See also: {@link renderRegularDialog}.
|
* See also: {@link renderRegularDialog}.
|
||||||
*/
|
*/
|
||||||
private renderCallTransferDialog(): React.ReactNode {
|
private renderCallTransferDialog(): React.ReactNode {
|
||||||
const usersSection = this.renderMainTab();
|
const usersSection = (
|
||||||
|
<React.Fragment>
|
||||||
|
<div className="mx_InviteDialog_addressBar">{this.renderEditor()}</div>
|
||||||
|
{this.state.busy ? <InviteProgressBody /> : this.renderSuggestions()}
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
|
||||||
const tabs: NonEmptyArray<Tab<TabId>> = [
|
const tabs: NonEmptyArray<Tab<TabId>> = [
|
||||||
new Tab(
|
new Tab(
|
||||||
|
|||||||
Reference in New Issue
Block a user