Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development: Migrate the online code editor to a standalone component #9505

Merged
merged 40 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
4c9cd52
Use signals (CodeEditorMonacoComponent)
pzdr7 Oct 14, 2024
6212991
Change CodeEditorHeaderComponent and CodeEditorMonacoComponent to sta…
pzdr7 Oct 14, 2024
c2b6a80
Fix most tests
pzdr7 Oct 14, 2024
e3b765e
Avoid explicit ngOnChanges
pzdr7 Oct 14, 2024
c9b6f3d
Fix more tests
pzdr7 Oct 14, 2024
cdccb62
Tryfix tutor assessment test
pzdr7 Oct 16, 2024
e50818a
Tryfix code editor container integration
pzdr7 Oct 16, 2024
7cd34a3
Workaround for CodeEditorStudentIntegration
pzdr7 Oct 16, 2024
cb7c18a
Workaround for CodeEditorInstructorIntegration
pzdr7 Oct 16, 2024
f9db5f2
Make override more concise
pzdr7 Oct 16, 2024
01318bf
Fix await
pzdr7 Oct 16, 2024
c70717a
Convert fileSession to signal, part 1
pzdr7 Oct 16, 2024
370769e
Convert fileSession to signal, part 2
pzdr7 Oct 16, 2024
666d451
Experimental: signal-based feedback widgets
pzdr7 Oct 16, 2024
7d13fc8
Experimental: viewState tracking
pzdr7 Oct 16, 2024
6b08934
Skip broken test
pzdr7 Oct 16, 2024
ffa54b0
Revert "Skip broken test"
pzdr7 Oct 16, 2024
445019e
Revert "Experimental: viewState tracking"
pzdr7 Oct 16, 2024
f4c7c98
Revert "Experimental: signal-based feedback widgets"
pzdr7 Oct 16, 2024
a439a2a
Disambiguate feedback widgets
pzdr7 Oct 16, 2024
8ee9a0c
Fix some signal updates
pzdr7 Oct 16, 2024
7797610
Remove TODO
pzdr7 Oct 16, 2024
4ef3146
Eliminate function calls with computed
pzdr7 Oct 16, 2024
188acc7
Experimental: viewChild-based widget rendering
pzdr7 Oct 16, 2024
9fad9ad
Experimental: view state tracking (v2)
pzdr7 Oct 16, 2024
2c80afc
Merge branch 'develop' into chore/development/standalone-online-code
pzdr7 Oct 17, 2024
e0c5297
Revert "Experimental: view state tracking (v2)"
pzdr7 Oct 18, 2024
0c59fa8
Revert "Experimental: viewChild-based widget rendering"
pzdr7 Oct 18, 2024
e226b06
Refactor MockInstance
pzdr7 Oct 18, 2024
9ec1587
Docs; cleanup
pzdr7 Oct 18, 2024
43a6202
Merge branch 'develop' into chore/development/standalone-online-code
pzdr7 Oct 18, 2024
32b0e02
Merge branch 'develop' into chore/development/standalone-online-code
pzdr7 Oct 19, 2024
d0d022f
Merge branch 'develop' into chore/development/standalone-online-code
pzdr7 Oct 20, 2024
ea5c616
Merge branch 'develop' into chore/development/standalone-online-code
pzdr7 Oct 20, 2024
64bac48
Cleanup
pzdr7 Oct 20, 2024
89d859e
Merge branch 'develop' into chore/development/standalone-online-code
pzdr7 Oct 20, 2024
ee12a8f
Merge branch 'develop' into chore/development/standalone-online-code
pzdr7 Oct 21, 2024
8760ea2
Merge branch 'develop' into chore/development/standalone-online-code
pzdr7 Oct 22, 2024
2089de8
Merge branch 'develop' into chore/development/standalone-online-code
pzdr7 Oct 23, 2024
b8d4512
Merge branch 'develop' into chore/development/standalone-online-code
pzdr7 Oct 24, 2024
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
Expand Up @@ -40,7 +40,7 @@
</button>
</div>
<div class="card build-plan-editor">
<jhi-code-editor-header [filename]="'artemisApp.programmingExercise.buildplan' | artemisTranslate" [isLoading]="isLoading" (tabSizeChanged)="updateTabSize($event)" />
<jhi-code-editor-header [fileName]="'artemisApp.programmingExercise.buildplan' | artemisTranslate" [isLoading]="isLoading" (onValidateTabSize)="updateTabSize($event)" />
<div class="d-flex card-body build-plan-editor__content">
<div class="build-plan-editor__content__editor">
<jhi-monaco-editor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { DetailModule } from 'app/detail-overview-list/detail.module';
import { IrisModule } from 'app/iris/iris.module';
import { ArtemisExerciseModule } from 'app/exercises/shared/exercise/exercise.module';
import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.component';
import { CodeEditorHeaderComponent } from 'app/exercises/programming/shared/code-editor/header/code-editor-header.component';

