Skip to content

Commit

Permalink
Merge pull request #49545 from Nodebrute/spreadsheet
Browse files Browse the repository at this point in the history
hide import spreadsheet button
  • Loading branch information
chiragsalian committed Sep 24, 2024
2 parents 3554281 + ea47bbe commit b95d37e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/pages/workspace/categories/ImportCategoriesPage.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import type {StackScreenProps} from '@react-navigation/stack';
import React from 'react';
import ImportSpreedsheet from '@components/ImportSpreadsheet';
import usePolicy from '@hooks/usePolicy';
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
import * as PolicyUtils from '@libs/PolicyUtils';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';

type ImportCategoriesPageProps = StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.CATEGORIES_IMPORT>;

function ImportCategoriesPage({route}: ImportCategoriesPageProps) {
const policyID = route.params.policyID;
const policy = usePolicy(policyID);
const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy);

if (hasAccountingConnections) {
return <NotFoundPage />;
}

return (
<ImportSpreedsheet
Expand Down
7 changes: 7 additions & 0 deletions src/pages/workspace/categories/ImportedCategoriesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {findDuplicate, generateColumnNames} from '@libs/importSpreadsheetUtils';
import Navigation from '@libs/Navigation/Navigation';
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
import {isControlPolicy} from '@libs/PolicyUtils';
import * as PolicyUtils from '@libs/PolicyUtils';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
Expand Down Expand Up @@ -105,6 +107,11 @@ function ImportedCategoriesPage({route}: ImportedCategoriesPageProps) {
}
}, [validate, spreadsheet, containsHeader, policyID, policyCategories]);

const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy);
if (hasAccountingConnections) {
return <NotFoundPage />;
}

const spreadsheetColumns = spreadsheet?.data;
if (!spreadsheetColumns) {
return;
Expand Down
11 changes: 6 additions & 5 deletions src/pages/workspace/categories/WorkspaceCategoriesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,9 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
);

const threeDotsMenuItems = useMemo(() => {
const menuItems = [
{
const menuItems = [];
if (!PolicyUtils.hasAccountingConnections(policy)) {
menuItems.push({
icon: Expensicons.Table,
text: translate('spreadsheet.importSpreadsheet'),
onSelected: () => {
Expand All @@ -313,8 +314,8 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
}
Navigation.navigate(ROUTES.WORKSPACE_CATEGORIES_IMPORT.getRoute(policyId));
},
},
];
});
}
if (hasVisibleCategories) {
menuItems.push({
icon: Expensicons.Download,
Expand All @@ -334,7 +335,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) {
}

return menuItems;
}, [policyId, translate, isOffline, hasVisibleCategories]);
}, [policyId, translate, isOffline, hasVisibleCategories, policy]);

const selectionModeHeader = selectionMode?.isEnabled && shouldUseNarrowLayout;

Expand Down

0 comments on commit b95d37e

Please sign in to comment.