Skip to content
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

Handle Xero beta in NewDot #41416

Merged
merged 8 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ const CONST = {
WORKFLOWS_DELAYED_SUBMISSION: 'workflowsDelayedSubmission',
SPOTNANA_TRAVEL: 'spotnanaTravel',
ACCOUNTING_ON_NEW_EXPENSIFY: 'accountingOnNewExpensify',
XERO_ON_NEW_EXPENSIFY: 'xeroOnNewExpensify',
},
BUTTON_STATES: {
DEFAULT: 'default',
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ function canUseAccountingIntegrations(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.ACCOUNTING_ON_NEW_EXPENSIFY) || canUseAllBetas(betas);
}

function canUseXeroIntegration(betas: OnyxEntry<Beta[]>): boolean {
return !!betas?.includes(CONST.BETAS.XERO_ON_NEW_EXPENSIFY) || canUseAllBetas(betas);
}

/**
* Link previews are temporarily disabled.
*/
Expand All @@ -62,4 +66,5 @@ export default {
canUseWorkflowsDelayedSubmission,
canUseSpotnanaTravel,
canUseAccountingIntegrations,
canUseXeroIntegration,
};
24 changes: 21 additions & 3 deletions src/pages/workspace/accounting/PolicyAccountingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import ThreeDotsMenu from '@components/ThreeDotsMenu';
import type ThreeDotsMenuProps from '@components/ThreeDotsMenu/types';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import usePermissions from '@hooks/usePermissions';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
Expand Down Expand Up @@ -47,8 +48,6 @@ type PolicyAccountingPageProps = WithPolicyProps &
policy: Policy;
};

const accountingIntegrations = Object.values(CONST.POLICY.CONNECTIONS.NAME);

type AccountingIntegration = {
title: string;
icon: IconAsset;
Expand Down Expand Up @@ -105,12 +104,21 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting
const styles = useThemeStyles();
const {translate} = useLocalize();
const {isOffline} = useNetwork();
const {canUseXeroIntegration} = usePermissions();
const {isSmallScreenWidth, windowWidth} = useWindowDimensions();
const [threeDotsMenuPosition, setThreeDotsMenuPosition] = useState<AnchorPosition>({horizontal: 0, vertical: 0});
const [isDisconnectModalOpen, setIsDisconnectModalOpen] = useState(false);
const threeDotsMenuContainerRef = useRef<View>(null);

const isSyncInProgress = !!connectionSyncProgress?.stageInProgress && connectionSyncProgress.stageInProgress !== CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.JOB_DONE;

const accountingIntegrations = Object.values(CONST.POLICY.CONNECTIONS.NAME).filter((name) => {
if (name === CONST.POLICY.CONNECTIONS.NAME.XERO && !canUseXeroIntegration) {
return false;
}

return true;
lakchote marked this conversation as resolved.
Show resolved Hide resolved
});
const connectedIntegration = accountingIntegrations.find((integration) => !!policy?.connections?.[integration]) ?? connectionSyncProgress?.connectionName;
const policyID = policy?.id ?? '';

Expand Down Expand Up @@ -258,6 +266,7 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting
theme.spinner,
threeDotsMenuPosition,
translate,
accountingIntegrations,
]);

const otherIntegrationsItems = useMemo(() => {
Expand All @@ -279,7 +288,16 @@ function PolicyAccountingPage({policy, connectionSyncProgress}: PolicyAccounting
wrapperStyle: styles.sectionMenuItemTopDescription,
};
});
}, [connectedIntegration, connectionSyncProgress?.connectionName, isSyncInProgress, policy?.connections, policyID, styles.sectionMenuItemTopDescription, translate]);
}, [
connectedIntegration,
connectionSyncProgress?.connectionName,
isSyncInProgress,
policy?.connections,
policyID,
styles.sectionMenuItemTopDescription,
translate,
accountingIntegrations,
]);

const headerThreeDotsMenuItems: ThreeDotsMenuProps['menuItems'] = [
{
Expand Down
Loading