From 02b39184c000d70d6784e28be506df096cd00d54 Mon Sep 17 00:00:00 2001 From: Daniel Gale-Rosen Date: Wed, 20 Sep 2023 15:45:49 +0800 Subject: [PATCH 01/11] add and send welcome message --- src/libs/ReportUtils.js | 4 +++- src/libs/actions/Report.js | 7 ++++++- src/pages/workspace/WorkspaceNewRoomPage.js | 21 +++++++++++++++++++-- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 17dd97277150..5edef387f0c9 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -2380,6 +2380,7 @@ function buildOptimisticTaskReportAction(taskReportID, actionName, message = '') * @param {String} notificationPreference * @param {String} parentReportActionID * @param {String} parentReportID + * @param {String} welcomeMessage * @returns {Object} */ function buildOptimisticChatReport( @@ -2395,6 +2396,7 @@ function buildOptimisticChatReport( notificationPreference = CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, parentReportActionID = '', parentReportID = '', + welcomeMessage = '', ) { const currentTime = DateUtils.getDBTime(); return { @@ -2421,7 +2423,7 @@ function buildOptimisticChatReport( stateNum: 0, statusNum: 0, visibility, - welcomeMessage: '', + welcomeMessage, writeCapability, }; } diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 2a34c839a94e..4af458672fb3 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -1317,8 +1317,9 @@ function navigateToConciergeChat() { * @param {String} visibility * @param {Array} policyMembersAccountIDs * @param {String} writeCapability + * @param {String} welcomeMessage */ -function addPolicyReport(policyID, reportName, visibility, policyMembersAccountIDs, writeCapability = CONST.REPORT.WRITE_CAPABILITIES.ALL) { +function addPolicyReport(policyID, reportName, visibility, policyMembersAccountIDs, writeCapability = CONST.REPORT.WRITE_CAPABILITIES.ALL, welcomeMessage = '') { // 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]); @@ -1335,6 +1336,9 @@ 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); @@ -1399,6 +1403,7 @@ function addPolicyReport(policyID, reportName, visibility, policyMembersAccountI reportID: policyReport.reportID, createdReportActionID: createdReportAction.reportActionID, writeCapability, + welcomeMessage, }, {optimisticData, successData, failureData}, ); diff --git a/src/pages/workspace/WorkspaceNewRoomPage.js b/src/pages/workspace/WorkspaceNewRoomPage.js index f112744842b3..01babc4379f8 100644 --- a/src/pages/workspace/WorkspaceNewRoomPage.js +++ b/src/pages/workspace/WorkspaceNewRoomPage.js @@ -1,4 +1,4 @@ -import React, {useState, useCallback, useMemo} from 'react'; +import React, {useState, useRef, useCallback, useMemo} from 'react'; import {View} from 'react-native'; import _ from 'underscore'; import {withOnyx} from 'react-native-onyx'; @@ -14,6 +14,7 @@ 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'; @@ -85,7 +86,9 @@ function WorkspaceNewRoomPage(props) { */ const submit = (values) => { const policyMembers = _.map(_.keys(props.allPolicyMembers[`${ONYXKEYS.COLLECTION.POLICY_MEMBERS}${values.policyID}`]), (accountID) => Number(accountID)); - Report.addPolicyReport(values.policyID, values.roomName, values.visibility, policyMembers, values.writeCapability); + debugger; + console.log(values.welcomeMessage); + Report.addPolicyReport(values.policyID, values.roomName, values.visibility, policyMembers, values.writeCapability, values.welcomeMessage); }; /** @@ -176,6 +179,20 @@ function WorkspaceNewRoomPage(props) { autoFocus /> + + + Date: Wed, 20 Sep 2023 17:30:30 +0800 Subject: [PATCH 02/11] add initial ValuePicker component --- .../ValuePicker/ValueSelectorModal.js | 79 ++++++++++++++++ src/components/ValuePicker/index.js | 92 +++++++++++++++++++ 2 files changed, 171 insertions(+) create mode 100644 src/components/ValuePicker/ValueSelectorModal.js create mode 100644 src/components/ValuePicker/index.js diff --git a/src/components/ValuePicker/ValueSelectorModal.js b/src/components/ValuePicker/ValueSelectorModal.js new file mode 100644 index 000000000000..fb7d5787a272 --- /dev/null +++ b/src/components/ValuePicker/ValueSelectorModal.js @@ -0,0 +1,79 @@ +import React, {useState, useEffect} from 'react'; +import PropTypes from 'prop-types'; +import CONST from '../../CONST'; +import useLocalize from '../../hooks/useLocalize'; +import HeaderWithBackButton from '../HeaderWithBackButton'; +import SelectionList from '../SelectionList'; +import Modal from '../Modal'; +import ScreenWrapper from '../ScreenWrapper'; +import styles from '../../styles/styles'; +import _ from 'lodash'; + +const propTypes = { + /** Whether the modal is visible */ + isVisible: PropTypes.bool.isRequired, + + /** Country value selected */ + currentCountry: PropTypes.string, + + /** Items to pick from */ + items: PropTypes.arrayOf(PropTypes.shape({value: PropTypes.string, label: PropTypes.string})), + + /** Function to call when the user selects a Country */ + onCountrySelected: PropTypes.func, + + /** Function to call when the user closes the Country modal */ + onClose: PropTypes.func, +}; + +const defaultProps = { + currentCountry: '', + items: [], + onClose: () => {}, + onCountrySelected: () => {}, +}; + +function ValueSelectorModal({currentCountry, items, isVisible, onClose, onCountrySelected}) { + const [sectionsData, setSectionsData] = useState([]); + + + useEffect(() => { + const itemsData = _.map(items, (item) => ({value: item.value, keyForList: item.value, text: item.label, isSelected: true})); + setSectionsData(itemsData); + }, [items]); + + const {translate} = useLocalize(); + + return ( + + + + + + + ); +} + +ValueSelectorModal.propTypes = propTypes; +ValueSelectorModal.defaultProps = defaultProps; +ValueSelectorModal.displayName = 'ValueSelectorModal'; + +export default ValueSelectorModal; diff --git a/src/components/ValuePicker/index.js b/src/components/ValuePicker/index.js new file mode 100644 index 000000000000..1c1291a39a8b --- /dev/null +++ b/src/components/ValuePicker/index.js @@ -0,0 +1,92 @@ +import React, {useState} from 'react'; +import {View} from 'react-native'; +import PropTypes from 'prop-types'; +import styles from '../../styles/styles'; +import MenuItemWithTopDescription from '../MenuItemWithTopDescription'; +import ValueSelectorModal from './ValueSelectorModal'; +import FormHelpMessage from '../FormHelpMessage'; +import refPropTypes from '../refPropTypes'; + +const propTypes = { + /** Form Error description */ + errorText: PropTypes.string, + + /** Country to display */ + value: PropTypes.string, + + /** Items to pick from */ + items: PropTypes.arrayOf(PropTypes.shape({value: PropTypes.string, label: PropTypes.string})), + + /** Label of picker */ + label: PropTypes.string, + + /** Callback to call when the input changes */ + onInputChange: PropTypes.func, + + /** A ref to forward to MenuItemWithTopDescription */ + forwardedRef: refPropTypes, +}; + +const defaultProps = { + value: undefined, + label: undefined, + items: {}, + forwardedRef: undefined, + errorText: '', + onInputChange: () => {}, +}; + +function ValuePicker({value, label, items, errorText, onInputChange, forwardedRef}) { + const [isPickerVisible, setIsPickerVisible] = useState(false); + + const showPickerModal = () => { + setIsPickerVisible(true); + }; + + const hidePickerModal = () => { + setIsPickerVisible(false); + }; + + const updateCountryInput = (country) => { + onInputChange(country.value); + hidePickerModal(); + }; + + const title = value || ''; + const descStyle = title.length === 0 ? styles.textNormal : null; + + return ( + + + + + + + + ); +} + +ValuePicker.propTypes = propTypes; +ValuePicker.defaultProps = defaultProps; +ValuePicker.displayName = 'ValuePicker'; + +export default React.forwardRef((props, ref) => ( + +)); From 4e2f8081cdfdd9acb46359917d75c8be5adcd59b Mon Sep 17 00:00:00 2001 From: Daniel Gale-Rosen Date: Thu, 21 Sep 2023 12:54:07 +0800 Subject: [PATCH 03/11] handle selected items --- .../ValuePicker/ValueSelectorModal.js | 18 ++++++++++++------ src/components/ValuePicker/index.js | 7 +++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/components/ValuePicker/ValueSelectorModal.js b/src/components/ValuePicker/ValueSelectorModal.js index fb7d5787a272..f8911a7a6529 100644 --- a/src/components/ValuePicker/ValueSelectorModal.js +++ b/src/components/ValuePicker/ValueSelectorModal.js @@ -19,6 +19,12 @@ const propTypes = { /** Items to pick from */ items: PropTypes.arrayOf(PropTypes.shape({value: PropTypes.string, label: PropTypes.string})), + /** The selected item */ + selectedItem: PropTypes.shape({value: PropTypes.string, label: PropTypes.string}), + + /** Label for values */ + label: PropTypes.string, + /** Function to call when the user selects a Country */ onCountrySelected: PropTypes.func, @@ -29,20 +35,20 @@ const propTypes = { const defaultProps = { currentCountry: '', items: [], + selectedItem: {}, + label: '', onClose: () => {}, onCountrySelected: () => {}, }; -function ValueSelectorModal({currentCountry, items, isVisible, onClose, onCountrySelected}) { +function ValueSelectorModal({currentCountry, items, selectedItem, label, isVisible, onClose, onCountrySelected}) { const [sectionsData, setSectionsData] = useState([]); useEffect(() => { - const itemsData = _.map(items, (item) => ({value: item.value, keyForList: item.value, text: item.label, isSelected: true})); + const itemsData = _.map(items, (item) => ({value: item.value, keyForList: item.value, text: item.label, isSelected: item === selectedItem})); setSectionsData(itemsData); - }, [items]); - - const {translate} = useLocalize(); + }, [items, selectedItem]); return ( Date: Thu, 21 Sep 2023 13:38:05 +0800 Subject: [PATCH 04/11] clean up --- .../ValuePicker/ValueSelectorModal.js | 26 +++++++++---------- src/components/ValuePicker/index.js | 25 +++++++++++------- src/pages/workspace/WorkspaceNewRoomPage.js | 14 +++++----- 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/components/ValuePicker/ValueSelectorModal.js b/src/components/ValuePicker/ValueSelectorModal.js index f8911a7a6529..8bb8e5d01c78 100644 --- a/src/components/ValuePicker/ValueSelectorModal.js +++ b/src/components/ValuePicker/ValueSelectorModal.js @@ -1,20 +1,19 @@ import React, {useState, useEffect} from 'react'; import PropTypes from 'prop-types'; +import _ from 'lodash'; import CONST from '../../CONST'; -import useLocalize from '../../hooks/useLocalize'; import HeaderWithBackButton from '../HeaderWithBackButton'; import SelectionList from '../SelectionList'; import Modal from '../Modal'; import ScreenWrapper from '../ScreenWrapper'; import styles from '../../styles/styles'; -import _ from 'lodash'; const propTypes = { /** Whether the modal is visible */ isVisible: PropTypes.bool.isRequired, - /** Country value selected */ - currentCountry: PropTypes.string, + /** Current value selected */ + currentValue: PropTypes.string, /** Items to pick from */ items: PropTypes.arrayOf(PropTypes.shape({value: PropTypes.string, label: PropTypes.string})), @@ -25,26 +24,25 @@ const propTypes = { /** Label for values */ label: PropTypes.string, - /** Function to call when the user selects a Country */ - onCountrySelected: PropTypes.func, + /** Function to call when the user selects a item */ + onItemSelected: PropTypes.func, - /** Function to call when the user closes the Country modal */ + /** Function to call when the user closes the modal */ onClose: PropTypes.func, }; const defaultProps = { - currentCountry: '', + currentValue: '', items: [], selectedItem: {}, label: '', onClose: () => {}, - onCountrySelected: () => {}, + onItemSelected: () => {}, }; -function ValueSelectorModal({currentCountry, items, selectedItem, label, isVisible, onClose, onCountrySelected}) { +function ValueSelectorModal({currentValue, items, selectedItem, label, isVisible, onClose, onItemSelected}) { const [sectionsData, setSectionsData] = useState([]); - useEffect(() => { const itemsData = _.map(items, (item) => ({value: item.value, keyForList: item.value, text: item.label, isSelected: item === selectedItem})); setSectionsData(itemsData); @@ -69,9 +67,9 @@ function ValueSelectorModal({currentCountry, items, selectedItem, label, isVisib onBackButtonPress={onClose} /> diff --git a/src/components/ValuePicker/index.js b/src/components/ValuePicker/index.js index c72b2683c2c8..e7e329a9f453 100644 --- a/src/components/ValuePicker/index.js +++ b/src/components/ValuePicker/index.js @@ -1,6 +1,7 @@ import React, {useState} from 'react'; import {View} from 'react-native'; import PropTypes from 'prop-types'; +import _ from 'lodash'; import styles from '../../styles/styles'; import MenuItemWithTopDescription from '../MenuItemWithTopDescription'; import ValueSelectorModal from './ValueSelectorModal'; @@ -11,9 +12,12 @@ const propTypes = { /** Form Error description */ errorText: PropTypes.string, - /** Country to display */ + /** Item to display */ value: PropTypes.string, + /** A placeholder value to display */ + placeholder: PropTypes.string, + /** Items to pick from */ items: PropTypes.arrayOf(PropTypes.shape({value: PropTypes.string, label: PropTypes.string})), @@ -30,13 +34,14 @@ const propTypes = { const defaultProps = { value: undefined, label: undefined, + placeholder: '', items: {}, forwardedRef: undefined, errorText: '', onInputChange: () => {}, }; -function ValuePicker({value, label, items, errorText, onInputChange, forwardedRef}) { +function ValuePicker({value, label, items, placeholder, errorText, onInputChange, forwardedRef}) { const [isPickerVisible, setIsPickerVisible] = useState(false); const showPickerModal = () => { @@ -47,21 +52,21 @@ function ValuePicker({value, label, items, errorText, onInputChange, forwardedRe setIsPickerVisible(false); }; - const updateCountryInput = (country) => { - onInputChange(country.value); + const updateInput = (item) => { + onInputChange(item.value); hidePickerModal(); }; - const title = value || ''; - const descStyle = title.length === 0 ? styles.textNormal : null; - const selectedItem = _.find(items, { 'value': value}); + const descStyle = value.length === 0 ? styles.textNormal : null; + const selectedItem = _.find(items, {value}); + const selectedLabel = selectedItem ? selectedItem.label : ''; return ( ); diff --git a/src/pages/workspace/WorkspaceNewRoomPage.js b/src/pages/workspace/WorkspaceNewRoomPage.js index 01babc4379f8..3bd7bdb890f8 100644 --- a/src/pages/workspace/WorkspaceNewRoomPage.js +++ b/src/pages/workspace/WorkspaceNewRoomPage.js @@ -1,4 +1,4 @@ -import React, {useState, useRef, useCallback, useMemo} from 'react'; +import React, {useState, useCallback, useMemo} from 'react'; import {View} from 'react-native'; import _ from 'underscore'; import {withOnyx} from 'react-native-onyx'; @@ -8,7 +8,6 @@ import * as Report from '../../libs/actions/Report'; 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'; @@ -25,6 +24,7 @@ import policyMemberPropType from '../policyMemberPropType'; import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoundView'; import compose from '../../libs/compose'; import variables from '../../styles/variables'; +import ValuePicker from '../../components/ValuePicker'; const propTypes = { /** All reports shared with the user */ @@ -86,8 +86,6 @@ function WorkspaceNewRoomPage(props) { */ const submit = (values) => { const policyMembers = _.map(_.keys(props.allPolicyMembers[`${ONYXKEYS.COLLECTION.POLICY_MEMBERS}${values.policyID}`]), (accountID) => Number(accountID)); - debugger; - console.log(values.welcomeMessage); Report.addPolicyReport(values.policyID, values.roomName, values.visibility, policyMembers, values.writeCapability, values.welcomeMessage); }; @@ -194,17 +192,17 @@ function WorkspaceNewRoomPage(props) { /> - {isPolicyAdmin && ( - )} - Date: Thu, 21 Sep 2023 14:58:42 +0800 Subject: [PATCH 05/11] padding and margins --- src/pages/workspace/WorkspaceNewRoomPage.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/workspace/WorkspaceNewRoomPage.js b/src/pages/workspace/WorkspaceNewRoomPage.js index 3bd7bdb890f8..bc9f4c573834 100644 --- a/src/pages/workspace/WorkspaceNewRoomPage.js +++ b/src/pages/workspace/WorkspaceNewRoomPage.js @@ -177,7 +177,7 @@ function WorkspaceNewRoomPage(props) { autoFocus /> - + - + {isPolicyAdmin && ( - + )} - + Date: Thu, 21 Sep 2023 15:27:59 +0800 Subject: [PATCH 06/11] update bottom margins --- src/pages/workspace/WorkspaceNewRoomPage.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/WorkspaceNewRoomPage.js b/src/pages/workspace/WorkspaceNewRoomPage.js index bc9f4c573834..318f8aa1b82b 100644 --- a/src/pages/workspace/WorkspaceNewRoomPage.js +++ b/src/pages/workspace/WorkspaceNewRoomPage.js @@ -191,7 +191,7 @@ function WorkspaceNewRoomPage(props) { containerStyles={[styles.autoGrowHeightMultilineInput]} /> - + {isPolicyAdmin && ( - + )} - + Date: Thu, 21 Sep 2023 15:28:29 +0800 Subject: [PATCH 07/11] let NewChatSelectorPage actually access the betas --- src/pages/NewChatSelectorPage.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/pages/NewChatSelectorPage.js b/src/pages/NewChatSelectorPage.js index 89a3fd1adc72..1d3b27ed38cb 100755 --- a/src/pages/NewChatSelectorPage.js +++ b/src/pages/NewChatSelectorPage.js @@ -1,10 +1,12 @@ import React from 'react'; +import {withOnyx} from 'react-native-onyx'; import OnyxTabNavigator, {TopTab} from '../libs/Navigation/OnyxTabNavigator'; import TabSelector from '../components/TabSelector/TabSelector'; import Navigation from '../libs/Navigation/Navigation'; import Permissions from '../libs/Permissions'; import NewChatPage from './NewChatPage'; import WorkspaceNewRoomPage from './workspace/WorkspaceNewRoomPage'; +import ONYXKEYS from '../ONYXKEYS'; import CONST from '../CONST'; import withWindowDimensions, {windowDimensionsPropTypes} from '../components/withWindowDimensions'; import HeaderWithBackButton from '../components/HeaderWithBackButton'; @@ -66,4 +68,11 @@ NewChatSelectorPage.propTypes = propTypes; NewChatSelectorPage.defaultProps = defaultProps; NewChatSelectorPage.displayName = 'NewChatPage'; -export default compose(withLocalize, withWindowDimensions)(NewChatSelectorPage); +export default compose( + withLocalize, + withOnyx({ + betas: { + key: ONYXKEYS.BETAS, + }, + }), + withWindowDimensions)(NewChatSelectorPage); From bcbd156f73c5833f317f6dc32ed03f0246b49618 Mon Sep 17 00:00:00 2001 From: Daniel Gale-Rosen Date: Mon, 25 Sep 2023 11:40:04 +0800 Subject: [PATCH 08/11] address feedback - add optional to welcome message --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + src/pages/workspace/WorkspaceNewRoomPage.js | 5 ++--- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index f7c028d2a106..80eab2974118 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -854,6 +854,7 @@ 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: { diff --git a/src/languages/es.ts b/src/languages/es.ts index a68f33a33730..7a1231259759 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -850,6 +850,7 @@ 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: { diff --git a/src/pages/workspace/WorkspaceNewRoomPage.js b/src/pages/workspace/WorkspaceNewRoomPage.js index 318f8aa1b82b..7cf13746fa64 100644 --- a/src/pages/workspace/WorkspaceNewRoomPage.js +++ b/src/pages/workspace/WorkspaceNewRoomPage.js @@ -180,11 +180,10 @@ function WorkspaceNewRoomPage(props) { Date: Tue, 26 Sep 2023 14:53:20 +0800 Subject: [PATCH 09/11] address feedback --- src/pages/workspace/WorkspaceNewRoomPage.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pages/workspace/WorkspaceNewRoomPage.js b/src/pages/workspace/WorkspaceNewRoomPage.js index 7cf13746fa64..9048c27b4353 100644 --- a/src/pages/workspace/WorkspaceNewRoomPage.js +++ b/src/pages/workspace/WorkspaceNewRoomPage.js @@ -72,6 +72,7 @@ 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) { @@ -163,7 +164,6 @@ function WorkspaceNewRoomPage(props) {
- + {isPolicyAdmin && ( - + )} @@ -215,7 +216,7 @@ function WorkspaceNewRoomPage(props) { label={translate('newRoomPage.visibility')} items={visibilityOptions} onValueChange={setVisibility} - defaultValue={CONST.REPORT.VISIBILITY.RESTRICTED} + defaultValue={visibility} /> {visibilityDescription} From c3b3508cdd85e2812027508b43de0c48ab429dba Mon Sep 17 00:00:00 2001 From: Daniel Gale-Rosen Date: Tue, 26 Sep 2023 16:50:05 +0800 Subject: [PATCH 10/11] mirror change on main --- src/components/ValuePicker/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/ValuePicker/index.js b/src/components/ValuePicker/index.js index e7e329a9f453..161fbbfadb8b 100644 --- a/src/components/ValuePicker/index.js +++ b/src/components/ValuePicker/index.js @@ -53,7 +53,9 @@ function ValuePicker({value, label, items, placeholder, errorText, onInputChange }; const updateInput = (item) => { - onInputChange(item.value); + if (item.value !== value) { + onInputChange(item.value); + } hidePickerModal(); }; From 03f63bf25bdc999c83706da91232193ad5027ed2 Mon Sep 17 00:00:00 2001 From: Daniel Gale-Rosen Date: Fri, 29 Sep 2023 20:40:52 +0800 Subject: [PATCH 11/11] update value based on policy --- src/components/ValuePicker/ValueSelectorModal.js | 1 + src/pages/workspace/WorkspaceNewRoomPage.js | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/ValuePicker/ValueSelectorModal.js b/src/components/ValuePicker/ValueSelectorModal.js index 8bb8e5d01c78..23aac4839d2a 100644 --- a/src/components/ValuePicker/ValueSelectorModal.js +++ b/src/components/ValuePicker/ValueSelectorModal.js @@ -61,6 +61,7 @@ function ValueSelectorModal({currentValue, items, selectedItem, label, isVisible style={[styles.pb0]} includePaddingTop={false} includeSafeAreaPaddingBottom={false} + testID="ValueSelectorModal" > { const policyMembers = _.map(_.keys(props.allPolicyMembers[`${ONYXKEYS.COLLECTION.POLICY_MEMBERS}${values.policyID}`]), (accountID) => Number(accountID)); - Report.addPolicyReport(values.policyID, values.roomName, values.visibility, policyMembers, values.writeCapability, values.welcomeMessage); + Report.addPolicyReport(policyID, values.roomName, visibility, policyMembers, writeCapability, values.welcomeMessage); }; + 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} @@ -212,7 +220,7 @@ function WorkspaceNewRoomPage(props) { inputID="writeCapability" label={translate('writeCapabilityPage.label')} items={writeCapabilityOptions} - defaultValue={writeCapability} + value={writeCapability} onValueChange={setWriteCapability} /> @@ -223,7 +231,7 @@ function WorkspaceNewRoomPage(props) { label={translate('newRoomPage.visibility')} items={visibilityOptions} onValueChange={setVisibility} - defaultValue={visibility} + value={visibility} /> {visibilityDescription}