-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #367 from fujaba/refactor/config
Refactor Assignments Config
- Loading branch information
Showing
17 changed files
with
173 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import {IsBoolean, IsEmail, IsIn, IsNotEmpty, IsString} from "class-validator"; | ||
import {Presentation} from "@mean-stream/ngbx"; | ||
import {Transform} from "class-transformer"; | ||
|
||
export class Config { | ||
@Presentation({ | ||
description: 'Your full name for use in assignments, solutions, comments and evaluations.', | ||
}) | ||
@IsString() | ||
@IsNotEmpty() | ||
name: string = ''; | ||
|
||
@Presentation({ | ||
label: 'E-Mail Address', | ||
description: 'Your email address for use in assignments, solutions, comments and evaluations.', | ||
}) | ||
@IsEmail() | ||
email: string = ''; | ||
|
||
@Presentation({ | ||
label: 'IDE', | ||
description: 'Your preferred IDE for cloning repositories.', | ||
optionLabels: { | ||
vscode: 'VSCode', | ||
'code-oss': 'Code - OSS', | ||
vscodium: 'VSCodium', | ||
}, | ||
}) | ||
@IsIn(['vscode', 'code-oss', 'vscodium']) | ||
ide: 'vscode' | 'code-oss' | 'vscodium' = 'vscode'; | ||
|
||
@Presentation({ | ||
label: 'Git Clone Protocol', | ||
description: 'The protocol to use when cloning a repository.', | ||
optionLabels: { | ||
https: 'HTTPS', | ||
ssh: 'SSH', | ||
}, | ||
}) | ||
@IsIn(['https', 'ssh']) | ||
cloneProtocol: 'https' | 'ssh' = 'https'; | ||
|
||
@Presentation({ | ||
label: 'Git Clone Ref', | ||
description: 'The ref to use when cloning a repository. ' + | ||
'Tags are only supported in VSCode v1.74+ and Assignments imported after 2022-12-21.', | ||
optionLabels: { | ||
none: 'None', | ||
tag: 'Tag', | ||
}, | ||
}) | ||
@IsIn(['none', 'tag']) | ||
cloneRef: 'none' | 'tag' = 'tag'; | ||
|
||
@Presentation({ | ||
description: 'Enable Code Search globally.', | ||
}) | ||
@IsBoolean() | ||
@Transform(({value}) => value === 'true') | ||
codeSearch = true; | ||
|
||
@Presentation({ | ||
description: 'Enable Similar Solutions globally.', | ||
}) | ||
@IsBoolean() | ||
@Transform(({value}) => value === 'true') | ||
similarSolutions = true; | ||
|
||
@Presentation({ | ||
description: 'Enable Snippet Suggestions globally.', | ||
}) | ||
@IsBoolean() | ||
@Transform(({value}) => value === 'true') | ||
snippetSuggestions = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import {Pipe, PipeTransform} from '@angular/core'; | ||
import {ReadAssignmentDto} from '../../../model/assignment'; | ||
import Solution from '../../../model/solution'; | ||
import {ConfigKey} from '../../../services/config.service'; | ||
import {Config} from "../../../model/config"; | ||
|
||
|
||
const clonePrefix = {https: 'https://github.com/', ssh: '[email protected]:'}; | ||
|
@@ -11,16 +11,13 @@ const cloneSuffix = {https: '', ssh: '.git'}; | |
name: 'cloneLink', | ||
}) | ||
export class CloneLinkPipe implements PipeTransform { | ||
transform(assignment: ReadAssignmentDto, solution: Solution, options: Record<ConfigKey, string>): string { | ||
transform(assignment: ReadAssignmentDto, solution: Solution, options: Config): string { | ||
const {ide, cloneProtocol, cloneRef} = options; | ||
const user = solution.author.github; | ||
const org = assignment.classroom?.org; | ||
const prefix = assignment.classroom?.prefix; | ||
let ref = ''; | ||
switch (cloneRef) { | ||
case 'commit': | ||
ref = `&ref=${solution.commit}`; | ||
break; | ||
case 'tag': | ||
ref = `&ref=assignments/${assignment._id}`; | ||
break; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
frontend/src/app/assignment/pages/config-form/config-form.component.html
This file was deleted.
Oops, something went wrong.
Empty file.
24 changes: 0 additions & 24 deletions
24
frontend/src/app/assignment/pages/config-form/config-form.component.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.