Skip to content

Commit

Permalink
Merge branch 'main' into fix-regression-splitbilll-tag-not-found
Browse files Browse the repository at this point in the history
  • Loading branch information
FitseTLT committed Mar 7, 2024
2 parents cd5b626 + 44267d3 commit 987444e
Show file tree
Hide file tree
Showing 67 changed files with 1,121 additions and 767 deletions.
4 changes: 2 additions & 2 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {OnyxEntry} from 'react-native-onyx';
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import type CONST from './CONST';
import type * as FormTypes from './types/form';
Expand Down Expand Up @@ -589,7 +589,7 @@ type OnyxFormDraftKey = keyof OnyxFormDraftValuesMapping;
type OnyxValueKey = keyof OnyxValuesMapping;

type OnyxKey = OnyxValueKey | OnyxCollectionKey | OnyxFormKey | OnyxFormDraftKey;
type OnyxValue<TOnyxKey extends OnyxKey> = OnyxEntry<OnyxValues[TOnyxKey]>;
type OnyxValue<TOnyxKey extends OnyxKey> = TOnyxKey extends keyof OnyxCollectionValuesMapping ? OnyxCollection<OnyxValues[TOnyxKey]> : OnyxEntry<OnyxValues[TOnyxKey]>;

type MissingOnyxKeysError = `Error: Types don't match, OnyxKey type is missing: ${Exclude<AllOnyxKeys, OnyxKey>}`;
/** If this type errors, it means that the `OnyxKey` type is missing some keys. */
Expand Down
9 changes: 9 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,15 @@ const ROUTES = {
route: 'workspace/:policyID/tags',
getRoute: (policyID: string) => `workspace/${policyID}/tags` as const,
},
WORKSPACE_MEMBER_DETAILS: {
route: 'workspace/:policyID/members/:accountID',
getRoute: (policyID: string, accountID: number, backTo?: string) => getUrlWithBackToParam(`workspace/${policyID}/members/${accountID}`, backTo),
},
WORKSPACE_MEMBER_ROLE_SELECTION: {
route: 'workspace/:policyID/members/:accountID/role-selection',
getRoute: (policyID: string, accountID: number, backTo?: string) => getUrlWithBackToParam(`workspace/${policyID}/members/${accountID}/role-selection`, backTo),
},

