fix: show edit button only if you have permission
This commit is contained in:
parent
29b95e6083
commit
df52ec28d6
1 changed files with 3 additions and 1 deletions
|
@ -23,6 +23,7 @@ import { _t } from "../../languageHandler";
|
||||||
import * as sdk from "../../index";
|
import * as sdk from "../../index";
|
||||||
import MatrixClientContext from "../../contexts/MatrixClientContext";
|
import MatrixClientContext from "../../contexts/MatrixClientContext";
|
||||||
import { SendCustomEvent } from "../views/dialogs/DevtoolsDialog";
|
import { SendCustomEvent } from "../views/dialogs/DevtoolsDialog";
|
||||||
|
import { canEditContent } from "../../utils/EventUtils";
|
||||||
|
|
||||||
export default class ViewSource extends React.Component {
|
export default class ViewSource extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -162,6 +163,7 @@ export default class ViewSource extends React.Component {
|
||||||
const isEditing = this.state.isEditing;
|
const isEditing = this.state.isEditing;
|
||||||
const roomId = mxEvent.getRoomId();
|
const roomId = mxEvent.getRoomId();
|
||||||
const eventId = mxEvent.getId();
|
const eventId = mxEvent.getId();
|
||||||
|
const canEdit = canEditContent(this.props.mxEvent);
|
||||||
return (
|
return (
|
||||||
<BaseDialog className="mx_ViewSource" onFinished={this.props.onFinished} title={_t("View Source")}>
|
<BaseDialog className="mx_ViewSource" onFinished={this.props.onFinished} title={_t("View Source")}>
|
||||||
<div>
|
<div>
|
||||||
|
@ -170,7 +172,7 @@ export default class ViewSource extends React.Component {
|
||||||
<div className="mx_ViewSource_separator" />
|
<div className="mx_ViewSource_separator" />
|
||||||
{isEditing ? this.editSourceContent() : this.viewSourceContent()}
|
{isEditing ? this.editSourceContent() : this.viewSourceContent()}
|
||||||
</div>
|
</div>
|
||||||
{!isEditing && (
|
{!isEditing && canEdit && (
|
||||||
<div className="mx_Dialog_buttons">
|
<div className="mx_Dialog_buttons">
|
||||||
<button onClick={() => this.onEdit()}>{_t("Edit")}</button>
|
<button onClick={() => this.onEdit()}>{_t("Edit")}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue