Skip to content

Commit

Permalink
Merge pull request #51816 from FitseTLT/fix-empty-page-approval-workf…
Browse files Browse the repository at this point in the history
…low-bug

Fix - Workflows - Edit approval workflow becomes blank after editing it offline and returning online
  • Loading branch information
neil-marcellini authored Nov 1, 2024
2 parents b47c0ad + d14b37f commit 55b58ee
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 51 deletions.
1 change: 0 additions & 1 deletion src/libs/WorkflowUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const INITIAL_APPROVAL_WORKFLOW: ApprovalWorkflowOnyx = {
usedApproverEmails: [],
isDefault: false,
action: CONST.APPROVAL_WORKFLOW.ACTION.CREATE,
isLoading: false,
};

type GetApproversParams = {
Expand Down
48 changes: 6 additions & 42 deletions src/libs/actions/Workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ function createApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork

const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.APPROVAL_WORKFLOW,
value: {
isLoading: true,
},
value: null,
},
{
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -80,11 +78,6 @@ function createApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork
];

const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.APPROVAL_WORKFLOW,
value: {...approvalWorkflow, isLoading: false},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
Expand All @@ -96,11 +89,6 @@ function createApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork
];

const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.APPROVAL_WORKFLOW,
value: null,
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
Expand Down Expand Up @@ -139,11 +127,9 @@ function updateApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork

const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.APPROVAL_WORKFLOW,
value: {
isLoading: true,
},
value: null,
},
{
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -156,11 +142,6 @@ function updateApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork
];

const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.APPROVAL_WORKFLOW,
value: {...approvalWorkflow, isLoading: false},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
Expand All @@ -173,11 +154,6 @@ function updateApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork
];

const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.APPROVAL_WORKFLOW,
value: null,
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
Expand Down Expand Up @@ -213,11 +189,9 @@ function removeApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork

const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.APPROVAL_WORKFLOW,
value: {
isLoading: true,
},
value: null,
},
{
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -230,11 +204,6 @@ function removeApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork
];

const failureData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.APPROVAL_WORKFLOW,
value: {...approvalWorkflow, isLoading: false},
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
Expand All @@ -246,11 +215,6 @@ function removeApprovalWorkflow(policyID: string, approvalWorkflow: ApprovalWork
];

const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.APPROVAL_WORKFLOW,
value: null,
},
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ function WorkspaceWorkflowsApprovalsCreatePage({policy, isLoadingReportData = tr
onFixTheErrorsLinkPressed={() => {
formRef.current?.scrollTo({y: 0, animated: true});
}}
isLoading={approvalWorkflow?.isLoading}
buttonText={translate('workflowsCreateApprovalsPage.submitButton')}
containerStyles={[styles.mb5, styles.mh5]}
enabledWhenOffline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ function WorkspaceWorkflowsApprovalsEditPage({policy, isLoadingReportData = true
availableMembers: [...currentApprovalWorkflow.members, ...defaultWorkflowMembers],
usedApproverEmails,
action: CONST.APPROVAL_WORKFLOW.ACTION.EDIT,
isLoading: false,
errors: null,
});
setInitialApprovalWorkflow(currentApprovalWorkflow);
Expand Down Expand Up @@ -147,7 +146,6 @@ function WorkspaceWorkflowsApprovalsEditPage({policy, isLoadingReportData = true
onFixTheErrorsLinkPressed={() => {
formRef.current?.scrollTo({y: 0, animated: true});
}}
isLoading={approvalWorkflow?.isLoading}
buttonText={translate('common.save')}
containerStyles={[styles.mb5, styles.mh5]}
enabledWhenOffline
Expand Down
5 changes: 0 additions & 5 deletions src/types/onyx/ApprovalWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ type ApprovalWorkflowOnyx = Omit<ApprovalWorkflow, 'approvers'> & {
*/
action: ValueOf<typeof CONST.APPROVAL_WORKFLOW.ACTION>;

/**
* Whether we are waiting for the API action to complete
*/
isLoading: boolean;

/**
* List of available members that can be selected in the workflow
*/
Expand Down

0 comments on commit 55b58ee

Please sign in to comment.