-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix rename room permission #22316
fix rename room permission #22316
Changes from 4 commits
e300fe4
fc84f5e
346f13c
9823d69
3fec021
eae6aba
17c1ae9
277dcd1
795cd90
5fa3661
bf510dd
4585740
229b7a8
dd3d99f
56c632e
d02784e
4e02c35
00e18fc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ import reportPropTypes from '../../reportPropTypes'; | |
import ROUTES from '../../../ROUTES'; | ||
import * as Report from '../../../libs/actions/Report'; | ||
import RoomNameInput from '../../../components/RoomNameInput'; | ||
import * as Policy from '../../../libs/actions/Policy'; | ||
import FullPageNotFoundView from '../../../components/BlockingViews/FullPageNotFoundView'; | ||
|
||
const propTypes = { | ||
...withLocalizePropTypes, | ||
|
@@ -27,12 +29,20 @@ const propTypes = { | |
|
||
/** All reports shared with the user */ | ||
reports: PropTypes.objectOf(reportPropTypes), | ||
|
||
/** */ | ||
policy: PropTypes.shape({ | ||
role: PropTypes.string, | ||
owner: PropTypes.string, | ||
}), | ||
}; | ||
const defaultProps = { | ||
reports: {}, | ||
policy: {}, | ||
}; | ||
|
||
function RoomNamePage(props) { | ||
const policy = props.policy; | ||
const report = props.report; | ||
const reports = props.reports; | ||
const translate = props.translate; | ||
|
@@ -67,26 +77,28 @@ function RoomNamePage(props) { | |
|
||
return ( | ||
<ScreenWrapper includeSafeAreaPaddingBottom={false}> | ||
<HeaderWithBackButton | ||
title={translate('newRoomPage.roomName')} | ||
onBackButtonPress={() => Navigation.goBack(ROUTES.getReportSettingsRoute(report.reportID))} | ||
/> | ||
<Form | ||
style={[styles.flexGrow1, styles.ph5]} | ||
formID={ONYXKEYS.FORMS.ROOM_NAME_FORM} | ||
onSubmit={(values) => Report.updatePolicyRoomNameAndNavigate(report, values.roomName)} | ||
validate={validate} | ||
submitButtonText={translate('common.save')} | ||
enabledWhenOffline | ||
> | ||
<View style={styles.mb4}> | ||
<RoomNameInput | ||
inputID="roomName" | ||
autoFocus | ||
defaultValue={report.reportName} | ||
/> | ||
</View> | ||
</Form> | ||
<FullPageNotFoundView shouldShow={!Policy.isPolicyOwner(policy) && policy.role !== CONST.POLICY.ROLE.ADMIN}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hungvu193 This is duplicating the room rename permission logic. We should create a util function to have the logic of room rename permission check and use it in both these places. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abdulrahuman5196 Thank you, I've just fixed it |
||
<HeaderWithBackButton | ||
title={translate('newRoomPage.roomName')} | ||
onBackButtonPress={() => Navigation.goBack(ROUTES.getReportSettingsRoute(report.reportID))} | ||
/> | ||
<Form | ||
style={[styles.flexGrow1, styles.ph5]} | ||
formID={ONYXKEYS.FORMS.ROOM_NAME_FORM} | ||
onSubmit={(values) => Report.updatePolicyRoomNameAndNavigate(report, values.roomName)} | ||
validate={validate} | ||
submitButtonText={translate('common.save')} | ||
enabledWhenOffline | ||
> | ||
<View style={styles.mb4}> | ||
<RoomNameInput | ||
inputID="roomName" | ||
autoFocus | ||
defaultValue={report.reportName} | ||
/> | ||
</View> | ||
</Form> | ||
</FullPageNotFoundView> | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
@@ -102,5 +114,8 @@ export default compose( | |
reports: { | ||
key: ONYXKEYS.COLLECTION.REPORT, | ||
}, | ||
policy: { | ||
key: ({report}) => `${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, | ||
}, | ||
}), | ||
)(RoomNamePage); |
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.
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.
@hungvu193 Kindly add proper comment for the policy
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.
Oops my bad. Updated!