Improve formatting

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-04-29 19:57:02 +02:00
parent 46bfbbadf9
commit 232b87a3b4
No known key found for this signature in database
GPG key ID: 9760693FDD98A790
17 changed files with 193 additions and 163 deletions

View file

@ -148,13 +148,15 @@ function _onGroupAddRoomFinished(groupId, addrs, addRoomsPublicly) {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog( Modal.createTrackedDialog(
'Failed to add the following room to the group', 'Failed to add the following room to the group',
'', ErrorDialog, '',
ErrorDialog,
{ {
title: _t( title: _t(
"Failed to add the following rooms to %(groupId)s:", "Failed to add the following rooms to %(groupId)s:",
{groupId}, {groupId},
), ),
description: errorList.join(", "), description: errorList.join(", "),
}); },
);
}); });
} }

View file

@ -547,17 +547,23 @@ function textForMjolnirEvent(event) {
// else the entity !== prevEntity - count as a removal & add // else the entity !== prevEntity - count as a removal & add
if (USER_RULE_TYPES.includes(event.getType())) { if (USER_RULE_TYPES.includes(event.getType())) {
return _t("%(senderName)s changed a rule that was banning users matching %(oldGlob)s to matching " + return _t(
"%(senderName)s changed a rule that was banning users matching %(oldGlob)s to matching " +
"%(newGlob)s for %(reason)s", "%(newGlob)s for %(reason)s",
{senderName, oldGlob: prevEntity, newGlob: entity, reason}); {senderName, oldGlob: prevEntity, newGlob: entity, reason},
);
} else if (ROOM_RULE_TYPES.includes(event.getType())) { } else if (ROOM_RULE_TYPES.includes(event.getType())) {
return _t("%(senderName)s changed a rule that was banning rooms matching %(oldGlob)s to matching " + return _t(
"%(senderName)s changed a rule that was banning rooms matching %(oldGlob)s to matching " +
"%(newGlob)s for %(reason)s", "%(newGlob)s for %(reason)s",
{senderName, oldGlob: prevEntity, newGlob: entity, reason}); {senderName, oldGlob: prevEntity, newGlob: entity, reason},
);
} else if (SERVER_RULE_TYPES.includes(event.getType())) { } else if (SERVER_RULE_TYPES.includes(event.getType())) {
return _t("%(senderName)s changed a rule that was banning servers matching %(oldGlob)s to matching " + return _t(
"%(senderName)s changed a rule that was banning servers matching %(oldGlob)s to matching " +
"%(newGlob)s for %(reason)s", "%(newGlob)s for %(reason)s",
{senderName, oldGlob: prevEntity, newGlob: entity, reason}); {senderName, oldGlob: prevEntity, newGlob: entity, reason},
);
} }
// Unknown type. We'll say something but we shouldn't end up here. // Unknown type. We'll say something but we shouldn't end up here.

View file

@ -44,14 +44,14 @@ import {replaceableComponent} from "../../utils/replaceableComponent";
const LONG_DESC_PLACEHOLDER = _td( const LONG_DESC_PLACEHOLDER = _td(
`<h1>HTML for your community's page</h1> `<h1>HTML for your community's page</h1>
<p> <p>
Use the long description to introduce new members to the community, or distribute Use the long description to introduce new members to the community, or distribute
some important <a href="foo">links</a> some important <a href="foo">links</a>
</p> </p>
<p> <p>
You can even add images with Matrix URLs <img src="mxc://url" /> You can even add images with Matrix URLs <img src="mxc://url" />
</p> </p>`,
`); );
const RoomSummaryType = PropTypes.shape({ const RoomSummaryType = PropTypes.shape({
room_id: PropTypes.string.isRequired, room_id: PropTypes.string.isRequired,
@ -110,13 +110,14 @@ class CategoryRoomList extends React.Component {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog( Modal.createTrackedDialog(
'Failed to add the following room to the group summary', 'Failed to add the following room to the group summary',
'', ErrorDialog, '',
ErrorDialog,
{ {
title: _t( title: _t(
"Failed to add the following rooms to the summary of %(groupId)s:", "Failed to add the following rooms to the summary of %(groupId)s:",
{groupId: this.props.groupId}, {groupId: this.props.groupId},
), ),
description: errorList.join(", "), description: errorList.join(", "),
}, },
); );
}); });
@ -146,8 +147,7 @@ class CategoryRoomList extends React.Component {
let catHeader = <div />; let catHeader = <div />;
if (this.props.category && this.props.category.profile) { if (this.props.category && this.props.category.profile) {
catHeader = <div catHeader = <div className="mx_GroupView_featuredThings_category">
className="mx_GroupView_featuredThings_category">
{ this.props.category.profile.name } { this.props.category.profile.name }
</div>; </div>;
} }
@ -193,11 +193,11 @@ class FeaturedRoom extends React.Component {
'Failed to remove room from group summary', 'Failed to remove room from group summary',
'', ErrorDialog, '', ErrorDialog,
{ {
title: _t( title: _t(
"Failed to remove the room from the summary of %(groupId)s", "Failed to remove the room from the summary of %(groupId)s",
{groupId: this.props.groupId}, {groupId: this.props.groupId},
), ),
description: _t("The room '%(roomName)s' could not be removed from the summary.", {roomName}), description: _t("The room '%(roomName)s' could not be removed from the summary.", {roomName}),
}, },
); );
}); });
@ -287,12 +287,13 @@ class RoleUserList extends React.Component {
'Failed to add the following users to the community summary', 'Failed to add the following users to the community summary',
'', ErrorDialog, '', ErrorDialog,
{ {
title: _t( title: _t(
"Failed to add the following users to the summary of %(groupId)s:", "Failed to add the following users to the summary of %(groupId)s:",
{groupId: this.props.groupId}, {groupId: this.props.groupId},
), ),
description: errorList.join(", "), description: errorList.join(", "),
}); },
);
}); });
}, },
}, /*className=*/null, /*isPriority=*/false, /*isStatic=*/true); }, /*className=*/null, /*isPriority=*/false, /*isStatic=*/true);
@ -355,13 +356,14 @@ class FeaturedUser extends React.Component {
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog( Modal.createTrackedDialog(
'Failed to remove user from community summary', 'Failed to remove user from community summary',
'', ErrorDialog, '',
ErrorDialog,
{ {
title: _t( title: _t(
"Failed to remove a user from the summary of %(groupId)s", "Failed to remove a user from the summary of %(groupId)s",
{groupId: this.props.groupId}, {groupId: this.props.groupId},
), ),
description: _t("The user '%(displayName)s' could not be removed from the summary.", {displayName}), description: _t("The user '%(displayName)s' could not be removed from the summary.", {displayName}),
}, },
); );
}); });
@ -1059,11 +1061,12 @@ export default class GroupView extends React.Component {
return null; return null;
} }
const membershipButtonClasses = classnames([ const membershipButtonClasses = classnames(
'mx_RoomHeader_textButton', [
'mx_GroupView_textButton', 'mx_RoomHeader_textButton',
], 'mx_GroupView_textButton',
membershipButtonExtraClasses, ],
membershipButtonExtraClasses,
); );
const membershipContainerClasses = classnames( const membershipContainerClasses = classnames(

View file

@ -884,19 +884,20 @@ export default class ScrollPanel extends React.Component {
// give the <ol> an explicit role=list because Safari+VoiceOver seems to think an ordered-list with // give the <ol> an explicit role=list because Safari+VoiceOver seems to think an ordered-list with
// list-style-type: none; is no longer a list // list-style-type: none; is no longer a list
return (<AutoHideScrollbar return (
wrappedRef={this._collectScroll} <AutoHideScrollbar
onScroll={this.onScroll} wrappedRef={this._collectScroll}
className={`mx_ScrollPanel ${this.props.className}`} onScroll={this.onScroll}
style={this.props.style} className={`mx_ScrollPanel ${this.props.className}`}
> style={this.props.style}
{ this.props.fixedChildren } >
<div className="mx_RoomView_messageListWrapper"> { this.props.fixedChildren }
<ol ref={this._itemlist} className="mx_RoomView_MessageList" aria-live="polite" role="list"> <div className="mx_RoomView_messageListWrapper">
{ this.props.children } <ol ref={this._itemlist} className="mx_RoomView_MessageList" aria-live="polite" role="list">
</ol> { this.props.children }
</div> </ol>
</AutoHideScrollbar> </div>
</AutoHideScrollbar>
); );
} }
} }

