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

FIX: TypeError: [UNCAUGHT] Cannot read properties of undefined (reading 'map') #982 #999

Merged
merged 1 commit into from
Aug 10, 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
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,19 @@ export const BulkUpdateFromQueryModal: FunctionComponent<BulkUpdateFromQueryModa
size="lg"
closeOnBackdropClick={false}
closeOnEsc={false}
closeDisabled={deployInProgress}
hide={isSecondModalOpen}
footer={
<Grid align="spread">
<NotSeeingRecentMetadataPopover
org={selectedOrg}
loading={refreshLoading}
serverUrl={serverUrl}
disabled={deployInProgress}
onReload={handleRefreshMetadata}
/>
<div>
<button className="slds-button slds-button_neutral" onClick={() => onModalClose(didDeploy)}>
<button className="slds-button slds-button_neutral" disabled={deployInProgress} onClick={() => onModalClose(didDeploy)}>
Close
</button>
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Card, FileDownloadModal, Grid, SalesforceLogin, ScopedNotification, Spi
import { Fragment, FunctionComponent, useEffect, useState } from 'react';
import { useRecoilValue } from 'recoil';
import { useAmplitude } from '../analytics';
import ConfirmPageChange from '../app/ConfirmPageChange';
import { fromJetstreamEvents } from '../jetstream-events';
import LoadRecordsBulkApiResultsTable from '../load-records-results/LoadRecordsBulkApiResultsTable';
import LoadRecordsResultsModal from '../load/LoadRecordsResultsModal';
Expand Down Expand Up @@ -160,6 +161,7 @@ export const MassUpdateRecordsDeploymentRow: FunctionComponent<MassUpdateRecords

return (
<Fragment>
<ConfirmPageChange actionInProgress={status?.includes('In Progress')} />
{downloadModalData.open && (
<FileDownloadModal
org={selectedOrg}
Expand Down
19 changes: 9 additions & 10 deletions libs/shared/ui-core/src/mass-update-records/useDeployRecords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,21 @@ export function useDeployRecords(
deployResults.jobInfo = jobInfo;
deployResults.numberOfBatches = batches.length;
deployResults.records = records;
onDeployResults(sobject, { ...deployResults });
isMounted.current && onDeployResults(sobject, { ...deployResults });

let currItem = 0;
for (const batch of batches) {
try {
if (!isMounted.current) {
return;
}
const batchResult = await bulkApiAddBatchToJob(org, jobId, batch.csv, currItem === batches.length - 1);
deployResults.batchIdToIndex = { ...deployResults.batchIdToIndex, [batchResult.id]: currItem };
deployResults.jobInfo = { ...deployResults.jobInfo };
deployResults.jobInfo.batches = deployResults.jobInfo.batches || [];
deployResults.jobInfo.batches = [...deployResults.jobInfo.batches, batchResult];

onDeployResults(sobject, { ...deployResults });
isMounted.current && onDeployResults(sobject, { ...deployResults });
} catch (ex) {
// error loading batch
logger.error('Error loading batch', ex);
Expand All @@ -90,7 +93,7 @@ export function useDeployRecords(
}
deployResults.status = 'In Progress';
deployResults.lastChecked = formatDate(new Date(), 'h:mm:ss');
onDeployResults(sobject, { ...deployResults });
isMounted.current && onDeployResults(sobject, { ...deployResults });
},
[org, rollbar, onDeployResults]
);
Expand Down Expand Up @@ -130,12 +133,12 @@ export function useDeployRecords(
batchIdToIndex: {},
status: 'Finished',
};
onDeployResults(row.sobject, { ...deployResults });
isMounted.current && onDeployResults(row.sobject, { ...deployResults });
return;
}

deployResults.status = 'In Progress - Uploading';
onDeployResults(row.sobject, { ...deployResults });
isMounted.current && onDeployResults(row.sobject, { ...deployResults });

await performLoad({
deployResults,
Expand All @@ -146,10 +149,6 @@ export function useDeployRecords(
batchSize,
serialMode,
});

if (!isMounted.current) {
return;
}
},
[org, performLoad, onDeployResults]
);
Expand Down Expand Up @@ -178,7 +177,7 @@ export function useDeployRecords(
status: 'Error',
};

onDeployResults(row.sobject, deployResults);
isMounted.current && onDeployResults(row.sobject, deployResults);

rollbar.error('There was an error loading data for mass record update', { message: ex.message, stack: ex.stack });
logger.error('Error loading data for row', ex);
Expand Down
3 changes: 3 additions & 0 deletions libs/ui/src/lib/widgets/NotSeeingRecentMetadataPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface NotSeeingRecentMetadataPopoverProps {
title: string;
link: string;
};
disabled?: boolean;
onReload: () => void;
}

Expand All @@ -30,6 +31,7 @@ export const NotSeeingRecentMetadataPopover: FunctionComponent<NotSeeingRecentMe
link: `/lightning/setup/ObjectManager/home`,
title: `View object in Salesforce setup`,
},
disabled,
onReload,
}) => {
const popoverRef = useRef<PopoverRef>(null);
Expand Down Expand Up @@ -83,6 +85,7 @@ export const NotSeeingRecentMetadataPopover: FunctionComponent<NotSeeingRecentMe
}
buttonProps={{
className: 'slds-button',
disabled,
}}
>
{loading && <Spinner size="x-small" />}
Expand Down