* add link_inline accessiblebutton variant * valid anchors in SecurityRoomSettingsTab Signed-off-by: Kerry Archibald <kerrya@element.io> * new room intro link button Signed-off-by: Kerry Archibald <kerrya@element.io> * replace anchor with button in rerequest encryption keys message Signed-off-by: Kerry Archibald <kerrya@element.io> * inline button in UrlPreviewSettings Signed-off-by: Kerry Archibald <kerrya@element.io> * ButtonResetDefault mixin Signed-off-by: Kerry Archibald <kerrya@element.io> * inline link buttons in TextForEvent Signed-off-by: Kerry Archibald <kerrya@element.io> * fix anchors in InviteDialog Signed-off-by: Kerry Archibald <kerrya@element.io> * fix anchors in DevToolsDialog Signed-off-by: Kerry Archibald <kerrya@element.io> * fix anchors in login/registration/reset pword flows Signed-off-by: Kerry Archibald <kerrya@element.io> * fix types after fixing anchors in devtools Signed-off-by: Kerry Archibald <kerrya@element.io> * fix anchors in MemberEventListSummary Signed-off-by: Kerry Archibald <kerrya@element.io> * fix anchors in ReactionsRow and RoomUpgrade Signed-off-by: Kerry Archibald <kerrya@element.io> * fix anchors in ReplyChain Signed-off-by: Kerry Archibald <kerrya@element.io> * fix more anchors Signed-off-by: Kerry Archibald <kerrya@element.io> * fix anchors in auth comps * stylelint fixes Signed-off-by: Kerry Archibald <kerrya@element.io> * remove ignore of jsx-a11y rule that is not added yet Signed-off-by: Kerry Archibald <kerrya@element.io> * devtools style important explainer Signed-off-by: Kerry Archibald <kerrya@element.io> * translate button alt in devtools dialog Signed-off-by: Kerry Archibald <kerrya@element.io> * AccessibleButton is reactionsrow Signed-off-by: Kerry Archibald <kerrya@element.io> * fix viewsourcevent button placement, use AccessibleButton Signed-off-by: Kerry Archibald <kerrya@element.io> * use AccessibleButton in EventTile Signed-off-by: Kerry Archibald <kerrya@element.io> * unignore jsx-a11y/anchor-is-valid Signed-off-by: Kerry Archibald <kerrya@element.io> * fix lint issue in test jsx Signed-off-by: Kerry Archibald <kerrya@element.io> * update coment Signed-off-by: Kerry Archibald <kerrya@element.io>
90 lines
2.8 KiB
TypeScript
90 lines
2.8 KiB
TypeScript
/*
|
|
Copyright 2020 - 2021 The Matrix.org Foundation C.I.C.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
import React from 'react';
|
|
import classNames from 'classnames';
|
|
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
|
|
|
import { _t } from '../../../languageHandler';
|
|
import Modal from '../../../Modal';
|
|
import SdkConfig from "../../../SdkConfig";
|
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
|
import BugReportDialog from '../dialogs/BugReportDialog';
|
|
import AccessibleButton from '../elements/AccessibleButton';
|
|
|
|
interface IProps {
|
|
mxEvent: MatrixEvent;
|
|
}
|
|
|
|
interface IState {
|
|
error: Error;
|
|
}
|
|
|
|
@replaceableComponent("views.messages.TileErrorBoundary")
|
|
export default class TileErrorBoundary extends React.Component<IProps, IState> {
|
|
constructor(props) {
|
|
super(props);
|
|
|
|
this.state = {
|
|
error: null,
|
|
};
|
|
}
|
|
|
|
static getDerivedStateFromError(error: Error): Partial<IState> {
|
|
// Side effects are not permitted here, so we only update the state so
|
|
// that the next render shows an error message.
|
|
return { error };
|
|
}
|
|
|
|
private onBugReport = (): void => {
|
|
Modal.createTrackedDialog('Bug Report Dialog', '', BugReportDialog, {
|
|
label: 'react-soft-crash-tile',
|
|
error: this.state.error,
|
|
});
|
|
};
|
|
|
|
render() {
|
|
if (this.state.error) {
|
|
const { mxEvent } = this.props;
|
|
const classes = {
|
|
mx_EventTile: true,
|
|
mx_EventTile_info: true,
|
|
mx_EventTile_content: true,
|
|
mx_EventTile_tileError: true,
|
|
};
|
|
|
|
let submitLogsButton;
|
|
if (SdkConfig.get().bug_report_endpoint_url) {
|
|
submitLogsButton = <AccessibleButton kind="link_inline" onClick={this.onBugReport}>
|
|
{ _t("Submit logs") }
|
|
</AccessibleButton>;
|
|
}
|
|
|
|
return (<div className={classNames(classes)}>
|
|
<div className="mx_EventTile_line">
|
|
<span>
|
|
{ _t("Can't load this message") }
|
|
{ mxEvent && ` (${mxEvent.getType()})` }
|
|
{ submitLogsButton }
|
|
</span>
|
|
</div>
|
|
</div>);
|
|
}
|
|
|
|
return this.props.children;
|
|
}
|
|
}
|