File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
app/components/course-admin/submissions-page/submission-details Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 1010 <div class =" bg-gray-800 p-4 text-white font-mono text-xs leading-relaxed rounded-sm mb-4" >
1111 This submission doesn't have any autofix requests.
1212 </div >
13+
14+ <PrimaryButtonWithSpinner @shouldShowSpinner ={{ this.createAutofixRequestTask.isRunning }} {{ on " click" this.handleCreateAutofixButtonClick }} >
15+ Create Autofix Request
16+ </PrimaryButtonWithSpinner >
17+
18+ {{ #if this.autofixCreationError }}
19+ <AlertWithIcon @type =" error" class =" mt-3" >
20+ <p >
21+ {{ this.autofixCreationError }}
22+ </p >
23+ </AlertWithIcon >
24+ {{ /if }}
1325 {{ /if }}
1426</div >
Original file line number Diff line number Diff line change 11import Component from '@glimmer/component' ;
2+ import type Store from '@ember-data/store' ;
23import type SubmissionModel from 'codecrafters-frontend/models/submission' ;
4+ import { action } from '@ember/object' ;
5+ import { service } from '@ember/service' ;
6+ import { task } from 'ember-concurrency' ;
7+ import { tracked } from '@glimmer/tracking' ;
38
49interface Signature {
510 Element : HTMLDivElement ;
@@ -9,7 +14,30 @@ interface Signature {
914 } ;
1015}
1116
12- export default class AutofixContainer extends Component < Signature > { }
17+ export default class AutofixContainer extends Component < Signature > {
18+ @service declare store : Store ;
19+
20+ @tracked autofixCreationError : string | null = null ;
21+
22+ createAutofixRequestTask = task ( { drop : true } , async ( ) : Promise < void > => {
23+ this . autofixCreationError = null ;
24+
25+ const autofixRequest = this . store . createRecord ( 'autofix-request' , {
26+ submission : this . args . submission ,
27+ } ) ;
28+
29+ try {
30+ await autofixRequest . save ( ) ;
31+ } catch {
32+ this . autofixCreationError = 'Failed to create autofix request! Try again? Post on #engineering if this persists.' ;
33+ }
34+ } ) ;
35+
36+ @action
37+ handleCreateAutofixButtonClick ( ) {
38+ this . createAutofixRequestTask . perform ( ) ;
39+ }
40+ }
1341
1442declare module '@glint/environment-ember-loose/registry' {
1543 export default interface Registry {
You can’t perform that action at this time.
0 commit comments