Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the NewRoomPage #6314

Merged
merged 53 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
020c905
translations
jasperhuangg Nov 11, 2021
d3de848
setup navigation
jasperhuangg Nov 11, 2021
cb21b63
more translations
jasperhuangg Nov 16, 2021
ad233af
add styles for textInputWithPrefix
jasperhuangg Nov 16, 2021
06480a3
Add TextInputWithPrefix (modify TextInputWithLabel)
jasperhuangg Nov 16, 2021
5ff5cd7
WorkspaceNewRoomPage WIP
jasperhuangg Nov 16, 2021
6beddeb
Wip Workspace picker
jasperhuangg Nov 16, 2021
e029ca2
wip
jasperhuangg Nov 16, 2021
ca2c8dc
Social Spanish translation
jasperhuangg Nov 17, 2021
f20186f
Pickers working, need to rethink TextInputWithPrefix since it doesn't…
jasperhuangg Nov 18, 2021
c8aedbf
revert ExpensiTextInput
jasperhuangg Nov 18, 2021
57b0dc1
merge main
jasperhuangg Nov 18, 2021
758f52d
add Create Room button
jasperhuangg Nov 18, 2021
0169faf
limit room name length to 80 chars
jasperhuangg Nov 18, 2021
38a4334
filter workspaces
jasperhuangg Nov 18, 2021
57d78fe
typo
jasperhuangg Nov 18, 2021
791c561
perform checks to modify room name in real time as you type
jasperhuangg Nov 18, 2021
e209667
remove unused styles
jasperhuangg Nov 18, 2021
309836a
existing room name validation
jasperhuangg Nov 18, 2021
fa2eca0
remove console logs
jasperhuangg Nov 18, 2021
6554d32
Add option to global create menu
jasperhuangg Nov 18, 2021
b936cbf
Merge branch 'main' of github.com:Expensify/App into jasper-ucprRNFro…
jasperhuangg Nov 18, 2021
9ef9565
remove isRequired checks
jasperhuangg Nov 18, 2021
0f52610
translations
jasperhuangg Nov 18, 2021
9c06ec5
style
jasperhuangg Nov 18, 2021
068a8cd
Fix TextInputWithPrefix on Android
jasperhuangg Nov 18, 2021
d731cf4
style
jasperhuangg Nov 18, 2021
bd5f153
add Hashtag svg
jasperhuangg Nov 18, 2021
60293f7
componentDidMount => componentDidUpdate
jasperhuangg Nov 19, 2021
9c6dddc
componentDidMount => componentDidUpdate
jasperhuangg Nov 19, 2021
e5981d3
componentDidMount => componentDidUpdate
jasperhuangg Nov 19, 2021
f7d26eb
componentDidMount => componentDidUpdate
jasperhuangg Nov 19, 2021
b31eb64
comments
jasperhuangg Nov 19, 2021
b0a57a7
put containerStyles at end so they don't given overwritten
jasperhuangg Nov 19, 2021
18ac388
remove unrelated change
jasperhuangg Nov 19, 2021
216edb3
remove unrelated change
jasperhuangg Nov 19, 2021
d0ddaa6
comment
jasperhuangg Nov 22, 2021
e2dbd3e
catch error from createPolicyRoom
jasperhuangg Nov 22, 2021
5bb254f
omit unnecessary props before spreading
jasperhuangg Nov 22, 2021
8855bce
Update src/components/TextInputWithPrefix/index.android.js
jasperhuangg Nov 22, 2021
64024cf
use conditional chaining
jasperhuangg Nov 22, 2021
63b68f5
use translation
jasperhuangg Nov 22, 2021
6da57f5
alphabetize styles
jasperhuangg Nov 22, 2021
5d89b6c
translation
jasperhuangg Nov 23, 2021
6e0ed17
add logic in componentDidDMount for first render
Dec 8, 2021
684401e
Merge branch 'main' of github.com:Expensify/App into jasper-ucprRNFro…
Dec 8, 2021
e2d3944
remove extra code missed in merge
Dec 8, 2021
b83df70
Fix more import issues
Dec 9, 2021
87a7f08
Match import logic to new rules ExpensifyComponents
Dec 9, 2021
3c09488
Move loading to Onyx to satisfy no-thenable-actions-in-views
Dec 9, 2021
9ea046a
Fix unrestricted import issue
Dec 9, 2021
8f01cb3
Put Create Policy Room behind default rooms beta
Dec 9, 2021
fb9b7fb
Fix style for ExpensiPicker to apply margin correctly
Dec 9, 2021
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
7 changes: 7 additions & 0 deletions assets/images/hashtag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ const CONST = {
POLICY_ANNOUNCE: 'policyAnnounce',
POLICY_ADMINS: 'policyAdmins',
DOMAIN_ALL: 'domainAll',
POLICY_ROOM: 'policyRoom',
},
STATE_NUM: {
OPEN: 0,
Expand All @@ -230,7 +231,12 @@ const CONST = {
DAILY: 'daily',
ALWAYS: 'always',
},
VISIBILITY: {
RESTRICTED: 'restricted',
PRIVATE: 'private',
},
MAX_PREVIEW_AVATARS: 4,
MAX_ROOM_NAME_LENGTH: 80,
},
MODAL: {
MODAL_TYPE: {
Expand Down
3 changes: 3 additions & 0 deletions src/ONYXKEYS.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,7 @@ export default {

// Is report data loading?
IS_LOADING_REPORT_DATA: 'isLoadingReportData',

// Are we loading the create policy room command
IS_LOADING_CREATE_POLICY_ROOM: 'isLoadingCratePolicyRoom',
};
1 change: 1 addition & 0 deletions src/ROUTES.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export default {
WORKSPACE_TRAVEL: 'workspace/:policyID/travel',
WORKSPACE_MEMBERS: 'workspace/:policyID/members',
WORKSPACE_BANK_ACCOUNT: 'workspace/:policyID/bank-account',
WORKSPACE_NEW_ROOM: 'workspace/new-room',
getWorkspaceInitialRoute: policyID => `workspace/${policyID}`,
getWorkspaceInviteRoute: policyID => `workspace/${policyID}/invite`,
getWorkspaceSettingsRoute: policyID => `workspace/${policyID}/settings`,
Expand Down
4 changes: 4 additions & 0 deletions src/components/ExpensiPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ const propTypes = {

/** Error text to display */
errorText: PropTypes.string,

/** Customize the ExpensiPicker container */
containerStyles: PropTypes.arrayOf(PropTypes.object),
};

const defaultProps = {
label: '',
isDisabled: false,
hasError: false,
errorText: '',
containerStyles: [],
};

class ExpensiPicker extends PureComponent {
Expand Down
2 changes: 2 additions & 0 deletions src/components/Icon/Expensicons.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import EyeDisabled from '../../../assets/images/eye-disabled.svg';
import ExpensifyCard from '../../../assets/images/expensifycard.svg';
import Gallery from '../../../assets/images/gallery.svg';
import Gear from '../../../assets/images/gear.svg';
import Hashtag from '../../../assets/images/hashtag.svg';
import Info from '../../../assets/images/info.svg';
import Invoice from '../../../assets/images/invoice.svg';
import Link from '../../../assets/images/link.svg';
Expand Down Expand Up @@ -92,6 +93,7 @@ export {
ExpensifyCard,
Gallery,
Gear,
Hashtag,
Info,
Invoice,
Link,
Expand Down
28 changes: 16 additions & 12 deletions src/components/TextInputWithLabel.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import _ from 'underscore';
import React from 'react';
// eslint-disable-next-line no-restricted-imports
import {View, TextInput} from 'react-native';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../styles/styles';
import ExpensifyText from './ExpensifyText';
import TextLink from './TextLink';
import TextInputWithPrefix from './TextInputWithPrefix';

const propTypes = {
/** Label text */
Expand All @@ -14,6 +14,12 @@ const propTypes = {
/** Text to show if there is an error */
errorText: PropTypes.string,

/** Prefix character prepended to the text input */
prefixCharacter: PropTypes.string,

/** Placeholder to display when the text input is empty */
placeholder: PropTypes.string,

/** Styles for the outermost container for this component. */
containerStyles: PropTypes.arrayOf(PropTypes.object),

Expand All @@ -25,15 +31,21 @@ const propTypes = {

/** Whether to disable the field and style */
disabled: PropTypes.bool,

/** Callback to execute when the text input is modified */
onChangeText: PropTypes.func,
};

const defaultProps = {
label: '',
errorText: '',
prefixCharacter: '',
containerStyles: [],
helpLinkText: '',
helpLinkURL: '',
disabled: false,
placeholder: '',
onChangeText: () => {},
};

const TextInputWithLabel = props => (
Expand All @@ -54,16 +66,8 @@ const TextInputWithLabel = props => (
</TextLink>
)}
</View>
<TextInput
style={[
styles.textInput,
styles.mb1,
props.disabled ? styles.inputDisabled : undefined,
props.errorText ? styles.errorOutline : undefined,
]}
// eslint-disable-next-line react/jsx-props-no-spreading
{..._.omit(props, ['label', 'errorText'])}
/>
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
<TextInputWithPrefix {...(_.omit(props, 'helpLinkText', 'helpLinkURL', 'containerStyles', 'label'))} />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yuwenmemon See my comment here about implicitly passing TextInput props.

{props.errorText !== '' && (
<ExpensifyText style={[styles.formError]}>{props.errorText}</ExpensifyText>
)}
Expand Down
58 changes: 58 additions & 0 deletions src/components/TextInputWithPrefix/index.android.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import PropTypes from 'prop-types';
// eslint-disable-next-line no-restricted-imports
import {TextInput, View} from 'react-native';
import _ from 'underscore';
import React from 'react';
import ExpensifyText from '../ExpensifyText';
import styles from '../../styles/styles';

const propTypes = {
/** Prefix character */
prefixCharacter: PropTypes.string,

/** Text to show if there is an error */
errorText: PropTypes.string,

/** Whether to disable the field and style */
disabled: PropTypes.bool,

/** Callback to execute the text input is modified */
onChangeText: PropTypes.func,
};

const defaultProps = {
errorText: '',
prefixCharacter: '',
disabled: false,
onChangeText: () => {},
};

const TextInputWithPrefix = props => (_.isEmpty(props.prefixCharacter)
// eslint-disable-next-line react/jsx-props-no-spreading
? <TextInput {..._.omit(props, ['prefixCharacter', 'errorText'])} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about props spreading as the one above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, there are other TextInput props that are being passed implicitly in addition with the other props we've defined in propTypes, so I think it makes sense to use prop spreading here. Otherwise, I'd have to pass every single one of these props individually, which seems unnecessary.

: (
<View
style={[
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, linter was being weird.

styles.textInputWithPrefix.container,
{paddingTop: 0},
props.disabled && styles.inputDisabled,
props.errorText && styles.errorOutline,
]}
>
<ExpensifyText style={[styles.textInputWithPrefix.prefix, {paddingTop: 10}]}>{props.prefixCharacter}</ExpensifyText>
<TextInput
style={[
styles.textInputWithPrefix.textInput,
styles.noOutline,
{height: 40},
]}
onChangeText={text => props.onChangeText(`${props.prefixCharacter}${text}`)}
// eslint-disable-next-line react/jsx-props-no-spreading
{..._.omit(props, ['prefixCharacter', 'errorText', 'onChangeText'])}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, let's just explicitly list out the props to pass if we can

/>
</View>
));

TextInputWithPrefix.propTypes = propTypes;
TextInputWithPrefix.defaultProps = defaultProps;
export default TextInputWithPrefix;
56 changes: 56 additions & 0 deletions src/components/TextInputWithPrefix/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import PropTypes from 'prop-types';
// eslint-disable-next-line no-restricted-imports
import {TextInput, View} from 'react-native';
import _ from 'underscore';
import React from 'react';
import ExpensifyText from '../ExpensifyText';
import styles from '../../styles/styles';

const propTypes = {
/** Prefix character */
prefixCharacter: PropTypes.string,

/** Text to show if there is an error */
errorText: PropTypes.string,

/** Whether to disable the field and style */
disabled: PropTypes.bool,

/** Callback to execute the text input is modified */
onChangeText: PropTypes.func,
};

const defaultProps = {
errorText: '',
prefixCharacter: '',
disabled: false,
onChangeText: () => {},
};

const TextInputWithPrefix = props => (_.isEmpty(props.prefixCharacter)
// eslint-disable-next-line react/jsx-props-no-spreading
? <TextInput {..._.omit(props, ['prefixCharacter', 'errorText'])} />
: (
<View
style={[
Copy link
Contributor Author

@jasperhuangg jasperhuangg Nov 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linter was being weird here and required an extra 4 spaces for some reason, hence the extra indent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a problem with our linter?

styles.textInputWithPrefix.container,
props.disabled ? styles.inputDisabled : undefined,
props.errorText ? styles.errorOutline : undefined,
]}
>
<ExpensifyText style={styles.textInputWithPrefix.prefix}>{props.prefixCharacter}</ExpensifyText>
<TextInput
style={[
styles.textInputWithPrefix.textInput,
styles.noOutline,
]}
onChangeText={text => props.onChangeText(`${props.prefixCharacter}${text}`)}
// eslint-disable-next-line react/jsx-props-no-spreading
{..._.omit(props, ['prefixCharacter', 'errorText', 'onChangeText'])}
/>
</View>
));

TextInputWithPrefix.propTypes = propTypes;
TextInputWithPrefix.defaultProps = defaultProps;
export default TextInputWithPrefix;
13 changes: 13 additions & 0 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export default {
fabAction: 'New chat',
newChat: 'New chat',
newGroup: 'New group',
newRoom: 'New Room',
headerChat: 'Chats',
buttonSearch: 'Search',
buttonMySettings: 'My settings',
Expand Down Expand Up @@ -793,6 +794,18 @@ export default {
emojiPicker: {
skinTonePickerLabel: 'Change default skin tone',
},
newRoomPage: {
newRoom: 'New Room',
roomName: 'Room Name',
visibility: 'Visibility',
restrictedDescription: 'People in your workspace are able to find this room using Search',
privateDescription: 'Only people invited to this room are able to find it',
createRoom: 'Create Room',
roomAlreadyExists: 'A room with this name already exists',
social: 'social',
selectAWorkspace: 'Select a workspace',
growlMessageOnError: 'Unable to create policy room, please check your connection and try again.',
},
keyboardShortcutModal: {
title: 'Keyboard Shortcuts',
subtitle: 'Save time with these handy keyboard shortcuts:',
Expand Down
13 changes: 13 additions & 0 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export default {
fabAction: 'Nuevo chat',
newChat: 'Nuevo chat',
newGroup: 'Nuevo grupo',
newRoom: 'Nueva sala de chat',
headerChat: 'Chats',
buttonSearch: 'Buscar',
buttonMySettings: 'Mi configuración',
Expand Down Expand Up @@ -795,6 +796,18 @@ export default {
emojiPicker: {
skinTonePickerLabel: 'Elige el tono de piel por defecto',
},
newRoomPage: {
newRoom: 'Nueva sala de chat',
roomName: 'Nombre de la sala',
visibility: 'Visibilidad',
restrictedDescription: 'Sólo las personas en tu espacio de trabajo pueden encontrar esta sala a través de "Buscar"',
privateDescription: 'Sólo las personas que están invitadas a esta sala pueden encontrarla',
createRoom: 'Crea una sala de chat',
roomAlreadyExists: 'Ya existe una sala con este nombre',
social: 'social',
selectAWorkspace: 'Seleccionar un espacio de trabajo',
growlMessageOnError: 'No ha sido posible crear el espacio de trabajo, por favor comprueba tu conexión e inténtalo de nuevo.',
},
keyboardShortcutModal: {
title: 'Atajos de teclado',
subtitle: 'Ahorra tiempo con estos atajos de teclado:',
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Navigation/AppNavigator/ModalStackNavigators.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import WorkspaceBillsPage from '../../../pages/workspace/bills/WorkspaceBillsPag
import WorkspaceTravelPage from '../../../pages/workspace/travel/WorkspaceTravelPage';
import WorkspaceMembersPage from '../../../pages/workspace/WorkspaceMembersPage';
import WorkspaceBankAccountPage from '../../../pages/workspace/WorkspaceBankAccountPage';
import WorkspaceNewRoomPage from '../../../pages/workspace/WorkspaceNewRoomPage';
import CONST from '../../../CONST';

const defaultSubRouteOptions = {
Expand Down Expand Up @@ -222,6 +223,10 @@ const SettingsModalStackNavigator = createModalStackNavigator([
Component: WorkspaceInvitePage,
name: 'Workspace_Invite',
},
{
Component: WorkspaceNewRoomPage,
name: 'Workspace_NewRoom',
},
{
Component: ReimbursementAccountPage,
name: 'ReimbursementAccount',
Expand Down
3 changes: 3 additions & 0 deletions src/libs/Navigation/linkingConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ export default {
Workspace_Invite: {
path: ROUTES.WORKSPACE_INVITE,
},
Workspace_NewRoom: {
path: ROUTES.WORKSPACE_NEW_ROOM,
},
ReimbursementAccount: {
path: ROUTES.BANK_ACCOUNT_WITH_STEP_TO_OPEN,
exact: true,
Expand Down
13 changes: 9 additions & 4 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1451,28 +1451,33 @@ function handleInaccessibleReport() {
}

/**
* Creates a policy room and fetches it
* Creates a policy room, fetches it, and navigates to it.
* @param {String} policyID
* @param {String} reportName
* @param {String} visibility
* @return {Promise}
*/
function createPolicyRoom(policyID, reportName, visibility) {
Onyx.set(ONYXKEYS.IS_LOADING_CREATE_POLICY_ROOM, true);
return API.CreatePolicyRoom({policyID, reportName, visibility})
.then((response) => {
if (response.jsonCode !== 200) {
Log.hmmm(response.message);
Growl.error(response.message);
return;
}
return fetchChatReportsByIDs([response.reportID]);
})
.then(([{reportID}]) => {
if (!reportID) {
Log.hmmm('Unable to grab policy room after creation');
Log.error('Unable to grab policy room after creation', reportID);
return;
}
Navigation.navigate(ROUTES.getReportRoute(reportID));
});
})
.catch(() => {
Growl.error(Localize.translateLocal('newRoomPage.growlMessageOnError'));
})
.finally(() => Onyx.set(ONYXKEYS.IS_LOADING_CREATE_POLICY_ROOM, false));
}

export {
Expand Down
Loading