Skip to content
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
5 changes: 1 addition & 4 deletions config/oxlint/oxlint.seatbelt.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
"../../src/components/ReimbursementAccountLoadingIndicator.tsx" "no-restricted-imports" 1
"../../src/components/ReportActionItem/MoneyRequestReceiptView.tsx" "@typescript-eslint/no-unsafe-type-assertion" 2
"../../src/components/ReportActionItem/MoneyRequestReceiptView.tsx" "react-hooks/set-state-in-effect" 1
"../../src/components/ReportActionItem/MoneyRequestView.tsx" "@typescript-eslint/no-deprecated/MenuItemWithTopDescription" 5
"../../src/components/ReportActionItem/MoneyRequestView.tsx" "@typescript-eslint/no-deprecated/MenuItemWithTopDescription" 4
"../../src/components/ReportActionItem/ReportActionItemImage.tsx" "@typescript-eslint/no-unnecessary-type-assertion" 2
"../../src/components/ReportActionItem/TaskPreview.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/components/ReportActionItem/TaskView.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
Expand Down Expand Up @@ -460,7 +460,6 @@
"../../src/components/UserInitialsAvatar.tsx" "@typescript-eslint/no-deprecated/fontSize" 1
"../../src/components/ValidateCodeActionModal/ValidateCodeActionContent.tsx" "rulesdir/no-onyx-loading-status" 1
"../../src/components/ValidateCodeInput.tsx" "react-hooks/set-state-in-effect" 3
"../../src/components/ValuePicker/index.tsx" "@typescript-eslint/no-deprecated/MenuItemWithTopDescription" 1
"../../src/components/ValuePicker/ValueSelectorModal.tsx" "no-restricted-imports" 1
"../../src/components/VideoPlayer/BaseVideoPlayer.tsx" "@typescript-eslint/no-unnecessary-type-assertion" 4
"../../src/components/VideoPlayer/BaseVideoPlayer.tsx" "@typescript-eslint/no-unsafe-type-assertion" 7
Expand Down Expand Up @@ -1052,7 +1051,6 @@
"../../src/pages/domain/Members/MoveUserBetweenGroupsPage.tsx" "no-restricted-imports" 1
"../../src/pages/domain/Members/MoveUsersBetweenGroupsPage.tsx" "no-restricted-imports" 1
"../../src/pages/DynamicEditReportFieldPage.tsx" "no-restricted-imports" 1
"../../src/pages/DynamicFlagCommentPage.tsx" "@typescript-eslint/no-deprecated/MenuItem" 1
"../../src/pages/DynamicFlagCommentPage.tsx" "no-restricted-imports" 1
"../../src/pages/DynamicNewReportWorkspaceSelectionPage.tsx" "no-restricted-imports" 1
"../../src/pages/DynamicReferralDetailsPage.tsx" "@typescript-eslint/no-deprecated/MenuItem" 1
Expand Down Expand Up @@ -1373,7 +1371,6 @@
"../../src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx" "@typescript-eslint/no-unsafe-type-assertion" 7
"../../src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx" "no-restricted-imports" 1
"../../src/pages/settings/Profile/PersonalDetails/PrivatePersonalDetailsPage.tsx" "react-hooks/purity" 2
"../../src/pages/settings/Profile/ProfilePage.tsx" "@typescript-eslint/no-deprecated/MenuItemWithTopDescription" 1
"../../src/pages/settings/Profile/ProfilePage.tsx" "@typescript-eslint/no-unsafe-type-assertion" 1
"../../src/pages/settings/Profile/ProfilePage.tsx" "no-restricted-imports" 1
"../../src/pages/settings/Profile/PronounsPage.tsx" "no-restricted-imports" 1
Expand Down
78 changes: 53 additions & 25 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ function MoneyRequestView({
event?.stopPropagation();
openExternalLink(`${CONST.GOOGLE_SEARCH_URL}${encodeURIComponent(originalMerchantForGoogleSearch)}`);
}}
style={[styles.flexRow, styles.alignItemsCenter, styles.mt1, styles.alignSelfStart]}
style={[styles.flexRow, styles.alignItemsCenter, styles.alignSelfStart]}
>
<Text style={styles.textLabelSupporting}>
{translate('common.googleThisMerchant', {
Expand Down Expand Up @@ -1412,31 +1412,59 @@ function MoneyRequestView({
distanceRequestFields
) : (
<OfflineWithFeedback pendingAction={getPendingFieldAction('merchant')}>
<MenuItemWithTopDescription
<MenuItem.Root
sentryLabel={CONST.SENTRY_LABEL.MONEY_REQUEST_VIEW.MERCHANT_FIELD}
description={translate('common.merchant')}
descriptionTextStyle={[styles.breakWord, styles.userSelectNone]}
title={updatedMerchantTitle}
interactive={canEditMerchant}
shouldShowRightIcon={canEditMerchant}
titleStyle={styles.flex1}
onPress={() => {
Navigation.navigate(
createDynamicRoute(
DYNAMIC_ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(CONST.IOU.ACTION.EDIT, iouType, transaction.transactionID, transactionThreadReport?.reportID),
),
);
}}
wrapperStyle={[styles.taskDescriptionMenuItem]}
furtherDetailsComponent={shouldShowGoogleMerchantSearchLink ? renderGoogleMerchantSearchLink() : undefined}
brickRoadIndicator={getErrorForField('merchant') ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
errorText={getErrorForField('merchant')}
errorTextStyle={styles.userSelectNone}
numberOfLinesTitle={0}
copyValue={merchantCopyValue}
copyable={!canEditMerchant && !!merchantCopyValue}
isTitleSelectable={!!merchantCopyValue}
/>
shouldAllowTextSelection={!!merchantCopyValue}
shouldBeAccessible={canEditMerchant || !shouldShowGoogleMerchantSearchLink}
style={styles.taskDescriptionMenuItem}
onPress={
canEditMerchant
? callIfAuthenticated(() => {
Navigation.navigate(
createDynamicRoute(
DYNAMIC_ROUTES.MONEY_REQUEST_STEP_MERCHANT.getRoute(
CONST.IOU.ACTION.EDIT,
iouType,
transaction.transactionID,
transactionThreadReport?.reportID,
),
),
);
}, session)
: undefined
}
>
<MenuItem.Row>
<MenuItem.Content>
{updatedMerchantTitle ? (
<>
<MenuItem.FieldName>{translate('common.merchant')}</MenuItem.FieldName>
<MenuItem.FieldValue
numberOfLines={0}
isSelectable={!!merchantCopyValue}
style={styles.flex1}
>
{updatedMerchantTitle}
</MenuItem.FieldValue>
</>
) : (
<MenuItem.FieldNamePlaceholder>{translate('common.merchant')}</MenuItem.FieldNamePlaceholder>
)}
{shouldShowGoogleMerchantSearchLink && renderGoogleMerchantSearchLink()}
</MenuItem.Content>
<MenuItem.Trailing>
{!!getErrorForField('merchant') && <MenuItem.BrickRoadIndicator status={CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR} />}
{canEditMerchant && <MenuItem.Chevron />}
{!canEditMerchant && !!merchantCopyValue && <MenuItem.Copy value={merchantCopyValue} />}
</MenuItem.Trailing>
</MenuItem.Row>
{!!getErrorForField('merchant') && (
<MenuItem.HelpText
isError
message={getErrorForField('merchant')}
/>
)}
</MenuItem.Root>
</OfflineWithFeedback>
)}
<OfflineWithFeedback pendingAction={getPendingFieldAction('created')}>
Expand Down
2 changes: 0 additions & 2 deletions src/components/TextPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function TextPicker({
errorText = '',
onInputChange,
onValueCommitted,
furtherDetails,
rightLabel,
disabled = false,
interactive = true,
Expand Down Expand Up @@ -67,7 +66,6 @@ function TextPicker({
title={value ?? placeholder ?? ''}
description={description}
onPress={showPickerModal}
furtherDetails={furtherDetails}
rightLabel={rightLabel}
brickRoadIndicator={errorText ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
errorText={errorText}
Expand Down
3 changes: 0 additions & 3 deletions src/components/TextPicker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ type TextPickerProps = {
*/
onValueCommitted?: (value: string) => void;

/** Text to display under the main menu item */
furtherDetails?: string;

shouldShowTooltips?: boolean;

/** The ID used to uniquely identify the input in a Form */
Expand Down
62 changes: 49 additions & 13 deletions src/components/ValuePicker/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
import MenuItem from '@components/MenuItem';
import Text from '@components/Text';

import useOnyx from '@hooks/useOnyx';
import useThemeStyles from '@hooks/useThemeStyles';

import Navigation from '@libs/Navigation/Navigation';

import {callIfAuthenticated} from '@userActions/Session';

import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';

import {authTokenTypeSelector} from '@selectors/Session';
import React, {useState} from 'react';
import {View} from 'react-native';

Expand All @@ -14,7 +22,7 @@ import ValueSelectorModal from './ValueSelectorModal';

function ValuePicker({
value,
label,
label = '',
modalHeaderTitle,
shouldReadErrorWithLabel,
items,
Expand All @@ -33,6 +41,8 @@ function ValuePicker({
disabled = false,
}: ValuePickerProps) {
const [isPickerVisible, setIsPickerVisible] = useState(false);
const [session] = useOnyx(ONYXKEYS.SESSION, {selector: authTokenTypeSelector});
const styles = useThemeStyles();

const showPickerModal = () => {
setIsPickerVisible(true);
Expand All @@ -51,25 +61,51 @@ function ValuePicker({
};

const selectedItem = items?.find((item) => item.value === value);
const title = selectedItem?.label || placeholder || '';

return (
<View>
{shouldShowModal ? (
<>
<MenuItemWithTopDescription
<MenuItem.Root
ref={ref}
shouldShowRightIcon
title={selectedItem?.label || placeholder || ''}
description={label}
onPress={showPickerModal}
disabled={disabled}
onPress={callIfAuthenticated(showPickerModal, session)}
isDisabled={disabled}
sentryLabel={CONST.SENTRY_LABEL.VALUE_PICKER.OPEN}
furtherDetails={furtherDetails}
brickRoadIndicator={errorText ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
errorText={errorText}
shouldReadErrorWithLabel={shouldReadErrorWithLabel}
forwardedFSClass={forwardedFSClass}
/>
>
<MenuItem.Row>
<MenuItem.Content>
{title ? (
<>
<MenuItem.FieldName>{label}</MenuItem.FieldName>
<MenuItem.FieldValue forwardedFSClass={forwardedFSClass}>{title}</MenuItem.FieldValue>
</>
) : (
<MenuItem.FieldNamePlaceholder>{label}</MenuItem.FieldNamePlaceholder>
)}
{!!furtherDetails && (
<Text
style={styles.textLabelSupporting}
numberOfLines={2}
>
{furtherDetails}
</Text>
)}
</MenuItem.Content>
<MenuItem.Trailing>
{!!errorText && <MenuItem.BrickRoadIndicator status={CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR} />}
<MenuItem.Chevron />
</MenuItem.Trailing>
</MenuItem.Row>
{!!errorText && (
<MenuItem.HelpText
isError
message={errorText}
shouldReadErrorWithLabel={shouldReadErrorWithLabel}
/>
)}
</MenuItem.Root>
<ValueSelectorModal
isVisible={isPickerVisible}
label={modalHeaderTitle ?? label}
Expand Down
32 changes: 25 additions & 7 deletions src/pages/DynamicFlagCommentPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import InlineIcon from '@components/Icon/InlineIcon';
import MenuItem from '@components/MenuItem';
import ScreenWrapper from '@components/ScreenWrapper';
import ScrollView from '@components/ScrollView';
Expand Down Expand Up @@ -145,17 +146,34 @@ function DynamicFlagCommentPage({parentReportAction, report, parentReport, repor
};

const severityMenuItems = severities.map((item) => (
<MenuItem
<MenuItem.Root
sentryLabel={item.sentryLabel}
key={`${item.severity}`}
shouldShowRightIcon
title={item.name}
description={item.description}
onPress={callIfAuthenticated(() => flagComment(item.severity), session)}
style={[styles.pt2, styles.pb4, styles.ph5, styles.flexRow]}
furtherDetails={item.furtherDetails}
furtherDetailsIcon={item.furtherDetailsIcon}
/>
>
<MenuItem.Row>
<MenuItem.Content>
<MenuItem.Title>{item.name}</MenuItem.Title>
<MenuItem.Description>{item.description}</MenuItem.Description>
<View style={[styles.flexRow, styles.alignItemsCenter]}>
<InlineIcon
src={item.furtherDetailsIcon}
size={CONST.ICON_SIZE.MEDIUM}
/>
<Text
style={[styles.furtherDetailsText, styles.pl2, styles.pt1]}
numberOfLines={2}
>
{item.furtherDetails}
</Text>
</View>
</MenuItem.Content>
<MenuItem.Trailing>
<MenuItem.Chevron />
</MenuItem.Trailing>
</MenuItem.Row>
</MenuItem.Root>
));

return (
Expand Down
Loading
Loading