Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild, inject } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable, Subscription, of, throwError } from 'rxjs';
import { Observable, Subscription, from, of, throwError } from 'rxjs';
import { catchError, map as rxMap, switchMap, tap } from 'rxjs/operators';
import { fromPairs, toPairs } from 'lodash-es';
import { Interactable } from '@interactjs/core/Interactable';
Expand Down Expand Up @@ -33,6 +33,7 @@ import {
} from 'app/programming/shared/code-editor/model/code-editor.model';
import { CodeEditorFileService } from 'app/programming/shared/code-editor/services/code-editor-file.service';
import { CodeEditorConflictStateService } from 'app/programming/shared/code-editor/services/code-editor-conflict-state.service';
import { ConfirmAutofocusModalComponent } from 'app/shared/components/confirm-autofocus-modal/confirm-autofocus-modal.component';
import { findItemInList } from 'app/programming/shared/code-editor/treeview/helpers/tree-view-helper';

export type InteractableEvent = {
Expand Down Expand Up @@ -212,6 +213,34 @@ export class CodeEditorFileBrowserComponent implements OnInit, OnChanges, AfterV
tap((commitState) => {
this.commitState = commitState;
}),
// In tutor assessment mode, offer to resolve dirty/conflicted working copies
// by resetting to the last commit so that the latest committed state is shown.
switchMap((commitState) => {
const needsAutoResolve = this.isTutorAssessment && (commitState === CommitState.UNCOMMITTED_CHANGES || commitState === CommitState.CONFLICT);
if (needsAutoResolve) {
const modalRef = this.modalService.open(ConfirmAutofocusModalComponent);
modalRef.componentInstance.title = 'artemisApp.editor.fileBrowser.autoResolve.title';
modalRef.componentInstance.text = 'artemisApp.editor.fileBrowser.autoResolve.text';
modalRef.componentInstance.translateText = true;

return from(modalRef.result).pipe(
switchMap(() =>
this.repositoryService.resetRepository().pipe(
// After reset, re-check status before continuing
switchMap(() => this.checkIfRepositoryIsClean()),
tap((resolvedState) => {
this.commitState = resolvedState;
if (resolvedState !== CommitState.CONFLICT) {
this.conflictService.notifyConflictState(GitConflictState.OK);
}
}),
),
),
catchError(() => of(commitState)),
);
}
return of(commitState);
}),
switchMap(() => {
if (this.commitState === CommitState.COULD_NOT_BE_RETRIEVED) {
return throwError(() => new Error('couldNotBeRetrieved'));
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/i18n/de/editor.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
"compressTree": "Leere Verzeichnisse zusammenfassen",
"fileBadgeTooltips": {
"feedbackSuggestions": "Anzahl von Feedback-Vorschlägen in dieser Datei / diesem Ordner"
},
"autoResolve": {
"title": "Repository zurücksetzen?",
"text": "Die Arbeitskopie enthält nicht übernommene Änderungen oder Konflikte. Durch das Zurücksetzen werden diese Änderungen verworfen und der zuletzt commitete Zustand angezeigt. Möchtest Du das Repository jetzt zurücksetzen?"
}
},
"errors": {
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/i18n/en/editor.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@
"compressTree": "Combine empty folders",
"fileBadgeTooltips": {
"feedbackSuggestions": "Number of feedback suggestions in this file/folder"
},
"autoResolve": {
"title": "Reset repository?",
"text": "The working copy contains uncommitted changes or conflicts. Resetting will discard those changes and show the latest committed state. Do you want to reset the repository now?"
}
},
"errors": {
Expand Down
Loading