-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Vendor matching CC: Add Vendors tab to Workspace settings #96143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Beamanator
wants to merge
25
commits into
main
Choose a base branch
from
beaman-vendors-tab
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
79c5adc
Add Vendors tab to Workspace settings (Phase 1: name column only)
Beamanator f6a5d12
Address Codex review: admin gate + wide-layout focus trap exemption
Beamanator 4d184b9
Address Codex review: Intacct pre-sync gate + read-only vendor rows
Beamanator de45732
Address Codex review: prefetch connections for Vendors gate
Beamanator a9f0095
Address Codex review: fetch connections for direct-URL access to Vendors
Beamanator 2ab6b5b
Address Codex review: wait for fetch flag to hydrate before refetching
Beamanator 90fa1fd
Address Codex review: skip connections fetch while offline, retry on …
Beamanator 33c6455
Address Codex review: gate connections prefetch on admin
Beamanator 5072eec
Address Codex review: use login-aware admin check
Beamanator 8c47fcf
Merge remote-tracking branch 'origin/main' into beaman-vendors-tab
Beamanator acb2c17
Loosen Vendors tab access to read-only roles (Auditor et al.)
Beamanator 0ad9d17
Fix Oxfmt: sort import order in WorkspaceInitialPage.tsx
Beamanator 92181ca
Address Codex review: loosen prefetch gate to match menu-row gate
Beamanator 21d7c86
Extract usePolicyConnectionsPrefetch hook shared by withPolicyConnect…
Beamanator 28a7f46
Merge remote-tracking branch 'origin/main' into beaman-vendors-tab
Beamanator ec0dfdb
Merge remote-tracking branch 'origin/main' into beaman-vendors-tab
Beamanator a666286
Fix Oxfmt: restore AuthScreensInitHandler formatting lost in merge fr…
Beamanator acd0897
Fix Oxfmt: reformat AuthScreensInitHandler to match pinned oxfmt@0.55.0
Beamanator 30a06c1
Redesign Vendors page to match Jenna's mock: table layout + subtitle
Beamanator 5af593f
Refactor Vendors page to follow workspace-table convention
Beamanator e53412f
Fix Knip: drop unused WorkspaceVendorTableColumnKey type export
Beamanator 0405c51
Sort vendors alphabetically in the page; drop Name-column sort arrow
Beamanator 3926fc5
Restore sortable Name column on the Vendors table
Beamanator 2124bfd
Swap Vendors tab icon to briefcase (Suitcase) to match Jenna's mock
Beamanator c2a45d4
Use illustrations.Luggage for the Vendors page header icon
Beamanator File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import type {CompareItemsCallback, IsItemInSearchCallback, TableColumn, TableData} from '@components/Table'; | ||
| import Table from '@components/Table'; | ||
| import TextWithTooltip from '@components/TextWithTooltip'; | ||
|
|
||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
|
|
||
| import tokenizedSearch from '@libs/tokenizedSearch'; | ||
|
|
||
| import CONST from '@src/CONST'; | ||
|
|
||
| import type {ListRenderItemInfo} from '@shopify/flash-list'; | ||
|
|
||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
|
|
||
| type WorkspaceVendorTableColumnKey = 'name'; | ||
|
|
||
| type WorkspaceVendorTableRowData = TableData & { | ||
| name: string; | ||
| }; | ||
|
|
||
| type WorkspaceVendorsTableProps = { | ||
| vendors: WorkspaceVendorTableRowData[]; | ||
| }; | ||
|
|
||
| function WorkspaceVendorsTable({vendors}: WorkspaceVendorsTableProps) { | ||
| const styles = useThemeStyles(); | ||
| const {translate, localeCompare} = useLocalize(); | ||
|
|
||
| const columns: Array<TableColumn<WorkspaceVendorTableColumnKey>> = [ | ||
| { | ||
| key: 'name', | ||
| label: translate('common.name'), | ||
| sortable: true, | ||
| }, | ||
| ]; | ||
|
|
||
| const compareItems: CompareItemsCallback<WorkspaceVendorTableRowData> = (item1, item2, activeSorting) => { | ||
| const orderMultiplier = activeSorting.order === 'asc' ? 1 : -1; | ||
| return localeCompare(item1.name, item2.name) * orderMultiplier; | ||
| }; | ||
|
|
||
| const isItemInSearch: IsItemInSearchCallback<WorkspaceVendorTableRowData> = (item, searchValue) => { | ||
| const results = tokenizedSearch([item], searchValue.toLowerCase(), (option) => [option.name]); | ||
| return results.length > 0; | ||
| }; | ||
|
|
||
| const renderVendorItem = ({item, index}: ListRenderItemInfo<WorkspaceVendorTableRowData>) => ( | ||
| <Table.Row | ||
| interactive={false} | ||
| rowIndex={index} | ||
| sentryLabel={CONST.SENTRY_LABEL.WORKSPACE.INITIAL.VENDORS} | ||
| > | ||
| <View style={[styles.flex1, styles.flexRow, styles.alignItemsCenter]}> | ||
| <TextWithTooltip | ||
| shouldShowTooltip | ||
| numberOfLines={1} | ||
| text={item.name} | ||
| /> | ||
| </View> | ||
| </Table.Row> | ||
| ); | ||
|
|
||
| return ( | ||
| <Table | ||
| data={vendors} | ||
| initialSortColumn="name" | ||
| title={translate('workspace.common.vendors')} | ||
| columns={columns} | ||
| compareItems={compareItems} | ||
| isItemInSearch={isItemInSearch} | ||
| renderItem={renderVendorItem} | ||
| keyExtractor={(item) => item.keyForList} | ||
| > | ||
| <Table.FilterBar label={translate('workspace.vendors.findVendor')} /> | ||
| <Table.EmptyState | ||
| title={translate('workspace.vendors.emptyTitle')} | ||
| subtitleText={translate('workspace.vendors.emptySubtitle')} | ||
| /> | ||
| <Table.NoResultsState /> | ||
| <Table.Header /> | ||
| <Table.Body /> | ||
| </Table> | ||
| ); | ||
| } | ||
|
|
||
| export default WorkspaceVendorsTable; | ||
|
|
||
| export type {WorkspaceVendorTableRowData}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import {openPolicyAccountingPage} from '@libs/actions/PolicyConnections'; | ||
|
|
||
| import ONYXKEYS from '@src/ONYXKEYS'; | ||
| import type * as OnyxTypes from '@src/types/onyx'; | ||
| import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||
| import isLoadingOnyxValue from '@src/types/utils/isLoadingOnyxValue'; | ||
|
|
||
| import type {OnyxEntry} from 'react-native-onyx'; | ||
|
|
||
| import {useEffect} from 'react'; | ||
|
|
||
| import useNetwork from './useNetwork'; | ||
| import useOnyx from './useOnyx'; | ||
|
|
||
| type PrefetchState = { | ||
| isFetchNeeded: boolean; | ||
| isLoadingFetchedFlag: boolean; | ||
| hasBeenFetched: boolean | undefined; | ||
| }; | ||
|
|
||
| /** | ||
| * Fetches `policy.connections` lazily for a non-active workspace. `withPolicyConnections` | ||
| * uses this to hydrate connections before rendering an accounting-adjacent page, and callers | ||
| * that need the connection data without wrapping (e.g. `WorkspaceInitialPage` deciding whether | ||
| * to render the Vendors row) pass a scoped `enabled` gate to opt in. | ||
| * | ||
| * The hook itself only bails on the shared safety guards — Onyx flag still hydrating, offline, | ||
| * no policy loaded, no accounting/connections on the policy, already fetched — that need to | ||
| * stay in sync across callers so callers don't reinvent them. | ||
| */ | ||
| function usePolicyConnectionsPrefetch(policy: OnyxEntry<OnyxTypes.Policy>, enabled: boolean): PrefetchState { | ||
| const {isOffline} = useNetwork(); | ||
| const [hasBeenFetched, hasBeenFetchedResult] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_HAS_CONNECTIONS_DATA_BEEN_FETCHED}${policy?.id}`); | ||
| const isLoadingFetchedFlag = isLoadingOnyxValue(hasBeenFetchedResult); | ||
| const isFetchNeeded = enabled && !isLoadingFetchedFlag && !isOffline && !!policy && (!!policy.areConnectionsEnabled || !isEmptyObject(policy.connections)) && !hasBeenFetched; | ||
|
|
||
| useEffect(() => { | ||
| if (!isFetchNeeded || !policy?.id) { | ||
| return; | ||
| } | ||
| openPolicyAccountingPage(policy.id); | ||
| }, [policy?.id, isFetchNeeded]); | ||
|
|
||
| return {isFetchNeeded, isLoadingFetchedFlag, hasBeenFetched}; | ||
| } | ||
|
|
||
| export default usePolicyConnectionsPrefetch; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add 1 more condition
hasVendorFeature(policy, beta)to avoid redundant prefetch for user that has areConnectionsEnabled (no vendor matching)