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
91 changes: 48 additions & 43 deletions src/pages/workspace/WorkspaceOverviewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa
if (!isFocused || !prevIsPendingDelete || isPendingDelete) {
return;
}
setIsDeleteModalOpen(false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming from this issue #78514, removing setIsDeleteModalOpen from here caused that issue.

if (!policyLastErrorMessage) {
goBackFromInvalidPolicy();
return;
Expand Down Expand Up @@ -468,6 +468,52 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa
return renderDropdownMenu(secondaryActions);
};

const modals = (
<>
<ConfirmModal
title={translate('workspace.common.delete')}
isVisible={isDeleteModalOpen}
onConfirm={confirmDelete}
onCancel={() => setIsDeleteModalOpen(false)}
prompt={hasCardFeedOrExpensifyCard ? translate('workspace.common.deleteWithCardsConfirmation') : translate('workspace.common.deleteConfirmation')}
confirmText={translate('common.delete')}
cancelText={translate('common.cancel')}
isConfirmLoading={isPendingDeletePolicy(policy)}
danger
/>
<ConfirmModal
title={translate('common.leaveWorkspace')}
isVisible={isLeaveModalOpen}
onConfirm={handleLeaveWorkspace}
onCancel={() => setIsLeaveModalOpen(false)}
prompt={confirmModalPrompt()}
confirmText={translate('common.leave')}
cancelText={translate('common.cancel')}
danger
/>
<ConfirmModal
title={translate('common.leaveWorkspace')}
isVisible={isCannotLeaveWorkspaceModalOpen}
onConfirm={() => {
setIsCannotLeaveWorkspaceModalOpen(false);
}}
prompt={confirmModalPrompt()}
confirmText={translate('common.buttonConfirm')}
shouldShowCancelButton={false}
success
/>
<ConfirmModal
title={translate('workspace.common.delete')}
isVisible={isDeleteWorkspaceErrorModalOpen}
onConfirm={hideDeleteWorkspaceErrorModal}
onCancel={hideDeleteWorkspaceErrorModal}
prompt={policyLastErrorMessage}
confirmText={translate('common.buttonConfirm')}
shouldShowCancelButton={false}
success={false}
/>
</>
);
return (
<WorkspacePageWithSections
headerText={translate('workspace.common.profile')}
Expand All @@ -482,6 +528,7 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa
onBackButtonPress={handleBackButtonPress}
addBottomSafeAreaPadding
headerContent={!shouldUseNarrowLayout && getHeaderButtons()}
modals={modals}
>
{(hasVBA?: boolean) => (
<View style={[styles.flex1, styles.mt3, shouldUseNarrowLayout ? styles.workspaceSectionMobile : styles.workspaceSection]}>
Expand Down Expand Up @@ -665,48 +712,6 @@ function WorkspaceOverviewPage({policyDraft, policy: policyProp, route}: Workspa
</OfflineWithFeedback>
</Section>
) : null}
<ConfirmModal
title={translate('workspace.common.delete')}
isVisible={isDeleteModalOpen}
onConfirm={confirmDelete}
onCancel={() => setIsDeleteModalOpen(false)}
prompt={hasCardFeedOrExpensifyCard ? translate('workspace.common.deleteWithCardsConfirmation') : translate('workspace.common.deleteConfirmation')}
confirmText={translate('common.delete')}
cancelText={translate('common.cancel')}
isConfirmLoading={isPendingDeletePolicy(policy)}
danger
/>
<ConfirmModal
title={translate('common.leaveWorkspace')}
isVisible={isLeaveModalOpen}
onConfirm={handleLeaveWorkspace}
onCancel={() => setIsLeaveModalOpen(false)}
prompt={confirmModalPrompt()}
confirmText={translate('common.leave')}
cancelText={translate('common.cancel')}
danger
/>
<ConfirmModal
title={translate('common.leaveWorkspace')}
isVisible={isCannotLeaveWorkspaceModalOpen}
onConfirm={() => {
setIsCannotLeaveWorkspaceModalOpen(false);
}}
prompt={confirmModalPrompt()}
confirmText={translate('common.buttonConfirm')}
shouldShowCancelButton={false}
success
/>
<ConfirmModal
title={translate('workspace.common.delete')}
isVisible={isDeleteWorkspaceErrorModalOpen}
onConfirm={hideDeleteWorkspaceErrorModal}
onCancel={hideDeleteWorkspaceErrorModal}
prompt={policyLastErrorMessage}
confirmText={translate('common.buttonConfirm')}
shouldShowCancelButton={false}
success={false}
/>
</View>
)}
</WorkspacePageWithSections>
Expand Down
5 changes: 5 additions & 0 deletions src/pages/workspace/WorkspacePageWithSections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ type WorkspacePageWithSectionsProps = WithPolicyAndFullscreenLoadingProps &
* If enabled, the content will have a bottom padding equal to account for the safe bottom area inset.
*/
addBottomSafeAreaPadding?: boolean;

/** Content to be added as modal */
modals?: ReactNode;
};

