Skip to content

Commit

Permalink
add tax pages, update wrapper workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
waterim committed Mar 20, 2024
1 parent 0b908d8 commit 58e1b4b
Show file tree
Hide file tree
Showing 12 changed files with 384 additions and 321 deletions.
60 changes: 33 additions & 27 deletions src/pages/workspace/tags/EditTagPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as PolicyUtils from '@libs/PolicyUtils';
import * as ValidationUtils from '@libs/ValidationUtils';
import type {SettingsNavigatorParamList} from '@navigation/types';
import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper';
import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper';
import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper';
import * as Policy from '@userActions/Policy';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -66,36 +67,41 @@ function EditTagPage({route, policyTags}: EditTagPageProps) {
return (
<AdminPolicyAccessOrNotFoundWrapper policyID={route.params.policyID}>
<PaidPolicyAccessOrNotFoundWrapper policyID={route.params.policyID}>
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
style={[styles.defaultModalContainer]}
testID={EditTagPage.displayName}
shouldEnableMaxHeight
<FeatureEnabledAccessOrNotFoundWrapper
policyID={route.params.policyID}
featureName={CONST.POLICY.MORE_FEATURES.ARE_TAGS_ENABLED}
>
<HeaderWithBackButton
title={translate('workspace.tags.editTag')}
onBackButtonPress={Navigation.goBack}
/>
<FormProvider
formID={ONYXKEYS.FORMS.WORKSPACE_TAG_FORM}
onSubmit={editTag}
submitButtonText={translate('common.save')}
validate={validate}
style={[styles.mh5, styles.flex1]}
enabledWhenOffline
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
style={[styles.defaultModalContainer]}
testID={EditTagPage.displayName}
shouldEnableMaxHeight
>
<InputWrapper
InputComponent={TextInput}
maxLength={CONST.TAG_NAME_LIMIT}
defaultValue={currentTagName}
label={translate('common.name')}
accessibilityLabel={translate('common.name')}
inputID={INPUT_IDS.TAG_NAME}
role={CONST.ROLE.PRESENTATION}
ref={inputCallbackRef}
<HeaderWithBackButton
title={translate('workspace.tags.editTag')}
onBackButtonPress={Navigation.goBack}
/>
</FormProvider>
</ScreenWrapper>
<FormProvider
formID={ONYXKEYS.FORMS.WORKSPACE_TAG_FORM}
onSubmit={editTag}
submitButtonText={translate('common.save')}
validate={validate}
style={[styles.mh5, styles.flex1]}
enabledWhenOffline
>
<InputWrapper
InputComponent={TextInput}
maxLength={CONST.TAG_NAME_LIMIT}
defaultValue={currentTagName}
label={translate('common.name')}
accessibilityLabel={translate('common.name')}
inputID={INPUT_IDS.TAG_NAME}
role={CONST.ROLE.PRESENTATION}
ref={inputCallbackRef}
/>
</FormProvider>
</ScreenWrapper>
</FeatureEnabledAccessOrNotFoundWrapper>
</PaidPolicyAccessOrNotFoundWrapper>
</AdminPolicyAccessOrNotFoundWrapper>
);
Expand Down
113 changes: 60 additions & 53 deletions src/pages/workspace/tags/TagSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import * as PolicyUtils from '@libs/PolicyUtils';
import type {SettingsNavigatorParamList} from '@navigation/types';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper';
import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper';
import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper';
import * as Policy from '@userActions/Policy';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
Expand Down Expand Up @@ -67,61 +69,66 @@ function TagSettingsPage({route, policyTags}: TagSettingsPageProps) {
return (
<AdminPolicyAccessOrNotFoundWrapper policyID={route.params.policyID}>
<PaidPolicyAccessOrNotFoundWrapper policyID={route.params.policyID}>
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
style={[styles.defaultModalContainer]}
testID={TagSettingsPage.displayName}
<FeatureEnabledAccessOrNotFoundWrapper
policyID={route.params.policyID}
featureName={CONST.POLICY.MORE_FEATURES.ARE_TAGS_ENABLED}
>
<HeaderWithBackButton
title={route.params.tagName}
shouldShowThreeDotsButton
shouldSetModalVisibility={false}
threeDotsAnchorPosition={styles.threeDotsPopoverOffset(windowWidth)}
threeDotsMenuItems={[
{
icon: Trashcan,
text: translate('workspace.tags.deleteTag'),
onSelected: () => setIsDeleteTagModalOpen(true),
},
]}
/>
<ConfirmModal
title={translate('workspace.tags.deleteTag')}
isVisible={isDeleteTagModalOpen}
onConfirm={deleteTagAndHideModal}
onCancel={() => setIsDeleteTagModalOpen(false)}
shouldSetModalVisibility={false}
prompt={translate('workspace.tags.deleteTagConfirmation')}
confirmText={translate('common.delete')}
cancelText={translate('common.cancel')}
danger
/>
<View style={styles.flexGrow1}>
<OfflineWithFeedback
errors={ErrorUtils.getLatestErrorMessageField(currentPolicyTag)}
pendingAction={currentPolicyTag.pendingFields?.enabled}
errorRowStyles={styles.mh5}
onClose={() => Policy.clearPolicyTagErrors(route.params.policyID, route.params.tagName)}
>
<View style={[styles.mt2, styles.mh5]}>
<View style={[styles.flexRow, styles.mb5, styles.mr2, styles.alignItemsCenter, styles.justifyContentBetween]}>
<Text>{translate('workspace.tags.enableTag')}</Text>
<Switch
isOn={currentPolicyTag.enabled}
accessibilityLabel={translate('workspace.tags.enableTag')}
onToggle={updateWorkspaceTagEnabled}
/>
</View>
</View>
</OfflineWithFeedback>
<MenuItemWithTopDescription
title={currentPolicyTag.name}
description={translate(`workspace.tags.tagName`)}
onPress={navigateToEditTag}
shouldShowRightIcon
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
style={[styles.defaultModalContainer]}
testID={TagSettingsPage.displayName}
>
<HeaderWithBackButton
title={route.params.tagName}
shouldShowThreeDotsButton
shouldSetModalVisibility={false}
threeDotsAnchorPosition={styles.threeDotsPopoverOffset(windowWidth)}
threeDotsMenuItems={[
{
icon: Trashcan,
text: translate('workspace.tags.deleteTag'),
onSelected: () => setIsDeleteTagModalOpen(true),
},
]}
/>
<ConfirmModal
title={translate('workspace.tags.deleteTag')}
isVisible={isDeleteTagModalOpen}
onConfirm={deleteTagAndHideModal}
onCancel={() => setIsDeleteTagModalOpen(false)}
shouldSetModalVisibility={false}
prompt={translate('workspace.tags.deleteTagConfirmation')}
confirmText={translate('common.delete')}
cancelText={translate('common.cancel')}
danger
/>
</View>
</ScreenWrapper>
<View style={styles.flexGrow1}>
<OfflineWithFeedback
errors={ErrorUtils.getLatestErrorMessageField(currentPolicyTag)}
pendingAction={currentPolicyTag.pendingFields?.enabled}
errorRowStyles={styles.mh5}
onClose={() => Policy.clearPolicyTagErrors(route.params.policyID, route.params.tagName)}
>
<View style={[styles.mt2, styles.mh5]}>
<View style={[styles.flexRow, styles.mb5, styles.mr2, styles.alignItemsCenter, styles.justifyContentBetween]}>
<Text>{translate('workspace.tags.enableTag')}</Text>
<Switch
isOn={currentPolicyTag.enabled}
accessibilityLabel={translate('workspace.tags.enableTag')}
onToggle={updateWorkspaceTagEnabled}
/>
</View>
</View>
</OfflineWithFeedback>
<MenuItemWithTopDescription
title={currentPolicyTag.name}
description={translate(`workspace.tags.tagName`)}
onPress={navigateToEditTag}
shouldShowRightIcon
/>
</View>
</ScreenWrapper>
</FeatureEnabledAccessOrNotFoundWrapper>
</PaidPolicyAccessOrNotFoundWrapper>
</AdminPolicyAccessOrNotFoundWrapper>
);
Expand Down
58 changes: 32 additions & 26 deletions src/pages/workspace/tags/WorkspaceCreateTagPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as PolicyUtils from '@libs/PolicyUtils';
import * as ValidationUtils from '@libs/ValidationUtils';
import type {SettingsNavigatorParamList} from '@navigation/types';
import AdminPolicyAccessOrNotFoundWrapper from '@pages/workspace/AdminPolicyAccessOrNotFoundWrapper';
import FeatureEnabledAccessOrNotFoundWrapper from '@pages/workspace/FeatureEnabledAccessOrNotFoundWrapper';
import PaidPolicyAccessOrNotFoundWrapper from '@pages/workspace/PaidPolicyAccessOrNotFoundWrapper';
import * as Policy from '@userActions/Policy';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -70,35 +71,40 @@ function CreateTagPage({route, policyTags}: CreateTagPageProps) {
return (
<AdminPolicyAccessOrNotFoundWrapper policyID={route.params.policyID}>
<PaidPolicyAccessOrNotFoundWrapper policyID={route.params.policyID}>
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
style={[styles.defaultModalContainer]}
testID={CreateTagPage.displayName}
shouldEnableMaxHeight
<FeatureEnabledAccessOrNotFoundWrapper
policyID={route.params.policyID}
featureName={CONST.POLICY.MORE_FEATURES.ARE_TAGS_ENABLED}
>
<HeaderWithBackButton
title={translate('workspace.tags.addTag')}
onBackButtonPress={Navigation.goBack}
/>
<FormProvider
formID={ONYXKEYS.FORMS.WORKSPACE_TAG_FORM}
onSubmit={createTag}
submitButtonText={translate('common.save')}
validate={validate}
style={[styles.mh5, styles.flex1]}
enabledWhenOffline
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
style={[styles.defaultModalContainer]}
testID={CreateTagPage.displayName}
shouldEnableMaxHeight
>
<InputWrapper
InputComponent={TextInput}
maxLength={CONST.TAG_NAME_LIMIT}
label={translate('common.name')}
accessibilityLabel={translate('common.name')}
inputID={INPUT_IDS.TAG_NAME}
role={CONST.ROLE.PRESENTATION}
ref={inputCallbackRef}
<HeaderWithBackButton
title={translate('workspace.tags.addTag')}
onBackButtonPress={Navigation.goBack}
/>
</FormProvider>
</ScreenWrapper>
<FormProvider
formID={ONYXKEYS.FORMS.WORKSPACE_TAG_FORM}
onSubmit={createTag}
submitButtonText={translate('common.save')}
validate={validate}
style={[styles.mh5, styles.flex1]}
enabledWhenOffline
>
<InputWrapper
InputComponent={TextInput}
maxLength={CONST.TAG_NAME_LIMIT}
label={translate('common.name')}
accessibilityLabel={translate('common.name')}
inputID={INPUT_IDS.TAG_NAME}
role={CONST.ROLE.PRESENTATION}
ref={inputCallbackRef}
/>
</FormProvider>
</ScreenWrapper>
</FeatureEnabledAccessOrNotFoundWrapper>
</PaidPolicyAccessOrNotFoundWrapper>
</AdminPolicyAccessOrNotFoundWrapper>
);
Expand Down
Loading

0 comments on commit 58e1b4b

Please sign in to comment.