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

hide import spreadsheet button #49545

Merged
merged 6 commits into from
Sep 24, 2024
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
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
Loading