Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
import { sleep } from "matrix-js-sdk/src/utils";
|
||||
import { Room, RoomEvent } from "matrix-js-sdk/src/models/room";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
@ -38,9 +38,9 @@ import InlineSpinner from "../../../elements/InlineSpinner";
|
|||
import { PosthogAnalytics } from "../../../../../PosthogAnalytics";
|
||||
import { showDialog as showAnalyticsLearnMoreDialog } from "../../../dialogs/AnalyticsLearnMoreDialog";
|
||||
import { privateShouldBeEncrypted } from "../../../../../utils/rooms";
|
||||
import LoginWithQR, { Mode } from '../../../auth/LoginWithQR';
|
||||
import LoginWithQRSection from '../../devices/LoginWithQRSection';
|
||||
import type { IServerVersions } from 'matrix-js-sdk/src/matrix';
|
||||
import LoginWithQR, { Mode } from "../../../auth/LoginWithQR";
|
||||
import LoginWithQRSection from "../../devices/LoginWithQRSection";
|
||||
import type { IServerVersions } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
interface IIgnoredUserProps {
|
||||
userId: string;
|
||||
|
@ -56,11 +56,16 @@ export class IgnoredUser extends React.Component<IIgnoredUserProps> {
|
|||
public render(): JSX.Element {
|
||||
const id = `mx_SecurityUserSettingsTab_ignoredUser_${this.props.userId}`;
|
||||
return (
|
||||
<div className='mx_SecurityUserSettingsTab_ignoredUser'>
|
||||
<AccessibleButton onClick={this.onUnignoreClicked} kind='primary_sm' aria-describedby={id} disabled={this.props.inProgress}>
|
||||
{ _t('Unignore') }
|
||||
<div className="mx_SecurityUserSettingsTab_ignoredUser">
|
||||
<AccessibleButton
|
||||
onClick={this.onUnignoreClicked}
|
||||
kind="primary_sm"
|
||||
aria-describedby={id}
|
||||
disabled={this.props.inProgress}
|
||||
>
|
||||
{_t("Unignore")}
|
||||
</AccessibleButton>
|
||||
<span id={id}>{ this.props.userId }</span>
|
||||
<span id={id}>{this.props.userId}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -86,7 +91,7 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
super(props);
|
||||
|
||||
// Get rooms we're invited to
|
||||
const invitedRoomIds = new Set(this.getInvitedRooms().map(room => room.roomId));
|
||||
const invitedRoomIds = new Set(this.getInvitedRooms().map((room) => room.roomId));
|
||||
|
||||
this.state = {
|
||||
ignoredUserIds: MatrixClientPeg.get().getIgnoredUsers(),
|
||||
|
@ -100,7 +105,7 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
private onAction = ({ action }: ActionPayload) => {
|
||||
if (action === "ignore_state_changed") {
|
||||
const ignoredUserIds = MatrixClientPeg.get().getIgnoredUsers();
|
||||
const newWaitingUnignored = this.state.waitingUnignored.filter(e => ignoredUserIds.includes(e));
|
||||
const newWaitingUnignored = this.state.waitingUnignored.filter((e) => ignoredUserIds.includes(e));
|
||||
this.setState({ ignoredUserIds, waitingUnignored: newWaitingUnignored });
|
||||
}
|
||||
};
|
||||
|
@ -108,7 +113,9 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
public componentDidMount(): void {
|
||||
this.dispatcherRef = dis.register(this.onAction);
|
||||
MatrixClientPeg.get().on(RoomEvent.MyMembership, this.onMyMembership);
|
||||
MatrixClientPeg.get().getVersions().then(versions => this.setState({ versions }));
|
||||
MatrixClientPeg.get()
|
||||
.getVersions()
|
||||
.then((versions) => this.setState({ versions }));
|
||||
}
|
||||
|
||||
public componentWillUnmount(): void {
|
||||
|
@ -148,7 +155,7 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
|
||||
private onUserUnignored = async (userId: string): Promise<void> => {
|
||||
const { ignoredUserIds, waitingUnignored } = this.state;
|
||||
const currentlyIgnoredUserIds = ignoredUserIds.filter(e => !waitingUnignored.includes(e));
|
||||
const currentlyIgnoredUserIds = ignoredUserIds.filter((e) => !waitingUnignored.includes(e));
|
||||
|
||||
const index = currentlyIgnoredUserIds.indexOf(userId);
|
||||
if (index !== -1) {
|
||||
|
@ -159,9 +166,11 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
};
|
||||
|
||||
private getInvitedRooms = (): Room[] => {
|
||||
return MatrixClientPeg.get().getRooms().filter((r) => {
|
||||
return r.hasMembershipState(MatrixClientPeg.get().getUserId(), "invite");
|
||||
});
|
||||
return MatrixClientPeg.get()
|
||||
.getRooms()
|
||||
.filter((r) => {
|
||||
return r.hasMembershipState(MatrixClientPeg.get().getUserId(), "invite");
|
||||
});
|
||||
};
|
||||
|
||||
private manageInvites = async (accept: boolean): Promise<void> => {
|
||||
|
@ -179,23 +188,26 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
const roomId = invitedRoomIdsValues[i];
|
||||
|
||||
// Accept/reject invite
|
||||
await action(roomId).then(() => {
|
||||
// No error, update invited rooms button
|
||||
this.removeInvitedRoom(roomId);
|
||||
}, async (e) => {
|
||||
// Action failure
|
||||
if (e.errcode === "M_LIMIT_EXCEEDED") {
|
||||
// Add a delay between each invite change in order to avoid rate
|
||||
// limiting by the server.
|
||||
await sleep(e.retry_after_ms || 2500);
|
||||
await action(roomId).then(
|
||||
() => {
|
||||
// No error, update invited rooms button
|
||||
this.removeInvitedRoom(roomId);
|
||||
},
|
||||
async (e) => {
|
||||
// Action failure
|
||||
if (e.errcode === "M_LIMIT_EXCEEDED") {
|
||||
// Add a delay between each invite change in order to avoid rate
|
||||
// limiting by the server.
|
||||
await sleep(e.retry_after_ms || 2500);
|
||||
|
||||
// Redo last action
|
||||
i--;
|
||||
} else {
|
||||
// Print out error with joining/leaving room
|
||||
logger.warn(e);
|
||||
}
|
||||
});
|
||||
// Redo last action
|
||||
i--;
|
||||
} else {
|
||||
// Print out error with joining/leaving room
|
||||
logger.warn(e);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
this.setState({
|
||||
|
@ -215,24 +227,22 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
const { waitingUnignored, ignoredUserIds } = this.state;
|
||||
|
||||
const userIds = !ignoredUserIds?.length
|
||||
? _t('You have no ignored users.')
|
||||
? _t("You have no ignored users.")
|
||||
: ignoredUserIds.map((u) => {
|
||||
return (
|
||||
<IgnoredUser
|
||||
userId={u}
|
||||
onUnignored={this.onUserUnignored}
|
||||
key={u}
|
||||
inProgress={waitingUnignored.includes(u)}
|
||||
/>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<IgnoredUser
|
||||
userId={u}
|
||||
onUnignored={this.onUserUnignored}
|
||||
key={u}
|
||||
inProgress={waitingUnignored.includes(u)}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
return (
|
||||
<div className='mx_SettingsTab_section'>
|
||||
<span className='mx_SettingsTab_subheading'>{ _t('Ignored users') }</span>
|
||||
<div className='mx_SettingsTab_subsectionText'>
|
||||
{ userIds }
|
||||
</div>
|
||||
<div className="mx_SettingsTab_section">
|
||||
<span className="mx_SettingsTab_subheading">{_t("Ignored users")}</span>
|
||||
<div className="mx_SettingsTab_subsectionText">{userIds}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -245,15 +255,23 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
}
|
||||
|
||||
return (
|
||||
<div className='mx_SettingsTab_section mx_SecurityUserSettingsTab_bulkOptions'>
|
||||
<span className='mx_SettingsTab_subheading'>{ _t('Bulk options') }</span>
|
||||
<AccessibleButton onClick={this.onAcceptAllInvitesClicked} kind='primary' disabled={this.state.managingInvites}>
|
||||
{ _t("Accept all %(invitedRooms)s invites", { invitedRooms: invitedRoomIds.size }) }
|
||||
<div className="mx_SettingsTab_section mx_SecurityUserSettingsTab_bulkOptions">
|
||||
<span className="mx_SettingsTab_subheading">{_t("Bulk options")}</span>
|
||||
<AccessibleButton
|
||||
onClick={this.onAcceptAllInvitesClicked}
|
||||
kind="primary"
|
||||
disabled={this.state.managingInvites}
|
||||
>
|
||||
{_t("Accept all %(invitedRooms)s invites", { invitedRooms: invitedRoomIds.size })}
|
||||
</AccessibleButton>
|
||||
<AccessibleButton onClick={this.onRejectAllInvitesClicked} kind='danger' disabled={this.state.managingInvites}>
|
||||
{ _t("Reject all %(invitedRooms)s invites", { invitedRooms: invitedRoomIds.size }) }
|
||||
<AccessibleButton
|
||||
onClick={this.onRejectAllInvitesClicked}
|
||||
kind="danger"
|
||||
disabled={this.state.managingInvites}
|
||||
>
|
||||
{_t("Reject all %(invitedRooms)s invites", { invitedRooms: invitedRoomIds.size })}
|
||||
</AccessibleButton>
|
||||
{ this.state.managingInvites ? <InlineSpinner /> : <div /> }
|
||||
{this.state.managingInvites ? <InlineSpinner /> : <div />}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -268,9 +286,9 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
|
||||
public render(): JSX.Element {
|
||||
const secureBackup = (
|
||||
<div className='mx_SettingsTab_section'>
|
||||
<span className="mx_SettingsTab_subheading">{ _t("Secure Backup") }</span>
|
||||
<div className='mx_SettingsTab_subsectionText'>
|
||||
<div className="mx_SettingsTab_section">
|
||||
<span className="mx_SettingsTab_subheading">{_t("Secure Backup")}</span>
|
||||
<div className="mx_SettingsTab_subsectionText">
|
||||
<SecureBackupPanel />
|
||||
</div>
|
||||
</div>
|
||||
|
@ -278,7 +296,7 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
|
||||
const eventIndex = (
|
||||
<div className="mx_SettingsTab_section">
|
||||
<span className="mx_SettingsTab_subheading">{ _t("Message search") }</span>
|
||||
<span className="mx_SettingsTab_subheading">{_t("Message search")}</span>
|
||||
<EventIndexPanel />
|
||||
</div>
|
||||
);
|
||||
|
@ -288,9 +306,9 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
// in having advanced details here once all flows are implemented, we
|
||||
// can remove this.
|
||||
const crossSigning = (
|
||||
<div className='mx_SettingsTab_section'>
|
||||
<span className="mx_SettingsTab_subheading">{ _t("Cross-signing") }</span>
|
||||
<div className='mx_SettingsTab_subsectionText'>
|
||||
<div className="mx_SettingsTab_section">
|
||||
<span className="mx_SettingsTab_subheading">{_t("Cross-signing")}</span>
|
||||
<div className="mx_SettingsTab_subsectionText">
|
||||
<CrossSigningPanel />
|
||||
</div>
|
||||
</div>
|
||||
|
@ -298,10 +316,14 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
|
||||
let warning;
|
||||
if (!privateShouldBeEncrypted()) {
|
||||
warning = <div className="mx_SecurityUserSettingsTab_warning">
|
||||
{ _t("Your server admin has disabled end-to-end encryption by default " +
|
||||
"in private rooms & Direct Messages.") }
|
||||
</div>;
|
||||
warning = (
|
||||
<div className="mx_SecurityUserSettingsTab_warning">
|
||||
{_t(
|
||||
"Your server admin has disabled end-to-end encryption by default " +
|
||||
"in private rooms & Direct Messages.",
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
let privacySection;
|
||||
|
@ -312,35 +334,32 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
hasCancel: false,
|
||||
});
|
||||
};
|
||||
privacySection = <React.Fragment>
|
||||
<div className="mx_SettingsTab_heading">{ _t("Privacy") }</div>
|
||||
<div className="mx_SettingsTab_section">
|
||||
<span className="mx_SettingsTab_subheading">{ _t("Analytics") }</span>
|
||||
<div className="mx_SettingsTab_subsectionText">
|
||||
<p>
|
||||
{ _t("Share anonymous data to help us identify issues. Nothing personal. " +
|
||||
"No third parties.") }
|
||||
</p>
|
||||
<AccessibleButton
|
||||
kind="link"
|
||||
onClick={onClickAnalyticsLearnMore}
|
||||
>
|
||||
{ _t("Learn more") }
|
||||
</AccessibleButton>
|
||||
privacySection = (
|
||||
<React.Fragment>
|
||||
<div className="mx_SettingsTab_heading">{_t("Privacy")}</div>
|
||||
<div className="mx_SettingsTab_section">
|
||||
<span className="mx_SettingsTab_subheading">{_t("Analytics")}</span>
|
||||
<div className="mx_SettingsTab_subsectionText">
|
||||
<p>
|
||||
{_t(
|
||||
"Share anonymous data to help us identify issues. Nothing personal. " +
|
||||
"No third parties.",
|
||||
)}
|
||||
</p>
|
||||
<AccessibleButton kind="link" onClick={onClickAnalyticsLearnMore}>
|
||||
{_t("Learn more")}
|
||||
</AccessibleButton>
|
||||
</div>
|
||||
{PosthogAnalytics.instance.isEnabled() && (
|
||||
<SettingsFlag name="pseudonymousAnalyticsOptIn" level={SettingLevel.ACCOUNT} />
|
||||
)}
|
||||
</div>
|
||||
{ PosthogAnalytics.instance.isEnabled() && (
|
||||
<SettingsFlag
|
||||
name="pseudonymousAnalyticsOptIn"
|
||||
level={SettingLevel.ACCOUNT} />
|
||||
) }
|
||||
</div>
|
||||
<div className="mx_SettingsTab_section">
|
||||
<span className="mx_SettingsTab_subheading">{ _t("Sessions") }</span>
|
||||
<SettingsFlag
|
||||
name="deviceClientInformationOptIn"
|
||||
level={SettingLevel.ACCOUNT} />
|
||||
</div>
|
||||
</React.Fragment>;
|
||||
<div className="mx_SettingsTab_section">
|
||||
<span className="mx_SettingsTab_subheading">{_t("Sessions")}</span>
|
||||
<SettingsFlag name="deviceClientInformationOptIn" level={SettingLevel.ACCOUNT} />
|
||||
</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
let advancedSection;
|
||||
|
@ -350,62 +369,66 @@ export default class SecurityUserSettingsTab extends React.Component<IProps, ISt
|
|||
const e2ePanel = isE2eAdvancedPanelPossible() ? <E2eAdvancedPanel /> : null;
|
||||
// only show the section if there's something to show
|
||||
if (ignoreUsersPanel || invitesPanel || e2ePanel) {
|
||||
advancedSection = <>
|
||||
<div className="mx_SettingsTab_heading">{ _t("Advanced") }</div>
|
||||
<div className="mx_SettingsTab_section">
|
||||
{ ignoreUsersPanel }
|
||||
{ invitesPanel }
|
||||
{ e2ePanel }
|
||||
</div>
|
||||
</>;
|
||||
advancedSection = (
|
||||
<>
|
||||
<div className="mx_SettingsTab_heading">{_t("Advanced")}</div>
|
||||
<div className="mx_SettingsTab_section">
|
||||
{ignoreUsersPanel}
|
||||
{invitesPanel}
|
||||
{e2ePanel}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const useNewSessionManager = SettingsStore.getValue("feature_new_device_manager");
|
||||
const showQrCodeEnabled = SettingsStore.getValue("feature_qr_signin_reciprocate_show");
|
||||
const devicesSection = useNewSessionManager
|
||||
? null
|
||||
: <>
|
||||
<div className="mx_SettingsTab_heading">{ _t("Where you're signed in") }</div>
|
||||
<div
|
||||
className="mx_SettingsTab_section"
|
||||
data-testid="devices-section"
|
||||
>
|
||||
const devicesSection = useNewSessionManager ? null : (
|
||||
<>
|
||||
<div className="mx_SettingsTab_heading">{_t("Where you're signed in")}</div>
|
||||
<div className="mx_SettingsTab_section" data-testid="devices-section">
|
||||
<span className="mx_SettingsTab_subsectionText">
|
||||
{ _t(
|
||||
{_t(
|
||||
"Manage your signed-in devices below. " +
|
||||
"A device's name is visible to people you communicate with.",
|
||||
) }
|
||||
"A device's name is visible to people you communicate with.",
|
||||
)}
|
||||
</span>
|
||||
<DevicesPanel />
|
||||
</div>
|
||||
{ showQrCodeEnabled ?
|
||||
{showQrCodeEnabled ? (
|
||||
<LoginWithQRSection onShowQr={this.onShowQRClicked} versions={this.state.versions} />
|
||||
: null
|
||||
}
|
||||
</>;
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
|
||||
const client = MatrixClientPeg.get();
|
||||
|
||||
if (showQrCodeEnabled && this.state.showLoginWithQR) {
|
||||
return <div className="mx_SettingsTab mx_SecurityUserSettingsTab">
|
||||
<LoginWithQR onFinished={this.onLoginWithQRFinished} mode={this.state.showLoginWithQR} client={client} />
|
||||
</div>;
|
||||
return (
|
||||
<div className="mx_SettingsTab mx_SecurityUserSettingsTab">
|
||||
<LoginWithQR
|
||||
onFinished={this.onLoginWithQRFinished}
|
||||
mode={this.state.showLoginWithQR}
|
||||
client={client}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="mx_SettingsTab mx_SecurityUserSettingsTab">
|
||||
{ warning }
|
||||
{ devicesSection }
|
||||
<div className="mx_SettingsTab_heading">{ _t("Encryption") }</div>
|
||||
{warning}
|
||||
{devicesSection}
|
||||
<div className="mx_SettingsTab_heading">{_t("Encryption")}</div>
|
||||
<div className="mx_SettingsTab_section">
|
||||
{ secureBackup }
|
||||
{ eventIndex }
|
||||
{ crossSigning }
|
||||
{secureBackup}
|
||||
{eventIndex}
|
||||
{crossSigning}
|
||||
<CryptographyPanel />
|
||||
</div>
|
||||
{ privacySection }
|
||||
{ advancedSection }
|
||||
{privacySection}
|
||||
{advancedSection}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue