Add a developer mode 'view source' button to crashed event tiles (#7537)

* Add a developer mode 'view source' button to crashed event tiles

* appease the linter
This commit is contained in:
Travis Ralston 2022-01-14 07:43:13 -07:00 committed by GitHub
parent 52dd590b49
commit aa4131ed2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
/*
Copyright 2020 - 2021 The Matrix.org Foundation C.I.C.
Copyright 2020 - 2022 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.
@ -24,6 +24,8 @@ import SdkConfig from "../../../SdkConfig";
import { replaceableComponent } from "../../../utils/replaceableComponent";
import BugReportDialog from '../dialogs/BugReportDialog';
import AccessibleButton from '../elements/AccessibleButton';
import SettingsStore from "../../../settings/SettingsStore";
import ViewSource from "../../structures/ViewSource";
interface IProps {
mxEvent: MatrixEvent;
@ -56,6 +58,12 @@ export default class TileErrorBoundary extends React.Component<IProps, IState> {
});
};
private onViewSource = (): void => {
Modal.createTrackedDialog('View Event Source', 'from crash', ViewSource, {
mxEvent: this.props.mxEvent,
}, 'mx_Dialog_viewsource');
};
render() {
if (this.state.error) {
const { mxEvent } = this.props;
@ -73,12 +81,20 @@ export default class TileErrorBoundary extends React.Component<IProps, IState> {
</AccessibleButton>;
}
let viewSourceButton;
if (mxEvent && SettingsStore.getValue("developerMode")) {
viewSourceButton = <AccessibleButton onClick={this.onViewSource} kind="link_inline">
{ _t("View Source") }
</AccessibleButton>;
}
return (<div className={classNames(classes)}>
<div className="mx_EventTile_line">
<span>
{ _t("Can't load this message") }
{ mxEvent && ` (${mxEvent.getType()})` }
{ submitLogsButton }
{ viewSourceButton }
</span>
</div>
</div>);