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 #42702 from code-dot-org/ben/code-review/create-co…
…de-review-data-api-class Code Review: move data API into class
- Loading branch information
Showing
3 changed files
with
115 additions
and
127 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
93 changes: 93 additions & 0 deletions
93
apps/src/templates/instructions/codeReview/CodeReviewDataApi.js
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,93 @@ | ||
import $ from 'jquery'; | ||
|
||
export default class CodeReviewDataApi { | ||
constructor(channelId, levelId, scriptId) { | ||
this.channelId = channelId; | ||
this.levelId = levelId; | ||
this.scriptId = scriptId; | ||
} | ||
|
||
getCodeReviewCommentsForProject() { | ||
return $.ajax({ | ||
url: `/code_review_comments/project_comments`, | ||
method: 'GET', | ||
data: {channel_id: this.channelId} | ||
}); | ||
} | ||
|
||
getPeerReviewStatus() { | ||
return $.ajax({ | ||
url: `/reviewable_projects/reviewable_status`, | ||
type: 'GET', | ||
data: { | ||
channel_id: this.channelId, | ||
level_id: this.levelId, | ||
script_id: this.scriptId | ||
} | ||
}); | ||
} | ||
|
||
getReviewablePeers() { | ||
return $.ajax({ | ||
url: `/reviewable_projects/for_level`, | ||
type: 'GET', | ||
data: { | ||
channel_id: this.channelId, | ||
level_id: this.levelId, | ||
script_id: this.scriptId | ||
} | ||
}); | ||
} | ||
|
||
submitNewCodeReviewComment(commentText, token) { | ||
return $.ajax({ | ||
url: `/code_review_comments`, | ||
type: 'POST', | ||
headers: {'X-CSRF-Token': token}, | ||
data: { | ||
channel_id: this.channelId, | ||
script_id: this.scriptId, | ||
level_id: this.levelId, | ||
comment: commentText | ||
} | ||
}); | ||
} | ||
|
||
resolveCodeReviewComment(commentId, resolvedStatus, token) { | ||
return $.ajax({ | ||
url: `/code_review_comments/${commentId}/toggle_resolved`, | ||
type: 'PATCH', | ||
headers: {'X-CSRF-Token': token}, | ||
data: {is_resolved: resolvedStatus} | ||
}); | ||
} | ||
|
||
deleteCodeReviewComment(commentId, token) { | ||
return $.ajax({ | ||
url: `/code_review_comments/${commentId}`, | ||
type: 'DELETE', | ||
headers: {'X-CSRF-Token': token} | ||
}); | ||
} | ||
|
||
enablePeerReview(token) { | ||
return $.ajax({ | ||
url: `/reviewable_projects`, | ||
type: 'POST', | ||
headers: {'X-CSRF-Token': token}, | ||
data: { | ||
channel_id: this.channelId, | ||
level_id: this.levelId, | ||
script_id: this.scriptId | ||
} | ||
}); | ||
} | ||
|
||
disablePeerReview(projectId, token) { | ||
return $.ajax({ | ||
url: `/reviewable_projects/${projectId}`, | ||
headers: {'X-CSRF-Token': token}, | ||
method: `DELETE` | ||
}); | ||
} | ||
} |
91 changes: 0 additions & 91 deletions
91
apps/src/templates/instructions/codeReview/codeReviewDataApi.js
This file was deleted.
Oops, something went wrong.