// Referral program promotion
REFERRAL_DETAILS_MODAL: {
route: 'referral/:contentType',
Expand Down
2 changes: 2 additions & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ const SCREENS = {
CATEGORY_CREATE: 'Category_Create',
CATEGORY_SETTINGS: 'Category_Settings',
CATEGORIES_SETTINGS: 'Categories_Settings',
MEMBER_DETAILS: 'Workspace_Member_Details',
MEMBER_DETAILS_ROLE_SELECTION: 'Workspace_Member_Details_Role_Selection',
},

EDIT_REQUEST: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function Button(
accessibilityLabel = '',
...rest
}: ButtonProps,
ref: ForwardedRef<View>,
ref: ForwardedRef<View | HTMLDivElement>,
) {
const theme = useTheme();
const styles = useThemeStyles();
Expand Down
11 changes: 6 additions & 5 deletions src/components/FloatingActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {ForwardedRef} from 'react';
import React, {forwardRef, useEffect, useRef} from 'react';
import type {GestureResponderEvent, Role} from 'react-native';
// eslint-disable-next-line no-restricted-imports
import type {GestureResponderEvent, Role, Text} from 'react-native';
import {Platform, View} from 'react-native';
import Animated, {createAnimatedPropAdapter, Easing, interpolateColor, processColor, useAnimatedProps, useAnimatedStyle, useSharedValue, withTiming} from 'react-native-reanimated';
import Svg, {Path} from 'react-native-svg';
Expand Down Expand Up @@ -58,12 +59,12 @@ type FloatingActionButtonProps = {
role: Role;
};

function FloatingActionButton({onPress, isActive, accessibilityLabel, role}: FloatingActionButtonProps, ref: ForwardedRef<HTMLDivElement | View>) {
function FloatingActionButton({onPress, isActive, accessibilityLabel, role}: FloatingActionButtonProps, ref: ForwardedRef<HTMLDivElement | View | Text>) {
const {success, buttonDefaultBG, textLight, textDark} = useTheme();
const styles = useThemeStyles();
const borderRadius = styles.floatingActionButton.borderRadius;
const {translate} = useLocalize();
const fabPressable = useRef<HTMLDivElement | View | null>(null);
const fabPressable = useRef<HTMLDivElement | View | Text | null>(null);
const sharedValue = useSharedValue(isActive ? 1 : 0);
const buttonRef = ref;

Expand Down Expand Up @@ -112,9 +113,9 @@ function FloatingActionButton({onPress, isActive, accessibilityLabel, role}: Flo
<View style={styles.bottomTabBarItem}>
<AnimatedPressable
ref={(el) => {
fabPressable.current = el;
fabPressable.current = el ?? null;
if (buttonRef && 'current' in buttonRef) {
buttonRef.current = el;
buttonRef.current = el ?? null;
}
}}
accessibilityLabel={accessibilityLabel}
Expand Down
12 changes: 6 additions & 6 deletions src/components/KYCWall/BaseKYCWall.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useCallback, useEffect, useRef, useState} from 'react';
import {Dimensions} from 'react-native';
import type {EmitterSubscription, GestureResponderEvent} from 'react-native';
import type {EmitterSubscription, GestureResponderEvent, View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import AddPaymentMethodMenu from '@components/AddPaymentMethodMenu';
Expand Down Expand Up @@ -69,8 +69,8 @@ function KYCWall({
walletTerms,
shouldShowPersonalBankAccountOption = false,
}: BaseKYCWallProps) {
const anchorRef = useRef<HTMLDivElement>(null);
const transferBalanceButtonRef = useRef<HTMLElement | null>(null);
const anchorRef = useRef<HTMLDivElement | View | null>(null);
const transferBalanceButtonRef = useRef<HTMLDivElement | View | null>(null);

const [shouldShowAddPaymentMenu, setShouldShowAddPaymentMenu] = useState(false);

Expand Down Expand Up @@ -111,7 +111,7 @@ function KYCWall({
return;
}

const buttonPosition = getClickedTargetLocation(transferBalanceButtonRef.current);
const buttonPosition = getClickedTargetLocation(transferBalanceButtonRef.current as HTMLDivElement);
const position = getAnchorPosition(buttonPosition);

setPositionAddPaymentMenu(position);
Expand Down Expand Up @@ -162,7 +162,7 @@ function KYCWall({
}

// Use event target as fallback if anchorRef is null for safety
const targetElement = anchorRef.current ?? (event?.currentTarget as HTMLElement);
const targetElement = anchorRef.current ?? (event?.currentTarget as HTMLDivElement);

transferBalanceButtonRef.current = targetElement;

Expand All @@ -181,7 +181,7 @@ function KYCWall({
return;
}

const clickedElementLocation = getClickedTargetLocation(targetElement);
const clickedElementLocation = getClickedTargetLocation(targetElement as HTMLDivElement);
const position = getAnchorPosition(clickedElementLocation);

setPositionAddPaymentMenu(position);
Expand Down
6 changes: 4 additions & 2 deletions src/components/OnyxProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import createOnyxContext from './createOnyxContext';
const [withNetwork, NetworkProvider, NetworkContext] = createOnyxContext(ONYXKEYS.NETWORK);
const [withPersonalDetails, PersonalDetailsProvider, , usePersonalDetails] = createOnyxContext(ONYXKEYS.PERSONAL_DETAILS_LIST);
const [withCurrentDate, CurrentDateProvider] = createOnyxContext(ONYXKEYS.CURRENT_DATE);
const [withReportActionsDrafts, ReportActionsDraftsProvider] = createOnyxContext(ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS);
const [withBlockedFromConcierge, BlockedFromConciergeProvider] = createOnyxContext(ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE);
const [withReportActionsDrafts, ReportActionsDraftsProvider, , useReportActionsDrafts] = createOnyxContext(ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS);
const [withBlockedFromConcierge, BlockedFromConciergeProvider, , useBlockedFromConcierge] = createOnyxContext(ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE);
const [withBetas, BetasProvider, BetasContext, useBetas] = createOnyxContext(ONYXKEYS.BETAS);
const [withReportCommentDrafts, ReportCommentDraftsProvider] = createOnyxContext(ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT);
const [withPreferredTheme, PreferredThemeProvider, PreferredThemeContext] = createOnyxContext(ONYXKEYS.PREFERRED_THEME);
Expand Down Expand Up @@ -66,5 +66,7 @@ export {
useFrequentlyUsedEmojis,
withPreferredEmojiSkinTone,
PreferredEmojiSkinToneContext,
useBlockedFromConcierge,
useReportActionsDrafts,
useSession,
};
5 changes: 3 additions & 2 deletions src/components/Popover/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {RefObject} from 'react';
import type {View} from 'react-native';
// eslint-disable-next-line no-restricted-imports
import type {Text, View} from 'react-native';
import type {PopoverAnchorPosition} from '@components/Modal/types';
import type BaseModalProps from '@components/Modal/types';
import type {WindowDimensionsProps} from '@components/withWindowDimensions/types';
Expand All @@ -20,7 +21,7 @@ type PopoverProps = BaseModalProps &
anchorAlignment?: AnchorAlignment;

/** The anchor ref of the popover */
anchorRef: RefObject<View | HTMLDivElement>;
anchorRef: RefObject<View | HTMLDivElement | Text>;

/** Whether disable the animations */
disableAnimation?: boolean;
Expand Down
7 changes: 4 additions & 3 deletions src/components/PopoverProvider/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type {RefObject} from 'react';
import React, {createContext, useCallback, useEffect, useMemo, useRef, useState} from 'react';
import type {View} from 'react-native';
// eslint-disable-next-line no-restricted-imports
import type {Text, View} from 'react-native';
import type {AnchorRef, PopoverContextProps, PopoverContextValue} from './types';

const PopoverContext = createContext<PopoverContextValue>({
Expand All @@ -10,7 +11,7 @@ const PopoverContext = createContext<PopoverContextValue>({
isOpen: false,
});

function elementContains(ref: RefObject<View | HTMLElement> | undefined, target: EventTarget | null) {
function elementContains(ref: RefObject<View | HTMLElement | Text> | undefined, target: EventTarget | null) {
if (ref?.current && 'contains' in ref.current && ref?.current?.contains(target as Node)) {
return true;
}
Expand All @@ -21,7 +22,7 @@ function PopoverContextProvider(props: PopoverContextProps) {
const [isOpen, setIsOpen] = useState(false);
const activePopoverRef = useRef<AnchorRef | null>(null);

const closePopover = useCallback((anchorRef?: RefObject<View | HTMLElement>): boolean => {
const closePopover = useCallback((anchorRef?: RefObject<View | HTMLElement | Text>): boolean => {
if (!activePopoverRef.current || (anchorRef && anchorRef !== activePopoverRef.current.anchorRef)) {
return false;
}
Expand Down
11 changes: 6 additions & 5 deletions src/components/PopoverProvider/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {ReactNode, RefObject} from 'react';
import type {View} from 'react-native';
// eslint-disable-next-line no-restricted-imports
import type {Text, View} from 'react-native';

type PopoverContextProps = {
children: ReactNode;
Expand All @@ -8,14 +9,14 @@ type PopoverContextProps = {
type PopoverContextValue = {
onOpen?: (popoverParams: AnchorRef) => void;
popover?: AnchorRef | Record<string, never> | null;
close: (anchorRef?: RefObject<View | HTMLDivElement>) => void;
close: (anchorRef?: RefObject<View | HTMLDivElement | Text>) => void;
isOpen: boolean;
};

type AnchorRef = {
ref: RefObject<View | HTMLDivElement>;
close: (anchorRef?: RefObject<View | HTMLDivElement>) => void;
anchorRef: RefObject<View | HTMLDivElement>;
ref: RefObject<View | HTMLDivElement | Text>;
close: (anchorRef?: RefObject<View | HTMLDivElement | Text>) => void;
anchorRef: RefObject<View | HTMLDivElement | Text>;
};

export type {PopoverContextProps, PopoverContextValue, AnchorRef};
5 changes: 3 additions & 2 deletions src/components/PopoverWithoutOverlay/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {RefObject} from 'react';
import type {View} from 'react-native';
// eslint-disable-next-line no-restricted-imports
import type {Text, View} from 'react-native';
import type BaseModalProps from '@components/Modal/types';
import type ChildrenProps from '@src/types/utils/ChildrenProps';

Expand All @@ -14,7 +15,7 @@ type PopoverWithoutOverlayProps = ChildrenProps &
};

/** The anchor ref of the popover */
anchorRef: RefObject<View | HTMLDivElement>;
anchorRef: RefObject<View | HTMLDivElement | Text>;

/** A react-native-animatable animation timing for the modal display animation */
animationInTiming?: number;
Expand Down
5 changes: 3 additions & 2 deletions src/components/Pressable/GenericPressable/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {ElementRef, ForwardedRef, RefObject} from 'react';
import type {GestureResponderEvent, HostComponent, PressableStateCallbackType, PressableProps as RNPressableProps, StyleProp, View, ViewStyle} from 'react-native';
// eslint-disable-next-line no-restricted-imports
import type {GestureResponderEvent, HostComponent, PressableStateCallbackType, PressableProps as RNPressableProps, Text as RNText, StyleProp, View, ViewStyle} from 'react-native';
import type {ValueOf} from 'type-fest';
import type {Shortcut} from '@libs/KeyboardShortcut';
import type CONST from '@src/CONST';
Expand Down Expand Up @@ -138,7 +139,7 @@ type PressableProps = RNPressableProps &
noDragArea?: boolean;
};

type PressableRef = ForwardedRef<HTMLDivElement | View>;
type PressableRef = ForwardedRef<HTMLDivElement | View | RNText | undefined>;

export default PressableProps;
export type {PressableRef};
2 changes: 1 addition & 1 deletion src/components/PressableWithSecondaryInteraction/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {ParsableStyle} from '@styles/utils/types';

type PressableWithSecondaryInteractionProps = PressableWithFeedbackProps & {
/** The function that should be called when this pressable is pressed */
onPress: (event?: GestureResponderEvent) => void;
onPress?: (event?: GestureResponderEvent) => void;

/** The function that should be called when this pressable is pressedIn */
onPressIn?: (event?: GestureResponderEvent) => void;
Expand Down
4 changes: 2 additions & 2 deletions src/components/Reactions/ReportActionItemEmojiReactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type ReportActionItemEmojiReactionsProps = WithCurrentUserPersonalDetailsProps &
emojiReactions: OnyxEntry<ReportActionReactions>;

/** The user's preferred locale. */
preferredLocale: OnyxEntry<Locale>;
preferredLocale?: OnyxEntry<Locale>;

/** The report action that these reactions are for */
reportAction: ReportAction;
Expand Down Expand Up @@ -155,7 +155,7 @@ function ReportActionItemEmojiReactions({
shouldDisableOpacity={!!reportAction.pendingAction}
>
<EmojiReactionBubble
ref={(ref) => (popoverReactionListAnchors.current[reaction.reactionEmojiName] = ref)}
ref={(ref) => (popoverReactionListAnchors.current[reaction.reactionEmojiName] = ref ?? null)}
count={reaction.reactionCount}
emojiCodes={reaction.emojiCodes}
onPress={reaction.onPress}
Expand Down
3 changes: 2 additions & 1 deletion src/components/ReportActionItem/MoneyReportView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Str from 'expensify-common/lib/str';
import React, {useMemo} from 'react';
import type {StyleProp, TextStyle} from 'react-native';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription';
Expand All @@ -26,7 +27,7 @@ type MoneyReportViewProps = {
report: Report;

/** Policy that the report belongs to */
policy: Policy;
policy: OnyxEntry<Policy>;

/** Policy report fields */
policyReportFields: PolicyReportField[];
Expand Down
10 changes: 7 additions & 3 deletions src/components/ReportActionItem/TaskAction.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import React from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import RenderHTML from '@components/RenderHTML';
import Text from '@components/Text';
import useThemeStyles from '@hooks/useThemeStyles';
import * as TaskUtils from '@libs/TaskUtils';
import type {ReportAction} from '@src/types/onyx';

type TaskActionProps = {
/** Name of the reportAction action */
actionName: string;
action: OnyxEntry<ReportAction>;
};

function TaskAction({actionName}: TaskActionProps) {
function TaskAction({action}: TaskActionProps) {
const styles = useThemeStyles();
const message = TaskUtils.getTaskReportActionMessage(action);

return (
<View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}>
<Text style={[styles.chatItemMessage, styles.colorMuted]}>{TaskUtils.getTaskReportActionMessage(actionName)}</Text>
{message.html ? <RenderHTML html={`<muted-text>${message.html}</muted-text>`} /> : <Text style={[styles.chatItemMessage, styles.colorMuted]}>{message.text}</Text>}
</View>
);
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/createOnyxContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {ComponentType, ForwardedRef, ForwardRefExoticComponent, PropsWithou
import React, {createContext, forwardRef, useContext} from 'react';
import {withOnyx} from 'react-native-onyx';
import getComponentDisplayName from '@libs/getComponentDisplayName';
import type {OnyxKey, OnyxValue, OnyxValues} from '@src/ONYXKEYS';
import type {OnyxKey, OnyxValue} from '@src/ONYXKEYS';
import type ChildrenProps from '@src/types/utils/ChildrenProps';

// Provider types
Expand Down Expand Up @@ -32,11 +32,11 @@ type CreateOnyxContext<TOnyxKey extends OnyxKey> = [
WithOnyxKey<TOnyxKey>,
ComponentType<Omit<ProviderPropsWithOnyx<TOnyxKey>, TOnyxKey>>,
React.Context<OnyxValue<TOnyxKey>>,
() => OnyxValues[TOnyxKey],
() => NonNullable<OnyxValue<TOnyxKey>>,
];

export default <TOnyxKey extends OnyxKey>(onyxKeyName: TOnyxKey): CreateOnyxContext<TOnyxKey> => {
const Context = createContext<OnyxValue<TOnyxKey>>(null);
const Context = createContext<OnyxValue<TOnyxKey>>(null as OnyxValue<TOnyxKey>);
function Provider(props: ProviderPropsWithOnyx<TOnyxKey>): ReactNode {
return <Context.Provider value={props[onyxKeyName]}>{props.children}</Context.Provider>;
}
Expand Down Expand Up @@ -86,7 +86,7 @@ export default <TOnyxKey extends OnyxKey>(onyxKeyName: TOnyxKey): CreateOnyxCont
if (value === null) {
throw new Error(`useOnyxContext must be used within a OnyxProvider [key: ${onyxKeyName}]`);
}
return value;
return value as NonNullable<OnyxValue<TOnyxKey>>;
};

return [withOnyxKey, ProviderWithOnyx, Context, useOnyxContext];
Expand Down
3 changes: 3 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1809,6 +1809,9 @@ export default {
genericFailureMessage: 'An error occurred removing a user from the workspace, please try again.',
removeMembersPrompt: 'Are you sure you want to remove these members?',
removeMembersTitle: 'Remove members',
removeMemberButtonTitle: 'Remove from workspace',
removeMemberPrompt: ({memberName}) => `Are you sure you want to remove ${memberName}`,
removeMemberTitle: 'Remove member',
makeMember: 'Make member',
makeAdmin: 'Make admin',
selectAll: 'Select all',
Expand Down
3 changes: 3 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,9 @@ export default {
genericFailureMessage: 'Se ha producido un error al intentar eliminar a un usuario del espacio de trabajo. Por favor, inténtalo más tarde.',
removeMembersPrompt: '¿Estás seguro de que deseas eliminar a estos miembros?',
removeMembersTitle: 'Eliminar miembros',
removeMemberButtonTitle: 'Quitar del espacio de trabajo',
removeMemberPrompt: ({memberName}) => `¿Estás seguro de que deseas eliminar a ${memberName}`,
removeMemberTitle: 'Eliminar miembro',
makeMember: 'Hacer miembro',
makeAdmin: 'Hacer administrador',
selectAll: 'Seleccionar todo',
Expand Down
Loading

0 comments on commit 987444e

Please sign in to comment.