2018-03-29 17:55:37 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2018-09-25 19:28:42 +00:00
|
|
|
import {
|
2018-10-23 21:39:48 +00:00
|
|
|
Text, View, ScrollView, TouchableOpacity, Keyboard, Alert
|
2018-09-25 19:28:42 +00:00
|
|
|
} from 'react-native';
|
2018-03-29 17:55:37 +00:00
|
|
|
import { connect } from 'react-redux';
|
2019-03-12 16:23:06 +00:00
|
|
|
import { SafeAreaView } from 'react-navigation';
|
2018-12-21 10:55:35 +00:00
|
|
|
import equal from 'deep-equal';
|
2018-03-29 17:55:37 +00:00
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
import database from '../../lib/database';
|
2018-09-25 19:28:42 +00:00
|
|
|
import { eraseRoom as eraseRoomAction } from '../../actions/room';
|
2018-03-29 17:55:37 +00:00
|
|
|
import KeyboardView from '../../presentation/KeyboardView';
|
|
|
|
import sharedStyles from '../Styles';
|
|
|
|
import styles from './styles';
|
|
|
|
import scrollPersistTaps from '../../utils/scrollPersistTaps';
|
2019-07-23 14:02:57 +00:00
|
|
|
import { showErrorAlert } from '../../utils/info';
|
|
|
|
import { LISTENER } from '../../containers/Toast';
|
|
|
|
import EventEmitter from '../../utils/events';
|
2018-03-29 17:55:37 +00:00
|
|
|
import RocketChat from '../../lib/rocketchat';
|
|
|
|
import RCTextInput from '../../containers/TextInput';
|
2018-04-24 19:34:03 +00:00
|
|
|
import Loading from '../../containers/Loading';
|
2018-03-29 17:55:37 +00:00
|
|
|
import SwitchContainer from './SwitchContainer';
|
|
|
|
import random from '../../utils/random';
|
2018-05-18 17:55:08 +00:00
|
|
|
import log from '../../utils/log';
|
2018-06-01 17:38:13 +00:00
|
|
|
import I18n from '../../i18n';
|
2019-03-12 16:23:06 +00:00
|
|
|
import StatusBar from '../../containers/StatusBar';
|
2018-03-29 17:55:37 +00:00
|
|
|
|
|
|
|
const PERMISSION_SET_READONLY = 'set-readonly';
|
|
|
|
const PERMISSION_SET_REACT_WHEN_READONLY = 'set-react-when-readonly';
|
|
|
|
const PERMISSION_ARCHIVE = 'archive-room';
|
|
|
|
const PERMISSION_UNARCHIVE = 'unarchive-room';
|
|
|
|
const PERMISSION_DELETE_C = 'delete-c';
|
|
|
|
const PERMISSION_DELETE_P = 'delete-p';
|
|
|
|
const PERMISSIONS_ARRAY = [
|
|
|
|
PERMISSION_SET_READONLY,
|
|
|
|
PERMISSION_SET_REACT_WHEN_READONLY,
|
|
|
|
PERMISSION_ARCHIVE,
|
|
|
|
PERMISSION_UNARCHIVE,
|
|
|
|
PERMISSION_DELETE_C,
|
|
|
|
PERMISSION_DELETE_P
|
|
|
|
];
|
|
|
|
|
2019-08-07 13:51:34 +00:00
|
|
|
class RoomInfoEditView extends React.Component {
|
2019-03-12 16:23:06 +00:00
|
|
|
static navigationOptions = {
|
|
|
|
title: I18n.t('Room_Info_Edit')
|
2018-10-23 21:39:48 +00:00
|
|
|
}
|
|
|
|
|
2018-03-29 17:55:37 +00:00
|
|
|
static propTypes = {
|
2019-03-12 16:23:06 +00:00
|
|
|
navigation: PropTypes.object,
|
2018-03-29 17:55:37 +00:00
|
|
|
eraseRoom: PropTypes.func
|
|
|
|
};
|
|
|
|
|
|
|
|
constructor(props) {
|
2019-05-28 13:03:08 +00:00
|
|
|
super(props);
|
2018-03-29 17:55:37 +00:00
|
|
|
this.state = {
|
2019-09-16 20:26:32 +00:00
|
|
|
room: {},
|
|
|
|
permissions: {},
|
2018-03-29 17:55:37 +00:00
|
|
|
name: '',
|
|
|
|
description: '',
|
|
|
|
topic: '',
|
|
|
|
announcement: '',
|
|
|
|
joinCode: '',
|
|
|
|
nameError: {},
|
|
|
|
saving: false,
|
|
|
|
t: false,
|
|
|
|
ro: false,
|
2019-09-16 20:26:32 +00:00
|
|
|
reactWhenReadOnly: false,
|
|
|
|
archived: false
|
2018-03-29 17:55:37 +00:00
|
|
|
};
|
2019-09-16 20:26:32 +00:00
|
|
|
this.loadRoom();
|
2018-03-29 17:55:37 +00:00
|
|
|
}
|
|
|
|
|
2018-12-21 10:55:35 +00:00
|
|
|
shouldComponentUpdate(nextProps, nextState) {
|
|
|
|
if (!equal(nextState, this.state)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!equal(nextProps, this.props)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-03-29 17:55:37 +00:00
|
|
|
componentWillUnmount() {
|
2019-09-16 20:26:32 +00:00
|
|
|
if (this.querySubscription && this.querySubscription.unsubscribe) {
|
|
|
|
this.querySubscription.unsubscribe();
|
|
|
|
}
|
2018-03-29 17:55:37 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
// eslint-disable-next-line react/sort-comp
|
|
|
|
loadRoom = async() => {
|
|
|
|
const { navigation } = this.props;
|
|
|
|
const rid = navigation.getParam('rid', null);
|
|
|
|
if (!rid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
const db = database.active;
|
|
|
|
const sub = await db.collections.get('subscriptions').find(rid);
|
|
|
|
const observable = sub.observe();
|
|
|
|
|
|
|
|
this.querySubscription = observable.subscribe((data) => {
|
|
|
|
this.room = data;
|
|
|
|
this.init(this.room);
|
|
|
|
});
|
|
|
|
|
|
|
|
const permissions = await RocketChat.hasPermission(PERMISSIONS_ARRAY, rid);
|
|
|
|
this.setState({ permissions });
|
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
|
|
|
}
|
2018-03-29 17:55:37 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
init = (room) => {
|
2018-03-29 17:55:37 +00:00
|
|
|
const {
|
|
|
|
name, description, topic, announcement, t, ro, reactWhenReadOnly, joinCodeRequired
|
2018-09-25 19:28:42 +00:00
|
|
|
} = room;
|
2018-03-29 17:55:37 +00:00
|
|
|
// fake password just to user knows about it
|
|
|
|
this.randomValue = random(15);
|
|
|
|
this.setState({
|
2019-09-16 20:26:32 +00:00
|
|
|
room,
|
2018-03-29 17:55:37 +00:00
|
|
|
name,
|
|
|
|
description,
|
|
|
|
topic,
|
|
|
|
announcement,
|
|
|
|
t: t === 'p',
|
|
|
|
ro,
|
|
|
|
reactWhenReadOnly,
|
2019-09-16 20:26:32 +00:00
|
|
|
joinCode: joinCodeRequired ? this.randomValue : '',
|
|
|
|
archived: room.archived
|
2018-03-29 17:55:37 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
clearErrors = () => {
|
|
|
|
this.setState({
|
|
|
|
nameError: {}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
reset = () => {
|
|
|
|
this.clearErrors();
|
2019-09-16 20:26:32 +00:00
|
|
|
this.init(this.room);
|
2018-03-29 17:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
formIsChanged = () => {
|
|
|
|
const {
|
|
|
|
room, name, description, topic, announcement, t, ro, reactWhenReadOnly, joinCode
|
|
|
|
} = this.state;
|
2018-09-25 19:28:42 +00:00
|
|
|
return !(room.name === name
|
|
|
|
&& room.description === description
|
|
|
|
&& room.topic === topic
|
|
|
|
&& room.announcement === announcement
|
|
|
|
&& this.randomValue === joinCode
|
|
|
|
&& room.t === 'p' === t
|
|
|
|
&& room.ro === ro
|
|
|
|
&& room.reactWhenReadOnly === reactWhenReadOnly
|
2018-03-29 17:55:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
submit = async() => {
|
|
|
|
Keyboard.dismiss();
|
|
|
|
const {
|
|
|
|
room, name, description, topic, announcement, t, ro, reactWhenReadOnly, joinCode
|
|
|
|
} = this.state;
|
|
|
|
|
|
|
|
this.setState({ saving: true });
|
|
|
|
let error = false;
|
|
|
|
|
|
|
|
if (!this.formIsChanged()) {
|
2018-06-01 17:38:13 +00:00
|
|
|
showErrorAlert(I18n.t('Nothing_to_save'));
|
2018-03-29 17:55:37 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear error objects
|
|
|
|
await this.clearErrors();
|
|
|
|
|
|
|
|
const params = {};
|
|
|
|
|
|
|
|
// Name
|
|
|
|
if (room.name !== name) {
|
|
|
|
params.roomName = name;
|
|
|
|
}
|
|
|
|
// Description
|
|
|
|
if (room.description !== description) {
|
|
|
|
params.roomDescription = description;
|
|
|
|
}
|
|
|
|
// Topic
|
|
|
|
if (room.topic !== topic) {
|
|
|
|
params.roomTopic = topic;
|
|
|
|
}
|
|
|
|
// Announcement
|
|
|
|
if (room.announcement !== announcement) {
|
|
|
|
params.roomAnnouncement = announcement;
|
|
|
|
}
|
|
|
|
// Room Type
|
|
|
|
if (room.t !== t) {
|
|
|
|
params.roomType = t ? 'p' : 'c';
|
|
|
|
}
|
|
|
|
// Read Only
|
|
|
|
if (room.ro !== ro) {
|
|
|
|
params.readOnly = ro;
|
|
|
|
}
|
|
|
|
// React When Read Only
|
|
|
|
if (room.reactWhenReadOnly !== reactWhenReadOnly) {
|
|
|
|
params.reactWhenReadOnly = reactWhenReadOnly;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Join Code
|
|
|
|
if (this.randomValue !== joinCode) {
|
|
|
|
params.joinCode = joinCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
await RocketChat.saveRoomSettings(room.rid, params);
|
|
|
|
} catch (e) {
|
|
|
|
if (e.error === 'error-invalid-room-name') {
|
|
|
|
this.setState({ nameError: e });
|
|
|
|
}
|
|
|
|
error = true;
|
2019-08-23 13:18:47 +00:00
|
|
|
log(e);
|
2018-03-29 17:55:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
await this.setState({ saving: false });
|
|
|
|
setTimeout(() => {
|
|
|
|
if (error) {
|
2018-06-13 01:33:00 +00:00
|
|
|
showErrorAlert(I18n.t('There_was_an_error_while_action', { action: I18n.t('saving_settings') }));
|
2018-03-29 17:55:37 +00:00
|
|
|
} else {
|
2019-07-23 14:02:57 +00:00
|
|
|
EventEmitter.emit(LISTENER, { message: I18n.t('Settings_succesfully_changed') });
|
2018-03-29 17:55:37 +00:00
|
|
|
}
|
|
|
|
}, 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
delete = () => {
|
2018-09-25 19:28:42 +00:00
|
|
|
const { room } = this.state;
|
|
|
|
const { eraseRoom } = this.props;
|
|
|
|
|
2018-03-29 17:55:37 +00:00
|
|
|
Alert.alert(
|
2018-06-01 17:38:13 +00:00
|
|
|
I18n.t('Are_you_sure_question_mark'),
|
|
|
|
I18n.t('Delete_Room_Warning'),
|
2018-03-29 17:55:37 +00:00
|
|
|
[
|
|
|
|
{
|
2018-06-01 17:38:13 +00:00
|
|
|
text: I18n.t('Cancel'),
|
2018-03-29 17:55:37 +00:00
|
|
|
style: 'cancel'
|
|
|
|
},
|
|
|
|
{
|
2018-06-01 17:38:13 +00:00
|
|
|
text: I18n.t('Yes_action_it', { action: I18n.t('delete') }),
|
2018-03-29 17:55:37 +00:00
|
|
|
style: 'destructive',
|
2018-12-12 15:15:10 +00:00
|
|
|
onPress: () => eraseRoom(room.rid, room.t)
|
2018-03-29 17:55:37 +00:00
|
|
|
}
|
|
|
|
],
|
|
|
|
{ cancelable: false }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleArchive = () => {
|
2018-09-25 19:28:42 +00:00
|
|
|
const { room } = this.state;
|
2018-12-12 15:15:10 +00:00
|
|
|
const { rid, archived, t } = room;
|
2018-09-25 19:28:42 +00:00
|
|
|
|
2018-06-01 17:38:13 +00:00
|
|
|
const action = I18n.t(`${ archived ? 'un' : '' }archive`);
|
2018-03-29 17:55:37 +00:00
|
|
|
Alert.alert(
|
2018-06-01 17:38:13 +00:00
|
|
|
I18n.t('Are_you_sure_question_mark'),
|
|
|
|
I18n.t('Do_you_really_want_to_key_this_room_question_mark', { key: action }),
|
2018-03-29 17:55:37 +00:00
|
|
|
[
|
|
|
|
{
|
2018-06-01 17:38:13 +00:00
|
|
|
text: I18n.t('Cancel'),
|
2018-03-29 17:55:37 +00:00
|
|
|
style: 'cancel'
|
|
|
|
},
|
|
|
|
{
|
2018-06-01 17:38:13 +00:00
|
|
|
text: I18n.t('Yes_action_it', { action }),
|
2018-03-29 17:55:37 +00:00
|
|
|
style: 'destructive',
|
2018-12-12 15:15:10 +00:00
|
|
|
onPress: async() => {
|
2018-03-29 17:55:37 +00:00
|
|
|
try {
|
2018-12-12 15:15:10 +00:00
|
|
|
await RocketChat.toggleArchiveRoom(rid, t, !archived);
|
2018-05-18 17:55:08 +00:00
|
|
|
} catch (e) {
|
2019-08-23 13:18:47 +00:00
|
|
|
log(e);
|
2018-03-29 17:55:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
{ cancelable: false }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
hasDeletePermission = () => {
|
2019-09-16 20:26:32 +00:00
|
|
|
const { room, permissions } = this.state;
|
2018-09-25 19:28:42 +00:00
|
|
|
return (
|
2019-09-16 20:26:32 +00:00
|
|
|
room.t === 'p' ? permissions[PERMISSION_DELETE_P] : permissions[PERMISSION_DELETE_C]
|
2018-09-25 19:28:42 +00:00
|
|
|
);
|
|
|
|
}
|
2018-03-29 17:55:37 +00:00
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
hasArchivePermission = () => {
|
|
|
|
const { permissions } = this.state;
|
|
|
|
return (permissions[PERMISSION_ARCHIVE] || permissions[PERMISSION_UNARCHIVE]);
|
|
|
|
};
|
2018-03-29 17:55:37 +00:00
|
|
|
|
|
|
|
render() {
|
|
|
|
const {
|
2019-09-16 20:26:32 +00:00
|
|
|
name, nameError, description, topic, announcement, t, ro, reactWhenReadOnly, room, joinCode, saving, permissions, archived
|
2018-03-29 17:55:37 +00:00
|
|
|
} = this.state;
|
|
|
|
return (
|
|
|
|
<KeyboardView
|
|
|
|
contentContainerStyle={sharedStyles.container}
|
|
|
|
keyboardVerticalOffset={128}
|
|
|
|
>
|
2019-03-12 16:23:06 +00:00
|
|
|
<StatusBar />
|
2018-05-23 13:39:18 +00:00
|
|
|
<ScrollView
|
|
|
|
contentContainerStyle={sharedStyles.containerScrollView}
|
|
|
|
testID='room-info-edit-view-list'
|
|
|
|
{...scrollPersistTaps}
|
|
|
|
>
|
2019-08-07 13:51:34 +00:00
|
|
|
<SafeAreaView style={sharedStyles.container} testID='room-info-edit-view' forceInset={{ vertical: 'never' }}>
|
2018-06-13 01:33:00 +00:00
|
|
|
<RCTextInput
|
|
|
|
inputRef={(e) => { this.name = e; }}
|
|
|
|
label={I18n.t('Name')}
|
|
|
|
value={name}
|
|
|
|
onChangeText={value => this.setState({ name: value })}
|
|
|
|
onSubmitEditing={() => { this.description.focus(); }}
|
|
|
|
error={nameError}
|
|
|
|
testID='room-info-edit-view-name'
|
|
|
|
/>
|
|
|
|
<RCTextInput
|
|
|
|
inputRef={(e) => { this.description = e; }}
|
|
|
|
label={I18n.t('Description')}
|
|
|
|
value={description}
|
|
|
|
onChangeText={value => this.setState({ description: value })}
|
|
|
|
onSubmitEditing={() => { this.topic.focus(); }}
|
|
|
|
testID='room-info-edit-view-description'
|
|
|
|
/>
|
|
|
|
<RCTextInput
|
|
|
|
inputRef={(e) => { this.topic = e; }}
|
|
|
|
label={I18n.t('Topic')}
|
|
|
|
value={topic}
|
|
|
|
onChangeText={value => this.setState({ topic: value })}
|
|
|
|
onSubmitEditing={() => { this.announcement.focus(); }}
|
|
|
|
testID='room-info-edit-view-topic'
|
|
|
|
/>
|
|
|
|
<RCTextInput
|
|
|
|
inputRef={(e) => { this.announcement = e; }}
|
|
|
|
label={I18n.t('Announcement')}
|
|
|
|
value={announcement}
|
|
|
|
onChangeText={value => this.setState({ announcement: value })}
|
|
|
|
onSubmitEditing={() => { this.joinCode.focus(); }}
|
|
|
|
testID='room-info-edit-view-announcement'
|
|
|
|
/>
|
|
|
|
<RCTextInput
|
|
|
|
inputRef={(e) => { this.joinCode = e; }}
|
|
|
|
label={I18n.t('Password')}
|
|
|
|
value={joinCode}
|
|
|
|
onChangeText={value => this.setState({ joinCode: value })}
|
|
|
|
onSubmitEditing={this.submit}
|
|
|
|
secureTextEntry
|
|
|
|
testID='room-info-edit-view-password'
|
|
|
|
/>
|
|
|
|
<SwitchContainer
|
|
|
|
value={t}
|
|
|
|
leftLabelPrimary={I18n.t('Public')}
|
|
|
|
leftLabelSecondary={I18n.t('Everyone_can_access_this_channel')}
|
|
|
|
rightLabelPrimary={I18n.t('Private')}
|
|
|
|
rightLabelSecondary={I18n.t('Just_invited_people_can_access_this_channel')}
|
|
|
|
onValueChange={value => this.setState({ t: value })}
|
|
|
|
testID='room-info-edit-view-t'
|
|
|
|
/>
|
|
|
|
<SwitchContainer
|
|
|
|
value={ro}
|
2018-10-24 19:10:44 +00:00
|
|
|
leftLabelPrimary={I18n.t('Collaborative')}
|
2018-06-13 01:33:00 +00:00
|
|
|
leftLabelSecondary={I18n.t('All_users_in_the_channel_can_write_new_messages')}
|
|
|
|
rightLabelPrimary={I18n.t('Read_Only')}
|
|
|
|
rightLabelSecondary={I18n.t('Only_authorized_users_can_write_new_messages')}
|
|
|
|
onValueChange={value => this.setState({ ro: value })}
|
2019-09-16 20:26:32 +00:00
|
|
|
disabled={!permissions[PERMISSION_SET_READONLY] || room.broadcast}
|
2018-06-13 01:33:00 +00:00
|
|
|
testID='room-info-edit-view-ro'
|
|
|
|
/>
|
2018-09-25 19:28:42 +00:00
|
|
|
{ro && !room.broadcast
|
|
|
|
? (
|
|
|
|
<SwitchContainer
|
|
|
|
value={reactWhenReadOnly}
|
|
|
|
leftLabelPrimary={I18n.t('No_Reactions')}
|
|
|
|
leftLabelSecondary={I18n.t('Reactions_are_disabled')}
|
|
|
|
rightLabelPrimary={I18n.t('Allow_Reactions')}
|
|
|
|
rightLabelSecondary={I18n.t('Reactions_are_enabled')}
|
|
|
|
onValueChange={value => this.setState({ reactWhenReadOnly: value })}
|
2019-09-16 20:26:32 +00:00
|
|
|
disabled={!permissions[PERMISSION_SET_REACT_WHEN_READONLY]}
|
2018-09-25 19:28:42 +00:00
|
|
|
testID='room-info-edit-view-react-when-ro'
|
|
|
|
/>
|
|
|
|
)
|
2018-06-13 01:33:00 +00:00
|
|
|
: null
|
|
|
|
}
|
2018-09-25 19:28:42 +00:00
|
|
|
{room.broadcast
|
|
|
|
? [
|
2018-06-13 01:33:00 +00:00
|
|
|
<Text style={styles.broadcast}>{I18n.t('Broadcast_Channel')}</Text>,
|
|
|
|
<View style={styles.divider} />
|
|
|
|
]
|
|
|
|
: null
|
|
|
|
}
|
|
|
|
<TouchableOpacity
|
|
|
|
style={[sharedStyles.buttonContainer, !this.formIsChanged() && styles.buttonContainerDisabled]}
|
|
|
|
onPress={this.submit}
|
|
|
|
disabled={!this.formIsChanged()}
|
|
|
|
testID='room-info-edit-view-submit'
|
|
|
|
>
|
|
|
|
<Text style={sharedStyles.button} accessibilityTraits='button'>{I18n.t('SAVE')}</Text>
|
|
|
|
</TouchableOpacity>
|
|
|
|
<View style={{ flexDirection: 'row' }}>
|
2018-03-29 17:55:37 +00:00
|
|
|
<TouchableOpacity
|
2018-06-13 01:33:00 +00:00
|
|
|
style={[sharedStyles.buttonContainer_inverted, styles.buttonInverted, { flex: 1 }]}
|
|
|
|
onPress={this.reset}
|
|
|
|
testID='room-info-edit-view-reset'
|
2018-03-29 17:55:37 +00:00
|
|
|
>
|
2018-06-13 01:33:00 +00:00
|
|
|
<Text style={sharedStyles.button_inverted} accessibilityTraits='button'>{I18n.t('RESET')}</Text>
|
2018-03-29 17:55:37 +00:00
|
|
|
</TouchableOpacity>
|
|
|
|
<TouchableOpacity
|
|
|
|
style={[
|
|
|
|
sharedStyles.buttonContainer_inverted,
|
|
|
|
styles.buttonDanger,
|
2018-06-13 01:33:00 +00:00
|
|
|
!this.hasArchivePermission() && sharedStyles.opacity5,
|
|
|
|
{ flex: 1, marginLeft: 10 }
|
2018-03-29 17:55:37 +00:00
|
|
|
]}
|
2018-06-13 01:33:00 +00:00
|
|
|
onPress={this.toggleArchive}
|
|
|
|
disabled={!this.hasArchivePermission()}
|
|
|
|
testID='room-info-edit-view-archive'
|
2018-03-29 17:55:37 +00:00
|
|
|
>
|
2018-06-13 01:33:00 +00:00
|
|
|
<Text style={[sharedStyles.button_inverted, styles.colorDanger]} accessibilityTraits='button'>
|
2019-09-16 20:26:32 +00:00
|
|
|
{ archived ? I18n.t('UNARCHIVE') : I18n.t('ARCHIVE') }
|
2018-06-13 01:33:00 +00:00
|
|
|
</Text>
|
2018-03-29 17:55:37 +00:00
|
|
|
</TouchableOpacity>
|
|
|
|
</View>
|
2018-06-13 01:33:00 +00:00
|
|
|
<View style={styles.divider} />
|
|
|
|
<TouchableOpacity
|
|
|
|
style={[
|
|
|
|
sharedStyles.buttonContainer_inverted,
|
|
|
|
sharedStyles.buttonContainerLastChild,
|
|
|
|
styles.buttonDanger,
|
|
|
|
!this.hasDeletePermission() && sharedStyles.opacity5
|
|
|
|
]}
|
|
|
|
onPress={this.delete}
|
|
|
|
disabled={!this.hasDeletePermission()}
|
|
|
|
testID='room-info-edit-view-delete'
|
|
|
|
>
|
|
|
|
<Text style={[sharedStyles.button_inverted, styles.colorDanger]} accessibilityTraits='button'>{I18n.t('DELETE')}</Text>
|
|
|
|
</TouchableOpacity>
|
2018-09-25 19:28:42 +00:00
|
|
|
<Loading visible={saving} />
|
2018-03-29 17:55:37 +00:00
|
|
|
</SafeAreaView>
|
|
|
|
</ScrollView>
|
|
|
|
</KeyboardView>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-08-07 13:51:34 +00:00
|
|
|
|
|
|
|
const mapDispatchToProps = dispatch => ({
|
|
|
|
eraseRoom: (rid, t) => dispatch(eraseRoomAction(rid, t))
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(null, mapDispatchToProps)(RoomInfoEditView);
|