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

optionslist-to-selectionslist #29337

Merged
Show file tree
Hide file tree
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
25 changes: 4 additions & 21 deletions src/pages/settings/Report/NotificationPreferencePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import _ from 'underscore';
import ScreenWrapper from '../../../components/ScreenWrapper';
import HeaderWithBackButton from '../../../components/HeaderWithBackButton';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
import styles from '../../../styles/styles';
import OptionsList from '../../../components/OptionsList';
import Navigation from '../../../libs/Navigation/Navigation';
import compose from '../../../libs/compose';
import withReportOrNotFound from '../../home/report/withReportOrNotFound';
Expand All @@ -14,16 +12,14 @@ import ROUTES from '../../../ROUTES';
import CONST from '../../../CONST';
import * as Report from '../../../libs/actions/Report';
import * as ReportUtils from '../../../libs/ReportUtils';
import * as Expensicons from '../../../components/Icon/Expensicons';
import themeColors from '../../../styles/themes/default';
import SelectionList from '../../../components/SelectionList';

const propTypes = {
...withLocalizePropTypes,

/** The report for which we are setting notification preferences */
report: reportPropTypes.isRequired,
};
const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success};

function NotificationPreferencePage(props) {
const shouldDisableNotificationPreferences = ReportUtils.isArchivedRoom(props.report);
Expand All @@ -33,12 +29,7 @@ function NotificationPreferencePage(props) {
value: preference,
text: props.translate(`notificationPreferencesPage.notificationPreferences.${preference}`),
keyForList: preference,

// Include the green checkmark icon to indicate the currently selected value
customIcon: preference === props.report.notificationPreference ? greenCheckmark : null,

// This property will make the currently selected value have bold text
boldStyle: preference === props.report.notificationPreference,
isSelected: preference === props.report.notificationPreference,
}),
);

Expand All @@ -52,18 +43,10 @@ function NotificationPreferencePage(props) {
title={props.translate('notificationPreferencesPage.header')}
onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(props.report.reportID))}
/>
<OptionsList
<SelectionList
sections={[{data: notificationPreferenceOptions}]}
onSelectRow={(option) => Report.updateNotificationPreference(props.report.reportID, props.report.notificationPreference, option.value, true)}
hideSectionHeaders
optionHoveredStyle={{
...styles.hoveredComponentBG,
...styles.mhn5,
...styles.ph5,
}}
shouldHaveOptionSeparator
shouldDisableRowInnerPadding
contentContainerStyles={[styles.ph5]}
initiallyFocusedOptionKey={_.find(notificationPreferenceOptions, (locale) => locale.isSelected).keyForList}
/>
</FullPageNotFoundView>
</ScreenWrapper>
Expand Down
26 changes: 4 additions & 22 deletions src/pages/settings/Report/WriteCapabilityPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@ import CONST from '../../../CONST';
import ScreenWrapper from '../../../components/ScreenWrapper';
import HeaderWithBackButton from '../../../components/HeaderWithBackButton';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
import styles from '../../../styles/styles';
import OptionsList from '../../../components/OptionsList';
import Navigation from '../../../libs/Navigation/Navigation';
import compose from '../../../libs/compose';
import withReportOrNotFound from '../../home/report/withReportOrNotFound';
import reportPropTypes from '../../reportPropTypes';
import ROUTES from '../../../ROUTES';
import * as Report from '../../../libs/actions/Report';
import * as Expensicons from '../../../components/Icon/Expensicons';
import themeColors from '../../../styles/themes/default';
import * as ReportUtils from '../../../libs/ReportUtils';
import FullPageNotFoundView from '../../../components/BlockingViews/FullPageNotFoundView';
import * as PolicyUtils from '../../../libs/PolicyUtils';
import {policyPropTypes, policyDefaultProps} from '../../workspace/withPolicy';
import SelectionList from '../../../components/SelectionList';

const propTypes = {
...withLocalizePropTypes,
Expand All @@ -33,19 +30,12 @@ const defaultProps = {
...policyDefaultProps,
};

const greenCheckmark = {src: Expensicons.Checkmark, color: themeColors.success};

function WriteCapabilityPage(props) {
const writeCapabilityOptions = _.map(CONST.REPORT.WRITE_CAPABILITIES, (value) => ({
value,
text: props.translate(`writeCapabilityPage.writeCapability.${value}`),
keyForList: value,

// Include the green checkmark icon to indicate the currently selected value
customIcon: value === (props.report.writeCapability || CONST.REPORT.WRITE_CAPABILITIES.ALL) ? greenCheckmark : null,

// This property will make the currently selected value have bold text
boldStyle: value === (props.report.writeCapability || CONST.REPORT.WRITE_CAPABILITIES.ALL),
isSelected: value === (props.report.writeCapability || CONST.REPORT.WRITE_CAPABILITIES.ALL),
}));

const isAbleToEdit = !ReportUtils.isAdminRoom(props.report) && PolicyUtils.isPolicyAdmin(props.policy) && !ReportUtils.isArchivedRoom(props.report);
Expand All @@ -61,18 +51,10 @@ function WriteCapabilityPage(props) {
shouldShowBackButton
onBackButtonPress={() => Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(props.report.reportID))}
/>
<OptionsList
<SelectionList
sections={[{data: writeCapabilityOptions}]}
onSelectRow={(option) => Report.updateWriteCapabilityAndNavigate(props.report, option.value)}
hideSectionHeaders
optionHoveredStyle={{
...styles.hoveredComponentBG,
...styles.mhn5,
...styles.ph5,
}}
shouldHaveOptionSeparator
shouldDisableRowInnerPadding
contentContainerStyles={[styles.ph5]}
initiallyFocusedOptionKey={_.find(writeCapabilityOptions, (locale) => locale.isSelected).keyForList}
/>
</FullPageNotFoundView>
</ScreenWrapper>
Expand Down
Loading