diff --git a/assets/images/product-illustrations/earth-with-controls.svg b/assets/images/product-illustrations/earth-with-controls.svg new file mode 100644 index 000000000000..924a6943fb18 --- /dev/null +++ b/assets/images/product-illustrations/earth-with-controls.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 3505c855d189..2cb9d3cb3d1b 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -793,7 +793,14 @@ const ROUTES = { INBOX: 'inbox', HOME: 'home', - WORKSPACES_LIST: {route: 'workspaces', getRoute: (backTo?: string) => getUrlWithBackToParam('workspaces', backTo)}, + WORKSPACES_LIST: { + route: 'workspaces', + getRoute: (backTo?: string) => getUrlWithBackToParam('workspaces', backTo), + }, + DOMAINS_LIST: { + route: 'domains', + getRoute: () => 'domains' as const, + }, SEARCH_ROUTER: 'search-router', SEARCH_ROOT: { route: 'search', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index bf032a86e874..c541dd306aaa 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -544,6 +544,7 @@ const SCREENS = { }, WORKSPACES_LIST: 'Workspaces_List', + DOMAINS_LIST: 'Domains_List', WORKSPACE: { ACCOUNTING: { diff --git a/src/components/Domain/DomainListEmptyState.tsx b/src/components/Domain/DomainListEmptyState.tsx new file mode 100644 index 000000000000..02f46df74a9b --- /dev/null +++ b/src/components/Domain/DomainListEmptyState.tsx @@ -0,0 +1,35 @@ +import React from 'react'; +import GenericEmptyStateComponent from '@components/EmptyStateComponent/GenericEmptyStateComponent'; +import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import interceptAnonymousUser from '@libs/interceptAnonymousUser'; +import Navigation from '@libs/Navigation/Navigation'; +import ROUTES from '@src/ROUTES'; + +function DomainListEmptyState() { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + const illustrations = useMemoizedLazyIllustrations(['EarthWithControls']); + + return ( + interceptAnonymousUser(() => Navigation.navigate(ROUTES.WORKSPACES_ADD_DOMAIN)), + buttonText: translate('domain.addDomain.newDomain'), + }, + ]} + /> + ); +} + +export default DomainListEmptyState; diff --git a/src/components/Domain/DomainMenuItem.tsx b/src/components/Domain/DomainMenuItem.tsx deleted file mode 100644 index 862d0fde196d..000000000000 --- a/src/components/Domain/DomainMenuItem.tsx +++ /dev/null @@ -1,114 +0,0 @@ -import React, {useMemo} from 'react'; -import type {ValueOf} from 'type-fest'; -import type {OfflineWithFeedbackProps} from '@components/OfflineWithFeedback'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; -import type {PopoverMenuItem} from '@components/PopoverMenu'; -import {PressableWithoutFeedback} from '@components/Pressable'; -import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import Navigation from '@libs/Navigation/Navigation'; -import CONST from '@src/CONST'; -import {clearDomainErrors} from '@src/libs/actions/Domain'; -import ROUTES from '@src/ROUTES'; -import type {Errors} from '@src/types/onyx/OnyxCommon'; -import type WithSentryLabel from '@src/types/utils/SentryLabel'; -import DomainsListRow from './DomainsListRow'; - -type DomainMenuItemProps = { - /** Domain menu item data */ - item: DomainItem; - - /** Row index in the menu */ - index: number; -}; - -type DomainItem = { - /** Type of menu item row in the list of workspaces and domains */ - listItemType: 'domain'; - - /** Main text to show in the row */ - title: string; - - /** Function to run after clicking on the row */ - action: () => void; - - /** ID of the row's domain */ - accountID: number; - - /** Whether the user is an admin of the row's domain */ - isAdmin: boolean; - - /** Whether the row's domain is validated (aka verified) */ - isValidated: boolean; - - /** Current errors for domain */ - errors?: Errors; - - /** The type of brick road indicator to show */ - brickRoadIndicator?: ValueOf; -} & Pick & - WithSentryLabel; - -function DomainMenuItem({item, index}: DomainMenuItemProps) { - const icons = useMemoizedLazyExpensifyIcons(['Globe']); - const styles = useThemeStyles(); - const {translate} = useLocalize(); - const {isAdmin, isValidated, action} = item; - - let badgeText: string | undefined; - if (isAdmin) { - badgeText = isValidated ? translate('common.verified') : translate('domain.notVerified'); - } - - const threeDotsMenuItems: PopoverMenuItem[] | undefined = useMemo( - () => - isAdmin - ? [ - { - icon: icons.Globe, - text: translate('domain.goToDomain'), - onSelected: action, - }, - !isValidated && { - icon: icons.Globe, - text: translate('domain.verifyDomain.title'), - onSelected: () => Navigation.navigate(ROUTES.WORKSPACES_VERIFY_DOMAIN.getRoute(item.accountID)), - }, - ].filter((menuItem) => !!menuItem) - : undefined, - [isAdmin, icons.Globe, translate, action, isValidated, item.accountID], - ); - - return ( - clearDomainErrors(item.accountID)} - > - - {({hovered}) => ( - - )} - - - ); -} - -export type {DomainItem}; -export default DomainMenuItem; diff --git a/src/components/Domain/DomainsListRow.tsx b/src/components/Domain/DomainsListRow.tsx deleted file mode 100644 index 0f44bdf92f58..000000000000 --- a/src/components/Domain/DomainsListRow.tsx +++ /dev/null @@ -1,103 +0,0 @@ -import React from 'react'; -import {View} from 'react-native'; -import type {ValueOf} from 'type-fest'; -import Badge from '@components/Badge'; -import Icon from '@components/Icon'; -import type {PopoverMenuItem} from '@components/PopoverMenu'; -import TextWithTooltip from '@components/TextWithTooltip'; -import ThreeDotsMenu from '@components/ThreeDotsMenu'; -import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; -import useTheme from '@hooks/useTheme'; -import useThemeStyles from '@hooks/useThemeStyles'; -import variables from '@styles/variables'; -import CONST from '@src/CONST'; - -type DomainsListRowProps = { - /** Name of the domain */ - title: string; - - /** Whether the row is hovered, so we can modify its style */ - isHovered: boolean; - - /** The text to display inside a badge next to the title */ - badgeText?: string; - - /** Whether the badge should use success styling */ - isBadgeSuccess?: boolean; - - /** Items for the three dots menu */ - menuItems?: PopoverMenuItem[]; - - /** The type of brick road indicator to show */ - brickRoadIndicator?: ValueOf; -}; - -function DomainsListRow({title, isHovered, badgeText, isBadgeSuccess, brickRoadIndicator, menuItems}: DomainsListRowProps) { - const styles = useThemeStyles(); - const theme = useTheme(); - - const icons = useMemoizedLazyExpensifyIcons(['Globe', 'ArrowRight', 'DotIndicator']); - - return ( - - - - - - {!!badgeText && ( - - - - )} - - - - - - - {!!brickRoadIndicator && ( - - )} - - {!!menuItems?.length && ( - - )} - - - - - - - - ); -} - -export default DomainsListRow; diff --git a/src/components/DomainsEmptyStateComponent.tsx b/src/components/DomainsEmptyStateComponent.tsx deleted file mode 100644 index 8864f5b079b4..000000000000 --- a/src/components/DomainsEmptyStateComponent.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react'; -import {View} from 'react-native'; -import {useMemoizedLazyAsset} from '@hooks/useLazyAsset'; -import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; -import Navigation from '@libs/Navigation/Navigation'; -import BillingBanner from '@pages/settings/Subscription/CardSection/BillingBanner/BillingBanner'; -import ROUTES from '@src/ROUTES'; -import Button from './Button'; -import {loadIllustration} from './Icon/IllustrationLoader'; - -function DomainsEmptyStateComponent() { - const {asset: BlueShield} = useMemoizedLazyAsset(() => loadIllustration('BlueShield')); - const styles = useThemeStyles(); - const {translate} = useLocalize(); - - return ( - - Navigation.navigate(ROUTES.WORKSPACES_ADD_DOMAIN)} - /> - } - /> - - ); -} - -export default DomainsEmptyStateComponent; diff --git a/src/components/Icon/chunks/illustrations.chunk.ts b/src/components/Icon/chunks/illustrations.chunk.ts index 104be0d8911f..9bc76cdce03c 100644 --- a/src/components/Icon/chunks/illustrations.chunk.ts +++ b/src/components/Icon/chunks/illustrations.chunk.ts @@ -63,6 +63,7 @@ import BigVault from '@assets/images/product-illustrations/big-vault.svg'; import BrokenCompanyCardBankConnection from '@assets/images/product-illustrations/broken-humpty-dumpty.svg'; import BrokenMagnifyingGlass from '@assets/images/product-illustrations/broken-magnifying-glass.svg'; import DjBoothReferenceHands from '@assets/images/product-illustrations/dj-booth-reference-hands.svg'; +import EarthWithControls from '@assets/images/product-illustrations/earth-with-controls.svg'; import EmptyStateExpenses from '@assets/images/product-illustrations/emptystate__expenses.svg'; import HoldExpense from '@assets/images/product-illustrations/emptystate__holdexpense.svg'; import ReceiptFairy from '@assets/images/product-illustrations/emptystate__receiptfairy.svg'; @@ -268,6 +269,7 @@ const Illustrations = { HoldExpense, ReceiptFairy, EmptyStateTravel, + EarthWithControls, Fireworks, FolderWithPapersAndWatch, FolderWithPapers, diff --git a/src/components/Navigation/SearchSidebar.tsx b/src/components/Navigation/SearchSidebar.tsx index d66d3aa1e8b4..be8531d05a33 100644 --- a/src/components/Navigation/SearchSidebar.tsx +++ b/src/components/Navigation/SearchSidebar.tsx @@ -46,7 +46,7 @@ function SearchSidebar({state}: SearchSidebarProps) { } return ( - + processedData; + } + return listRef.current?.[property as keyof FlashListRef]; }, }) as TableHandle; diff --git a/src/components/Table/TableBody.tsx b/src/components/Table/TableBody.tsx index e2a5eb0a3dc8..b6851e307f04 100644 --- a/src/components/Table/TableBody.tsx +++ b/src/components/Table/TableBody.tsx @@ -3,6 +3,7 @@ import React from 'react'; import {View} from 'react-native'; import type {StyleProp, ViewProps, ViewStyle} from 'react-native'; import Text from '@components/Text'; +import useBottomSafeSafeAreaPaddingStyle from '@hooks/useBottomSafeSafeAreaPaddingStyle'; import useDebouncedAccessibilityAnnouncement from '@hooks/useDebouncedAccessibilityAnnouncement'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -44,12 +45,18 @@ type TableBodyProps = ViewProps & { * * ``` */ -function TableBody({contentContainerStyle, ...props}: TableBodyProps) { +function TableBody({contentContainerStyle, style, ...props}: TableBodyProps) { const styles = useThemeStyles(); const {translate} = useLocalize(); - const {processedData: filteredAndSortedData, activeSearchString, listProps, hasActiveFilters, hasSearchString, isEmptyResult} = useTableContext(); + const {processedData: filteredAndSortedData, activeSearchString, listProps, listRef, shouldUseNarrowTableLayout, hasActiveFilters, hasSearchString, isEmptyResult} = useTableContext(); const {ListEmptyComponent, contentContainerStyle: listContentContainerStyle, ...restListProps} = listProps ?? {}; + const tableBodyContentContainerStyle = useBottomSafeSafeAreaPaddingStyle({ + addBottomSafeAreaPadding: true, + addOfflineIndicatorBottomSafeAreaPadding: true, + style: shouldUseNarrowTableLayout ? styles.pb20 : styles.pb4, + }); + // Determine the message based on what caused the empty result const getEmptyMessage = () => { if (hasSearchString) { @@ -78,13 +85,17 @@ function TableBody({contentContainerStyle, ...props}: TableBodyProps) { return ( + ref={listRef} data={filteredAndSortedData} + style={[styles.flex1, styles.mnh0]} + showsVerticalScrollIndicator={false} + maintainVisibleContentPosition={{disabled: true}} ListEmptyComponent={isEmptyResult ? EmptyResultComponent : ListEmptyComponent} - contentContainerStyle={[filteredAndSortedData.length === 0 && styles.flex1, listContentContainerStyle, contentContainerStyle]} + contentContainerStyle={[filteredAndSortedData.length === 0 && styles.flex1, listContentContainerStyle, tableBodyContentContainerStyle, contentContainerStyle]} keyboardShouldPersistTaps="handled" {...restListProps} /> diff --git a/src/components/Table/TableHeader.tsx b/src/components/Table/TableHeader.tsx index 57a45410ce69..dcaec3a1b032 100644 --- a/src/components/Table/TableHeader.tsx +++ b/src/components/Table/TableHeader.tsx @@ -1,6 +1,6 @@ import React, {useRef} from 'react'; import {View} from 'react-native'; -import type {ViewProps, ViewStyle} from 'react-native'; +import type {ViewProps} from 'react-native'; import Icon from '@components/Icon'; import {PressableWithFeedback} from '@components/Pressable'; import Text from '@components/Text'; @@ -21,10 +21,7 @@ const NUMBER_OF_TOGGLES_BEFORE_RESET = 2; /** * Props for the TableHeader component. */ -type TableHeaderProps = ViewProps & { - /** Hide table header when search returns no results. */ - shouldHideHeaderWhenEmptySearch?: boolean; -}; +type TableHeaderProps = ViewProps; /** * Renders the table header row with sortable column headers. @@ -49,19 +46,21 @@ type TableHeaderProps = ViewProps & { * * ``` */ -function TableHeader({style, shouldHideHeaderWhenEmptySearch = true, ...props}: TableHeaderProps) { +function TableHeader({style, ...props}: TableHeaderProps) { const theme = useTheme(); const styles = useThemeStyles(); - const {columns, isEmptyResult, title, shouldUseNarrowTableLayout} = useTableContext(); + const {columns, isEmptyResult, title, processedData, shouldUseNarrowTableLayout} = useTableContext(); if (shouldUseNarrowTableLayout && !title) { return null; } - if (shouldHideHeaderWhenEmptySearch && isEmptyResult) { + if (isEmptyResult || !processedData.length) { return null; } + const gridTemplateColumns = columns.map((column) => (column.width ? `${column.width}px` : '1fr')).join(' '); + return ( ({style, shouldHideHea styles.gap3, // Use Grid on web when available (will override flex if supported) styles.dGrid, - !shouldUseNarrowTableLayout && {gridTemplateColumns: columns.map((column) => (column.width ? `${column.width}px` : '1fr')).join(' ')}, + !shouldUseNarrowTableLayout && {gridTemplateColumns}, style, ]} {...props} > {shouldUseNarrowTableLayout && ( - - {title} - + + + {title} + + )} {!shouldUseNarrowTableLayout && @@ -141,14 +142,14 @@ function TableHeaderColumn({column}: {colu toggleColumnSorting(columnKey); }; - let columnSizeStyle: ViewStyle | undefined; - if (column.width) { - columnSizeStyle = {width: column.width}; - } else if (column.styling?.flex) { - columnSizeStyle = {flex: column.styling.flex}; - } - - const tableHeaderStyles = [styles.flexRow, styles.alignItemsCenter, styles.tableHeaderContentHeight, columnSizeStyle ?? styles.flex1, column.styling?.containerStyles]; + const tableHeaderStyles = [ + styles.flexRow, + styles.alignItemsCenter, + styles.tableHeaderContentHeight, + column.styling?.flex ? {flex: column.styling.flex} : styles.flex1, + column.styling?.containerStyles, + !column.sortable && styles.cursorDefault, + ]; return ( ({column}: {colu accessibilityRole="button" sentryLabel={CONST.SENTRY_LABEL.TABLE_HEADER.SORTABLE_COLUMN} style={tableHeaderStyles} + disabled={!column.sortable} onPress={() => toggleSorting(column.key)} > & { /** Whether or not the table row is loading */ isLoading?: boolean; + /** Whether or not the row should animate in highlighted */ + shouldAnimateInHighlight?: boolean; + /** The loading component to render within the table row when the row is loading */ LoadingComponent?: React.ComponentType; @@ -44,6 +50,7 @@ export default function TableRow({ sentryLabel, interactive, isLoading, + shouldAnimateInHighlight, skeletonReasonAttributes, LoadingComponent, onPress, @@ -57,30 +64,45 @@ export default function TableRow({ const {processedData, columns, shouldUseNarrowTableLayout} = useTableContext(); const rowCount = processedData.length; + const isFirstRow = rowIndex === 0; const isLastRow = rowIndex === rowCount - 1; const isInteractive = interactive && !isLoading; + const gridTemplateColumns = columns.map((column) => (column.width ? `${column.width}px` : '1fr')).join(' '); + + const animatedHighlightStyle = useAnimatedHighlightStyle({ + shouldHighlight: !!shouldAnimateInHighlight, + highlightColor: theme.messageHighlightBG, + backgroundColor: theme.transparent, + }); const tableRowPressableStyles = [ styles.mh5, - styles.flexRow, styles.highlightBG, - styles.alignItemsCenter, isInteractive && styles.userSelectNone, + !isFirstRow && styles.borderTop, + isLastRow && styles.tableBottomRadius, + shouldUseNarrowTableLayout ? styles.tableRowHeightCompact : styles.tableRowHeight, + ]; + + const tableRowContentContainerStyles = [ + styles.flex1, + styles.gap3, shouldUseNarrowTableLayout ? styles.ph4 : styles.ph3, shouldUseNarrowTableLayout && !isLoading && styles.pv4, !shouldUseNarrowTableLayout && !isLoading && styles.pv2, - isLastRow ? styles.tableBottomRadius : styles.borderBottom, - shouldUseNarrowTableLayout ? styles.tableRowHeightCompact : styles.tableRowHeight, + animatedHighlightStyle, + isLastRow && styles.tableBottomRadius, ]; const tableRowContentStyles = [ styles.flex1, styles.flexRow, styles.alignItemsCenter, + styles.alignContentCenter, styles.gap3, styles.dFlex, // Use Grid on web when available (will override flex if supported) - !shouldUseNarrowTableLayout && [styles.dGrid, {gridTemplateColumns: columns.map((column) => (column.width ? `${column.width}px` : '1fr')).join(' ')}], + !shouldUseNarrowTableLayout && [styles.dGrid, {gridTemplateColumns}], ]; const renderChildren = (state: PressableStateCallbackType) => { @@ -93,9 +115,8 @@ export default function TableRow({ return ( - {(state) => - !!isLoading && LoadingComponent ? ( - - - - - - ) : ( - {renderChildren(state)} - ) - } + {(state) => ( + + {!!isLoading && LoadingComponent ? ( + + + + + + ) : ( + {renderChildren(state)} + )} + + {!!offlineWithFeedback?.errors && ( + + )} + + )} ); diff --git a/src/components/Table/TableSearchBar.tsx b/src/components/Table/TableSearchBar.tsx index 12507f84b5f5..218a10431ccf 100644 --- a/src/components/Table/TableSearchBar.tsx +++ b/src/components/Table/TableSearchBar.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import {View} from 'react-native'; -import TextInput from '@components/TextInput'; +import type {StyleProp, ViewStyle} from 'react-native'; +import SearchBar from '@components/SearchBar'; import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; import {useTableContext} from './TableContext'; @@ -34,9 +34,12 @@ import {useTableContext} from './TableContext'; type TableSearchBarProps = { /** Label and accessibility label for the search input. */ label: string; + + /** Optional style for the search bar container. */ + style?: StyleProp; }; -function TableSearchBar({label}: TableSearchBarProps) { +function TableSearchBar({label, style}: TableSearchBarProps) { const expensifyIcons = useMemoizedLazyExpensifyIcons(['MagnifyingGlass']); const { activeSearchString, @@ -44,22 +47,13 @@ function TableSearchBar({label}: TableSearchBarProps) { } = useTableContext(); return ( - - updateSearchString(text)} - icon={activeSearchString.length === 0 ? expensifyIcons.MagnifyingGlass : undefined} - includeIconPadding={false} - shouldShowClearButton - shouldHideClearButton={activeSearchString.length === 0} - onClearInput={() => updateSearchString('')} - autoCapitalize="none" - autoCorrect={false} - spellCheck={false} - /> - + updateSearchString(text)} + /> ); } diff --git a/src/components/Table/types.ts b/src/components/Table/types.ts index dfc23294b771..4944fc870bfc 100644 --- a/src/components/Table/types.ts +++ b/src/components/Table/types.ts @@ -36,6 +36,9 @@ type TableColumn = { /** Optional styling configuration for the column. */ styling?: TableColumnStyling; + + /** Whether or not the column is sortable */ + sortable: boolean; }; /** @@ -56,7 +59,11 @@ type TableMethods = FlashListRef & TableMethods; +type TableHandle = FlashListRef & + TableMethods & { + /** Method to get all of the processed data after filtering, searching, and sorting have been applied. */ + getProcessedData: () => T[]; + }; /** * FlashList props with the 'data' prop omitted, as the Table manages data internally. diff --git a/src/components/Tables/DomainListTable/DomainListTableRow.tsx b/src/components/Tables/DomainListTable/DomainListTableRow.tsx new file mode 100644 index 000000000000..064648e9902f --- /dev/null +++ b/src/components/Tables/DomainListTable/DomainListTableRow.tsx @@ -0,0 +1,130 @@ +import React from 'react'; +import {View} from 'react-native'; +import Badge from '@components/Badge'; +import Icon from '@components/Icon'; +import type {PopoverMenuItem} from '@components/PopoverMenu'; +import TableRow from '@components/Table/TableRow'; +import TextWithTooltip from '@components/TextWithTooltip'; +import ThreeDotsMenu from '@components/ThreeDotsMenu'; +import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; +import useLocalize from '@hooks/useLocalize'; +import useTheme from '@hooks/useTheme'; +import useThemeStyles from '@hooks/useThemeStyles'; +import {clearDomainErrors} from '@libs/actions/Domain'; +import Navigation from '@libs/Navigation/Navigation'; +import variables from '@styles/variables'; +import ROUTES from '@src/ROUTES'; +import type {DomainRowData} from '.'; + +type DomainListTableRowProps = { + item: DomainRowData; + + rowIndex: number; + + shouldUseNarrowTableLayout: boolean; +}; + +export default function DomainListTableRow({item, rowIndex, shouldUseNarrowTableLayout}: DomainListTableRowProps) { + const theme = useTheme(); + const styles = useThemeStyles(); + const {translate} = useLocalize(); + const icons = useMemoizedLazyExpensifyIcons(['Globe', 'ArrowRight']); + + const threeDotMenuItems: PopoverMenuItem[] = []; + + if (item.isAdmin) { + threeDotMenuItems.push({ + icon: icons.Globe, + text: translate('domain.goToDomain'), + onSelected: item.action, + }); + } + + if (item.isAdmin && !item.isValidated) { + threeDotMenuItems.push({ + icon: icons.Globe, + text: translate('domain.verifyDomain.title'), + onSelected: () => Navigation.navigate(ROUTES.WORKSPACES_VERIFY_DOMAIN.getRoute(item.domainAccountID)), + }); + } + + const VerifiedDomainBadge = ( + + ); + + const domainDetailsContainerStyles = [ + styles.flex1, + !shouldUseNarrowTableLayout && styles.alignItemsCenter, + !shouldUseNarrowTableLayout && styles.flexRow, + shouldUseNarrowTableLayout ? styles.gap1 : styles.gap2, + ]; + + const accessibilityLabel = [ + translate('domain.addDomain.domainName'), + item.title, + item.isValidated && item.isAdmin && translate('common.verified'), + !item.isValidated && item.isAdmin && translate('domain.notVerified'), + ] + .filter(Boolean) + .join(', '); + + return ( + clearDomainErrors(item.domainAccountID), + }} + > + {({hovered}) => ( + <> + + + + + {item.isAdmin && VerifiedDomainBadge} + + + + {threeDotMenuItems.length > 0 && ( + + )} + + + + + )} + + ); +} diff --git a/src/components/Tables/DomainListTable/index.tsx b/src/components/Tables/DomainListTable/index.tsx new file mode 100644 index 000000000000..4bc1f5c692a7 --- /dev/null +++ b/src/components/Tables/DomainListTable/index.tsx @@ -0,0 +1,83 @@ +import type {ListRenderItemInfo} from '@shopify/flash-list'; +import React from 'react'; +import type {ValueOf} from 'type-fest'; +import DomainListEmptyState from '@components/Domain/DomainListEmptyState'; +import type {CompareItemsCallback, IsItemInSearchCallback, TableColumn} from '@components/Table'; +import Table from '@components/Table'; +import useLocalize from '@hooks/useLocalize'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; +import useThemeStyles from '@hooks/useThemeStyles'; +import variables from '@styles/variables'; +import CONST from '@src/CONST'; +import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; +import DomainListTableRow from './DomainListTableRow'; + +type DomainTableColumnKey = 'domains' | 'actions'; + +type DomainRowData = { + domainAccountID: number; + title: string; + disabled: boolean; + isAdmin: boolean; + isValidated: boolean; + pendingAction?: OnyxCommon.PendingAction; + errors?: OnyxCommon.Errors; + brickRoadIndicator?: ValueOf; + action: () => void; +}; + +type DomainListTableProps = { + domains: DomainRowData[]; +}; + +export default function DomainListTable({domains}: DomainListTableProps) { + const styles = useThemeStyles(); + const {translate, localeCompare} = useLocalize(); + const {shouldUseNarrowLayout, isMediumScreenWidth} = useResponsiveLayout(); + + const shouldUseNarrowTableLayout = shouldUseNarrowLayout || isMediumScreenWidth; + + const domainTableColumns: Array> = [ + {key: 'domains', label: translate('common.domains'), sortable: true}, + {key: 'actions', width: variables.domainTableActionColumnWidth, label: '', styling: {containerStyles: [styles.justifyContentEnd, styles.pr3]}, sortable: false}, + ]; + + const compareTableItems: CompareItemsCallback = (item1, item2, activeSorting) => { + const orderMultiplier = activeSorting.order === 'asc' ? 1 : -1; + return orderMultiplier * localeCompare(item1.title, item2.title); + }; + + const isTableItemInSearch: IsItemInSearchCallback = (item, searchValue) => { + return item.title.toLowerCase().includes(searchValue.toLowerCase()); + }; + + const renderTableItem = ({item, index}: ListRenderItemInfo) => { + return ( + + ); + }; + + return ( + `${row.domainAccountID}-${index}`} + > + {domains.length >= CONST.STANDARD_LIST_ITEM_LIMIT && } + + +
+ ); +} + +export type {DomainRowData}; diff --git a/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableHeaderButtons.tsx b/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableHeaderButtons.tsx index db55234f7608..7f7dd18cdf14 100644 --- a/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableHeaderButtons.tsx +++ b/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableHeaderButtons.tsx @@ -154,7 +154,10 @@ function WorkspaceCompanyCardsTableHeaderButtons({policyID, feedName, isLoading, > {!isLoading && showTableControls && ( - + )} diff --git a/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableRow.tsx b/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableRow.tsx index bdc2ac9a40e1..d15aa4ff9334 100644 --- a/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableRow.tsx +++ b/src/components/Tables/WorkspaceCompanyCardsTable/WorkspaceCompanyCardsTableRow.tsx @@ -153,7 +153,7 @@ function WorkspaceCompanyCardTableRow({item, policyID, CardFeedIcon, shouldUseNa
{!shouldUseNarrowTableLayout && ( - + + `${item.cardName}_${index}`; - const tableBodyContentContainerStyle = useBottomSafeSafeAreaPaddingStyle({ - addBottomSafeAreaPadding: true, - addOfflineIndicatorBottomSafeAreaPadding: true, - style: styles.pb4, - }); - const compareItems: CompareItemsCallback = (a, b, activeSorting) => { const orderMultiplier = activeSorting.order === 'asc' ? 1 : -1; @@ -425,7 +423,7 @@ function WorkspaceCompanyCardsTable({ )} - {showCards && } + {showCards && } ); } diff --git a/src/components/Tables/WorkspaceListTable/WorkspaceTableRow.tsx b/src/components/Tables/WorkspaceListTable/WorkspaceTableRow.tsx new file mode 100644 index 000000000000..eb09f3348a2b --- /dev/null +++ b/src/components/Tables/WorkspaceListTable/WorkspaceTableRow.tsx @@ -0,0 +1,252 @@ +import {useIsFocused} from '@react-navigation/core'; +import React, {useEffect, useRef} from 'react'; +import {View} from 'react-native'; +import Avatar from '@components/Avatar'; +import Badge from '@components/Badge'; +import Icon from '@components/Icon'; +import Table from '@components/Table'; +import Text from '@components/Text'; +import TextWithTooltip from '@components/TextWithTooltip'; +import ThreeDotsMenu from '@components/ThreeDotsMenu'; +import Tooltip from '@components/Tooltip'; +import WorkspacesListRowDisplayName from '@components/WorkspacesListRowDisplayName'; +import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; +import useLocalize from '@hooks/useLocalize'; +import useTheme from '@hooks/useTheme'; +import useThemeStyles from '@hooks/useThemeStyles'; +import {getUserFriendlyWorkspaceType} from '@libs/PolicyUtils'; +import variables from '@styles/variables'; +import CONST from '@src/CONST'; +import type {WorkspaceRowData} from '.'; + +type WorkspaceRowProps = { + /** The workspace data */ + item: WorkspaceRowData; + + /** The index of the row relative to all other rows */ + rowIndex: number; + + /** Whether to use narrow table row layout */ + shouldUseNarrowTableLayout: boolean; +}; + +export default function WorkspaceRow({item, shouldUseNarrowTableLayout, rowIndex}: WorkspaceRowProps) { + const threeDotsMenuRef = useRef<{hidePopoverMenu: () => void; isPopupMenuVisible: boolean}>(null); + + const theme = useTheme(); + const styles = useThemeStyles(); + const isFocused = useIsFocused(); + const {translate} = useLocalize(); + const icons = useMemoizedLazyExpensifyIcons(['ArrowRight', 'Building', 'FallbackWorkspaceAvatar', 'DotIndicator', 'Hourglass']); + + const isLoadingBill = item.isLoadingBill; + const formattedOwnerName = item.ownerName ?? ''; + const formattedWorkspaceType = getUserFriendlyWorkspaceType(item.type, translate); + const narrowWorkspaceLabel = `${translate('common.owner')}: ${formattedOwnerName} • ${formattedWorkspaceType}`; + const itemDeletedStyles = item.isDeleted ? [styles.offlineFeedbackDeleted] : [{}]; + const resetLoadingSpinnerIconIndex = item.resetLoadingSpinnerIconIndex; + + const accessibilityLabel = [ + `${translate('workspace.common.workspaceName')}: ${item.title}`, + item.isDefault ? translate('common.default') : '', + item.isJoinRequestPending ? translate('workspace.common.requested') : '', + item.ownerName ? `${translate('workspace.common.workspaceOwner')}: ${item.ownerName}` : '', + item.type ? `${translate('workspace.common.workspaceType')}: ${formattedWorkspaceType}` : '', + ] + .filter(Boolean) + .join(', '); + + const BrickRoadIndicator = !!item.brickRoadIndicator && ( + + + + ); + + const JoinRequestPendingBadge = ( + + + + ); + + const DefaultWorkspaceBadge = ( + + + + + + ); + + const ThreeDotsMenuWithBrickRoadIndicator = ( + + {item.brickRoadIndicator && BrickRoadIndicator} + + + ); + + useEffect(() => { + if (isLoadingBill) { + return; + } + + resetLoadingSpinnerIconIndex?.(); + + if (!threeDotsMenuRef.current?.isPopupMenuVisible) { + return; + } + threeDotsMenuRef?.current?.hidePopoverMenu(); + }, [isLoadingBill, resetLoadingSpinnerIconIndex]); + + return ( + + {({hovered}) => ( + <> + {shouldUseNarrowTableLayout && ( + + + + + + + + {item.isDefault && DefaultWorkspaceBadge} + {item.isJoinRequestPending && JoinRequestPendingBadge} + + {narrowWorkspaceLabel} + + + + + {!item.isJoinRequestPending && ThreeDotsMenuWithBrickRoadIndicator} + + + + )} + + {!shouldUseNarrowTableLayout && ( + <> + + + + + {item.isDefault && DefaultWorkspaceBadge} + {item.isJoinRequestPending && JoinRequestPendingBadge} + + + + + + + + + + + {formattedWorkspaceType} + + + + + {!item.isJoinRequestPending && ThreeDotsMenuWithBrickRoadIndicator} + + + + + )} + + )} + + ); +} diff --git a/src/components/Tables/WorkspaceListTable/index.tsx b/src/components/Tables/WorkspaceListTable/index.tsx new file mode 100644 index 000000000000..4345c94fe14c --- /dev/null +++ b/src/components/Tables/WorkspaceListTable/index.tsx @@ -0,0 +1,117 @@ +import type {ListRenderItemInfo} from '@shopify/flash-list'; +import React from 'react'; +import type {ValueOf} from 'type-fest'; +import type {PopoverMenuItem} from '@components/PopoverMenu'; +import type {CompareItemsCallback, IsItemInSearchCallback, TableColumn, TableHandle} from '@components/Table'; +import Table from '@components/Table'; +import useLocalize from '@hooks/useLocalize'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; +import useThemeStyles from '@hooks/useThemeStyles'; +import type {ModifiedMouseEvent} from '@libs/Navigation/helpers/openInternalRouteInNewTab'; +import {getUserFriendlyWorkspaceType} from '@libs/PolicyUtils'; +import type {AvatarSource} from '@libs/UserUtils'; +import WorkspacesEmptyStateComponent from '@pages/workspace/WorkspacesEmptyStateComponent'; +import variables from '@styles/variables'; +import CONST from '@src/CONST'; +import type * as OnyxCommon from '@src/types/onyx/OnyxCommon'; +import WorkspaceRow from './WorkspaceTableRow'; + +type WorkspaceTableColumnKey = 'workspaces' | 'owner' | 'type' | 'actions'; + +type WorkspaceRowData = { + title: string; + icon: AvatarSource; + disabled: boolean; + isDefault: boolean; + isDeleted: boolean; + isLoadingBill: boolean; + isJoinRequestPending: boolean; + shouldAnimateInHighlight: boolean; + policyID: string; + ownerAccountID?: number; + ownerName?: string; + ownerLogin?: string; + ownerAvatar?: AvatarSource; + threeDotMenuItems?: PopoverMenuItem[]; + type: ValueOf; + role: ValueOf; + iconType: typeof CONST.ICON_TYPE_AVATAR | typeof CONST.ICON_TYPE_ICON; + errors?: OnyxCommon.Errors; + pendingAction?: OnyxCommon.PendingAction; + brickRoadIndicator?: ValueOf; + action: (event?: ModifiedMouseEvent) => void; + dismissError: () => void; + resetLoadingSpinnerIconIndex?: () => void; +}; + +type WorkspaceListTableProps = { + ref?: React.Ref> | undefined; + workspaces: WorkspaceRowData[]; +}; + +export default function WorkspaceListTable({ref, workspaces}: WorkspaceListTableProps) { + const styles = useThemeStyles(); + const {translate, localeCompare} = useLocalize(); + const {shouldUseNarrowLayout, isMediumScreenWidth} = useResponsiveLayout(); + const shouldUseNarrowTableLayout = shouldUseNarrowLayout || isMediumScreenWidth; + + const workspaceTableColumns: Array> = [ + {key: 'workspaces', label: translate('common.workspaces'), sortable: true}, + {key: 'owner', label: translate('common.owner'), sortable: true}, + {key: 'type', label: translate('workspace.common.workspaceType'), sortable: true}, + {key: 'actions', width: variables.workspaceTableActionColumnWidth, label: '', styling: {containerStyles: [styles.justifyContentEnd, styles.pr3]}, sortable: false}, + ]; + + const compareTableItems: CompareItemsCallback = (item1, item2, activeSorting) => { + const orderMultiplier = activeSorting.order === 'asc' ? 1 : -1; + + if (activeSorting.columnKey === 'workspaces') { + return orderMultiplier * localeCompare(item1.title, item2.title); + } + + if (activeSorting.columnKey === 'owner') { + return orderMultiplier * localeCompare(item1.ownerName ?? '', item2.ownerName ?? ''); + } + + if (activeSorting.columnKey === 'type') { + return orderMultiplier * localeCompare(getUserFriendlyWorkspaceType(item1.type, translate), getUserFriendlyWorkspaceType(item2.type, translate)); + } + + return 0; + }; + + const isTableItemInSearch: IsItemInSearchCallback = (item, searchValue) => { + return item.title.toLowerCase().includes(searchValue.toLowerCase()); + }; + + const renderTableItem = ({item, index}: ListRenderItemInfo) => { + return ( + + ); + }; + + return ( + `${row.policyID}-${index}`} + > + {workspaces.length >= CONST.STANDARD_LIST_ITEM_LIMIT && } + + +
+ ); +} + +export type {WorkspaceRowData, WorkspaceTableColumnKey}; diff --git a/src/components/Tables/WorkspaceRoomsTable/index.tsx b/src/components/Tables/WorkspaceRoomsTable/index.tsx index 04396e8e45d3..f16c9c90be24 100644 --- a/src/components/Tables/WorkspaceRoomsTable/index.tsx +++ b/src/components/Tables/WorkspaceRoomsTable/index.tsx @@ -1,6 +1,5 @@ import type {ListRenderItemInfo} from '@shopify/flash-list'; import React from 'react'; -import {View} from 'react-native'; import type {CompareItemsCallback, IsItemInSearchCallback, TableColumn} from '@components/Table'; import Table from '@components/Table'; import useLocalize from '@hooks/useLocalize'; @@ -24,10 +23,10 @@ function WorkspaceRoomsTable({rooms}: WorkspaceRoomsTableProps) { const shouldUseNarrowTableLayout = shouldUseNarrowLayout || isMediumScreenWidth; const columns: Array> = [ - {key: 'name', label: translate('common.name')}, - {key: 'createdBy', label: translate('common.createdBy')}, - {key: 'members', label: translate('common.members'), width: variables.workspaceRoomsMembersColumnWidth}, - {key: 'actions', label: '', width: variables.workspaceRoomsActionsColumnWidth, styling: {containerStyles: [styles.justifyContentEnd, styles.pr3]}}, + {key: 'name', label: translate('common.name'), sortable: true}, + {key: 'createdBy', label: translate('common.createdBy'), sortable: true}, + {key: 'members', label: translate('common.members'), width: variables.workspaceRoomsMembersColumnWidth, sortable: true}, + {key: 'actions', label: '', width: variables.workspaceRoomsActionsColumnWidth, styling: {containerStyles: [styles.justifyContentEnd, styles.pr3]}, sortable: false}, ]; const compareItems: CompareItemsCallback = (a, b, activeSorting) => { @@ -63,11 +62,9 @@ function WorkspaceRoomsTable({rooms}: WorkspaceRoomsTableProps) { isItemInSearch={isItemInSearch} initialSortColumn="name" title={translate('workspace.common.rooms')} - keyExtractor={(row) => row.reportID} + keyExtractor={(row, index) => `${row.reportID}-${index}`} > - - - + diff --git a/src/components/WorkspaceListLayout.tsx b/src/components/WorkspaceListLayout.tsx new file mode 100644 index 000000000000..3eb26808ac21 --- /dev/null +++ b/src/components/WorkspaceListLayout.tsx @@ -0,0 +1,96 @@ +import type {PropsWithChildren} from 'react'; +import React from 'react'; +import {View} from 'react-native'; +import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; +import useLocalize from '@hooks/useLocalize'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; +import useShouldDisplayButtonsInSeparateLine from '@hooks/useShouldDisplayButtonsInSeparateLine'; +import useThemeStyles from '@hooks/useThemeStyles'; +import Navigation from '@libs/Navigation/Navigation'; +import ROUTES from '@src/ROUTES'; +import SCREENS from '@src/SCREENS'; +import NAVIGATION_TABS from './Navigation/NavigationTabBar/NAVIGATION_TABS'; +import TabBarBottomContent from './Navigation/TabBarBottomContent'; +import TopBarWithLoadingBar from './Navigation/TopBarWithLoadingBar'; +import OfflineIndicator from './OfflineIndicator'; +import ScreenWrapper from './ScreenWrapper'; +import TabSelectorBase from './TabSelector/TabSelectorBase'; + +type WorkspaceListLayoutProps = PropsWithChildren<{ + headerButton?: React.ReactNode; + activeTabKey: 'workspaces' | 'domains'; +}>; + +export default function WorkspaceListLayout({children, activeTabKey, headerButton}: WorkspaceListLayoutProps) { + const styles = useThemeStyles(); + const {translate} = useLocalize(); + + const {shouldUseNarrowLayout} = useResponsiveLayout(); + const icons = useMemoizedLazyExpensifyIcons(['Globe', 'Building']); + const shouldDisplayButtonsInSeparateLine = useShouldDisplayButtonsInSeparateLine(); + + const isWorkspacesListPage = activeTabKey === 'workspaces'; + const testID = isWorkspacesListPage ? 'WorkspacesListPage' : 'DomainsListPage'; + const activeTabLabel = isWorkspacesListPage ? translate('common.workspaces') : translate('common.domains'); + + const navigationOptions = [ + { + key: 'workspaces', + title: translate('common.workspaces'), + icon: icons.Building, + route: ROUTES.WORKSPACES_LIST.getRoute(), + screenName: SCREENS.WORKSPACES_LIST, + }, + { + key: 'domains', + title: translate('common.domains'), + icon: icons.Globe, + route: ROUTES.DOMAINS_LIST.getRoute(), + screenName: SCREENS.DOMAINS_LIST, + }, + ]; + + const onTabPress = (key: string) => { + const matchingNavigationOption = navigationOptions.find((option) => option.key === key); + + if (!matchingNavigationOption) { + return; + } + + Navigation.navigate(matchingNavigationOption.route); + }; + + return ( + } + > + + + + {!shouldDisplayButtonsInSeparateLine && headerButton} + + + + + {shouldDisplayButtonsInSeparateLine && headerButton} + + + {children} + {!shouldUseNarrowLayout && } + + + + ); +} diff --git a/src/components/WorkspacesListRowDisplayName/index.native.tsx b/src/components/WorkspacesListRowDisplayName/index.native.tsx index 0aaeea620894..172ffe019488 100644 --- a/src/components/WorkspacesListRowDisplayName/index.native.tsx +++ b/src/components/WorkspacesListRowDisplayName/index.native.tsx @@ -11,7 +11,7 @@ function WorkspacesListRowDisplayName({isDeleted, ownerName}: WorkspacesListRowD return ( {processedOwnerName.length !== 0 ? getProcessedText(processedOwnerName, [styles.labelStrong, isDeleted ? styles.offlineFeedbackDeleted : {}, styles.emojisWithTextFontFamily]) diff --git a/src/components/WorkspacesListRowDisplayName/index.tsx b/src/components/WorkspacesListRowDisplayName/index.tsx index ddd9226c5f48..9c9ff5dd4149 100644 --- a/src/components/WorkspacesListRowDisplayName/index.tsx +++ b/src/components/WorkspacesListRowDisplayName/index.tsx @@ -9,7 +9,7 @@ function WorkspacesListRowDisplayName({isDeleted, ownerName}: WorkspacesListRowD return ( {ownerName} diff --git a/src/languages/de.ts b/src/languages/de.ts index 0fe93f7a0714..af83dc186223 100644 --- a/src/languages/de.ts +++ b/src/languages/de.ts @@ -4410,6 +4410,7 @@ ${amount} für ${merchant} – ${date}`, travelInvoicingPayableAccount: 'Reiseverbindlichkeitskonto', hr: 'Personalwesen', rooms: 'Räume', + findDomain: 'Domain finden', cardAdminAlternateText: 'Arbeitsbereichskarten verwalten.', peopleAdminAlternateText: 'Mitglieder und Genehmigungsabläufe verwalten.', paymentsAdminAlternateText: 'Workflow-Zahlungen verwalten.', @@ -7303,6 +7304,10 @@ Fügen Sie weitere Ausgabelimits hinzu, um den Cashflow Ihres Unternehmens zu sc syncingModalDescription: 'Die erste Verbindung kann einige Zeit dauern. Sie werden über alle Fehler benachrichtigt.', syncing: 'Mitarbeitende werden synchronisiert', }, + emptyDomain: { + title: 'Stärken Sie Ihre Sicherheit mit Domains', + subtitle: 'Verlangen Sie, dass Mitglieder in Ihrer Domain sich per Single Sign-On anmelden, schränken Sie das Erstellen von Arbeitsbereichen ein und mehr.', + }, }, getAssistancePage: { title: 'Hilfe erhalten', diff --git a/src/languages/en.ts b/src/languages/en.ts index d66a0d18d979..3b1c22263ffe 100644 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -4347,6 +4347,7 @@ const translations = { workflows: 'Workflows', workspace: 'Workspace', findWorkspace: 'Find workspace', + findDomain: 'Find domain', findRoom: 'Find room', edit: 'Edit workspace', enabled: 'Enabled', @@ -6097,6 +6098,10 @@ const translations = { `You’re about to create and share ${newWorkspaceName ?? ''} with ${totalMembers ?? 0} members from the original workspace.`, error: 'An error occurred while duplicating your new workspace. Please try again.', }, + emptyDomain: { + title: 'Enhance your security with domains', + subtitle: 'Require members on your domain to log in via single sign-on, restrict workspace creation, and more.', + }, copyPolicySettings: { error: 'An error occurred while copying workspace settings. Please try again.', title: 'Copy settings', diff --git a/src/languages/es.ts b/src/languages/es.ts index f5a04285c1d1..75c5ae9d605e 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -4299,6 +4299,7 @@ ${amount} para ${merchant} - ${date}`, travelInvoicing: 'Exportar gastos de facturación de viajes como', travelInvoicingVendor: 'Proveedor de viajes', travelInvoicingPayableAccount: 'Cuenta por pagar de viajes', + findDomain: 'Buscar dominio', cardAdminAlternateText: 'Gestiona tarjetas del espacio de trabajo.', peopleAdminAlternateText: 'Gestiona miembros y flujos de aprobación.', paymentsAdminAlternateText: 'Gestiona los pagos del flujo de trabajo.', @@ -7096,6 +7097,10 @@ ${amount} para ${merchant} - ${date}`, }, }, }, + emptyDomain: { + title: 'Mejora tu seguridad con dominios', + subtitle: 'Exige que los miembros de tu dominio inicien sesión mediante inicio de sesión único, restrinjan la creación de espacios de trabajo y más.', + }, }, getAssistancePage: { title: 'Obtener ayuda', diff --git a/src/languages/fr.ts b/src/languages/fr.ts index 549a4b124e2b..ca47a2232b67 100644 --- a/src/languages/fr.ts +++ b/src/languages/fr.ts @@ -4421,6 +4421,7 @@ ${amount} pour ${merchant} - ${date}`, travelInvoicingPayableAccount: 'Compte fournisseur déplacements', hr: 'RH', rooms: 'Salons', + findDomain: 'Trouver un domaine', cardAdminAlternateText: 'Gérer les cartes de l’espace de travail.', peopleAdminAlternateText: 'Gérez les membres et les workflows d’approbation.', paymentsAdminAlternateText: 'Gérer les paiements de workflow.', @@ -7336,6 +7337,10 @@ Ajoutez davantage de règles de dépenses pour protéger la trésorerie de l’e syncingModalDescription: 'La première connexion peut prendre un certain temps. Vous serez informé de toute erreur.', syncing: 'Synchronisation des employés', }, + emptyDomain: { + title: 'Renforcez votre sécurité avec des domaines', + subtitle: 'Obligez les membres de votre domaine à se connecter via l’authentification unique, restreignez la création d’espaces de travail, et plus encore.', + }, }, getAssistancePage: { title: 'Obtenir de l’aide', diff --git a/src/languages/it.ts b/src/languages/it.ts index e007ebbadb59..8fe9b4adc4cb 100644 --- a/src/languages/it.ts +++ b/src/languages/it.ts @@ -4395,6 +4395,7 @@ ${amount} per ${merchant} - ${date}`, travelInvoicingPayableAccount: 'Conto debiti per viaggi', hr: 'Risorse umane', rooms: 'Stanze', + findDomain: 'Trova dominio', cardAdminAlternateText: 'Gestisci le carte dello spazio di lavoro.', peopleAdminAlternateText: 'Gestisci i membri e i flussi di approvazione.', paymentsAdminAlternateText: 'Gestisci i pagamenti del flusso di lavoro.', @@ -7287,6 +7288,10 @@ Aggiungi altre regole di spesa per proteggere il flusso di cassa aziendale.`, syncingModalDescription: "La prima connessione può richiedere un po' di tempo. Ti verrà notificato qualsiasi errore.", syncing: 'Sincronizzazione dipendenti', }, + emptyDomain: { + title: 'Migliora la tua sicurezza con i domini', + subtitle: 'Richiedi ai membri del tuo dominio di accedere tramite accesso Single Sign-On, limita la creazione di space di lavoro e altro ancora.', + }, }, getAssistancePage: { title: 'Ottieni assistenza', diff --git a/src/languages/ja.ts b/src/languages/ja.ts index e8d949c3f539..5e0f2a989070 100644 --- a/src/languages/ja.ts +++ b/src/languages/ja.ts @@ -4364,6 +4364,7 @@ ${integrationName === CONST.ONBOARDING_ACCOUNTING_MAPPING.other ? 'あなたの' travelInvoicingPayableAccount: '旅費未払金勘定', hr: '人事', rooms: 'ルーム', + findDomain: 'ドメインを検索', cardAdminAlternateText: 'ワークスペースカードを管理します。', peopleAdminAlternateText: 'メンバーと承認ワークフローを管理します。', paymentsAdminAlternateText: 'ワークフローの支払いを管理します。', @@ -7206,6 +7207,10 @@ ${reportName} syncingModalDescription: '最初の接続には時間がかかる場合があります。エラーが発生した場合は通知されます。', syncing: '従業員を同期しています', }, + emptyDomain: { + title: 'ドメインでセキュリティを強化しましょう', + subtitle: 'ドメインのメンバーにシングルサインオンでのログインを必須にし、ワークスペースの作成を制限するなどの管理ができます。', + }, }, getAssistancePage: { title: 'サポートを受ける', diff --git a/src/languages/nl.ts b/src/languages/nl.ts index 80f6be11a1a7..f66eef9e396c 100644 --- a/src/languages/nl.ts +++ b/src/languages/nl.ts @@ -4391,6 +4391,7 @@ ${amount} voor ${merchant} - ${date}`, travelInvoicingPayableAccount: 'Reiscrediteurenrekening', hr: 'HR', rooms: 'Kamers', + findDomain: 'Domein zoeken', cardAdminAlternateText: 'Werkruimtekaarten beheren.', peopleAdminAlternateText: 'Beheer leden en goedkeuringsworkflows.', paymentsAdminAlternateText: 'Workflowsbetalingen beheren.', @@ -7261,6 +7262,7 @@ er bestedingsregels toe om de kasstroom van het bedrijf te beschermen.`, syncingModalDescription: 'De eerste verbinding kan even duren. Je krijgt een melding als er fouten optreden.', syncing: 'Werknemers synchroniseren', }, + emptyDomain: {title: 'Verbeter je beveiliging met domeinen', subtitle: 'Vereis dat leden op je domein inloggen via single sign-on, beperk het aanmaken van werkruimtes en meer.'}, }, getAssistancePage: { title: 'Hulp krijgen', diff --git a/src/languages/pl.ts b/src/languages/pl.ts index e712db5e509d..f06b0a94f24e 100644 --- a/src/languages/pl.ts +++ b/src/languages/pl.ts @@ -4383,6 +4383,7 @@ ${amount} dla ${merchant} - ${date}`, travelInvoicingPayableAccount: 'Konto zobowiązań z tytułu podróży', hr: 'HR', rooms: 'Pokoje', + findDomain: 'Znajdź domenę', cardAdminAlternateText: 'Zarządzaj kartami przestrzeni roboczej.', peopleAdminAlternateText: 'Zarządzaj członkami i procesami akceptacji.', paymentsAdminAlternateText: 'Zarządzaj płatnościami w przepływie pracy.', @@ -7254,6 +7255,10 @@ Dodaj więcej zasad wydatków, żeby chronić płynność finansową firmy.`, syncingModalDescription: 'Pierwsze połączenie może chwilę potrwać. Zostaniesz powiadomiony o wszelkich błędach.', syncing: 'Synchronizowanie pracowników', }, + emptyDomain: { + title: 'Zwiększ swoje bezpieczeństwo dzięki domenom', + subtitle: 'Wymagaj od członków swojej domeny logowania jednokrotnym logowaniem (SSO), ograniczaj tworzenie przestrzeni roboczych i nie tylko.', + }, }, getAssistancePage: { title: 'Uzyskaj pomoc', diff --git a/src/languages/pt-BR.ts b/src/languages/pt-BR.ts index 706993fe5a06..4214bc759aa0 100644 --- a/src/languages/pt-BR.ts +++ b/src/languages/pt-BR.ts @@ -4385,6 +4385,7 @@ ${amount} para ${merchant} - ${date}`, travelInvoicingPayableAccount: 'Conta a pagar de viagens', hr: 'RH', rooms: 'Salas', + findDomain: 'Encontrar domínio', cardAdminAlternateText: 'Gerenciar cartões do workspace.', peopleAdminAlternateText: 'Gerencie membros e fluxos de aprovação.', paymentsAdminAlternateText: 'Gerencie pagamentos de fluxo de trabalho.', @@ -7261,6 +7262,10 @@ Adicione mais regras de gasto para proteger o fluxo de caixa da empresa.`, syncingModalDescription: 'A primeira conexão pode levar algum tempo. Você será notificado sobre quaisquer erros.', syncing: 'Sincronizando funcionários', }, + emptyDomain: { + title: 'Aumente sua segurança com domínios', + subtitle: 'Exija que os membros do seu domínio façam login via logon único, restrinja a criação de workspaces e muito mais.', + }, }, getAssistancePage: { title: 'Obter ajuda', diff --git a/src/languages/zh-hans.ts b/src/languages/zh-hans.ts index 7d173515abcc..8bdcd00d9cde 100644 --- a/src/languages/zh-hans.ts +++ b/src/languages/zh-hans.ts @@ -4286,6 +4286,7 @@ ${amount},商户:${merchant} - 日期:${date}`, travelInvoicingPayableAccount: '差旅应付账户', hr: '人力资源', rooms: '房间', + findDomain: '查找域名', cardAdminAlternateText: '管理工作区卡片。', peopleAdminAlternateText: '管理成员和审批流程。', paymentsAdminAlternateText: '管理工作流付款。', @@ -7072,6 +7073,7 @@ ${reportName} syncingModalDescription: '首次连接可能需要一些时间。若发生任何错误,我们会通知你。', syncing: '正在同步员工', }, + emptyDomain: {title: '通过域名提升安全性', subtitle: '要求您域中的成员通过单点登录登录、限制工作区创建等。'}, }, getAssistancePage: { title: '获取帮助', diff --git a/src/libs/Navigation/AppNavigator/Navigators/WorkspaceNavigator.tsx b/src/libs/Navigation/AppNavigator/Navigators/WorkspaceNavigator.tsx index d1954db6117b..2927debc4a7e 100644 --- a/src/libs/Navigation/AppNavigator/Navigators/WorkspaceNavigator.tsx +++ b/src/libs/Navigation/AppNavigator/Navigators/WorkspaceNavigator.tsx @@ -7,6 +7,7 @@ import Animations from '@libs/Navigation/PlatformStackNavigation/navigationOptio import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import type {TabNavigatorParamList, WorkspaceNavigatorParamList} from '@libs/Navigation/types'; import createWorkspaceNavigator from '@navigation/AppNavigator/createWorkspaceNavigator'; +import DomainsListPage from '@pages/domain/DomainsListPage'; import WorkspacesListPage from '@pages/workspace/WorkspacesListPage'; import NAVIGATORS from '@src/NAVIGATORS'; import SCREENS from '@src/SCREENS'; @@ -32,6 +33,10 @@ function WorkspaceNavigator({route}: PlatformStackScreenProps + ([ SCREENS.SEARCH.ROOT, SCREENS.SETTINGS.ROOT, SCREENS.WORKSPACES_LIST, + SCREENS.DOMAINS_LIST, SCREENS.WORKSPACE.INITIAL, SCREENS.DOMAIN.INITIAL, ]); diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 5074861fe46a..667314d5afac 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -2312,6 +2312,10 @@ const config: LinkingOptions['config'] = { path: ROUTES.WORKSPACES_LIST.route, exact: true, }, + [SCREENS.DOMAINS_LIST]: { + path: ROUTES.DOMAINS_LIST.route, + exact: true, + }, [NAVIGATORS.WORKSPACE_SPLIT_NAVIGATOR]: { screens: { [SCREENS.WORKSPACE.INITIAL]: { diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 4e01c66699df..dcd5071a87e0 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -2972,6 +2972,7 @@ type WorkspaceNavigatorParamList = { // eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md backTo?: Routes; }; + [SCREENS.DOMAINS_LIST]: undefined; [NAVIGATORS.WORKSPACE_SPLIT_NAVIGATOR]: NavigatorScreenParams; [NAVIGATORS.DOMAIN_SPLIT_NAVIGATOR]: NavigatorScreenParams; }; diff --git a/src/pages/domain/AddDomainPage.tsx b/src/pages/domain/AddDomainPage.tsx index 496d0b4552ed..a754cf448429 100644 --- a/src/pages/domain/AddDomainPage.tsx +++ b/src/pages/domain/AddDomainPage.tsx @@ -58,12 +58,9 @@ function AddDomainPage() { const accountID = Object.values(allDomains ?? {})?.find( (domain) => domain && submittedDomainName.current && Str.caseInsensitiveEquals(Str.extractEmailDomain(domain.email), submittedDomainName.current), )?.accountID; + if (accountID) { - Navigation.dismissModal({ - afterTransition: () => { - Navigation.navigate(ROUTES.WORKSPACES_DOMAIN_ADDED.getRoute(accountID), {forceReplace: true}); - }, - }); + Navigation.setNavigationActionToMicrotaskQueue(() => Navigation.navigate(ROUTES.WORKSPACES_DOMAIN_ADDED.getRoute(accountID), {forceReplace: true})); } }, [form?.hasCreationSucceeded, allDomains]); @@ -76,7 +73,7 @@ function AddDomainPage() { Navigation.goBack(ROUTES.WORKSPACES_LIST.getRoute())} + onBackButtonPress={() => Navigation.goBack(ROUTES.DOMAINS_LIST.getRoute())} /> Navigation.goBack(ROUTES.WORKSPACES_LIST.route)} + onBackButtonPress={() => Navigation.goBack(ROUTES.DOMAINS_LIST.route)} shouldDisplayHelpButton={shouldUseNarrowLayout} /> diff --git a/src/pages/domain/DomainNotFoundPageWrapper.tsx b/src/pages/domain/DomainNotFoundPageWrapper.tsx index e770ffbc2045..47e131de968d 100644 --- a/src/pages/domain/DomainNotFoundPageWrapper.tsx +++ b/src/pages/domain/DomainNotFoundPageWrapper.tsx @@ -58,7 +58,7 @@ function DomainNotFoundPageWrapper({domainAccountID, shouldBeBlocked, fullPageNo shouldForceFullScreen shouldShowOfflineIndicator={false} onBackButtonPress={() => { - Navigation.goBack(ROUTES.WORKSPACES_LIST.route); + Navigation.goBack(ROUTES.DOMAINS_LIST.route); }} {...fullPageNotFoundViewProps} shouldShowBackButton diff --git a/src/pages/domain/DomainResetPage.tsx b/src/pages/domain/DomainResetPage.tsx index 3b47b2af8749..b0c3daea5cc4 100644 --- a/src/pages/domain/DomainResetPage.tsx +++ b/src/pages/domain/DomainResetPage.tsx @@ -58,7 +58,7 @@ function DomainResetDomainPage({route}: DomainResetDomainPageProps) { return; } resetDomain(route.params.domainAccountID, domainName); - Navigation.goBack(ROUTES.WORKSPACES_LIST.route); + Navigation.goBack(ROUTES.DOMAINS_LIST.route); }; const validate = (values: FormOnyxValues) => { diff --git a/src/pages/domain/DomainSamlPage.tsx b/src/pages/domain/DomainSamlPage.tsx index e217d78276b8..8ec39aa84bbd 100644 --- a/src/pages/domain/DomainSamlPage.tsx +++ b/src/pages/domain/DomainSamlPage.tsx @@ -87,7 +87,7 @@ function DomainSamlPage({route}: DomainSamlPageProps) { testID="DomainSamlPage" > Navigation.goBack(ROUTES.WORKSPACES_LIST.route)} + onBackButtonPress={() => Navigation.goBack(ROUTES.DOMAINS_LIST.route)} shouldShow={!doesDomainExist || !isAdmin} shouldForceFullScreen shouldDisplaySearchRouter diff --git a/src/pages/domain/DomainsListPage.tsx b/src/pages/domain/DomainsListPage.tsx new file mode 100644 index 000000000000..e05a8c9cc67d --- /dev/null +++ b/src/pages/domain/DomainsListPage.tsx @@ -0,0 +1,110 @@ +import {Str} from 'expensify-common'; +import React from 'react'; +import {View} from 'react-native'; +import ActivityIndicator from '@components/ActivityIndicator'; +import Button from '@components/Button'; +import type {DomainRowData} from '@components/Tables/DomainListTable'; +import DomainListTable from '@components/Tables/DomainListTable'; +import WorkspaceListLayout from '@components/WorkspaceListLayout'; +import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'; +import useDocumentTitle from '@hooks/useDocumentTitle'; +import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset'; +import useLocalize from '@hooks/useLocalize'; +import useNetwork from '@hooks/useNetwork'; +import useOnyx from '@hooks/useOnyx'; +import useThemeStyles from '@hooks/useThemeStyles'; +import {hasDomainErrors} from '@libs/DomainUtils'; +import interceptAnonymousUser from '@libs/interceptAnonymousUser'; +import Navigation from '@libs/Navigation/Navigation'; +import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan'; +import CONST from '@src/CONST'; +import ONYXKEYS from '@src/ONYXKEYS'; +import ROUTES from '@src/ROUTES'; +import {isAdminSelector} from '@src/selectors/Domain'; +import {isEmptyObject} from '@src/types/utils/EmptyObject'; + +function DomainsListPage() { + const styles = useThemeStyles(); + const {isOffline} = useNetwork(); + const {translate} = useLocalize(); + const icons = useMemoizedLazyExpensifyIcons(['Plus']); + const currentUserPersonalDetails = useCurrentUserPersonalDetails(); + + useDocumentTitle(translate('common.domains')); + + const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP); + const [allDomains] = useOnyx(ONYXKEYS.COLLECTION.DOMAIN); + const [allDomainErrors] = useOnyx(ONYXKEYS.COLLECTION.DOMAIN_ERRORS); + + const navigateToDomain = ({domainAccountID, isAdmin}: {domainAccountID: number; isAdmin: boolean}) => { + if (!isAdmin) { + return Navigation.navigate(ROUTES.WORKSPACES_DOMAIN_ACCESS_RESTRICTED.getRoute(domainAccountID)); + } + + Navigation.navigate(ROUTES.DOMAIN_INITIAL.getRoute(domainAccountID)); + }; + + const domainRows: DomainRowData[] = []; + const shouldShowLoadingIndicator = !!isLoadingApp && !isOffline; + + if (!isEmptyObject(allDomains)) { + for (const domain of Object.values(allDomains)) { + if (!domain?.accountID || !domain.email) { + continue; + } + + const isDomainAdmin = isAdminSelector(currentUserPersonalDetails?.accountID)(domain); + const domainErrors = allDomainErrors?.[`${ONYXKEYS.COLLECTION.DOMAIN_ERRORS}${domain.accountID}`]; + + domainRows.push({ + isAdmin: isDomainAdmin, + isValidated: domain.validated, + domainAccountID: domain.accountID, + title: Str.extractEmailDomain(domain.email), + errors: domainErrors?.errors, + pendingAction: domain.pendingAction, + disabled: domain.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE, + brickRoadIndicator: hasDomainErrors(domainErrors) ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined, + action: () => navigateToDomain({domainAccountID: domain.accountID, isAdmin: isDomainAdmin}), + }); + } + } + + const activityIndicatorReasonAttributes = { + context: 'DomainsListPage', + isOffline, + } satisfies SkeletonSpanReasonAttributes; + + const headerButton = !!domainRows.length && ( +