-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[DB MileageRate] Replace workspace mileage rate list with table UI #90920
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
Draft
Krishna2323
wants to merge
7
commits into
Expensify:main
Choose a base branch
from
Krishna2323:krishna/89831-distance-rates-table-ui
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8d509c5
feat: replace distance rates list with Table UI behind beta gate
Krishna2323 bcdd150
Merge branch 'Expensify:main' into krishna/89831-distance-rates-table-ui
Krishna2323 8646759
fix: add mobile selection mode entry via long-press and search bar to…
Krishna2323 197712c
Merge branch 'main' into krishna/89831-distance-rates-table-ui
Krishna2323 17d558c
Merge branch 'main' into krishna/89831-distance-rates-table-ui
Krishna2323 6720f4c
Merge branch 'Expensify:main' into krishna/89831-distance-rates-table-ui
Krishna2323 365fd48
fix: add missing getRateStatus export and fix SEARCH_ITEM_LIMIT refer…
Krishna2323 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
This file contains hidden or 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
167 changes: 167 additions & 0 deletions
167
src/components/Tables/WorkspaceDistanceRatesTable/WorkspaceDistanceRatesTableRow.tsx
This file contains hidden or 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,167 @@ | ||
| import {format, parseISO} from 'date-fns'; | ||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
| import Checkbox from '@components/Checkbox'; | ||
| import Icon from '@components/Icon'; | ||
| import Table from '@components/Table'; | ||
| import Text from '@components/Text'; | ||
| import TextWithTooltip from '@components/TextWithTooltip'; | ||
| import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; | ||
| import useTheme from '@hooks/useTheme'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import {getRateStatus} from '@libs/PolicyDistanceRatesUtils'; | ||
| import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan'; | ||
| import variables from '@styles/variables'; | ||
| import CONST from '@src/CONST'; | ||
| import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; | ||
| import type {Rate} from '@src/types/onyx/Policy'; | ||
|
|
||
| type DistanceRateTableItemData = { | ||
| rateID: string; | ||
| rate: Rate; | ||
| formattedRate: string; | ||
| pendingAction?: OnyxCommon.PendingAction; | ||
| errors?: OnyxCommon.Errors; | ||
| onDismissError?: () => void; | ||
| }; | ||
|
|
||
| type WorkspaceDistanceRatesTableRowProps = { | ||
| item: DistanceRateTableItemData; | ||
| rowIndex: number; | ||
| isSelected: boolean; | ||
| canSelectMultiple: boolean; | ||
| onToggle: () => void; | ||
| onPress: () => void; | ||
| onLongPress?: () => void; | ||
| shouldUseNarrowTableLayout: boolean; | ||
| statusLabels: Record<string, string>; | ||
| }; | ||
|
|
||
| function formatDateColumn(dateString: string | undefined): string { | ||
| if (!dateString) { | ||
| return ''; | ||
| } | ||
| return format(parseISO(dateString), CONST.DATE.MONTH_DAY_YEAR_FORMAT); | ||
| } | ||
|
|
||
| function WorkspaceDistanceRatesTableRow({ | ||
| item, | ||
| rowIndex, | ||
| isSelected, | ||
| canSelectMultiple, | ||
| onToggle, | ||
| onPress, | ||
| onLongPress, | ||
| shouldUseNarrowTableLayout, | ||
| statusLabels, | ||
| }: WorkspaceDistanceRatesTableRowProps) { | ||
| const theme = useTheme(); | ||
| const styles = useThemeStyles(); | ||
| const Expensicons = useMemoizedLazyExpensifyIcons(['ArrowRight']); | ||
|
|
||
| const {rate, formattedRate, pendingAction, errors, onDismissError} = item; | ||
| const isDeleting = pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; | ||
|
|
||
| const status = getRateStatus(rate); | ||
|
|
||
| const reasonAttributes: SkeletonSpanReasonAttributes = { | ||
| context: 'WorkspaceDistanceRatesTableItem', | ||
| isDeleting, | ||
| }; | ||
|
|
||
| return ( | ||
| <Table.Row | ||
| interactive | ||
| rowIndex={rowIndex} | ||
| disabled={isDeleting} | ||
| skeletonReasonAttributes={reasonAttributes} | ||
| sentryLabel={CONST.SENTRY_LABEL.WORKSPACE.DISTANCE_RATES.ADD_BUTTON} | ||
| offlineWithFeedback={{errors, pendingAction, onClose: onDismissError, shouldHideOnDelete: false}} | ||
| onPress={onPress} | ||
| onLongPress={onLongPress} | ||
| > | ||
| {({hovered}) => ( | ||
| <> | ||
| {canSelectMultiple && ( | ||
| <View style={[styles.mr3]}> | ||
| <Checkbox | ||
| isChecked={isSelected} | ||
| onPress={onToggle} | ||
| accessibilityLabel={rate.name ?? ''} | ||
| disabled={isDeleting} | ||
| /> | ||
| </View> | ||
| )} | ||
|
|
||
| <View style={[styles.flex1]}> | ||
| <TextWithTooltip | ||
| text={statusLabels[status] ?? ''} | ||
| style={[styles.optionDisplayName, styles.pre]} | ||
| /> | ||
| {shouldUseNarrowTableLayout && ( | ||
| <TextWithTooltip | ||
| text={`${rate.name ?? ''} · ${formattedRate}`} | ||
| style={[styles.textLabelSupporting, styles.lh16, styles.pre]} | ||
| /> | ||
| )} | ||
| </View> | ||
|
|
||
| {!shouldUseNarrowTableLayout && ( | ||
| <View style={[styles.flex1]}> | ||
| <Text | ||
| numberOfLines={1} | ||
| style={[styles.lh16, styles.optionDisplayName, styles.pre]} | ||
| > | ||
| {rate.name} | ||
| </Text> | ||
| </View> | ||
| )} | ||
|
|
||
| {!shouldUseNarrowTableLayout && ( | ||
| <View style={[styles.flex1]}> | ||
| <Text | ||
| numberOfLines={1} | ||
| style={[styles.lh16, styles.optionDisplayName, styles.pre]} | ||
| > | ||
| {formattedRate} | ||
| </Text> | ||
| </View> | ||
| )} | ||
|
|
||
| {!shouldUseNarrowTableLayout && ( | ||
| <View style={[styles.flex1]}> | ||
| <Text | ||
| numberOfLines={1} | ||
| style={[styles.lh16, styles.optionDisplayName, styles.pre]} | ||
| > | ||
| {formatDateColumn(rate.startDate)} | ||
| </Text> | ||
| </View> | ||
| )} | ||
|
|
||
| {!shouldUseNarrowTableLayout && ( | ||
| <View style={[styles.flex1]}> | ||
| <Text | ||
| numberOfLines={1} | ||
| style={[styles.lh16, styles.optionDisplayName, styles.pre]} | ||
| > | ||
| {formatDateColumn(rate.endDate)} | ||
| </Text> | ||
| </View> | ||
| )} | ||
|
|
||
| <Icon | ||
| src={Expensicons.ArrowRight} | ||
| fill={theme.icon} | ||
| additionalStyles={[styles.alignSelfCenter, !hovered && styles.opacitySemiTransparent]} | ||
| width={variables.iconSizeNormal} | ||
| height={variables.iconSizeNormal} | ||
| /> | ||
| </> | ||
| )} | ||
| </Table.Row> | ||
| ); | ||
| } | ||
|
|
||
| export default WorkspaceDistanceRatesTableRow; | ||
| export type {DistanceRateTableItemData}; | ||
Oops, something went wrong.
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.
When the date-bound mileage rate table is shown on narrow screens,
canSelectMultipleis false until mobile selection mode is already enabled, and this row only renders the checkbox inside that gate while normal row presses navigate to details. The previousSelectionListWithModalpath enabled selection mode via long-press (turnOnSelectionModeOnLongPress), but the new table row does not provide any equivalentonLongPress/selection-mode trigger, so mobile users in this beta cannot select rates and therefore cannot reach the bulk delete/enable/disable actions.Useful? React with 👍 / 👎.