Browse Source

SONAR-19538 Add loading status to Project Import/Export page

tags/10.1.0.73491
Viktor Vorona 11 months ago
parent
commit
35d653420f

+ 15
- 3
server/sonar-web/src/main/js/api/mocks/ComputeEngineServiceMock.ts View File

@@ -117,6 +117,17 @@ export default class ComputeEngineServiceMock {
);
});

results.sort((a, b) => {
const getMaxDate = (t: Task) =>
Math.max(
+new Date(t.submittedAt),
+new Date(t.startedAt ?? 0),
+new Date(t.executedAt ?? 0)
);

return getMaxDate(b) - getMaxDate(a);
});

if (data.onlyCurrents) {
// This is more complex in real life, but it's a good enough approximation to suit tests.
results = Object.values(groupBy(results, (t) => t.componentKey))
@@ -125,13 +136,14 @@ export default class ComputeEngineServiceMock {
}

const page = data.p ?? 1;
const paginationIndex = (page - 1) * PAGE_SIZE;
const pageSize = data.ps ?? PAGE_SIZE;
const paginationIndex = (page - 1) * pageSize;

return Promise.resolve({
tasks: results.slice(paginationIndex, paginationIndex + PAGE_SIZE),
tasks: results.slice(paginationIndex, paginationIndex + pageSize),
paging: {
pageIndex: page,
pageSize: PAGE_SIZE,
pageSize,
total: results.length,
},
});

+ 1
- 1
server/sonar-web/src/main/js/apps/projectDump/ProjectDumpApp.tsx View File

@@ -71,7 +71,7 @@ export class ProjectDumpApp extends React.Component<Props, State> {
const data: ActivityRequestParameters = {
type,
component,
onlyCurrents: true,
ps: 1,
status: [
TaskStatuses.Pending,
TaskStatuses.InProgress,

+ 2
- 0
server/sonar-web/src/main/js/apps/projectDump/__tests__/ProjectDumpApp-it.tsx View File

@@ -120,6 +120,7 @@ it('should show pending->in progress->failed export', async () => {
componentKey: COMPONENT_KEY,
type: TaskTypes.ProjectExport,
status: TaskStatuses.Failed,
executedAt: '2023-06-08T12:05:00Z',
});
jest.runOnlyPendingTimers();
expect(await ui.failedExport.find()).toBeInTheDocument();
@@ -165,6 +166,7 @@ it('should show pending->in progress->failed import', async () => {
componentKey: COMPONENT_KEY,
type: TaskTypes.ProjectImport,
status: TaskStatuses.Failed,
executedAt: '2023-06-08T12:05:00Z',
});
jest.runOnlyPendingTimers();
expect(await ui.failedImport.find()).toBeInTheDocument();

Loading…
Cancel
Save