Skip to content

Commit

Permalink
Merge pull request #28955 from Expensify/vit-revert27836
Browse files Browse the repository at this point in the history
[CP Staging] Revert "Merge pull request #27836 from Expensify/dangrous-roomwelcomemessages"
  • Loading branch information
mountiny authored Oct 5, 2023
2 parents e5270fa + edd499a commit d420b0a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 233 deletions.
84 changes: 0 additions & 84 deletions src/components/ValuePicker/ValueSelectorModal.js

This file was deleted.

102 changes: 0 additions & 102 deletions src/components/ValuePicker/index.js

This file was deleted.

1 change: 0 additions & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,6 @@ export default {
},
welcomeMessagePage: {
welcomeMessage: 'Welcome message',
welcomeMessageOptional: 'Welcome message (optional)',
explainerText: 'Set a custom welcome message that will be sent to users when they join this room.',
},
languagePage: {
Expand Down
1 change: 0 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,6 @@ export default {
},
welcomeMessagePage: {
welcomeMessage: 'Mensaje de bienvenida',
welcomeMessageOptional: 'Mensaje de bienvenida (opcional)',
explainerText: 'Configura un mensaje de bienvenida privado y personalizado que se enviará cuando los usuarios se unan a esta sala de chat.',
},
languagePage: {
Expand Down
4 changes: 1 addition & 3 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2529,7 +2529,6 @@ function buildOptimisticTaskReportAction(taskReportID, actionName, message = '')
* @param {String} notificationPreference
* @param {String} parentReportActionID
* @param {String} parentReportID
* @param {String} welcomeMessage
* @returns {Object}
*/
function buildOptimisticChatReport(
Expand All @@ -2545,7 +2544,6 @@ function buildOptimisticChatReport(
notificationPreference = CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS,
parentReportActionID = '',
parentReportID = '',
welcomeMessage = '',
) {
const currentTime = DateUtils.getDBTime();
return {
Expand All @@ -2572,7 +2570,7 @@ function buildOptimisticChatReport(
stateNum: 0,
statusNum: 0,
visibility,
welcomeMessage,
welcomeMessage: '',
writeCapability,
};
}
Expand Down
7 changes: 1 addition & 6 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1410,9 +1410,8 @@ function navigateToConciergeChat() {
* @param {String} visibility
* @param {Array<Number>} policyMembersAccountIDs
* @param {String} writeCapability
* @param {String} welcomeMessage
*/
function addPolicyReport(policyID, reportName, visibility, policyMembersAccountIDs, writeCapability = CONST.REPORT.WRITE_CAPABILITIES.ALL, welcomeMessage = '') {
function addPolicyReport(policyID, reportName, visibility, policyMembersAccountIDs, writeCapability = CONST.REPORT.WRITE_CAPABILITIES.ALL) {
// The participants include the current user (admin), and for restricted rooms, the policy members. Participants must not be empty.
const members = visibility === CONST.REPORT.VISIBILITY.RESTRICTED ? policyMembersAccountIDs : [];
const participants = _.unique([currentUserAccountID, ...members]);
Expand All @@ -1429,9 +1428,6 @@ function addPolicyReport(policyID, reportName, visibility, policyMembersAccountI

// The room might contain all policy members so notifying always should be opt-in only.
CONST.REPORT.NOTIFICATION_PREFERENCE.DAILY,
'',
'',
welcomeMessage,
);
const createdReportAction = ReportUtils.buildOptimisticCreatedReportAction(CONST.POLICY.OWNER_EMAIL_FAKE);

Expand Down Expand Up @@ -1496,7 +1492,6 @@ function addPolicyReport(policyID, reportName, visibility, policyMembersAccountI
reportID: policyReport.reportID,
createdReportActionID: createdReportAction.reportActionID,
writeCapability,
welcomeMessage,
},
{optimisticData, successData, failureData},
);
Expand Down
49 changes: 13 additions & 36 deletions src/pages/workspace/WorkspaceNewRoomPage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState, useCallback, useEffect, useMemo, useRef} from 'react';
import React, {useState, useCallback, useMemo, useRef} from 'react';
import {View} from 'react-native';
import _ from 'underscore';
import {withOnyx} from 'react-native-onyx';
Expand All @@ -9,12 +9,12 @@ import * as App from '../../libs/actions/App';
import useLocalize from '../../hooks/useLocalize';
import styles from '../../styles/styles';
import RoomNameInput from '../../components/RoomNameInput';
import Picker from '../../components/Picker';
import KeyboardAvoidingView from '../../components/KeyboardAvoidingView';
import ScreenWrapper from '../../components/ScreenWrapper';
import ONYXKEYS from '../../ONYXKEYS';
import CONST from '../../CONST';
import Text from '../../components/Text';
import TextInput from '../../components/TextInput';
import Permissions from '../../libs/Permissions';
import * as ErrorUtils from '../../libs/ErrorUtils';
import * as ValidationUtils from '../../libs/ValidationUtils';
Expand All @@ -26,7 +26,6 @@ import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoun
import compose from '../../libs/compose';
import variables from '../../styles/variables';
import useDelayedInputFocus from '../../hooks/useDelayedInputFocus';
import ValuePicker from '../../components/ValuePicker';

const propTypes = {
/** All reports shared with the user */
Expand Down Expand Up @@ -74,7 +73,6 @@ function WorkspaceNewRoomPage(props) {
const {translate} = useLocalize();
const [visibility, setVisibility] = useState(CONST.REPORT.VISIBILITY.RESTRICTED);
const [policyID, setPolicyID] = useState(null);
const [writeCapability, setWriteCapability] = useState(CONST.REPORT.WRITE_CAPABILITIES.ALL);
const visibilityDescription = useMemo(() => translate(`newRoomPage.${visibility}Description`), [translate, visibility]);
const isPolicyAdmin = useMemo(() => {
if (!policyID) {
Expand All @@ -89,17 +87,9 @@ function WorkspaceNewRoomPage(props) {
*/
const submit = (values) => {
const policyMembers = _.map(_.keys(props.allPolicyMembers[`${ONYXKEYS.COLLECTION.POLICY_MEMBERS}${values.policyID}`]), (accountID) => Number(accountID));
Report.addPolicyReport(policyID, values.roomName, visibility, policyMembers, writeCapability, values.welcomeMessage);
Report.addPolicyReport(values.policyID, values.roomName, values.visibility, policyMembers, values.writeCapability);
};

useEffect(() => {
if (isPolicyAdmin) {
return;
}

setWriteCapability(CONST.REPORT.WRITE_CAPABILITIES.ALL);
}, [policyID, isPolicyAdmin]);

/**
* @param {Object} values - form input values passed by the Form component
* @returns {Boolean}
Expand Down Expand Up @@ -185,6 +175,7 @@ function WorkspaceNewRoomPage(props) {
<Form
formID={ONYXKEYS.FORMS.NEW_ROOM_FORM}
submitButtonText={translate('newRoomPage.createRoom')}
scrollContextEnabled
style={[styles.mh5, styles.flexGrow1]}
validate={validate}
onSubmit={submit}
Expand All @@ -199,46 +190,32 @@ function WorkspaceNewRoomPage(props) {
autoFocus
/>
</View>
<View style={styles.mb5}>
<TextInput
inputID="welcomeMessage"
label={translate('welcomeMessagePage.welcomeMessageOptional')}
accessibilityLabel={translate('welcomeMessagePage.welcomeMessageOptional')}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.TEXT}
autoGrowHeight
maxLength={CONST.MAX_COMMENT_LENGTH}
autoCapitalize="none"
textAlignVertical="top"
containerStyles={[styles.autoGrowHeightMultilineInput]}
/>
</View>
<View style={[styles.mhn5]}>
<ValuePicker
<View style={styles.mb2}>
<Picker
inputID="policyID"
label={translate('workspace.common.workspace')}
placeholder={translate('newRoomPage.selectAWorkspace')}
placeholder={{value: '', label: translate('newRoomPage.selectAWorkspace')}}
items={workspaceOptions}
onValueChange={setPolicyID}
/>
</View>
{isPolicyAdmin && (
<View style={styles.mhn5}>
<ValuePicker
<View style={styles.mb2}>
<Picker
inputID="writeCapability"
label={translate('writeCapabilityPage.label')}
items={writeCapabilityOptions}
value={writeCapability}
onValueChange={setWriteCapability}
defaultValue={CONST.REPORT.WRITE_CAPABILITIES.ALL}
/>
</View>
)}
<View style={[styles.mb1, styles.mhn5]}>
<ValuePicker
<View style={styles.mb2}>
<Picker
inputID="visibility"
label={translate('newRoomPage.visibility')}
items={visibilityOptions}
onValueChange={setVisibility}
value={visibility}
defaultValue={CONST.REPORT.VISIBILITY.RESTRICTED}
/>
</View>
<Text style={[styles.textLabel, styles.colorMuted]}>{visibilityDescription}</Text>
Expand Down

0 comments on commit d420b0a

Please sign in to comment.