mirror of
https://github.com/element-hq/element-web
synced 2024-11-26 19:26:04 +03:00
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:
parent
52dd590b49
commit
aa4131ed2e
1 changed files with 17 additions and 1 deletions
|
@ -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>);
|
||||
|
|
Loading…
Reference in a new issue