View file

@ -116,8 +116,12 @@ export default class RoomSettingsDialog extends React.Component {
const roomName = MatrixClientPeg.get().getRoom(this.props.roomId).name; const roomName = MatrixClientPeg.get().getRoom(this.props.roomId).name;
return ( return (
<BaseDialog className='mx_RoomSettingsDialog' hasCancel={true} <BaseDialog
onFinished={this.props.onFinished} title={_t("Room Settings - %(roomName)s", {roomName})}> className='mx_RoomSettingsDialog'
hasCancel={true}
onFinished={this.props.onFinished}
title={_t("Room Settings - %(roomName)s", {roomName})}
>
<div className='mx_SettingsDialog_content'> <div className='mx_SettingsDialog_content'>
<TabbedView tabs={this._getTabs()} /> <TabbedView tabs={this._getTabs()} />
</div> </div>

View file

@ -45,9 +45,10 @@ export default class StorageEvictedDialog extends React.Component {
let logRequest; let logRequest;
if (SdkConfig.get().bug_report_endpoint_url) { if (SdkConfig.get().bug_report_endpoint_url) {
logRequest = _t( logRequest = _t(
"To help us prevent this in future, please <a>send us logs</a>.", {}, "To help us prevent this in future, please <a>send us logs</a>.",
{},
{ {
a: text => <a href="#" onClick={this._sendBugReport}>{text}</a>, a: text => <a href="#" onClick={this._sendBugReport}>{text}</a>,
}, },
); );
} }

View file

@ -155,8 +155,12 @@ export default class UserSettingsDialog extends React.Component {
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog'); const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
return ( return (
<BaseDialog className='mx_UserSettingsDialog' hasCancel={true} <BaseDialog
onFinished={this.props.onFinished} title={_t("Settings")}> className='mx_UserSettingsDialog'
hasCancel={true}
onFinished={this.props.onFinished}
title={_t("Settings")}
>
<div className='mx_SettingsDialog_content'> <div className='mx_SettingsDialog_content'>
<TabbedView tabs={this._getTabs()} initialTabId={this.props.initialTabId} /> <TabbedView tabs={this._getTabs()} initialTabId={this.props.initialTabId} />
</div> </div>

View file

@ -70,9 +70,12 @@ export default class WidgetOpenIDPermissionsDialog extends React.Component {
const DialogButtons = sdk.getComponent('views.elements.DialogButtons'); const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
return ( return (
<BaseDialog className='mx_WidgetOpenIDPermissionsDialog' hasCancel={true} <BaseDialog
className='mx_WidgetOpenIDPermissionsDialog'
hasCancel={true}
onFinished={this.props.onFinished} onFinished={this.props.onFinished}
title={_t("Allow this widget to verify your identity")}> title={_t("Allow this widget to verify your identity")}
>
<div className='mx_WidgetOpenIDPermissionsDialog_content'> <div className='mx_WidgetOpenIDPermissionsDialog_content'>
<p> <p>
{_t("The widget will verify your user ID, but won't be able to perform actions for you:")} {_t("The widget will verify your user ID, but won't be able to perform actions for you:")}

View file

@ -43,7 +43,8 @@ export default class ConfirmDestroyCrossSigningDialog extends React.Component {
className='mx_ConfirmDestroyCrossSigningDialog' className='mx_ConfirmDestroyCrossSigningDialog'
hasCancel={true} hasCancel={true}
onFinished={this.props.onFinished} onFinished={this.props.onFinished}
title={_t("Destroy cross-signing keys?")}> title={_t("Destroy cross-signing keys?")}
>
<div className='mx_ConfirmDestroyCrossSigningDialog_content'> <div className='mx_ConfirmDestroyCrossSigningDialog_content'>
<p> <p>
{_t( {_t(

View file

@ -373,20 +373,23 @@ export default class RestoreKeyBackupDialog extends React.PureComponent {
{_t( {_t(
"If you've forgotten your Security Phrase you can "+ "If you've forgotten your Security Phrase you can "+
"<button1>use your Security Key</button1> or " + "<button1>use your Security Key</button1> or " +
"<button2>set up new recovery options</button2>" "<button2>set up new recovery options</button2>",
, {}, { {},
button1: s => <AccessibleButton className="mx_linkButton" {
element="span" button1: s => <AccessibleButton
onClick={this._onUseRecoveryKeyClick} className="mx_linkButton"
> element="span"
{s} onClick={this._onUseRecoveryKeyClick}
</AccessibleButton>, >
button2: s => <AccessibleButton className="mx_linkButton" {s}
element="span" </AccessibleButton>,
onClick={this._onResetRecoveryClick} button2: s => <AccessibleButton
> className="mx_linkButton"
{s} element="span"
</AccessibleButton>, onClick={this._onResetRecoveryClick}
>
{s}
</AccessibleButton>,
})} })}
</div>; </div>;
} else { } else {
@ -435,15 +438,17 @@ export default class RestoreKeyBackupDialog extends React.PureComponent {
</div> </div>
{_t( {_t(
"If you've forgotten your Security Key you can "+ "If you've forgotten your Security Key you can "+
"<button>set up new recovery options</button>" "<button>set up new recovery options</button>",
, {}, { {},
button: s => <AccessibleButton className="mx_linkButton" {
element="span" button: s => <AccessibleButton className="mx_linkButton"
onClick={this._onResetRecoveryClick} element="span"
> onClick={this._onResetRecoveryClick}
{s} >
</AccessibleButton>, {s}
})} </AccessibleButton>,
},
)}
</div>; </div>;
} }

View file

@ -127,8 +127,12 @@ export default class EditableItemList extends React.Component {
_renderNewItemField() { _renderNewItemField() {
return ( return (
<form onSubmit={this._onItemAdded} autoComplete="off" <form
noValidate={true} className="mx_EditableItemList_newItem"> onSubmit={this._onItemAdded}
autoComplete="off"
noValidate={true}
className="mx_EditableItemList_newItem"
>
<Field label={this.props.placeholder} type="text" <Field label={this.props.placeholder} type="text"
autoComplete="off" value={this.props.newItem || ""} onChange={this._onNewItemChanged} autoComplete="off" value={this.props.newItem || ""} onChange={this._onNewItemChanged}
list={this.props.suggestionsListId} /> list={this.props.suggestionsListId} />

View file

@ -82,9 +82,7 @@ export default class MKeyVerificationConclusion extends React.Component {
} }
// User isn't actually verified // User isn't actually verified
if (!MatrixClientPeg.get() if (!MatrixClientPeg.get().checkUserTrust(request.otherUserId).isCrossSigningVerified()) {
.checkUserTrust(request.otherUserId)
.isCrossSigningVerified()) {
return false; return false;
} }

View file

@ -187,8 +187,7 @@ export default class ReadReceiptMarker extends React.PureComponent {
} }
return ( return (
<NodeAnimator <NodeAnimator startStyles={this.state.startStyles}>
startStyles={this.state.startStyles} >
<MemberAvatar <MemberAvatar
member={this.props.member} member={this.props.member}
fallbackUserId={this.props.fallbackUserId} fallbackUserId={this.props.fallbackUserId}

View file

@ -785,8 +785,14 @@ export default class EventIndex extends EventEmitter {
* @returns {Promise<boolean>} Resolves to true if events were added to the * @returns {Promise<boolean>} Resolves to true if events were added to the
* timeline, false otherwise. * timeline, false otherwise.
*/ */
async populateFileTimeline(timelineSet, timeline, room, limit = 10, async populateFileTimeline(
fromEvent = null, direction = EventTimeline.BACKWARDS) { timelineSet,
timeline,
room,
limit = 10,
fromEvent = null,
direction = EventTimeline.BACKWARDS,
) {
const matrixEvents = await this.loadFileEvents(room, limit, fromEvent, direction); const matrixEvents = await this.loadFileEvents(room, limit, fromEvent, direction);
// If this is a normal fill request, not a pagination request, we need // If this is a normal fill request, not a pagination request, we need

View file

@ -124,15 +124,15 @@ class CustomRoomTagStore extends EventEmitter {
const tags = Object.assign({}, oldTags, tag); const tags = Object.assign({}, oldTags, tag);
this._setState({tags}); this._setState({tags});
} }
}
break; break;
}
case 'on_client_not_viable': case 'on_client_not_viable':
case 'on_logged_out': { case 'on_logged_out': {
// we assume to always have a tags object in the state // we assume to always have a tags object in the state
this._state = {tags: {}}; this._state = {tags: {}};
RoomListStore.instance.off(LISTS_UPDATE_EVENT, this._onListsUpdated); RoomListStore.instance.off(LISTS_UPDATE_EVENT, this._onListsUpdated);
}
break; break;
}
} }
} }

View file

@ -310,8 +310,7 @@ function unpackMegolmKeyFile(data) {
// look for the end line // look for the end line
while (1) { while (1) {
const lineEnd = fileStr.indexOf('\n', lineStart); const lineEnd = fileStr.indexOf('\n', lineStart);
const line = fileStr.slice(lineStart, lineEnd < 0 ? undefined : lineEnd) const line = fileStr.slice(lineStart, lineEnd < 0 ? undefined : lineEnd).trim();
.trim();
if (line === TRAILER_LINE) { if (line === TRAILER_LINE) {
break; break;
} }

View file

@ -245,9 +245,8 @@ describe('MemberEventListSummary', function() {
); );
}); });
it('truncates multiple sequences of repetitions with other events between', it('truncates multiple sequences of repetitions with other events between', function() {
function() { const events = generateEvents([
const events = generateEvents([
{ {
userId: "@user_1:some.domain", userId: "@user_1:some.domain",
prevMembership: "ban", prevMembership: "ban",
@ -276,29 +275,28 @@ describe('MemberEventListSummary', function() {
membership: "invite", membership: "invite",
senderId: "@some_other_user:some.domain", senderId: "@some_other_user:some.domain",
}, },
]); ]);
const props = { const props = {
events: events, events: events,
children: generateTiles(events), children: generateTiles(events),
summaryLength: 1, summaryLength: 1,
avatarsMaxLength: 5, avatarsMaxLength: 5,
threshold: 3, threshold: 3,
}; };
const instance = ReactTestUtils.renderIntoDocument( const instance = ReactTestUtils.renderIntoDocument(
<MemberEventListSummary {...props} />, <MemberEventListSummary {...props} />,
); );
const summary = ReactTestUtils.findRenderedDOMComponentWithClass( const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
instance, "mx_EventListSummary_summary", instance, "mx_EventListSummary_summary",
); );
const summaryText = summary.textContent; const summaryText = summary.textContent;
expect(summaryText).toBe( expect(summaryText).toBe(
"user_1 was unbanned, joined and left 2 times, was banned, " + "user_1 was unbanned, joined and left 2 times, was banned, " +
"joined and left 3 times and was invited", "joined and left 3 times and was invited",
); );
}, });
);
it('handles multiple users following the same sequence of memberships', function() { it('handles multiple users following the same sequence of memberships', function() {
const events = generateEvents([ const events = generateEvents([
@ -396,9 +394,8 @@ describe('MemberEventListSummary', function() {
); );
}); });
it('correctly orders sequences of transitions by the order of their first event', it('correctly orders sequences of transitions by the order of their first event', function() {
function() { const events = generateEvents([
const events = generateEvents([
{ {
userId: "@user_2:some.domain", userId: "@user_2:some.domain",
prevMembership: "ban", prevMembership: "ban",
@ -425,29 +422,28 @@ describe('MemberEventListSummary', function() {
{userId: "@user_2:some.domain", prevMembership: "join", membership: "leave"}, {userId: "@user_2:some.domain", prevMembership: "join", membership: "leave"},
{userId: "@user_2:some.domain", prevMembership: "leave", membership: "join"}, {userId: "@user_2:some.domain", prevMembership: "leave", membership: "join"},
{userId: "@user_2:some.domain", prevMembership: "join", membership: "leave"}, {userId: "@user_2:some.domain", prevMembership: "join", membership: "leave"},
]); ]);
const props = { const props = {
events: events, events: events,
children: generateTiles(events), children: generateTiles(events),
summaryLength: 1, summaryLength: 1,
avatarsMaxLength: 5, avatarsMaxLength: 5,
threshold: 3, threshold: 3,
}; };
const instance = ReactTestUtils.renderIntoDocument( const instance = ReactTestUtils.renderIntoDocument(
<MemberEventListSummary {...props} />, <MemberEventListSummary {...props} />,
); );
const summary = ReactTestUtils.findRenderedDOMComponentWithClass( const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
instance, "mx_EventListSummary_summary", instance, "mx_EventListSummary_summary",
); );
const summaryText = summary.textContent; const summaryText = summary.textContent;
expect(summaryText).toBe( expect(summaryText).toBe(
"user_2 was unbanned and joined and left 2 times, user_1 was unbanned, " + "user_2 was unbanned and joined and left 2 times, user_1 was unbanned, " +
"joined and left 2 times and was banned", "joined and left 2 times and was banned",
); );
}, });
);
it('correctly identifies transitions', function() { it('correctly identifies transitions', function() {
const events = generateEvents([ const events = generateEvents([
@ -570,9 +566,8 @@ describe('MemberEventListSummary', function() {
); );
}); });
it('handles invitation plurals correctly when there are multiple invites', it('handles invitation plurals correctly when there are multiple invites', function() {
function() { const events = generateEvents([
const events = generateEvents([
{ {
userId: "@user_1:some.domain", userId: "@user_1:some.domain",
prevMembership: "invite", prevMembership: "invite",
@ -583,28 +578,27 @@ describe('MemberEventListSummary', function() {
prevMembership: "invite", prevMembership: "invite",
membership: "leave", membership: "leave",
}, },
]); ]);
const props = { const props = {
events: events, events: events,
children: generateTiles(events), children: generateTiles(events),
summaryLength: 1, summaryLength: 1,
avatarsMaxLength: 5, avatarsMaxLength: 5,
threshold: 1, // threshold = 1 to force collapse threshold: 1, // threshold = 1 to force collapse
}; };
const instance = ReactTestUtils.renderIntoDocument( const instance = ReactTestUtils.renderIntoDocument(
<MemberEventListSummary {...props} />, <MemberEventListSummary {...props} />,
); );
const summary = ReactTestUtils.findRenderedDOMComponentWithClass( const summary = ReactTestUtils.findRenderedDOMComponentWithClass(
instance, "mx_EventListSummary_summary", instance, "mx_EventListSummary_summary",
); );
const summaryText = summary.textContent; const summaryText = summary.textContent;
expect(summaryText).toBe( expect(summaryText).toBe(
"user_1 rejected their invitation 2 times", "user_1 rejected their invitation 2 times",
); );
}, });
);
it('handles a summary length = 2, with no "others"', function() { it('handles a summary length = 2, with no "others"', function() {
const events = generateEvents([ const events = generateEvents([