Convert UrlPreviewSettings to TS
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
a43e3450a5
commit
6f004d219c
1 changed files with 12 additions and 13 deletions
|
@ -18,8 +18,6 @@ limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import * as sdk from "../../../index";
|
|
||||||
import { _t, _td } from '../../../languageHandler';
|
import { _t, _td } from '../../../languageHandler';
|
||||||
import SettingsStore from "../../../settings/SettingsStore";
|
import SettingsStore from "../../../settings/SettingsStore";
|
||||||
import dis from "../../../dispatcher/dispatcher";
|
import dis from "../../../dispatcher/dispatcher";
|
||||||
|
@ -27,21 +25,22 @@ import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||||
import { Action } from "../../../dispatcher/actions";
|
import { Action } from "../../../dispatcher/actions";
|
||||||
import { SettingLevel } from "../../../settings/SettingLevel";
|
import { SettingLevel } from "../../../settings/SettingLevel";
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
|
import SettingsFlag from "../elements/SettingsFlag";
|
||||||
|
|
||||||
|
interface IProps {
|
||||||
|
room: Room;
|
||||||
|
}
|
||||||
|
|
||||||
@replaceableComponent("views.room_settings.UrlPreviewSettings")
|
@replaceableComponent("views.room_settings.UrlPreviewSettings")
|
||||||
export default class UrlPreviewSettings extends React.Component {
|
export default class UrlPreviewSettings extends React.Component<IProps> {
|
||||||
static propTypes = {
|
private onClickUserSettings = (e: React.MouseEvent): void => {
|
||||||
room: PropTypes.object,
|
|
||||||
};
|
|
||||||
|
|
||||||
_onClickUserSettings = (e) => {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
dis.fire(Action.ViewUserSettings);
|
dis.fire(Action.ViewUserSettings);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
public render(): JSX.Element {
|
||||||
const SettingsFlag = sdk.getComponent("elements.SettingsFlag");
|
|
||||||
const roomId = this.props.room.roomId;
|
const roomId = this.props.room.roomId;
|
||||||
const isEncrypted = MatrixClientPeg.get().isRoomEncrypted(roomId);
|
const isEncrypted = MatrixClientPeg.get().isRoomEncrypted(roomId);
|
||||||
|
|
||||||
|
@ -54,18 +53,18 @@ export default class UrlPreviewSettings extends React.Component {
|
||||||
if (accountEnabled) {
|
if (accountEnabled) {
|
||||||
previewsForAccount = (
|
previewsForAccount = (
|
||||||
_t("You have <a>enabled</a> URL previews by default.", {}, {
|
_t("You have <a>enabled</a> URL previews by default.", {}, {
|
||||||
'a': (sub)=><a onClick={this._onClickUserSettings} href=''>{ sub }</a>,
|
'a': (sub)=><a onClick={this.onClickUserSettings} href=''>{ sub }</a>,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
previewsForAccount = (
|
previewsForAccount = (
|
||||||
_t("You have <a>disabled</a> URL previews by default.", {}, {
|
_t("You have <a>disabled</a> URL previews by default.", {}, {
|
||||||
'a': (sub)=><a onClick={this._onClickUserSettings} href=''>{ sub }</a>,
|
'a': (sub)=><a onClick={this.onClickUserSettings} href=''>{ sub }</a>,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SettingsStore.canSetValue("urlPreviewsEnabled", roomId, "room")) {
|
if (SettingsStore.canSetValue("urlPreviewsEnabled", roomId, SettingLevel.ROOM)) {
|
||||||
previewsForRoom = (
|
previewsForRoom = (
|
||||||
<label>
|
<label>
|
||||||
<SettingsFlag
|
<SettingsFlag
|
Loading…
Reference in a new issue