Skip to content

Commit b7862f2

Browse files
authored
feat(x2a): add collapsible details to the project list (#2253)
* feat(x2a): add collapsible details to the project list Signed-off-by: Marek Libra <marek.libra@gmail.com> * review --------- Signed-off-by: Marek Libra <marek.libra@gmail.com>
1 parent e45279c commit b7862f2

41 files changed

Lines changed: 1529 additions & 472 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-scaffolder-backend-module-x2a': patch
3+
'@red-hat-developer-hub/backstage-plugin-x2a-backend': patch
4+
'@red-hat-developer-hub/backstage-plugin-x2a-common': patch
5+
'@red-hat-developer-hub/backstage-plugin-x2a': patch
6+
---
7+
8+
Adding collapsible row detail to the Project List.

workspaces/x2a/plugins/x2a-backend/src/router.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ export async function createRouter({
395395
const lastAnalyzeJobsOfModules = await Promise.all(
396396
modules.map(module =>
397397
x2aDatabase.listJobs({
398+
projectId,
398399
moduleId: module.id,
399400
phase: 'analyze',
400401
lastJobOnly: true,
@@ -404,6 +405,7 @@ export async function createRouter({
404405
const lastMigrateJobsOfModules = await Promise.all(
405406
modules.map(module =>
406407
x2aDatabase.listJobs({
408+
projectId,
407409
moduleId: module.id,
408410
phase: 'migrate',
409411
lastJobOnly: true,
@@ -413,6 +415,7 @@ export async function createRouter({
413415
const lastPublishJobsOfModules = await Promise.all(
414416
modules.map(module =>
415417
x2aDatabase.listJobs({
418+
projectId,
416419
moduleId: module.id,
417420
phase: 'publish',
418421
lastJobOnly: true,
@@ -492,15 +495,16 @@ export async function createRouter({
492495
async (req: express.Request, res: express.Response) => {
493496
const endpoint = 'POST /projects/:projectId/modules/:moduleId/run';
494497
const { projectId, moduleId } = req.params;
495-
logger.info(
496-
`${endpoint} request received: projectId=${projectId}, moduleId=${moduleId}`,
497-
);
498498

499499
// Validate request body
500500
const runModuleRequestSchema = z.object({
501501
phase: z.enum(['analyze', 'migrate', 'publish']),
502-
sourceRepoToken: z.string(),
503-
targetRepoToken: z.string(),
502+
sourceRepoAuth: z.object({
503+
token: z.string(),
504+
}),
505+
targetRepoAuth: z.object({
506+
token: z.string(),
507+
}),
504508
aapCredentials: z
505509
.object({
506510
url: z.string(),
@@ -521,8 +525,8 @@ export async function createRouter({
521525
}
522526
const {
523527
phase,
524-
sourceRepoToken,
525-
targetRepoToken,
528+
sourceRepoAuth,
529+
targetRepoAuth,
526530
aapCredentials,
527531
userPrompt,
528532
} = parsedBody.data;
@@ -575,12 +579,12 @@ export async function createRouter({
575579
sourceRepo: {
576580
url: project.sourceRepoUrl,
577581
branch: project.sourceRepoBranch,
578-
token: sourceRepoToken,
582+
token: sourceRepoAuth.token,
579583
},
580584
targetRepo: {
581585
url: project.targetRepoUrl,
582586
branch: project.targetRepoBranch,
583-
token: targetRepoToken,
587+
token: targetRepoAuth.token,
584588
},
585589
aapCredentials,
586590
userPrompt,
@@ -646,6 +650,7 @@ export async function createRouter({
646650

647651
// Get latest job for module filtered by requested phase
648652
const jobs = await x2aDatabase.listJobs({
653+
projectId,
649654
moduleId,
650655
phase,
651656
});

workspaces/x2a/plugins/x2a-backend/src/schema/openapi.yaml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ paths:
297297
description: Optional user prompt for customizing the migration
298298
required:
299299
- phase
300-
- sourceRepo
301-
- targetRepo
300+
- sourceRepoAuth
301+
- targetRepoAuth
302302
responses:
303303
'200':
304304
description: Migration job created successfully
@@ -394,6 +394,9 @@ components:
394394
createdBy:
395395
type: string
396396
description: The user who created the project (Backstage user reference)
397+
migrationPlan:
398+
$ref: '#/components/schemas/Artifact'
399+
description: Project migration plan artifact (by init phase)
397400
required:
398401
- id
399402
- name
@@ -486,14 +489,21 @@ components:
486489
items:
487490
$ref: '#/components/schemas/Artifact'
488491

492+
ArtifactType:
493+
type: string
494+
enum:
495+
- migration_plan
496+
- module_migration_plan
497+
- migrated_sources
498+
489499
Artifact:
490500
type: object
491501
properties:
492502
id:
493503
type: string
494504
description: UUID for the artifact
495505
type:
496-
type: string
506+
$ref: '#/components/schemas/ArtifactType'
497507
description: Type of the artifact
498508
value:
499509
type: string

workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/models/Artifact.model.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// ******************************************************************
1818
// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
1919
// ******************************************************************
20+
import { ArtifactType } from '../models/ArtifactType.model';
2021

2122
/**
2223
* @public
@@ -26,10 +27,7 @@ export interface Artifact {
2627
* UUID for the artifact
2728
*/
2829
id: string;
29-
/**
30-
* Type of the artifact
31-
*/
32-
type: string;
30+
type: ArtifactType;
3331
/**
3432
* Value of the artifact
3533
*/
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright Red Hat, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
// ******************************************************************
18+
// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
19+
// ******************************************************************
20+
21+
/**
22+
* @public
23+
*/
24+
export type ArtifactType =
25+
| 'migration_plan'
26+
| 'module_migration_plan'
27+
| 'migrated_sources';

workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/models/Project.model.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// ******************************************************************
1818
// * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. *
1919
// ******************************************************************
20+
import { Artifact } from '../models/Artifact.model';
2021

2122
/**
2223
* @public
@@ -62,4 +63,5 @@ export interface Project {
6263
* The user who created the project (Backstage user reference)
6364
*/
6465
createdBy: string;
66+
migrationPlan?: Artifact;
6567
}

workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/models/ProjectsProjectIdModulesModuleIdRunPostRequest.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import { ModulePhase } from '../models/ModulePhase.model';
2626
*/
2727
export interface ProjectsProjectIdModulesModuleIdRunPostRequest {
2828
phase: ModulePhase;
29-
sourceRepoAuth?: GitRepoAuth;
30-
targetRepoAuth?: GitRepoAuth;
29+
sourceRepoAuth: GitRepoAuth;
30+
targetRepoAuth: GitRepoAuth;
3131
aapCredentials?: AAPCredentials;
3232
/**
3333
* Optional user prompt for customizing the migration

workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/models/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
export * from '../models/AAPCredentials.model';
1818
export * from '../models/Artifact.model';
19+
export * from '../models/ArtifactType.model';
1920
export * from '../models/GitRepoAuth.model';
2021
export * from '../models/Job.model';
2122
export * from '../models/JobStatusEnum.model';

workspaces/x2a/plugins/x2a-backend/src/schema/openapi/generated/router.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,8 @@ export const spec = {
452452
},
453453
"required": [
454454
"phase",
455-
"sourceRepo",
456-
"targetRepo"
455+
"sourceRepoAuth",
456+
"targetRepoAuth"
457457
]
458458
}
459459
}
@@ -597,6 +597,10 @@ export const spec = {
597597
"createdBy": {
598598
"type": "string",
599599
"description": "The user who created the project (Backstage user reference)"
600+
},
601+
"migrationPlan": {
602+
"$ref": "#/components/schemas/Artifact",
603+
"description": "Project migration plan artifact (by init phase)"
600604
}
601605
},
602606
"required": [
@@ -713,6 +717,14 @@ export const spec = {
713717
}
714718
}
715719
},
720+
"ArtifactType": {
721+
"type": "string",
722+
"enum": [
723+
"migration_plan",
724+
"module_migration_plan",
725+
"migrated_sources"
726+
]
727+
},
716728
"Artifact": {
717729
"type": "object",
718730
"properties": {
@@ -721,7 +733,7 @@ export const spec = {
721733
"description": "UUID for the artifact"
722734
},
723735
"type": {
724-
"type": "string",
736+
"$ref": "#/components/schemas/ArtifactType",
725737
"description": "Type of the artifact"
726738
},
727739
"value": {

0 commit comments

Comments
 (0)