Skip to content

Commit

Permalink
Merge branch 'ideal-nav-merge' into w8/ideal-nav-fixes-v7
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Feb 1, 2024
2 parents f305cc1 + e20a5f4 commit 5303059
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 14 deletions.
5 changes: 5 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,10 @@ const CONST = {
OTHER_INVISIBLE_CHARACTERS: /[\u3164]/g,

REPORT_FIELD_TITLE: /{report:([a-zA-Z]+)}/g,

PATH_WITHOUT_POLICY_ID: /\/w\/[a-zA-Z0-9]+(\/|$)/,

POLICY_ID_FROM_PATH: /\/w\/([a-zA-Z0-9]+)(\/|$)/,
},

PRONOUNS: {
Expand Down Expand Up @@ -3168,6 +3172,7 @@ const CONST = {
SUBSCRIPT_ICON_SIZE: 8,
MINIMUM_WORKSPACES_TO_SHOW_SEARCH: 8,
},

REPORT_FIELD_TITLE_FIELD_ID: 'text_title',
} as const;

Expand Down
1 change: 1 addition & 0 deletions src/components/AvatarWithImagePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const propTypes = {

/** Indicates if picker feature should be disabled */
disabled: PropTypes.bool,

/** Executed once click on view photo option */
onViewPhotoPress: PropTypes.func,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type CustomNavigatorProps = DefaultNavigatorOptions<ParamListBase, StackNavigati

function getStateToRender(state: StackNavigationState<ParamListBase>): StackNavigationState<ParamListBase> {
const routesToRender = [state.routes.at(-1)] as NavigationStateRoute[];

// We need to render at least one HOME screen to make sure everything load properly.
if (routesToRender[0].name !== SCREENS.HOME) {
const routeToRender = state.routes.find((route) => route.name === SCREENS.HOME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function compareAndAdaptState(state: StackNavigationState<RootStackParamList>) {
const topmostBottomTabRoute = getTopmostBottomTabRoute(state);
const isSmallScreenWidth = getIsSmallScreenWidth();

// This solutions is heurestis and will work for our cases. We may need to improve it in the future if we will have more cases to handle.
// This solutions is heuristics and will work for our cases. We may need to improve it in the future if we will have more cases to handle.
if (topmostBottomTabRoute && !isSmallScreenWidth) {
const fullScreenRoute = state.routes.find((route) => route.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR);

Expand Down Expand Up @@ -84,7 +84,7 @@ function compareAndAdaptState(state: StackNavigationState<RootStackParamList>) {
// If there is central pane route in state and template state has one, we need to check if they are the same.
if (topmostCentralPaneRouteExtracted && templateCentralPaneRouteExtracted && topmostCentralPaneRouteExtracted.name !== templateCentralPaneRouteExtracted.name) {
// Not every RHP screen has matching central pane defined. In that case we use the REPORT screen as default for initial screen.
// But we don't want to ovverride the central pane for those screens as they may be opened with different central panes under the overlay.
// But we don't want to override the central pane for those screens as they may be opened with different central panes under the overlay.
// e.g. i-know-a-teacher may be opened with different central panes under the overlay
if (templateCentralPaneRouteExtracted.name === SCREENS.REPORT) {
return;
Expand Down
10 changes: 5 additions & 5 deletions src/libs/Navigation/AppNavigator/getPartialStateDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ type GetPartialStateDiffReturnType = {
};

/**
* This function returns partial additive diff beteween the two states.
* The partial diff have information which bottom tab, central pane and full screen screens we need to push to go from state to templateState
* This function returns partial additive diff between the two states.
* The partial diff has information which bottom tab, central pane and full screen screens we need to push to go from state to templateState.
* @param state - Current state.
* @param templateState - Desired state generated with getAdaptedStateFromPath.
* @param metainfo - Additional info from getAdaptedStateFromPath funciton.
* @param metainfo - Additional info from getAdaptedStateFromPath function.
* @returns The screen options object
*/
function getPartialStateDiff(state: State<RootStackParamList>, templateState: State<RootStackParamList>, metainfo: Metainfo): GetPartialStateDiffReturnType {
Expand Down Expand Up @@ -60,8 +60,8 @@ function getPartialStateDiff(state: State<RootStackParamList>, templateState: St
}
}

// This one is heurestic and may need to improved if we will be able to navigate from modal screen with full screen in background to another modal screen with full screen in background.
// For now this simple check is enought.
// This one is heuristic and may need to be improved if we will be able to navigate from modal screen with full screen in background to another modal screen with full screen in background.
// For now this simple check is enough.
if (metainfo.isFullScreenNavigatorMandatory) {
const stateTopmostFullScreen = state.routes.filter((route) => route.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR).at(-1);
const templateStateTopmostFullScreen = templateState.routes.filter((route) => route.name === NAVIGATORS.FULL_SCREEN_NAVIGATOR).at(-1) as NavigationPartialRoute;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/linkTo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export default function linkTo(navigation: NavigationContainerRef<RootStackParam
},
});
} else {
// // If the layout is small we need to pop everything from the central pane so the bottom tab navigator is visible.
// If the layout is small we need to pop everything from the central pane so the bottom tab navigator is visible.
root.dispatch({
type: 'POP_TO_TOP',
target: rootState.key,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ function isPaidGroupPolicy(policy: OnyxEntry<Policy>): boolean {
}

function extractPolicyIDFromPath(path: string) {
return path.match(/\/w\/([a-zA-Z0-9]+)(\/|$)/)?.[1];
return path.match(CONST.REGEX.POLICY_ID_FROM_PATH)?.[1];
}

function getPathWithoutPolicyID(path: string) {
return path.replace(/\/w\/[a-zA-Z0-9]+(\/|$)/, '/');
return path.replace(CONST.REGEX.PATH_WITHOUT_POLICY_ID, '/');
}

function getPolicyMembersByIdWithoutCurrentUser(policyMembers: OnyxCollection<PolicyMembers>, currentPolicyID?: string, currentUserAccountID?: number) {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1830,7 +1830,7 @@ function showReportActionNotification(reportID: string, reportAction: ReportActi
Modal.close(() => {
const policyID = lastVisitedPath && extractPolicyIDFromPath(lastVisitedPath);
const policyMembersAccountIDs = policyID ? getPolicyMemberAccountIDs(policyID) : [];
const reportBelongsToWorkspace = policyID ? doesReportBelongToWorkspace(report, policyMembersAccountIDs, policyID) : true;
const reportBelongsToWorkspace = policyID ? doesReportBelongToWorkspace(report, policyMembersAccountIDs, policyID) : false;
if (!reportBelongsToWorkspace) {
Navigation.navigateWithSwitchPolicyID({policyID: undefined, route: ROUTES.HOME});
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/sidebar/AllSettingsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function AllSettingsScreen({policies, policyMembers}: AllSettingsScreenProps) {
const {isSmallScreenWidth} = useWindowDimensions();

/**
* Retuns a list of menu items data for "everything" settings
* Retuns a list of menu items data for All workspaces settings
* @returns {Object} object with translationKey, style and items
*/
const menuItems = useMemo(() => {
Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/WorkspacePageWithSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type WorkspacePageWithSectionsProps = WithPolicyAndFullscreenLoadingProps &
/** Should show the back button. It is used when in RHP. */
shouldShowBackButton?: boolean;

/** Whether the offline indicator should be shown in wide screen devices */
shouldShowOfflineIndicatorInWideScreen?: boolean;

/** Whether to show this page to non admin policy members */
Expand Down
4 changes: 2 additions & 2 deletions src/pages/workspace/WorkspacesListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ function WorkspacesListPage({policies, allPolicyMembers, reimbursementAccount, r
iconFill: theme.textLight,
fallbackIcon: Expensicons.FallbackWorkspaceAvatar,
policyID: policy.id,
adminRoom: policyRooms?.[policy.id].adminRoom ?? policy.chatReportIDAdmins?.toString(),
announceRoom: policyRooms?.[policy.id].announceRoom ?? policy.chatReportIDAnnounce?.toString(),
adminRoom: policyRooms?.[policy.id]?.adminRoom ?? policy.chatReportIDAdmins?.toString(),
announceRoom: policyRooms?.[policy.id]?.announceRoom ?? policy.chatReportIDAnnounce?.toString(),
ownerAccountID: policy.ownerAccountID,
role: policy.role,
type: policy.type,
Expand Down
1 change: 1 addition & 0 deletions src/types/onyx/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ type Policy = {
/** When tax tracking is enabled */
isTaxTrackingEnabled?: boolean;

/** ReportID of the admins room for this workspace */
chatReportIDAdmins?: number;

chatReportIDAnnounce?: number;
Expand Down

0 comments on commit 5303059

Please sign in to comment.