1
- import React , { useState , useCallback , useMemo , useEffect } from 'react' ;
1
+ import React , { useState , useCallback , useMemo } from 'react' ;
2
2
import { View } from 'react-native' ;
3
3
import _ from 'underscore' ;
4
4
import { withOnyx } from 'react-native-onyx' ;
5
5
import PropTypes from 'prop-types' ;
6
6
import * as Report from '../../libs/actions/Report' ;
7
7
import useLocalize from '../../hooks/useLocalize' ;
8
8
import HeaderWithBackButton from '../../components/HeaderWithBackButton' ;
9
- import Navigation from '../../libs/Navigation/Navigation' ;
10
9
import ScreenWrapper from '../../components/ScreenWrapper' ;
11
10
import styles from '../../styles/styles' ;
12
11
import RoomNameInput from '../../components/RoomNameInput' ;
@@ -15,14 +14,14 @@ import ONYXKEYS from '../../ONYXKEYS';
15
14
import CONST from '../../CONST' ;
16
15
import Text from '../../components/Text' ;
17
16
import Permissions from '../../libs/Permissions' ;
18
- import Log from '../../libs/Log' ;
19
17
import * as ErrorUtils from '../../libs/ErrorUtils' ;
20
18
import * as ValidationUtils from '../../libs/ValidationUtils' ;
21
19
import * as ReportUtils from '../../libs/ReportUtils' ;
22
20
import * as PolicyUtils from '../../libs/PolicyUtils' ;
23
21
import Form from '../../components/Form' ;
24
22
import shouldDelayFocus from '../../libs/shouldDelayFocus' ;
25
23
import policyMemberPropType from '../policyMemberPropType' ;
24
+ import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView' ;
26
25
27
26
const propTypes = {
28
27
/** All reports shared with the user */
@@ -140,70 +139,60 @@ function WorkspaceNewRoomPage(props) {
140
139
[ translate ] ,
141
140
) ;
142
141
143
- useEffect ( ( ) => {
144
- if ( Permissions . canUsePolicyRooms ( props . betas ) && workspaceOptions . length ) {
145
- return ;
146
- }
147
- Log . info ( 'Not showing create Policy Room page since user is not on policy rooms beta' ) ;
148
- Navigation . dismissModal ( ) ;
149
- } , [ props . betas , workspaceOptions ] ) ;
150
-
151
- if ( ! Permissions . canUsePolicyRooms ( props . betas ) || ! workspaceOptions . length ) {
152
- return null ;
153
- }
154
-
155
142
return (
156
143
< ScreenWrapper
157
144
includeSafeAreaPaddingBottom = { false }
158
145
shouldEnablePickerAvoiding = { false }
159
146
>
160
- < HeaderWithBackButton title = { translate ( 'newRoomPage.newRoom' ) } />
161
- < Form
162
- formID = { ONYXKEYS . FORMS . NEW_ROOM_FORM }
163
- submitButtonText = { translate ( 'newRoomPage.createRoom' ) }
164
- scrollContextEnabled
165
- style = { [ styles . mh5 , styles . flexGrow1 ] }
166
- validate = { validate }
167
- onSubmit = { submit }
168
- enabledWhenOffline
169
- >
170
- < View style = { styles . mb5 } >
171
- < RoomNameInput
172
- inputID = "roomName"
173
- autoFocus
174
- shouldDelayFocus = { shouldDelayFocus }
175
- />
176
- </ View >
177
- < View style = { styles . mb2 } >
178
- < Picker
179
- inputID = "policyID"
180
- label = { translate ( 'workspace.common.workspace' ) }
181
- placeholder = { { value : '' , label : translate ( 'newRoomPage.selectAWorkspace' ) } }
182
- items = { workspaceOptions }
183
- onValueChange = { setPolicyID }
184
- />
185
- </ View >
186
- { isPolicyAdmin && (
147
+ < FullPageNotFoundView shouldShow = { ! Permissions . canUsePolicyRooms ( props . betas ) || ! workspaceOptions . length } >
148
+ < HeaderWithBackButton title = { translate ( 'newRoomPage.newRoom' ) } />
149
+ < Form
150
+ formID = { ONYXKEYS . FORMS . NEW_ROOM_FORM }
151
+ submitButtonText = { translate ( 'newRoomPage.createRoom' ) }
152
+ scrollContextEnabled
153
+ style = { [ styles . mh5 , styles . flexGrow1 ] }
154
+ validate = { validate }
155
+ onSubmit = { submit }
156
+ enabledWhenOffline
157
+ >
158
+ < View style = { styles . mb5 } >
159
+ < RoomNameInput
160
+ inputID = "roomName"
161
+ autoFocus
162
+ shouldDelayFocus = { shouldDelayFocus }
163
+ />
164
+ </ View >
165
+ < View style = { styles . mb2 } >
166
+ < Picker
167
+ inputID = "policyID"
168
+ label = { translate ( 'workspace.common.workspace' ) }
169
+ placeholder = { { value : '' , label : translate ( 'newRoomPage.selectAWorkspace' ) } }
170
+ items = { workspaceOptions }
171
+ onValueChange = { setPolicyID }
172
+ />
173
+ </ View >
174
+ { isPolicyAdmin && (
175
+ < View style = { styles . mb2 } >
176
+ < Picker
177
+ inputID = "writeCapability"
178
+ label = { translate ( 'writeCapabilityPage.label' ) }
179
+ items = { writeCapabilityOptions }
180
+ defaultValue = { CONST . REPORT . WRITE_CAPABILITIES . ALL }
181
+ />
182
+ </ View >
183
+ ) }
187
184
< View style = { styles . mb2 } >
188
185
< Picker
189
- inputID = "writeCapability"
190
- label = { translate ( 'writeCapabilityPage.label' ) }
191
- items = { writeCapabilityOptions }
192
- defaultValue = { CONST . REPORT . WRITE_CAPABILITIES . ALL }
186
+ inputID = "visibility"
187
+ label = { translate ( 'newRoomPage.visibility' ) }
188
+ items = { visibilityOptions }
189
+ onValueChange = { setVisibility }
190
+ defaultValue = { CONST . REPORT . VISIBILITY . RESTRICTED }
193
191
/>
194
192
</ View >
195
- ) }
196
- < View style = { styles . mb2 } >
197
- < Picker
198
- inputID = "visibility"
199
- label = { translate ( 'newRoomPage.visibility' ) }
200
- items = { visibilityOptions }
201
- onValueChange = { setVisibility }
202
- defaultValue = { CONST . REPORT . VISIBILITY . RESTRICTED }
203
- />
204
- </ View >
205
- < Text style = { [ styles . textLabel , styles . colorMuted ] } > { visibilityDescription } </ Text >
206
- </ Form >
193
+ < Text style = { [ styles . textLabel , styles . colorMuted ] } > { visibilityDescription } </ Text >
194
+ </ Form >
195
+ </ FullPageNotFoundView >
207
196
</ ScreenWrapper >
208
197
) ;
209
198
}
0 commit comments