Skip to content

Commit

Permalink
Merge migration changes from #8897
Browse files Browse the repository at this point in the history
  • Loading branch information
iyannsch committed Aug 12, 2024
1 parent 851bc8f commit 4ffaf96
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,6 @@ public String getType() {
@Column(name = "package_name")
private String packageName;

@Nullable
@Column(name = "theia_image", table = "programming_exercise_details")
private String theiaImage;

@Column(name = "sequential_test_runs")
private Boolean sequentialTestRuns;

@Column(name = "show_test_names_to_students", table = "programming_exercise_details")
private boolean showTestNamesToStudents;

Expand Down Expand Up @@ -755,7 +748,7 @@ public void validateProgrammingSettings() {
}

// Check if theia image was selected if the online IDE is enabled
if (isAllowOnlineIde() && getTheiaImage() == null) {
if (isAllowOnlineIde() && buildConfig.getTheiaImage() == null) {
throw new BadRequestAlertException("The Theia image must be selected if the online IDE is enabled", "Exercise", "theiaImageNotSet");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public ResponseEntity<ProgrammingExercise> updateProgrammingExercise(@RequestBod
"noParticipationModeAllowed");
}
// Verify that a theia image is provided when the online IDE is enabled
if (updatedProgrammingExercise.isAllowOnlineIde() && updatedProgrammingExercise.getTheiaImage() == null) {
if (updatedProgrammingExercise.isAllowOnlineIde() && updatedProgrammingExercise.getBuildConfig().getTheiaImage() == null) {
throw new BadRequestAlertException("You need to provide a Theia image when the online IDE is enabled", ENTITY_NAME, "noTheiaImageProvided");
}
// Forbid changing the course the exercise belongs to.
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/config/liquibase/master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<include file="classpath:config/liquibase/changelog/20240617001400_changelog.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20240612123000_changelog.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20240614140000_changelog.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20240701134000_changelog.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20240620150000_changelog.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20240626200000_changelog.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/liquibase/changelog/20240708144500_changelog.xml" relativeToChangelogFile="false"/>
Expand Down
1 change: 1 addition & 0 deletions src/main/webapp/app/entities/programming-exercise.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class ProgrammingExerciseBuildConfig {
public dockerFlags?: string;
public windFile?: WindFile;
public testwiseCoverageEnabled?: boolean;
public theiaImage?: string;

constructor() {
this.checkoutSolutionRepository = false; // default value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ export class ProgrammingExerciseUpdateComponent implements AfterViewInit, OnDest
* Checking if the online IDE is selected and a valid image is selected
*/
validOnlineIdeSelection = () => {
return !this.programmingExercise?.allowOnlineIde || this.programmingExercise?.theiaImage !== undefined;
return !this.programmingExercise?.allowOnlineIde || this.programmingExercise?.buildConfig!.theiaImage !== undefined;
};

isEventInsideTextArea(event: Event): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#select="ngModel"
required
class="form-select"
[ngModel]="programmingExercise.theiaImage"
[ngModel]="programmingExercise.buildConfig?.theiaImage"
(ngModelChange)="onTheiaImageChange($event)"
name="theiaImage"
id="field_theiaImage"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export class ProgrammingExerciseTheiaComponent implements OnChanges {
}

onTheiaImageChange(theiaImage: string) {
this.programmingExercise.theiaImage = theiaImage;
if (this.programmingExercise.buildConfig) {
this.programmingExercise.buildConfig!.theiaImage = theiaImage;
}
}

shouldReloadTemplate(): boolean {
Expand All @@ -39,7 +41,9 @@ export class ProgrammingExerciseTheiaComponent implements OnChanges {
* @private
*/
resetImageSelection() {
this.programmingExercise.theiaImage = undefined;
if (this.programmingExercise.buildConfig) {
this.programmingExercise.buildConfig!.theiaImage = undefined;
}
}

/**
Expand All @@ -65,8 +69,8 @@ export class ProgrammingExerciseTheiaComponent implements OnChanges {
this.theiaImages = images;

// Set the first image as default if none is selected
if (this.programmingExercise && !this.programmingExercise.theiaImage && Object.values(images).length > 0) {
this.programmingExercise.theiaImage = Object.values(images).first() as string;
if (this.programmingExercise && this.programmingExercise.buildConfig && !this.programmingExercise.buildConfig!.theiaImage && Object.values(images).length > 0) {
this.programmingExercise.buildConfig!.theiaImage = Object.values(images).first() as string;
}
},
error: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class ExerciseDetailsStudentActionsComponent implements OnInit, OnChanges
}

// Verify that the exercise has a theia blueprint configured
if (!this.programmingExercise.theiaImage) {
if (!this.programmingExercise.buildConfig?.theiaImage) {
this.theiaEnabled = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,8 @@ describe('ExerciseDetailsStudentActionsComponent', () => {
},
{
allowOnlineIde: true,
},
{
theiaImage: 'this-is-a-theia-image',
},
true,
Expand All @@ -626,6 +628,8 @@ describe('ExerciseDetailsStudentActionsComponent', () => {
},
{
allowOnlineIde: true,
},
{
theiaImage: undefined,
},
false,
Expand All @@ -638,6 +642,8 @@ describe('ExerciseDetailsStudentActionsComponent', () => {
},
{
allowOnlineIde: false,
},
{
theiaImage: 'this-is-an-old-image',
},
false,
Expand All @@ -649,6 +655,8 @@ describe('ExerciseDetailsStudentActionsComponent', () => {
},
{
allowOnlineIde: true,
},
{
theiaImage: 'this-is-a-theia-image',
},
false,
Expand All @@ -660,16 +668,19 @@ describe('ExerciseDetailsStudentActionsComponent', () => {
},
{
allowOnlineIde: true,
},
{
theiaImage: 'this-is-a-theia-image',
},
false,
],
])('%s', (description, profileInfo, programmingExercise, expectedVisibility) => {
])('%s', (description, profileInfo, programmingExercise, buildConfig, expectedVisibility) => {
getProfileInfoSub = jest.spyOn(profileService, 'getProfileInfo');
getProfileInfoSub.mockReturnValue(of(profileInfo as ProfileInfo));

// Expand the programmingExercise by given properties
comp.exercise = { ...exercise, ...programmingExercise } as ProgrammingExercise;
comp.exercise.buildConfig = { ...comp.exercise.buildConfig, ...buildConfig };

Check failure on line 683 in src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.component.spec.ts

View workflow job for this annotation

GitHub Actions / client-tests

Property 'buildConfig' does not exist on type 'Exercise'.

Check failure on line 683 in src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.component.spec.ts

View workflow job for this annotation

GitHub Actions / client-tests

Property 'buildConfig' does not exist on type 'Exercise'.

Check failure on line 683 in src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.component.spec.ts

View workflow job for this annotation

GitHub Actions / client-tests-selected

Property 'buildConfig' does not exist on type 'Exercise'.

Check failure on line 683 in src/test/javascript/spec/component/overview/exercise-details/exercise-details-student-actions.component.spec.ts

View workflow job for this annotation

GitHub Actions / client-tests-selected

Property 'buildConfig' does not exist on type 'Exercise'.

fixture.detectChanges();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('ProgrammingExerciseTheiaComponent', () => {
fixture.detectChanges();
comp.loadTheiaImages();
tick();
expect(comp.programmingExercise.theiaImage).toBeUndefined();
expect(comp.programmingExercise.buildConfig?.theiaImage).toBeUndefined();
}));

it('should select first image when none was selected', fakeAsync(() => {
Expand All @@ -71,11 +71,11 @@ describe('ProgrammingExerciseTheiaComponent', () => {
fixture.detectChanges();
comp.loadTheiaImages();
tick();
expect(comp.programmingExercise.theiaImage).toMatch('test-url');
expect(comp.programmingExercise.buildConfig?.theiaImage).toMatch('test-url');
}));

it('should not overwrite selected image when others are loaded', fakeAsync(() => {
comp.programmingExercise.theiaImage = 'test-url-2';
comp.programmingExercise.buildConfig!.theiaImage = 'test-url-2';
theiaServiceMock.getTheiaImages.mockReturnValue(
of({
'Java-17': 'test-url',
Expand All @@ -85,6 +85,6 @@ describe('ProgrammingExerciseTheiaComponent', () => {
fixture.detectChanges();
comp.loadTheiaImages();
tick();
expect(comp.programmingExercise.theiaImage).toMatch('test-url-2');
expect(comp.programmingExercise.buildConfig?.theiaImage).toMatch('test-url-2');
}));
});

0 comments on commit 4ffaf96

Please sign in to comment.