Skip to content

Commit 2dd7520

Browse files
committed
fneat(training): set solution as readonly
If enabled, show terminal but deactivate code edition for exercise solutions Set input as signal on training step
1 parent 994eea7 commit 2dd7520

7 files changed

+36
-22
lines changed

apps/showcase/eslint.local.config.mjs

+6-6
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ export default [
7070
}
7171
}
7272
}
73-
],
74-
'@o3r/o3r-restriction-key-tags': [
75-
'error',
76-
{
77-
supportedKeys: ['api owners']
78-
}
7973
]
74+
// '@o3r/o3r-restriction-key-tags': [
75+
// 'error',
76+
// {
77+
// supportedKeys: ['api owners']
78+
// }
79+
// ]
8080
}
8181
}
8282
];

apps/showcase/src/components/training/code-editor-view/code-editor-view.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</as-split>
2626
</form>
2727
</as-split-area>
28-
@if (editorMode() === 'interactive') {
28+
@if (displayTerminal()) {
2929
<as-split-area [size]="50">
3030
<code-editor-control class="d-flex flex-column h-100"></code-editor-control>
3131
</as-split-area>

apps/showcase/src/components/training/code-editor-view/code-editor-view.component.ts

+8
Original file line numberDiff line numberDiff line change
@@ -153,16 +153,24 @@ export class CodeEditorViewComponent implements OnDestroy {
153153
* Allow to edit the code in the monaco editor
154154
*/
155155
public editorMode = input<EditorMode>('readonly');
156+
157+
/**
158+
* Display terminal
159+
*/
160+
public displayTerminal = input<boolean>(true);
161+
156162
/**
157163
* Project to load in the code editor.
158164
* It should describe the files to load, the starting file, the folder dedicated to the project as well as the
159165
* commands to initialize the project
160166
*/
161167
public project = input.required<TrainingProject>();
168+
162169
/**
163170
* Service to load files and run commands in the application instance of the webcontainer.
164171
*/
165172
public readonly webContainerService = inject(WebContainerService);
173+
166174
/**
167175
* File tree loaded in the project folder within the web container instance.
168176
*/

apps/showcase/src/components/training/training-step/training-step-pres.component.html

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
<div class="h-100">
22
<as-split direction="horizontal">
3-
@if (instructions) {
4-
<as-split-area [size]="project ? 50 : 100">
3+
@if (instructions()) {
4+
<as-split-area [size]="project() ? 50 : 100">
55
<div class="instructions h-100 overflow-auto pe-6">
6-
<h2>{{title}}</h2>
7-
<markdown clipboard [data]="instructions"></markdown>
6+
<h2>{{title()}}</h2>
7+
<markdown clipboard [data]="instructions()"></markdown>
88
</div>
99
</as-split-area>
1010
}
11-
@if (project) {
12-
<as-split-area [size]="instructions ? 50 : 100">
11+
@if (project()) {
12+
<as-split-area [size]="instructions() ? 50 : 100">
1313
<div class="h-100 overflow-hidden">
1414
<code-editor-view
15-
[project]="project"
16-
[editorMode]="editorMode"
15+
[project]="project()"
16+
[editorMode]="editorMode()"
17+
[displayTerminal]="displayTerminal()"
1718
></code-editor-view>
1819
</div>
1920
</as-split-area>

apps/showcase/src/components/training/training-step/training-step-pres.component.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
ChangeDetectionStrategy,
33
Component,
4-
Input,
4+
input,
55
} from '@angular/core';
66
import {
77
AngularSplitModule,
@@ -27,17 +27,21 @@ export class TrainingStepPresComponent {
2727
/**
2828
* Description of the coding project to load in the code view editor
2929
*/
30-
@Input() public project?: TrainingProject;
30+
public project = input<TrainingProject>();
3131
/**
3232
* Whether to allow the user to modify the project files in the editor
3333
*/
34-
@Input() public editorMode?: EditorMode;
34+
public editorMode = input<EditorMode>();
3535
/**
3636
* Training step title
3737
*/
38-
@Input() public title?: string;
38+
public title = input<string>();
3939
/**
4040
* Training instructions to do the exercise
4141
*/
42-
@Input() public instructions?: string;
42+
public instructions = input<string>();
43+
/**
44+
* Display terminal
45+
*/
46+
public displayTerminal = input<boolean>(true);
4347
}

apps/showcase/src/components/training/training.component.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ <h1 class="m-0 flex-grow-1">{{title()}}</h1>
3636
[instructions]="currentStep.dynamicContent.htmlContent()"
3737
[title]="currentStep.description.stepTitle"
3838
[project]="showSolution() ? currentStep.dynamicContent.solutionProject() : currentStep.dynamicContent.project()"
39-
[editorMode]="currentStep.description.filesConfiguration?.mode">
39+
[editorMode]="showSolution() ? 'readonly' : currentStep.description.filesConfiguration?.mode"
40+
[displayTerminal]="currentStep.description.filesConfiguration?.mode === 'interactive'">
4041
</o3r-training-step-pres>
4142
}

apps/showcase/src/components/training/training.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,12 @@ export class TrainingComponent implements OnInit {
258258
return;
259259
}
260260
this.currentStepIndex.set(index);
261+
this.showSolution.set(false);
261262

262263
const newHash = currentStepLocationRegExp.test(location.hash)
263264
? location.hash.replace(currentStepLocationRegExp, `#${this.currentStepIndex()}`)
264265
: `${location.hash}#${this.currentStepIndex()}`;
265266
history.pushState(null, '', newHash);
266-
this.showSolution.set(false);
267267
}
268268

269269
/**

0 commit comments

Comments
 (0)