@NgModule({
imports: [
Expand Down Expand Up @@ -55,6 +56,7 @@ import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.co
DetailModule,
IrisModule,
MonacoEditorComponent,
CodeEditorHeaderComponent,
],
declarations: [
ProgrammingExerciseDetailComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { CodeEditorContainerComponent } from 'app/exercises/programming/shared/c
import { ArtemisProgrammingManualAssessmentModule } from 'app/exercises/programming/assess/programming-manual-assessment.module';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TreeviewModule } from 'app/exercises/programming/shared/code-editor/treeview/treeview.module';
import { CodeEditorHeaderComponent } from 'app/exercises/programming/shared/code-editor/header/code-editor-header.component';
import { CodeEditorFileBrowserBadgeComponent } from 'app/exercises/programming/shared/code-editor/file-browser/code-editor-file-browser-badge.component';
import { CodeEditorMonacoComponent } from 'app/exercises/programming/shared/code-editor/monaco/code-editor-monaco.component';
import { ArtemisSharedComponentModule } from 'app/shared/components/shared-component.module';
Expand All @@ -37,6 +36,7 @@ import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.co
MonacoEditorComponent,
ArtemisSharedComponentModule,
RequestFeedbackButtonComponent,
CodeEditorMonacoComponent,
],
declarations: [
CodeEditorGridComponent,
Expand All @@ -54,8 +54,6 @@ import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.co
CodeEditorResolveConflictModalComponent,
CodeEditorConfirmRefreshModalComponent,
CodeEditorContainerComponent,
CodeEditorHeaderComponent,
CodeEditorMonacoComponent,
],
exports: [
CodeEditorGridComponent,
Expand All @@ -65,8 +63,6 @@ import { MonacoEditorComponent } from 'app/shared/monaco-editor/monaco-editor.co
CodeEditorInstructionsComponent,
CodeEditorBuildOutputComponent,
CodeEditorContainerComponent,
CodeEditorHeaderComponent,
CodeEditorMonacoComponent,
],
providers: [],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<div class="d-flex justify-content-between card-header bg-primary text-white">
<h3 class="mt-1 card-title">
<fa-icon [icon]="farFileAlt" />
<span> &nbsp;{{ filename }}</span>
@if (isLoading) {
<span> &nbsp;{{ fileName() }}</span>
@if (isLoading()) {
<fa-icon [icon]="faCircleNotch" animation="spin" class="ms-2" title="{{ 'artemisApp.editor.loadingFile' | artemisTranslate }}" />
}
</h3>
@if (showTabSizeSelector) {
@if (showTabSizeSelector()) {
<div ngbDropdown class="ms-2" placement="bottom-end auto" [autoClose]="'outside'" aria-label="Code Editor Settings">
<button ngbDropdownToggle class="btn btn-sm btn-primary" type="button" id="dropdownCodeEditorSettings" aria-expanded="false">
<fa-icon [icon]="faGear" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ChangeDetectionStrategy, Component, input, model, output } from '@angular/core';
import { faFileAlt } from '@fortawesome/free-regular-svg-icons';
import { faCircleNotch, faGear } from '@fortawesome/free-solid-svg-icons';
import { MAX_TAB_SIZE } from 'app/shared/monaco-editor/monaco-editor.component';
import { ArtemisSharedModule } from 'app/shared/shared.module';
pzdr7 marked this conversation as resolved.
Show resolved Hide resolved

@Component({
selector: 'jhi-code-editor-header',
templateUrl: './code-editor-header.component.html',
imports: [ArtemisSharedModule],
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CodeEditorHeaderComponent {
@Input()
filename: string;
readonly fileName = input<string>();
readonly isLoading = input<boolean>(false);
readonly showTabSizeSelector = input<boolean>(true);
readonly onValidateTabSize = output<number>();

@Input()
isLoading: boolean;

@Input()
showTabSizeSelector = true;

@Output()
tabSizeChanged = new EventEmitter<number>();

tabSize = 4;
readonly tabSize = model<number>(4);

readonly MAX_TAB_SIZE = MAX_TAB_SIZE;

Expand All @@ -35,7 +32,7 @@ export class CodeEditorHeaderComponent {
* Valid values are in range [1, {@link MAX_TAB_SIZE}].
*/
validateTabSize(): void {
this.tabSize = Math.max(1, Math.min(this.tabSize, MAX_TAB_SIZE));
this.tabSizeChanged.emit(this.tabSize);
this.tabSize.set(Math.max(1, Math.min(this.tabSize(), MAX_TAB_SIZE)));
this.onValidateTabSize.emit(this.tabSize());
}
}
Original file line number Diff line number Diff line change
@@ -1,60 +1,60 @@
<div class="card">
<jhi-code-editor-header [showTabSizeSelector]="false" [filename]="selectedFile!" [isLoading]="loadingCount > 0" />
<jhi-code-editor-header [showTabSizeSelector]="false" [fileName]="selectedFile()" [isLoading]="loadingCount() > 0" />
pzdr7 marked this conversation as resolved.
Show resolved Hide resolved
<div class="card-body card-body-monaco">
@if (selectedFile) {
@for (feedback of filterFeedbackForSelectedFile(feedbacks); track feedback.id) {
@if (selectedFile()) {
@for (feedback of feedbackForSelectedFile(); track feedback.id + feedback.reference) {
pzdr7 marked this conversation as resolved.
Show resolved Hide resolved
<!-- actual, stored feedback -->
<jhi-code-editor-tutor-assessment-inline-feedback
class="monaco-hidden-element"
[selectedFile]="selectedFile"
[codeLine]="Feedback.getReferenceLine(feedback)!"
[selectedFile]="selectedFile()!"
pzdr7 marked this conversation as resolved.
Show resolved Hide resolved
[codeLine]="feedback.line"
[feedback]="feedback"
[readOnly]="readOnlyManualFeedback"
[highlightDifferences]="highlightDifferences"
[course]="course"
[readOnly]="readOnlyManualFeedback()"
[highlightDifferences]="highlightDifferences()"
[course]="course()"
(onUpdateFeedback)="updateFeedback($event)"
(onDeleteFeedback)="deleteFeedback($event)"
(onCancelFeedback)="cancelFeedback($event)"
/>
}
<!-- new, unsaved feedback -->
@for (line of newFeedbackLines; track line) {
@for (line of newFeedbackLines(); track line) {
pzdr7 marked this conversation as resolved.
Show resolved Hide resolved
<jhi-code-editor-tutor-assessment-inline-feedback
class="monaco-hidden-element"
[selectedFile]="selectedFile"
[selectedFile]="selectedFile()!"
[codeLine]="line"
[feedback]="undefined"
[highlightDifferences]="highlightDifferences"
[readOnly]="readOnlyManualFeedback"
[course]="course"
[highlightDifferences]="highlightDifferences()"
[readOnly]="readOnlyManualFeedback()"
[course]="course()"
(onUpdateFeedback)="updateFeedback($event)"
(onDeleteFeedback)="deleteFeedback($event)"
(onCancelFeedback)="cancelFeedback($event)"
/>
}
<!-- feedback suggestions -->
@for (suggestion of filterFeedbackForSelectedFile(feedbackSuggestions); track suggestion.id) {
@for (suggestion of feedbackSuggestionsForSelectedFile(); track suggestion.id + suggestion.reference) {
pzdr7 marked this conversation as resolved.
Show resolved Hide resolved
<jhi-code-editor-tutor-assessment-inline-feedback-suggestion
[codeLine]="Feedback.getReferenceLine(suggestion)!"
[codeLine]="suggestion.line"
[feedback]="suggestion"
[course]="course"
[course]="course()"
(onAcceptSuggestion)="acceptSuggestion($event)"
(onDiscardSuggestion)="discardSuggestion($event)"
/>
}
}
<jhi-monaco-editor
(textChanged)="onFileTextChanged($event)"
[hidden]="!selectedFile || loadingCount > 0 || binaryFileSelected"
[readOnly]="editorLocked"
[hidden]="!selectedFile() || loadingCount() > 0 || binaryFileSelected()"
[readOnly]="editorLocked()"
pzdr7 marked this conversation as resolved.
Show resolved Hide resolved
[textChangedEmitDelay]="200"
#editor
[id]="'monaco-editor-' + sessionId"
[id]="'monaco-editor-' + sessionId()"
pzdr7 marked this conversation as resolved.
Show resolved Hide resolved
/>

@if (!selectedFile && !loadingCount) {
@if (!selectedFile() && !loadingCount()) {
<p id="no-file-selected" class="text-center lead text-body-secondary pt-5" jhiTranslate="artemisApp.editor.selectFile"></p>
} @else if (binaryFileSelected) {
} @else if (binaryFileSelected()) {
<p id="binary-file-selected" class="text-center lead pt-5" jhiTranslate="artemisApp.editor.binaryFileSelected"></p>
}
</div>
Expand Down
Loading
Loading