Skip to content

Commit 4af18f6

Browse files
authored
Merge pull request #23486 from Ollyws/issue-23067
Fix for: Web - Incorrect Redirection to Chat Page when Accessing /workspace/new-room URL
2 parents ed557b8 + ad95baf commit 4af18f6

File tree

1 file changed

+47
-58
lines changed

1 file changed

+47
-58
lines changed

src/pages/workspace/WorkspaceNewRoomPage.js

Lines changed: 47 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import React, {useState, useCallback, useMemo, useEffect} from 'react';
1+
import React, {useState, useCallback, useMemo} from 'react';
22
import {View} from 'react-native';
33
import _ from 'underscore';
44
import {withOnyx} from 'react-native-onyx';
55
import PropTypes from 'prop-types';
66
import * as Report from '../../libs/actions/Report';
77
import useLocalize from '../../hooks/useLocalize';
88
import HeaderWithBackButton from '../../components/HeaderWithBackButton';
9-
import Navigation from '../../libs/Navigation/Navigation';
109
import ScreenWrapper from '../../components/ScreenWrapper';
1110
import styles from '../../styles/styles';
1211
import RoomNameInput from '../../components/RoomNameInput';
@@ -15,14 +14,14 @@ import ONYXKEYS from '../../ONYXKEYS';
1514
import CONST from '../../CONST';
1615
import Text from '../../components/Text';
1716
import Permissions from '../../libs/Permissions';
18-
import Log from '../../libs/Log';
1917
import * as ErrorUtils from '../../libs/ErrorUtils';
2018
import * as ValidationUtils from '../../libs/ValidationUtils';
2119
import * as ReportUtils from '../../libs/ReportUtils';
2220
import * as PolicyUtils from '../../libs/PolicyUtils';
2321
import Form from '../../components/Form';
2422
import shouldDelayFocus from '../../libs/shouldDelayFocus';
2523
import policyMemberPropType from '../policyMemberPropType';
24+
import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView';
2625

2726
const propTypes = {
2827
/** All reports shared with the user */
@@ -140,70 +139,60 @@ function WorkspaceNewRoomPage(props) {
140139
[translate],
141140
);
142141

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-
155142
return (
156143
<ScreenWrapper
157144
includeSafeAreaPaddingBottom={false}
158145
shouldEnablePickerAvoiding={false}
159146
>
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+
)}
187184
<View style={styles.mb2}>
188185
<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}
193191
/>
194192
</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>
207196
</ScreenWrapper>
208197
);
209198
}

0 commit comments

Comments
 (0)