Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 63 additions & 65 deletions src/pages/workspace/WorkspaceSettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import Picker from '../../components/Picker';
import TextInput from '../../components/TextInput';
import FixedFooter from '../../components/FixedFooter';
import WorkspacePageWithSections from './WorkspacePageWithSections';
import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator';
import withFullPolicy, {fullPolicyPropTypes, fullPolicyDefaultProps} from './withFullPolicy';
import {withNetwork} from '../../components/OnyxProvider';
import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView';

const propTypes = {
...fullPolicyPropTypes,
Expand Down Expand Up @@ -96,73 +96,71 @@ class WorkspaceSettingsPage extends React.Component {
}

render() {
if (_.isEmpty(this.props.policy)) {
return <FullScreenLoadingIndicator />;
}

return (
<WorkspacePageWithSections
headerText={this.props.translate('workspace.common.settings')}
route={this.props.route}
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_SETTINGS}
footer={(
<FixedFooter style={[styles.w100]}>
<Button
success
isLoading={this.props.policy.isPolicyUpdating}
text={this.props.translate('workspace.editor.save')}
onPress={this.submit}
pressOnEnter
/>
</FixedFooter>
)}
>
{hasVBA => (
<View style={[styles.pageWrapper, styles.flex1, styles.alignItemsStretch]}>
<AvatarWithImagePicker
isUploading={this.props.policy.isAvatarUploading}
avatarURL={this.state.previewAvatarURL}
size={CONST.AVATAR_SIZE.LARGE}
DefaultAvatar={() => (
<Icon
src={Expensicons.Workspace}
height={80}
width={80}
fill={defaultTheme.iconSuccessFill}
/>
)}
fallbackIcon={Expensicons.FallbackWorkspaceAvatar}
style={[styles.mb3]}
anchorPosition={{top: 172, right: 18}}
isUsingDefaultAvatar={!this.state.previewAvatarURL}
onImageSelected={this.uploadAvatar}
onImageRemoved={this.removeAvatar}
/>

<TextInput
label={this.props.translate('workspace.editor.nameInputLabel')}
containerStyles={[styles.mt4]}
onChangeText={name => this.setState({name})}
value={this.state.name}
hasError={!this.state.name.trim().length}
errorText={this.state.name.trim().length ? '' : this.props.translate('workspace.editor.nameIsRequiredError')}
/>

<View style={[styles.mt4]}>
<Picker
label={this.props.translate('workspace.editor.currencyInputLabel')}
onInputChange={currency => this.setState({currency})}
items={this.getCurrencyItems()}
value={this.state.currency}
isDisabled={hasVBA}
<FullPageNotFoundView shouldShow={_.isEmpty(this.props.policy)}>
<WorkspacePageWithSections
headerText={this.props.translate('workspace.common.settings')}
route={this.props.route}
guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_SETTINGS}
footer={(
<FixedFooter style={[styles.w100]}>
<Button
success
isLoading={this.props.policy.isPolicyUpdating}
text={this.props.translate('workspace.editor.save')}
onPress={this.submit}
pressOnEnter
/>
</FixedFooter>
)}
>
{hasVBA => (
<View style={[styles.pageWrapper, styles.flex1, styles.alignItemsStretch]}>
<AvatarWithImagePicker
isUploading={this.props.policy.isAvatarUploading}
avatarURL={this.state.previewAvatarURL}
size={CONST.AVATAR_SIZE.LARGE}
DefaultAvatar={() => (
<Icon
src={Expensicons.Workspace}
height={80}
width={80}
fill={defaultTheme.iconSuccessFill}
/>
)}
fallbackIcon={Expensicons.FallbackWorkspaceAvatar}
style={[styles.mb3]}
anchorPosition={{top: 172, right: 18}}
isUsingDefaultAvatar={!this.state.previewAvatarURL}
onImageSelected={this.uploadAvatar}
onImageRemoved={this.removeAvatar}
/>

<TextInput
label={this.props.translate('workspace.editor.nameInputLabel')}
containerStyles={[styles.mt4]}
onChangeText={name => this.setState({name})}
value={this.state.name}
hasError={!this.state.name.trim().length}
errorText={this.state.name.trim().length ? '' : this.props.translate('workspace.editor.nameIsRequiredError')}
/>

<View style={[styles.mt4]}>
<Picker
label={this.props.translate('workspace.editor.currencyInputLabel')}
onInputChange={currency => this.setState({currency})}
items={this.getCurrencyItems()}
value={this.state.currency}
isDisabled={hasVBA}
/>
</View>
<Text style={[styles.textLabel, styles.colorMuted, styles.mt2]}>
{this.props.translate('workspace.editor.currencyInputHelpText')}
</Text>
</View>
<Text style={[styles.textLabel, styles.colorMuted, styles.mt2]}>
{this.props.translate('workspace.editor.currencyInputHelpText')}
</Text>
</View>
)}
</WorkspacePageWithSections>
)}
</WorkspacePageWithSections>
</FullPageNotFoundView>
);
}
}
Expand Down