-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Report Details and Settings for User Created Policy Rooms #7028
Merged
Merged
Changes from all commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
43379fd
Add skeleton for Policy Rooms Details Page items
1be77c7
Add report settings route
06b5357
Add copy for leaving a chat room
82918f0
Use SignOut icon for leaving the room
df53b7c
Use placeholders for functionality that will come in later issues
4311da5
Allow us to properly see when there are 0 other members in a policy room
a842885
Add routes for report settings
8581def
Merge branch 'main' of github.com:Expensify/App into amal-policy-room…
d5eac97
Rename SignOut to Exit to be more universally used
a20785a
Fix alphabetical ordering
1b7ef56
Remove typo extra line
bddeb9e
Create skeleton SettingsPage
e3962db
Fix imports
9f10475
Fix spacing
f556532
Add onyx props and definitions
75e9fc4
Add Report Settings to modal stack
5ed8498
lint fixes for space styling and imports
bcb5e99
Fix blank menu items for default rooms
0459d03
Move Notification Preferences to Report Settings Page for UCPRs
7dee263
Add route propTypes to new component
f5815da
Create Notification Preferences component
775cc93
Use NotificationPreferences component and remove redundant code
7933796
Fix style and use correct imports
84da563
Add title into component
4db2921
Add description in notification preferences and reorganize translation
f10df0c
Fix weird margins for SettingsPage
bbd1d4d
Add spanish translation for notification preferences
7faba99
Merge branch 'main' of github.com:Expensify/App into amal-policy-room…
aae68ad
Remove unneeded Notification Preferences
747b705
Move NotificationPrefences to Settings and set up view
440a8a7
Disable rename for defaultRooms and archived rooms
f5edbbd
Add in report name and prevent renaming for default and archived rooms
d127b85
Rework into class component to use room name changing
c591f0d
Rework room name renaming to work like in NewRoomPage
82912cc
Use substring instead of deprecated substr
d55a47c
Include policy details to correctly display Workspace Name
86ccf4e
Style fix
61bca31
Add visibility information
066ff33
Add visibility to simplifiedReportData so it can be used
9e1aabd
Add rest of visibility information to Settings component
776050a
Fix report visibility description and style
cde74ff
Lint style fix
bfe3e1d
Allow Buttons to have custom styles on the OpacityView to configure h…
a11bd00
Add styles for inner part of button in ReportSettingsPage
6454645
Merge branch 'main' of github.com:Expensify/App into amal-policy-room…
877c733
Add context to how report visibility is being used
b07962e
Move propTypes to appropriate location
f3b0b26
Remove unused values
39c2a5e
Remove unsued View and reorganize styles
5e10c08
Add RoomNameInput component to consolidate room naming component
763af4a
Use new RoomNameInput component
fb11343
Make RoomNameInput functional with the ReportSettingsPage
04fc0cc
lint fixes/ cleaning up unused code
a8b8fe3
Make RoomNameInput work with WorkspaceNewRoomPage
18552c1
lint import
a9e062d
Make this work with actual policies and room names
6ae4a2b
Better error checking with bubbling up to the top
2946b30
Fix error checking cases
1554534
Fix error when nothing is changed in RoomSettingsPage
61af6c8
Clean up Onyx Props and comments
ea6832c
Use styles to capitalize instead to better futureproof
698ae3f
Merge branch 'main' of github.com:Expensify/App into amal-policy-room…
ede4c29
Remove unneeded extra newlines
2130aff
Use ternary to simplify error logic
730cb46
Keep originalRoomName out of state to avoid react/no-access-state-in-…
9a03719
Use return early style instead and clear up comments
4545fb7
Merge branch 'main' of github.com:Expensify/App into amal-policy-room…
6ddfd43
Rename buttonStyles to innerStyles
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
import React, {Component} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import _ from 'underscore'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import CONST from '../CONST'; | ||
import ONYXKEYS from '../ONYXKEYS'; | ||
import styles from '../styles/styles'; | ||
import compose from '../libs/compose'; | ||
import withLocalize, {withLocalizePropTypes} from './withLocalize'; | ||
import withFullPolicy, {fullPolicyDefaultProps, fullPolicyPropTypes} from '../pages/workspace/withFullPolicy'; | ||
|
||
import TextInputWithPrefix from './TextInputWithPrefix'; | ||
|
||
const propTypes = { | ||
/** Callback to execute when the text input is modified correctly */ | ||
onChangeText: PropTypes.func, | ||
|
||
/** Callback to execute when an error gets found/cleared/modified */ | ||
onChangeError: PropTypes.func, | ||
|
||
/** Initial room name to show in input field. This should include the '#' already prefixed to the name */ | ||
initialValue: PropTypes.string, | ||
|
||
/** Whether we should show the input as disabled */ | ||
disabled: PropTypes.bool, | ||
|
||
/** ID of policy whose room names we should be checking for duplicates */ | ||
policyID: PropTypes.string, | ||
|
||
...withLocalizePropTypes, | ||
...fullPolicyPropTypes, | ||
|
||
/* Onyx Props */ | ||
|
||
/** All reports shared with the user */ | ||
reports: PropTypes.shape({ | ||
/** The report name */ | ||
reportName: PropTypes.string, | ||
|
||
/** ID of the report */ | ||
reportID: PropTypes.number, | ||
}).isRequired, | ||
|
||
/** The policies which the user has access to and which the report could be tied to */ | ||
policies: PropTypes.shape({ | ||
/** The policy name */ | ||
name: PropTypes.string, | ||
|
||
/** ID of the policy */ | ||
id: PropTypes.string, | ||
}).isRequired, | ||
}; | ||
|
||
const defaultProps = { | ||
onChangeText: () => {}, | ||
onChangeError: () => {}, | ||
initialValue: '', | ||
disabled: false, | ||
policyID: '', | ||
...fullPolicyDefaultProps, | ||
}; | ||
|
||
class RoomNameInput extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
roomName: props.initialValue, | ||
error: '', | ||
}; | ||
|
||
this.originalRoomName = props.initialValue; | ||
|
||
this.checkAndModifyRoomName = this.checkAndModifyRoomName.bind(this); | ||
} | ||
|
||
componentDidUpdate(prevProps, prevState) { | ||
// As we are modifying the text input, we'll bubble up any changes/errors so the parent component can see it | ||
if (prevState.roomName !== this.state.roomName) { | ||
this.props.onChangeText(this.state.roomName); | ||
} | ||
if (prevState.error !== this.state.error) { | ||
this.props.onChangeError(this.state.error); | ||
} | ||
} | ||
|
||
/** | ||
* Modifies the room name to follow our conventions: | ||
* - Max length 80 characters | ||
* - Cannot not include space or special characters, and we automatically apply an underscore for spaces | ||
* - Must be lowercase | ||
* Also checks to see if this room name already exists, and displays an error message if so. | ||
* @param {String} roomName | ||
* | ||
*/ | ||
checkAndModifyRoomName(roomName) { | ||
const modifiedRoomNameWithoutHash = roomName.substring(1) | ||
.replace(/ /g, '_') | ||
.replace(/[^a-zA-Z\d_]/g, '') | ||
.substring(0, CONST.REPORT.MAX_ROOM_NAME_LENGTH) | ||
.toLowerCase(); | ||
const finalRoomName = `#${modifiedRoomNameWithoutHash}`; | ||
|
||
const isExistingRoomName = _.some( | ||
_.values(this.props.reports), | ||
report => report && report.policyID === this.props.policyID && report.reportName === finalRoomName, | ||
); | ||
|
||
// We error if the room name already exists. We don't care if it matches the original name provided in this | ||
// component because then we are not changing the room's name. | ||
const error = isExistingRoomName && finalRoomName !== this.originalRoomName | ||
? this.props.translate('newRoomPage.roomAlreadyExists') | ||
: ''; | ||
|
||
this.setState({ | ||
roomName: finalRoomName, | ||
error, | ||
}); | ||
} | ||
|
||
render() { | ||
return ( | ||
<TextInputWithPrefix | ||
disabled={this.props.disabled} | ||
label={this.props.translate('newRoomPage.roomName')} | ||
prefixCharacter="#" | ||
placeholder={this.props.translate('newRoomPage.social')} | ||
containerStyles={[styles.mb5]} | ||
onChangeText={roomName => this.checkAndModifyRoomName(roomName)} | ||
value={this.state.roomName.substring(1)} | ||
errorText={this.state.error} | ||
autoCapitalize="none" | ||
/> | ||
); | ||
} | ||
} | ||
|
||
RoomNameInput.propTypes = propTypes; | ||
RoomNameInput.defaultProps = defaultProps; | ||
|
||
export default compose( | ||
withLocalize, | ||
withFullPolicy, | ||
withOnyx({ | ||
reports: { | ||
key: ONYXKEYS.COLLECTION.REPORT, | ||
}, | ||
policies: { | ||
key: ONYXKEYS.COLLECTION.POLICY, | ||
}, | ||
}), | ||
)(RoomNameInput); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra newline