function fetchData(policyID: string | undefined, skipVBBACal?: boolean) {
Expand Down Expand Up @@ -124,6 +127,7 @@ function WorkspacePageWithSections({
threeDotsMenuItems,
shouldUseHeadlineHeader = true,
addBottomSafeAreaPadding = false,
modals,
}: WorkspacePageWithSectionsProps) {
const styles = useThemeStyles();
const policyID = route.params?.policyID;
Expand Down Expand Up @@ -235,6 +239,7 @@ function WorkspacePageWithSections({
</>
)}
</FullPageNotFoundView>
{modals}
</ScreenWrapper>
);
}
Expand Down
95 changes: 42 additions & 53 deletions src/pages/workspace/WorkspacesListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ function WorkspacesListPage() {
const icons = useMemoizedLazyExpensifyIcons(['Building', 'Exit', 'Copy', 'Star', 'Trashcan', 'Transfer', 'FallbackWorkspaceAvatar', 'Plus'] as const);
const theme = useTheme();
const styles = useThemeStyles();
const expensifyIcons = useMemoizedLazyExpensifyIcons(['Building', 'Exit', 'Copy', 'Star', 'Trashcan', 'Transfer', 'Plus', 'FallbackWorkspaceAvatar']);
const {translate, localeCompare} = useLocalize();
const {isOffline} = useNetwork();
const isFocused = useIsFocused();
Expand Down Expand Up @@ -339,15 +340,15 @@ function WorkspacesListPage() {

const threeDotsMenuItems: PopoverMenuItem[] = [
{
icon: icons.Building,
icon: expensifyIcons.Building,
text: translate('workspace.common.goToWorkspace'),
onSelected: item.action,
},
];

if (!isOwner && (item.policyID !== preferredPolicyID || !isRestrictedToPreferredPolicy)) {
threeDotsMenuItems.push({
icon: icons.Exit,
icon: expensifyIcons.Exit,
text: translate('common.leave'),
onSelected: callFunctionIfActionIsAllowed(() => {
close(() => {
Expand Down Expand Up @@ -485,6 +486,8 @@ function WorkspacesListPage() {
policyIDToDelete,
preferredPolicyID,
icons,
expensifyIcons.Building,
expensifyIcons.Exit,
],
);

Expand Down Expand Up @@ -726,39 +729,7 @@ function WorkspacesListPage() {
[getWorkspaceMenuItem, styles, translate],
);

if (!workspaces.length && !domains.length) {
return (
<ScreenWrapper
shouldEnablePickerAvoiding={false}
shouldEnableMaxHeight
testID={WorkspacesListPage.displayName}
shouldShowOfflineIndicatorInWideScreen
bottomContent={
shouldUseNarrowLayout && (
<NavigationTabBar
selectedTab={NAVIGATION_TABS.WORKSPACES}
shouldShowFloatingCameraButton={false}
/>
)
}
enableEdgeToEdgeBottomSafeAreaPadding={false}
>
<View style={styles.topBarWrapper}>
<TopBar breadcrumbLabel={translate('common.workspaces')} />
</View>
{shouldShowLoadingIndicator ? (
<View style={[styles.flex1]}>
<FullScreenLoadingIndicator style={[styles.flex1, styles.pRelative]} />
</View>
) : (
<ScrollView contentContainerStyle={[styles.pt2, styles.flexGrow1, styles.flexShrink0]}>
<WorkspacesEmptyStateComponent />
</ScrollView>
)}
{shouldDisplayLHB && <NavigationTabBar selectedTab={NAVIGATION_TABS.WORKSPACES} />}
</ScreenWrapper>
);
}
const shouldShowEmptyState = !workspaces.length && !domains.length;

return (
<ScreenWrapper
Expand All @@ -774,25 +745,43 @@ function WorkspacesListPage() {
/>
)
}
shouldEnableMaxHeight={shouldShowEmptyState}
>
<View style={styles.flex1}>
<TopBar breadcrumbLabel={translate('common.workspaces')}>{!shouldUseNarrowLayout && <View style={[styles.pr2]}>{getHeaderButton()}</View>}</TopBar>
{shouldUseNarrowLayout && <View style={[styles.ph5, styles.pt2]}>{getHeaderButton()}</View>}
<FlatList
ref={flatlistRef}
data={data}
onScrollToIndexFailed={(info) => {
flatlistRef.current?.scrollToOffset({
offset: info.averageItemLength * info.index,
animated: true,
});
}}
renderItem={renderItem}
ListHeaderComponent={listHeaderComponent}
keyboardShouldPersistTaps="handled"
contentContainerStyle={styles.pb20}
/>
</View>
{shouldShowEmptyState ? (
<>
<View style={styles.topBarWrapper}>
<TopBar breadcrumbLabel={translate('common.workspaces')} />
</View>
{shouldShowLoadingIndicator ? (
<View style={[styles.flex1]}>
<FullScreenLoadingIndicator style={[styles.flex1, styles.pRelative]} />
</View>
) : (
<ScrollView contentContainerStyle={[styles.pt2, styles.flexGrow1, styles.flexShrink0]}>
<WorkspacesEmptyStateComponent />
</ScrollView>
)}
</>
) : (
<View style={styles.flex1}>
<TopBar breadcrumbLabel={translate('common.workspaces')}>{!shouldUseNarrowLayout && <View style={[styles.pr2]}>{getHeaderButton()}</View>}</TopBar>
{shouldUseNarrowLayout && <View style={[styles.ph5, styles.pt2]}>{getHeaderButton()}</View>}
<FlatList
ref={flatlistRef}
data={data}
onScrollToIndexFailed={(info) => {
flatlistRef.current?.scrollToOffset({
offset: info.averageItemLength * info.index,
animated: true,
});
}}
renderItem={renderItem}
ListHeaderComponent={listHeaderComponent}
keyboardShouldPersistTaps="handled"
contentContainerStyle={styles.pb20}
/>
</View>
)}
<ConfirmModal
title={translate('workspace.common.delete')}
isVisible={isDeleteModalOpen}
Expand Down
Loading