Skip to content
Merged
Changes from all commits
Commits
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
23 changes: 12 additions & 11 deletions src/pages/ReportDetailsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,34 +54,33 @@ const propTypes = {
};

class ReportDetailsPage extends Component {
constructor(props) {
super(props);
Comment on lines -57 to -58

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

constructor is compulsory for class components.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happened with this comment? If it is compulsory then why are we removing it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh I see it here: #14596 (comment)

getMenuItems() {
const menuItems = [];

this.menuItems = [];
if (ReportUtils.isArchivedRoom(this.props.report)) {
return;
return [];
}

// All nonarchived chats should let you see their members
this.menuItems.push({
menuItems.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.MEMBERS,
translationKey: 'common.members',
icon: Expensicons.Users,
subtitle: lodashGet(props.report, 'participants', []).length,
action: () => { Navigation.navigate(ROUTES.getReportParticipantsRoute(props.report.reportID)); },
subtitle: lodashGet(this.props.report, 'participants', []).length,
action: () => { Navigation.navigate(ROUTES.getReportParticipantsRoute(this.props.report.reportID)); },
});

if (ReportUtils.isPolicyExpenseChat(this.props.report) || ReportUtils.isChatRoom(this.props.report)) {
this.menuItems.push({
menuItems.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.SETTINGS,
translationKey: 'common.settings',
icon: Expensicons.Gear,
action: () => { Navigation.navigate(ROUTES.getReportSettingsRoute(props.report.reportID)); },
action: () => { Navigation.navigate(ROUTES.getReportSettingsRoute(this.props.report.reportID)); },
});
}

if (ReportUtils.isUserCreatedPolicyRoom(this.props.report)) {
this.menuItems.push({
menuItems.push({
key: CONST.REPORT_DETAILS_MENU_ITEM.INVITE,
translationKey: 'common.invite',
icon: Expensicons.Plus,
Expand All @@ -94,6 +93,7 @@ class ReportDetailsPage extends Component {
action: () => { /* Placeholder for when leaving rooms is built in */ },
});
}
return menuItems;
}

render() {
Expand All @@ -106,6 +106,7 @@ class ReportDetailsPage extends Component {
OptionsListUtils.getPersonalDetailsForLogins(participants, this.props.personalDetails),
isMultipleParticipant,
);
const menuItems = this.getMenuItems();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

NAB this variable isn't really necessary

return (
<ScreenWrapper>
<HeaderWithCloseButton
Expand Down Expand Up @@ -148,7 +149,7 @@ class ReportDetailsPage extends Component {
</View>
</View>
</View>
{_.map(this.menuItems, (item) => {
{_.map(menuItems, (item) => {
const brickRoadIndicator = (
ReportUtils.hasReportNameError(this.props.report)
&& item.key === CONST.REPORT_DETAILS_MENU_ITEM.SETTINGS
Expand Down