-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathNewWorkspacePage.js
95 lines (82 loc) · 3.14 KB
/
NewWorkspacePage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import React from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import ONYXKEYS from '../../ONYXKEYS';
import HeaderWithCloseButton from '../../components/HeaderWithCloseButton';
import ScreenWrapper from '../../components/ScreenWrapper';
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize';
import Navigation from '../../libs/Navigation/Navigation';
import Permissions from '../../libs/Permissions';
import styles from '../../styles/styles';
import WorkspaceDefaultAvatar from '../../../assets/images/workspace-default-avatar.svg';
import TextInputWithLabel from '../../components/TextInputWithLabel';
import Button from '../../components/Button';
import Text from '../../components/Text';
import compose from '../../libs/compose';
import {create} from '../../libs/actions/Policy';
import defaultTheme from '../../styles/themes/default';
const propTypes = {
/** List of betas */
betas: PropTypes.arrayOf(PropTypes.string),
...withLocalizePropTypes,
};
const defaultProps = {
betas: [],
};
class NewWorkspacePage extends React.Component {
constructor(props) {
super(props);
this.state = {
name: '',
};
this.submit = this.submit.bind(this);
}
submit() {
const name = this.state.name.trim();
create(name);
}
render() {
if (!Permissions.canUseFreePlan(this.props.betas)) {
console.debug('Not showing new workspace page because user is not on free plan beta');
return <Navigation.DismissModal />;
}
return (
<ScreenWrapper>
<HeaderWithCloseButton
title={this.props.translate('workspace.new.welcome')}
onCloseButtonPress={Navigation.dismissModal}
/>
<View style={[styles.pageWrapper, styles.flex1]}>
<WorkspaceDefaultAvatar height={80} width={80} fill={defaultTheme.iconSuccessFill} />
<View style={[styles.mt6, styles.w100, styles.flex1]}>
<TextInputWithLabel
label={this.props.translate('workspace.new.chooseAName')}
value={this.state.name}
onChangeText={name => this.setState({name})}
onSubmitEditting={this.submit}
/>
<Text style={[styles.mt6]}>{this.props.translate('workspace.new.helpText')}</Text>
</View>
<Button
success
style={[styles.w100]}
text={this.props.translate('workspace.new.getStarted')}
onPress={this.submit}
pressOnEnter
/>
</View>
</ScreenWrapper>
);
}
}
NewWorkspacePage.propTypes = propTypes;
NewWorkspacePage.defaultProps = defaultProps;
export default compose(
withOnyx({
betas: {
key: ONYXKEYS.BETAS,
},
}),
withLocalize,
)(NewWorkspacePage);