Skip to content

Commit 1473475

Browse files
mihaelabalutoiuDany9966
authored andcommitted
Fix empty executions after get_transfer optimization
The transfer details endpoint no longer returns the execution history (executions is now an empty list), so the UI can no longer read execution data off the transfer payload. Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
1 parent 06707f4 commit 1473475

5 files changed

Lines changed: 37 additions & 29 deletions

File tree

cypress/e2e/transfers/transfers-list.cy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ describe("Replicas list", () => {
147147
cy.get("div[class^='ActionDropdown__Wrapper']").click();
148148
cy.loadFixtures(["transfers/replicas"], (results: any[]) => {
149149
const transfers = results[0].transfers;
150-
cy.intercept(`**/coriolis/**/transfers/${transfers[0].id}*`, {
151-
fixture: "transfers/replica-unexecuted",
150+
cy.intercept(`**/coriolis/**/transfers/${transfers[0].id}/executions*`, {
151+
body: { executions: [] },
152152
}).as("transfer");
153153

154154
cy.get("div[class^='ActionDropdown__ListItem']")

src/components/modules/TransferModule/TransferDetailsContent/TransferDetailsContent.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,15 @@ class TransferDetailsContent extends React.Component<Props, State> {
124124
};
125125

126126
getLastExecution() {
127-
return this.props.item?.executions?.length
128-
? this.props.item.executions[this.props.item.executions.length - 1]
127+
return this.props.executions?.length
128+
? this.props.executions[this.props.executions.length - 1]
129129
: null;
130130
}
131131

132132
getStatus() {
133-
return this.getLastExecution()?.status;
133+
return (
134+
this.props.item?.last_execution_status || this.getLastExecution()?.status
135+
);
134136
}
135137

136138
isEndpointMissing() {

src/components/smart/TransferDetailsPage/TransferDetailsPage.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,17 @@ class TransferDetailsPage extends React.Component<Props, State> {
221221
}
222222

223223
getLastExecution() {
224-
if (this.transfer?.executions?.length) {
225-
return this.transfer.executions[this.transfer.executions.length - 1];
224+
const executions = transferStore.executionsList;
225+
if (executions.length) {
226+
return executions[executions.length - 1];
226227
}
227228
return null;
228229
}
229230

230231
getStatus() {
231-
return this.getLastExecution()?.status;
232+
return (
233+
this.transfer?.last_execution_status || this.getLastExecution()?.status
234+
);
232235
}
233236

234237
getTransferItemType(): string {
@@ -978,7 +981,9 @@ class TransferDetailsPage extends React.Component<Props, State> {
978981
/>
979982
{this.state.showDeleteTransferConfirmation ? (
980983
<DeleteTransferModal
981-
hasDisks={transferStore.testTransferHasDisks(this.transfer)}
984+
hasDisks={transferStore.testTransferHasDisks(
985+
transferStore.executionsList,
986+
)}
982987
onRequestClose={() => this.handleCloseDeleteTransferConfirmation()}
983988
onDeleteTransfer={() => {
984989
this.handleDeleteTransferConfirmation();

src/sources/TransferSource.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,11 @@ class TransferSource {
218218
let lastExecutionId = options.executionId;
219219

220220
if (!lastExecutionId) {
221-
const transferDetails = await this.getTransferDetails({
222-
transferId: options.transferId,
221+
const executions = await this.getExecutions(options.transferId, {
222+
limit: 1,
223223
});
224-
const lastExecution =
225-
transferDetails.executions[transferDetails.executions.length - 1];
226-
if (lastExecution.status !== "RUNNING") {
224+
const lastExecution = executions[0];
225+
if (!lastExecution || lastExecution.status !== "RUNNING") {
227226
return options.transferId;
228227
}
229228
lastExecutionId = lastExecution.id;

src/stores/TransferStore.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class TransferStore {
6868

6969
@observable startingExecution = false;
7070

71-
@observable transfersWithDisks: TransferItemDetails[] = [];
71+
@observable transfersWithDisks: TransferItem[] = [];
7272

7373
@observable transfersWithDisksLoading = false;
7474

@@ -534,14 +534,14 @@ class TransferStore {
534534
await TransferSource.update(options);
535535
}
536536

537-
testTransferHasDisks(transfer: TransferItemDetails | null) {
538-
if (!transfer || !transfer.executions || transfer.executions.length === 0) {
537+
testTransferHasDisks(executions: Execution[]) {
538+
if (!executions || executions.length === 0) {
539539
return false;
540540
}
541-
if (!transfer.executions.find(e => e.type === "transfer_execution")) {
541+
if (!executions.find(e => e.type === "transfer_execution")) {
542542
return false;
543543
}
544-
const lastExecution = transfer.executions[transfer.executions.length - 1];
544+
const lastExecution = executions[executions.length - 1];
545545
if (
546546
lastExecution.type === "transfer_disks_delete" &&
547547
lastExecution.status === "COMPLETED"
@@ -556,19 +556,21 @@ class TransferStore {
556556
this.transfersWithDisksLoading = true;
557557

558558
try {
559-
const transferDetails = await Promise.all(
560-
transfers.map(transfer =>
561-
TransferSource.getTransferDetails({
562-
transferId: transfer.id,
563-
includeTaskInfo: true,
564-
}),
565-
),
559+
const results = await Promise.all(
560+
transfers.map(async transfer => {
561+
const executions = await TransferSource.getExecutions(transfer.id, {
562+
limit: this.executionsPageSize,
563+
quietError: true,
564+
});
565+
TransferSourceUtils.sortExecutions(executions);
566+
return { transfer, hasDisks: this.testTransferHasDisks(executions) };
567+
}),
566568
);
567569

568570
runInAction(() => {
569-
this.transfersWithDisks = transferDetails.filter(r =>
570-
this.testTransferHasDisks(r),
571-
);
571+
this.transfersWithDisks = results
572+
.filter(r => r.hasDisks)
573+
.map(r => r.transfer);
572574
});
573575
} finally {
574576
runInAction(() => {

0 commit comments

Comments
 (0)