Skip to content

Commit a458b39

Browse files
authored
[Execution Engine] Refactor step/progress tracking and fix progress bar bugs (#3192)
1 parent 39c3d32 commit a458b39

780 files changed

Lines changed: 107935 additions & 142 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

assets/build/api/docs.jsonopenapi.json

Lines changed: 77279 additions & 1 deletion
Large diffs are not rendered by default.

assets/build/api/openapi-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const config: ConfigFile = {
193193
filterEndpoints: pathMatcher(/api\/thumbnails/i)
194194
},
195195
'../../js/src/core/modules/auth/authorization-api-slice.gen.ts': {
196-
filterEndpoints: pathMatcher(/(login|logout)/i)
196+
filterEndpoints: pathMatcher(/\/api\/(login|logout)/i)
197197
},
198198
'../../js/src/core/modules/class-definition/class-definition-slice.gen.ts': {
199199
filterEndpoints: pathMatcher(/api\/class\//i)

assets/js/src/core/modules/asset/asset-api-slice.gen.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ const injectedRtkApi = api
345345
}),
346346
assetPatchFolderById: build.mutation<AssetPatchFolderByIdApiResponse, AssetPatchFolderByIdApiArg>({
347347
query: (queryArg) => ({
348-
url: `/pimcore-studio/api/assets/folder`,
348+
url: `/pimcore-studio/api/assets/folder/${queryArg.id}`,
349349
method: "PATCH",
350350
body: queryArg.body,
351351
}),
@@ -876,15 +876,15 @@ export type AssetPatchFolderByIdApiResponse =
876876
jobRunId: number;
877877
};
878878
export type AssetPatchFolderByIdApiArg = {
879+
/** Id of the folder */
880+
id: number;
879881
body: {
880882
data: {
881-
/** Folder ID */
882-
folderId: number;
883883
parentId?: number | null;
884884
key?: string | null;
885885
locked?: string | null;
886886
metadata?: PatchCustomMetadata[] | null;
887-
}[];
887+
};
888888
filters?: ExportAllFilter;
889889
};
890890
};

assets/js/src/core/modules/class-definition/class-definition-slice.gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ export type CustomLayouts = {
11601160
/** Modification date timestamp */
11611161
modificationDate: number;
11621162
/** User id of owner */
1163-
userOwner: number;
1163+
userOwner: number | null;
11641164
/** Class id */
11651165
classId: string;
11661166
/** Whether it is the default layout */
@@ -1226,7 +1226,7 @@ export type ClassDefinition = {
12261226
/** Modification date timestamp */
12271227
modificationDate: number | null;
12281228
/** User id of owner */
1229-
userOwner: number;
1229+
userOwner: number | null;
12301230
/** Namespace of parent class */
12311231
parentClass: string;
12321232
/** Interface implementations */

assets/js/src/core/modules/data-object/data-object-api-slice.gen.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ const injectedRtkApi = api
186186
DataObjectPatchFolderByIdApiArg
187187
>({
188188
query: (queryArg) => ({
189-
url: `/pimcore-studio/api/data-objects/folder`,
189+
url: `/pimcore-studio/api/data-objects/folder/${queryArg.id}`,
190190
method: "PATCH",
191191
body: queryArg.body,
192192
}),
@@ -476,10 +476,10 @@ export type DataObjectPatchFolderByIdApiResponse =
476476
jobRunId: number;
477477
};
478478
export type DataObjectPatchFolderByIdApiArg = {
479+
/** Id of the folder */
480+
id: number;
479481
body: {
480482
data: {
481-
/** Folder ID */
482-
folderId: number;
483483
parentId?: number | null;
484484
index?: number | null;
485485
key?: string | null;
@@ -488,7 +488,7 @@ export type DataObjectPatchFolderByIdApiArg = {
488488
childrenSortOrder?: string | null;
489489
published?: boolean | null;
490490
editableData?: object | null;
491-
}[];
491+
};
492492
filters?: ExportAllFilter;
493493
classId: string;
494494
};

assets/js/src/core/modules/element/export-api-slice.gen.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const injectedRtkApi = api
2323
}),
2424
exportCsvFolder: build.mutation<ExportCsvFolderApiResponse, ExportCsvFolderApiArg>({
2525
query: (queryArg) => ({
26-
url: `/pimcore-studio/api/export/csv/folder`,
26+
url: `/pimcore-studio/api/export/csv/folder/${queryArg.id}`,
2727
method: "POST",
2828
body: queryArg.body,
2929
}),
@@ -46,7 +46,7 @@ const injectedRtkApi = api
4646
}),
4747
exportXlsxFolder: build.mutation<ExportXlsxFolderApiResponse, ExportXlsxFolderApiArg>({
4848
query: (queryArg) => ({
49-
url: `/pimcore-studio/api/export/xlsx/folder`,
49+
url: `/pimcore-studio/api/export/xlsx/folder/${queryArg.id}`,
5050
method: "POST",
5151
body: queryArg.body,
5252
}),
@@ -80,8 +80,9 @@ export type ExportCsvApiArg = {
8080
| "custom_report_config"
8181
| "custom_report_to_export"
8282
| "element_class_id"
83-
| "element_to_export"
83+
| "elements_to_export"
8484
| "element_type"
85+
| "export_format"
8586
| "folder_to_export"
8687
| "grid_export_data"
8788
| "grid_export_data_info"
@@ -101,15 +102,17 @@ export type ExportCsvApiArg = {
101102
delimiter?: string;
102103
};
103104
elementType?: "data-object" | "object" | "asset" | "document";
105+
classId?: string | null;
104106
};
105107
};
106108
export type ExportCsvFolderApiResponse = /** status 201 Successfully created <strong>jobRun</strong> for csv export */ {
107109
/** ID of created jobRun */
108110
jobRunId: number;
109111
};
110112
export type ExportCsvFolderApiArg = {
113+
/** Id of the folder */
114+
id: number;
111115
body: {
112-
folders?: number[];
113116
columns?: GridColumnRequest[];
114117
filters?: ExportAllFilter;
115118
config?: {
@@ -118,8 +121,9 @@ export type ExportCsvFolderApiArg = {
118121
| "custom_report_config"
119122
| "custom_report_to_export"
120123
| "element_class_id"
121-
| "element_to_export"
124+
| "elements_to_export"
122125
| "element_type"
126+
| "export_format"
123127
| "folder_to_export"
124128
| "grid_export_data"
125129
| "grid_export_data_info"
@@ -166,8 +170,9 @@ export type ExportXlsxApiArg = {
166170
| "custom_report_config"
167171
| "custom_report_to_export"
168172
| "element_class_id"
169-
| "element_to_export"
173+
| "elements_to_export"
170174
| "element_type"
175+
| "export_format"
171176
| "folder_to_export"
172177
| "grid_export_data"
173178
| "grid_export_data_info"
@@ -186,6 +191,7 @@ export type ExportXlsxApiArg = {
186191
| "bool";
187192
};
188193
elementType?: "data-object" | "object" | "asset" | "document";
194+
classId?: string | null;
189195
};
190196
};
191197
export type ExportXlsxFolderApiResponse =
@@ -194,8 +200,9 @@ export type ExportXlsxFolderApiResponse =
194200
jobRunId: number;
195201
};
196202
export type ExportXlsxFolderApiArg = {
203+
/** Id of the folder */
204+
id: number;
197205
body: {
198-
folders?: number[];
199206
columns?: GridColumnRequest[];
200207
filters?: ExportAllFilter;
201208
config?: {
@@ -204,8 +211,9 @@ export type ExportXlsxFolderApiArg = {
204211
| "custom_report_config"
205212
| "custom_report_to_export"
206213
| "element_class_id"
207-
| "element_to_export"
214+
| "elements_to_export"
208215
| "element_type"
216+
| "export_format"
209217
| "folder_to_export"
210218
| "grid_export_data"
211219
| "grid_export_data_info"

assets/js/src/core/modules/element/listing/batch-actions/csv-modal/csv-modal.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ export const CsvModal = (props: CsvModalProps): React.JSX.Element => {
113113
const job = new DownloadJob({
114114
title: t('jobs.csv-job.title', { title: jobTitle }),
115115
downloadUrl: `${getPrefix()}/export/download/csv/{jobRunId}`,
116-
action: async () => await getDownloadAction(values.delimiter, values.header)
116+
action: async () => await getDownloadAction(values.delimiter, values.header),
117+
...(numberedSelectedRows.length === 0 && { hasChildJob: true })
117118
})
118119
void executionEngine.runJob(job)
119120

@@ -148,8 +149,8 @@ export const CsvModal = (props: CsvModalProps): React.JSX.Element => {
148149
}
149150

150151
const promise = fetchCreateFolderCsv({
152+
id,
151153
body: {
152-
folders: [id],
153154
elementType,
154155
columns: extractedColumnsFromColumnArg,
155156
config: {
@@ -175,7 +176,8 @@ export const CsvModal = (props: CsvModalProps): React.JSX.Element => {
175176
config: {
176177
delimiter,
177178
header
178-
}
179+
},
180+
...(!isNil(selectedClassDefinition?.id) && { classId: selectedClassDefinition.id })
179181
}
180182
})
181183

assets/js/src/core/modules/element/listing/batch-actions/xlsx-modal/xlsx-modal.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ export const XlsxModal = (props: XlsxModalProps): React.JSX.Element => {
112112
const job = new DownloadJob({
113113
title: t('jobs.xlsx-job.title', { title: jobTitle }),
114114
downloadUrl: `${getPrefix()}/export/download/xlsx/{jobRunId}`,
115-
action: async () => await getDownloadAction(values.header)
115+
action: async () => await getDownloadAction(values.header),
116+
...(numberedSelectedRows.length === 0 && { hasChildJob: true })
116117
})
117118
void executionEngine.runJob(job)
118119

@@ -146,8 +147,8 @@ export const XlsxModal = (props: XlsxModalProps): React.JSX.Element => {
146147
}
147148

148149
const promise = fetchCreateFolderXlsx({
150+
id,
149151
body: {
150-
folders: [id],
151152
elementType,
152153
columns: extractedColumnsFromColumnArg,
153154
config: {
@@ -171,7 +172,8 @@ export const XlsxModal = (props: XlsxModalProps): React.JSX.Element => {
171172
columns: extractedColumnsFromColumnArg,
172173
config: {
173174
header
174-
}
175+
},
176+
...(!isNil(selectedClassDefinition?.id) && { classId: selectedClassDefinition.id })
175177
}
176178
})
177179

assets/js/src/core/modules/execution-engine/jobs/batch-delete/abstract-batch-delete-job.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { isNil } from 'lodash'
1212
import trackError, { GeneralError } from '@Pimcore/modules/app/error-handler'
1313
import { type JobInterface, type JobRunOptions } from '../job-interface'
1414
import { MessageBusJobHandler, type JobCompletionData } from '../../message-handlers/message-bus-job/message-bus-job-handler'
15+
import { StepCompletionCalculator } from '../../message-handlers/message-bus-job/progress-calculator/step-completion-calculator'
1516

1617
export interface AbstractBatchDeleteJobOptions {
1718
itemIds: number[]
@@ -44,6 +45,7 @@ export abstract class AbstractBatchDeleteJob implements JobInterface {
4445
const handler = new MessageBusJobHandler({
4546
jobRunId,
4647
title: this.title,
48+
progressCalculator: new StepCompletionCalculator(),
4749
onJobCompletion: async (data: JobCompletionData) => {
4850
if (data.isFinished) {
4951
try {

assets/js/src/core/modules/execution-engine/jobs/batch-edit/abstract-batch-edit-job.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import { isNil } from 'lodash'
1212
import trackError, { GeneralError } from '@Pimcore/modules/app/error-handler'
1313
import { type JobInterface, type JobRunOptions } from '../job-interface'
14-
import { MessageBusJobHandler, type JobCompletionData } from '../../message-handlers/message-bus-job/message-bus-job-handler'
14+
import { MessageBusJobHandler, type JobCompletionData, type MessageBusJobHandlerOptions } from '../../message-handlers/message-bus-job/message-bus-job-handler'
1515
import { type JobButtonCustomizationContext } from '../../message-handlers/message-bus-job/message-bus-job-notification'
1616
import { t } from 'i18next'
1717

@@ -46,7 +46,7 @@ export abstract class AbstractBatchEditJob implements JobInterface {
4646
return
4747
}
4848

49-
const handler = new MessageBusJobHandler({
49+
const handler = this.createHandler({
5050
jobRunId,
5151
title: this.title,
5252
onJobCompletion: async (data: JobCompletionData) => {
@@ -83,6 +83,10 @@ export abstract class AbstractBatchEditJob implements JobInterface {
8383
}
8484
}
8585

86+
protected createHandler (options: MessageBusJobHandlerOptions): MessageBusJobHandler {
87+
return new MessageBusJobHandler(options)
88+
}
89+
8690
protected abstract executeEditRequest (): Promise<number | null>
8791

8892
protected async handleCompletion (): Promise<void> {

0 commit comments

Comments
 (0)