Added actionTypes, actions, ENG strings for Teams and updated NewMessageView
This commit is contained in:
parent
585a9aea9a
commit
8b82bd456e
|
@ -38,6 +38,7 @@ export const INQUIRY = createRequestTypes('INQUIRY', [...defaultTypes, 'SET_ENAB
|
||||||
export const APP = createRequestTypes('APP', ['START', 'READY', 'INIT', 'INIT_LOCAL_SETTINGS', 'SET_MASTER_DETAIL']);
|
export const APP = createRequestTypes('APP', ['START', 'READY', 'INIT', 'INIT_LOCAL_SETTINGS', 'SET_MASTER_DETAIL']);
|
||||||
export const MESSAGES = createRequestTypes('MESSAGES', ['REPLY_BROADCAST']);
|
export const MESSAGES = createRequestTypes('MESSAGES', ['REPLY_BROADCAST']);
|
||||||
export const CREATE_CHANNEL = createRequestTypes('CREATE_CHANNEL', [...defaultTypes]);
|
export const CREATE_CHANNEL = createRequestTypes('CREATE_CHANNEL', [...defaultTypes]);
|
||||||
|
export const CREATE_TEAM = createRequestTypes('CREATE_TEAM', [...defaultTypes]);
|
||||||
export const CREATE_DISCUSSION = createRequestTypes('CREATE_DISCUSSION', [...defaultTypes]);
|
export const CREATE_DISCUSSION = createRequestTypes('CREATE_DISCUSSION', [...defaultTypes]);
|
||||||
export const SELECTED_USERS = createRequestTypes('SELECTED_USERS', ['ADD_USER', 'REMOVE_USER', 'RESET', 'SET_LOADING']);
|
export const SELECTED_USERS = createRequestTypes('SELECTED_USERS', ['ADD_USER', 'REMOVE_USER', 'RESET', 'SET_LOADING']);
|
||||||
export const SERVER = createRequestTypes('SERVER', [
|
export const SERVER = createRequestTypes('SERVER', [
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import * as types from './actionsTypes';
|
||||||
|
|
||||||
|
export function createTeamRequest(data) {
|
||||||
|
return {
|
||||||
|
type: types.CREATE_TEAM.REQUEST,
|
||||||
|
data
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createTeamSuccess(data) {
|
||||||
|
return {
|
||||||
|
type: types.CREATE_TEAM.SUCCESS,
|
||||||
|
data
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createTeamFailure(err) {
|
||||||
|
return {
|
||||||
|
type: types.CREATE_TEAM.FAILURE,
|
||||||
|
err
|
||||||
|
};
|
||||||
|
}
|
|
@ -711,5 +711,8 @@
|
||||||
"No_team_channels_found": "No channels found",
|
"No_team_channels_found": "No channels found",
|
||||||
"Team_not_found": "Team not found",
|
"Team_not_found": "Team not found",
|
||||||
"Create_Team": "Create Team",
|
"Create_Team": "Create Team",
|
||||||
"Team_Name": "Team Name"
|
"Team_Name": "Team Name",
|
||||||
|
"Private_Team": "Private Team",
|
||||||
|
"Read_Only_Team": "Read Only Team",
|
||||||
|
"Broadcast_Team": "Broadcast Team"
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import * as List from '../containers/List';
|
||||||
import TextInput from '../presentation/TextInput';
|
import TextInput from '../presentation/TextInput';
|
||||||
import Loading from '../containers/Loading';
|
import Loading from '../containers/Loading';
|
||||||
import { createChannelRequest as createChannelRequestAction } from '../actions/createChannel';
|
import { createChannelRequest as createChannelRequestAction } from '../actions/createChannel';
|
||||||
|
import { createTeamRequest as createTeamRequestAction } from '../actions/createTeam';
|
||||||
import { removeUser as removeUserAction } from '../actions/selectedUsers';
|
import { removeUser as removeUserAction } from '../actions/selectedUsers';
|
||||||
import sharedStyles from './Styles';
|
import sharedStyles from './Styles';
|
||||||
import KeyboardView from '../presentation/KeyboardView';
|
import KeyboardView from '../presentation/KeyboardView';
|
||||||
|
@ -68,15 +69,16 @@ const styles = StyleSheet.create({
|
||||||
});
|
});
|
||||||
|
|
||||||
class CreateChannelView extends React.Component {
|
class CreateChannelView extends React.Component {
|
||||||
static navigationOptions = () => ({
|
static navigationOptions = ({ route }) => ({
|
||||||
title: this.props?.route?.params?.isTeam ? I18n.t('Create_Team') : I18n.t('Create_Channel')
|
title: route?.params?.isTeam ? I18n.t('Create_Team') : I18n.t('Create_Channel')
|
||||||
})
|
})
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
navigation: PropTypes.object,
|
navigation: PropTypes.object,
|
||||||
route: PropTypes.object,
|
route: PropTypes.object,
|
||||||
baseUrl: PropTypes.string,
|
baseUrl: PropTypes.string,
|
||||||
create: PropTypes.func.isRequired,
|
createChannel: PropTypes.func.isRequired,
|
||||||
|
createTeam: PropTypes.func.isRequired,
|
||||||
removeUser: PropTypes.func.isRequired,
|
removeUser: PropTypes.func.isRequired,
|
||||||
error: PropTypes.object,
|
error: PropTypes.object,
|
||||||
failure: PropTypes.bool,
|
failure: PropTypes.bool,
|
||||||
|
@ -155,7 +157,10 @@ class CreateChannelView extends React.Component {
|
||||||
const {
|
const {
|
||||||
channelName, type, readOnly, broadcast, encrypted
|
channelName, type, readOnly, broadcast, encrypted
|
||||||
} = this.state;
|
} = this.state;
|
||||||
const { users: usersProps, isFetching, create } = this.props;
|
const {
|
||||||
|
users: usersProps, isFetching, createTeam, createChannel, route
|
||||||
|
} = this.props;
|
||||||
|
const { isTeam } = route?.params;
|
||||||
|
|
||||||
if (!channelName.trim() || isFetching) {
|
if (!channelName.trim() || isFetching) {
|
||||||
return;
|
return;
|
||||||
|
@ -164,10 +169,17 @@ class CreateChannelView extends React.Component {
|
||||||
// transform users object into array of usernames
|
// transform users object into array of usernames
|
||||||
const users = usersProps.map(user => user.name);
|
const users = usersProps.map(user => user.name);
|
||||||
|
|
||||||
// create channel
|
if (isTeam) {
|
||||||
create({
|
// create team
|
||||||
|
createTeam({
|
||||||
name: channelName, users, type, readOnly, broadcast, encrypted
|
name: channelName, users, type, readOnly, broadcast, encrypted
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// create channel
|
||||||
|
createChannel({
|
||||||
|
name: channelName, users, type, readOnly, broadcast, encrypted
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Review.pushPositiveEvent();
|
Review.pushPositiveEvent();
|
||||||
}
|
}
|
||||||
|
@ -198,10 +210,13 @@ class CreateChannelView extends React.Component {
|
||||||
|
|
||||||
renderType() {
|
renderType() {
|
||||||
const { type } = this.state;
|
const { type } = this.state;
|
||||||
|
const { route } = this.props;
|
||||||
|
const { isTeam } = route?.params;
|
||||||
|
|
||||||
return this.renderSwitch({
|
return this.renderSwitch({
|
||||||
id: 'type',
|
id: 'type',
|
||||||
value: type,
|
value: type,
|
||||||
label: 'Private_Channel',
|
label: isTeam ? 'Private_Team' : 'Private_Channel',
|
||||||
onValueChange: (value) => {
|
onValueChange: (value) => {
|
||||||
logEvent(events.CR_TOGGLE_TYPE);
|
logEvent(events.CR_TOGGLE_TYPE);
|
||||||
// If we set the channel as public, encrypted status should be false
|
// If we set the channel as public, encrypted status should be false
|
||||||
|
@ -212,10 +227,13 @@ class CreateChannelView extends React.Component {
|
||||||
|
|
||||||
renderReadOnly() {
|
renderReadOnly() {
|
||||||
const { readOnly, broadcast } = this.state;
|
const { readOnly, broadcast } = this.state;
|
||||||
|
const { route } = this.props;
|
||||||
|
const { isTeam } = route?.params;
|
||||||
|
|
||||||
return this.renderSwitch({
|
return this.renderSwitch({
|
||||||
id: 'readonly',
|
id: 'readonly',
|
||||||
value: readOnly,
|
value: readOnly,
|
||||||
label: 'Read_Only_Channel',
|
label: isTeam ? 'Read_Only_Team' : 'Read_Only_Channel',
|
||||||
onValueChange: (value) => {
|
onValueChange: (value) => {
|
||||||
logEvent(events.CR_TOGGLE_READ_ONLY);
|
logEvent(events.CR_TOGGLE_READ_ONLY);
|
||||||
this.setState({ readOnly: value });
|
this.setState({ readOnly: value });
|
||||||
|
@ -246,10 +264,13 @@ class CreateChannelView extends React.Component {
|
||||||
|
|
||||||
renderBroadcast() {
|
renderBroadcast() {
|
||||||
const { broadcast, readOnly } = this.state;
|
const { broadcast, readOnly } = this.state;
|
||||||
|
const { route } = this.props;
|
||||||
|
const { isTeam } = route?.params;
|
||||||
|
|
||||||
return this.renderSwitch({
|
return this.renderSwitch({
|
||||||
id: 'broadcast',
|
id: 'broadcast',
|
||||||
value: broadcast,
|
value: broadcast,
|
||||||
label: 'Broadcast_Channel',
|
label: isTeam ? 'Broadcast_Team' : 'Broadcast_Channel',
|
||||||
onValueChange: (value) => {
|
onValueChange: (value) => {
|
||||||
logEvent(events.CR_TOGGLE_BROADCAST);
|
logEvent(events.CR_TOGGLE_BROADCAST);
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -364,7 +385,8 @@ const mapStateToProps = state => ({
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
create: data => dispatch(createChannelRequestAction(data)),
|
createChannel: data => dispatch(createChannelRequestAction(data)),
|
||||||
|
createTeam: data => dispatch(createTeamRequestAction(data)),
|
||||||
removeUser: user => dispatch(removeUserAction(user))
|
removeUser: user => dispatch(removeUserAction(user))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import { withTheme } from '../theme';
|
||||||
import { getUserSelector } from '../selectors/login';
|
import { getUserSelector } from '../selectors/login';
|
||||||
import Navigation from '../lib/Navigation';
|
import Navigation from '../lib/Navigation';
|
||||||
import { createChannelRequest } from '../actions/createChannel';
|
import { createChannelRequest } from '../actions/createChannel';
|
||||||
|
import { createTeamRequest } from '../actions/createTeam';
|
||||||
import { goRoom } from '../utils/goRoom';
|
import { goRoom } from '../utils/goRoom';
|
||||||
import SafeAreaView from '../containers/SafeAreaView';
|
import SafeAreaView from '../containers/SafeAreaView';
|
||||||
|
|
||||||
|
@ -113,7 +114,7 @@ class NewMessageView extends React.Component {
|
||||||
createChannel = () => {
|
createChannel = () => {
|
||||||
logEvent(events.NEW_MSG_CREATE_CHANNEL);
|
logEvent(events.NEW_MSG_CREATE_CHANNEL);
|
||||||
const { navigation } = this.props;
|
const { navigation } = this.props;
|
||||||
navigation.navigate('SelectedUsersViewCreateChannel', { nextAction: () => navigation.navigate('CreateChannelView') });
|
navigation.navigate('SelectedUsersViewCreateChannel', { nextAction: () => navigation.navigate('CreateChannelView', { isTeam: false }) });
|
||||||
}
|
}
|
||||||
|
|
||||||
createTeam = () => {
|
createTeam = () => {
|
||||||
|
@ -265,7 +266,8 @@ const mapStateToProps = state => ({
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
createChannel: params => dispatch(createChannelRequest(params))
|
createChannel: params => dispatch(createChannelRequest(params)),
|
||||||
|
createTeam: params => dispatch(createTeamRequest(params))
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(withTheme(NewMessageView));
|
export default connect(mapStateToProps, mapDispatchToProps)(withTheme(NewMessageView));
|
||||||
|
|
Loading…
Reference in New Issue