Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
132755c
add accounting connected warning
rezkiy37 Jul 1, 2024
2e78fd3
restrict report fields creating
rezkiy37 Jul 1, 2024
f43fd8f
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Jul 2, 2024
1456672
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Jul 8, 2024
e956c79
Merge branch 'feature/43685-report-fields-edit-flow' of https://githu…
rezkiy37 Jul 8, 2024
8a3db8c
Merge branch 'feat-43687-reportFields-bulk' of https://github.com/wat…
rezkiy37 Jul 8, 2024
ecd971d
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Jul 9, 2024
3ef7223
hide selections when connection
rezkiy37 Jul 9, 2024
93f512b
restrict editing the initial value when connections
rezkiy37 Jul 9, 2024
cba71b4
simplify restrictions
rezkiy37 Jul 9, 2024
7bb8c89
restrict editing the values list when connections
rezkiy37 Jul 9, 2024
a3edcff
restrict creating when connections
rezkiy37 Jul 9, 2024
067051c
restrict editing when connections
rezkiy37 Jul 9, 2024
89a3721
simplify blocked condtions
rezkiy37 Jul 9, 2024
70ac403
Merge branch 'main' of https://github.com/rezkiy37/Expensify into fea…
rezkiy37 Jul 10, 2024
fba3ffa
translation into Spanish
rezkiy37 Jul 10, 2024
230aacf
simplify restrictions
rezkiy37 Jul 10, 2024
17e7117
fix report field type translation
rezkiy37 Jul 10, 2024
93f9fab
fix report field type translation
rezkiy37 Jul 10, 2024
a53a0a1
useOnyx instead
rezkiy37 Jul 10, 2024
d4f7081
Revert "useOnyx instead"
rezkiy37 Jul 10, 2024
07955d8
Merge remote-tracking branch 'expensify/main' into feature/43683-repo…
waterim Jul 15, 2024
9f136a6
Merge remote-tracking branch 'expensify/main' into feature/43683-repo…
waterim Jul 18, 2024
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/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2773,6 +2773,7 @@ export default {
subtitle: "Report fields apply to all spend and can be helpful when you'd like to prompt for extra information.",
disableReportFields: 'Disable report fields',
disableReportFieldsConfirmation: 'Are you sure? Text and date fields will be deleted, and lists will be disabled.',
importedFromAccountingSoftware: 'The report fields below are imported from your',
textType: 'Text',
dateType: 'Date',
dropdownType: 'List',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2822,6 +2822,7 @@ export default {
subtitle: 'Los campos de informe se aplican a todos los gastos y pueden ser útiles cuando quieras solicitar información adicional.',
disableReportFields: 'Desactivar campos de informe',
disableReportFieldsConfirmation: 'Estás seguro? Se eliminarán los campos de texto y fecha y se desactivarán las listas.',
importedFromAccountingSoftware: 'Campos de informes importadas desde',
textType: 'Texto',
dateType: 'Fecha',
dropdownType: 'Lista',
Expand Down
2 changes: 2 additions & 0 deletions src/pages/workspace/reportFields/CreateReportFieldsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import * as ReportField from '@libs/actions/Policy/ReportField';
import DateUtils from '@libs/DateUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import type {SettingsNavigatorParamList} from '@navigation/types';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading';
Expand Down Expand Up @@ -97,6 +98,7 @@ function CreateReportFieldsPage({
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
policyID={policyID}
featureName={CONST.POLICY.MORE_FEATURES.ARE_REPORT_FIELDS_ENABLED}
shouldBeBlocked={PolicyUtils.hasAccountingConnections(policy)}
>
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as ReportField from '@libs/actions/Policy/ReportField';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as WorkspaceReportFieldUtils from '@libs/WorkspaceReportFieldUtils';
import type {SettingsNavigatorParamList} from '@navigation/types';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading';
import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import INPUT_IDS from '@src/types/form/WorkspaceReportFieldForm';

type ReportFieldsAddListValuePageProps = StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.REPORT_FIELDS_ADD_VALUE>;
type ReportFieldsAddListValuePageProps = WithPolicyAndFullscreenLoadingProps & StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.REPORT_FIELDS_ADD_VALUE>;

function ReportFieldsAddListValuePage({
policy,
route: {
params: {policyID, reportFieldID},
},
Expand Down Expand Up @@ -57,6 +61,7 @@ function ReportFieldsAddListValuePage({
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
policyID={policyID}
featureName={CONST.POLICY.MORE_FEATURES.ARE_REPORT_FIELDS_ENABLED}
shouldBeBlocked={PolicyUtils.hasAccountingConnections(policy)}
>
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand Down Expand Up @@ -93,4 +98,4 @@ function ReportFieldsAddListValuePage({

ReportFieldsAddListValuePage.displayName = 'ReportFieldsAddListValuePage';

export default ReportFieldsAddListValuePage;
export default withPolicyAndFullscreenLoading(ReportFieldsAddListValuePage);
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@ import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as ReportField from '@libs/actions/Policy/ReportField';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as WorkspaceReportFieldUtils from '@libs/WorkspaceReportFieldUtils';
import type {SettingsNavigatorParamList} from '@navigation/types';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import type {WithPolicyAndFullscreenLoadingProps} from '@pages/workspace/withPolicyAndFullscreenLoading';
import withPolicyAndFullscreenLoading from '@pages/workspace/withPolicyAndFullscreenLoading';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type SCREENS from '@src/SCREENS';
import INPUT_IDS from '@src/types/form/WorkspaceReportFieldForm';

type ReportFieldsEditValuePageProps = StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.REPORT_FIELDS_EDIT_VALUE>;
type ReportFieldsEditValuePageProps = WithPolicyAndFullscreenLoadingProps & StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.REPORT_FIELDS_EDIT_VALUE>;

function ReportFieldsEditValuePage({
policy,
route: {
params: {policyID, valueIndex},
},
Expand Down Expand Up @@ -63,6 +67,7 @@ function ReportFieldsEditValuePage({
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
policyID={policyID}
featureName={CONST.POLICY.MORE_FEATURES.ARE_REPORT_FIELDS_ENABLED}
shouldBeBlocked={PolicyUtils.hasAccountingConnections(policy)}
>
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand Down Expand Up @@ -100,4 +105,4 @@ function ReportFieldsEditValuePage({

ReportFieldsEditValuePage.displayName = 'ReportFieldsEditValuePage';

export default ReportFieldsEditValuePage;
export default withPolicyAndFullscreenLoading(ReportFieldsEditValuePage);
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import * as ReportField from '@libs/actions/Policy/ReportField';
import Navigation from '@libs/Navigation/Navigation';
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import * as WorkspaceReportFieldUtils from '@libs/WorkspaceReportFieldUtils';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
Expand All @@ -37,6 +38,7 @@ function ReportFieldsInitialValuePage({
const {translate} = useLocalize();
const {inputCallbackRef} = useAutoFocusInput();

const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy);
const reportField = policy?.fieldList?.[ReportUtils.getReportFieldKey(reportFieldID)] ?? null;
const availableListValuesLength = (reportField?.disabledOptions ?? []).filter((disabledListValue) => !disabledListValue).length;

Expand Down Expand Up @@ -82,7 +84,7 @@ function ReportFieldsInitialValuePage({
[availableListValuesLength, policy?.fieldList, translate],
);

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

Expand Down
36 changes: 26 additions & 10 deletions src/pages/workspace/reportFields/ReportFieldsListValuesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import useWindowDimensions from '@hooks/useWindowDimensions';
import * as ReportField from '@libs/actions/Policy/ReportField';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import type {SettingsNavigatorParamList} from '@navigation/types';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
Expand Down Expand Up @@ -97,6 +98,7 @@ function ReportFieldsListValuesPage({
return [{data, isDisabled: false}];
}, [disabledListValues, listValues, policy?.fieldList, reportFieldID, selectedValues, translate]);

const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy);
const shouldShowEmptyState = Object.values(listValues ?? {}).length <= 0;
const selectedValuesArray = Object.keys(selectedValues).filter((key) => selectedValues[key]);

Expand Down Expand Up @@ -136,7 +138,7 @@ function ReportFieldsListValuesPage({
};

const openListValuePage = (valueItem: ValueListItem) => {
if (valueItem.index === undefined) {
if (valueItem.index === undefined || hasAccountingConnections) {
return;
}

Expand All @@ -145,12 +147,26 @@ function ReportFieldsListValuesPage({
setSelectedValues({});
};

const getCustomListHeader = () => (
<View style={[styles.flex1, styles.flexRow, styles.justifyContentBetween, styles.pl3]}>
<Text style={styles.searchInputStyle}>{translate('common.name')}</Text>
<Text style={[styles.searchInputStyle, styles.textAlignCenter]}>{translate('statusPage.status')}</Text>
</View>
);
const getCustomListHeader = () => {
const header = (
<View
style={[
styles.flex1,
styles.flexRow,
styles.justifyContentBetween,
// Required padding accounting for the checkbox and the right arrow in multi-select mode
!hasAccountingConnections && styles.pl3,
]}
>
<Text style={styles.searchInputStyle}>{translate('common.name')}</Text>
<Text style={[styles.searchInputStyle, styles.textAlignCenter]}>{translate('statusPage.status')}</Text>
</View>
);
if (!hasAccountingConnections) {
return header;
}
return <View style={[styles.flexRow, styles.ph9, styles.pv3, styles.pb5]}>{header}</View>;
};

const getHeaderButtons = () => {
const options: Array<DropdownOption<DeepValueOf<typeof CONST.POLICY.BULK_ACTION_TYPES>>> = [];
Expand Down Expand Up @@ -269,9 +285,9 @@ function ReportFieldsListValuesPage({
title={translate('workspace.reportFields.listValues')}
onBackButtonPress={Navigation.goBack}
>
{!isSmallScreenWidth && getHeaderButtons()}
{!isSmallScreenWidth && !hasAccountingConnections && getHeaderButtons()}
</HeaderWithBackButton>
{isSmallScreenWidth && <View style={[styles.pl5, styles.pr5]}>{getHeaderButtons()}</View>}
{isSmallScreenWidth && <View style={[styles.pl5, styles.pr5]}>{!hasAccountingConnections && getHeaderButtons()}</View>}
<View style={[styles.ph5, styles.pv4]}>
<Text style={[styles.sidebarLinkText, styles.optionAlternateText]}>{translate('workspace.reportFields.listInputSubtitle')}</Text>
</View>
Expand All @@ -285,7 +301,7 @@ function ReportFieldsListValuesPage({
)}
{!shouldShowEmptyState && (
<SelectionList
canSelectMultiple
canSelectMultiple={!hasAccountingConnections}
sections={listValuesSections}
onCheckboxPress={toggleValue}
onSelectRow={openListValuePage}
Expand Down
24 changes: 14 additions & 10 deletions src/pages/workspace/reportFields/ReportFieldsSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import * as WorkspaceReportFieldUtils from '@libs/WorkspaceReportFieldUtils';
import type {SettingsNavigatorParamList} from '@navigation/types';
Expand All @@ -35,6 +36,7 @@ function ReportFieldsSettingsPage({
const {translate} = useLocalize();
const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false);

const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy);
const reportFieldKey = ReportUtils.getReportFieldKey(reportFieldID);
const reportField = policy?.fieldList?.[reportFieldKey] ?? null;

Expand Down Expand Up @@ -85,8 +87,8 @@ function ReportFieldsSettingsPage({
titleStyle={styles.flex1}
title={WorkspaceReportFieldUtils.getReportFieldInitialValue(reportField)}
description={translate('common.initialValue')}
shouldShowRightIcon={!isDateFieldType}
interactive={!isDateFieldType}
shouldShowRightIcon={!isDateFieldType && !hasAccountingConnections}
interactive={!isDateFieldType && !hasAccountingConnections}
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_EDIT_REPORT_FIELDS_INITIAL_VALUE.getRoute(policyID, reportFieldID))}
/>
{isListFieldType && (
Expand All @@ -98,16 +100,18 @@ function ReportFieldsSettingsPage({
onPress={() => Navigation.navigate(ROUTES.WORKSPACE_REPORT_FIELDS_LIST_VALUES.getRoute(policyID, reportFieldID))}
/>
)}
<View style={styles.flexGrow1}>
<MenuItem
icon={Expensicons.Trashcan}
title={translate('common.delete')}
onPress={() => setIsDeleteModalVisible(true)}
/>
</View>
{!hasAccountingConnections && (
<View style={styles.flexGrow1}>
<MenuItem
icon={Expensicons.Trashcan}
title={translate('common.delete')}
onPress={() => setIsDeleteModalVisible(true)}
/>
</View>
)}
<ConfirmModal
title={translate('workspace.reportFields.delete')}
isVisible={isDeleteModalVisible}
isVisible={isDeleteModalVisible && !hasAccountingConnections}
onConfirm={deleteReportFieldAndHideModal}
onCancel={() => setIsDeleteModalVisible(false)}
shouldSetModalVisibility={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as ReportField from '@libs/actions/Policy/ReportField';
import Navigation from '@libs/Navigation/Navigation';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import type {SettingsNavigatorParamList} from '@navigation/types';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
Expand Down Expand Up @@ -56,7 +57,9 @@ function ReportFieldsValueSettingsPage({
return [reportFieldValue, reportFieldDisabledValue];
}, [formDraft?.disabledListValues, formDraft?.listValues, policy?.fieldList, reportFieldID, valueIndex]);

if (!currentValueName) {
const hasAccountingConnections = PolicyUtils.hasAccountingConnections(policy);

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

Expand Down
Loading