This repository was archived by the owner on Apr 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
Allfollowups #22
Open
gmkumar2005
wants to merge
5
commits into
softwaremill:master
Choose a base branch
from
gmkumar2005:allfollowups
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Allfollowups #22
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3ba8ef6
added all followups in ui layer
gmkumar2005 569ac6f
added all followup service , dao changes, ui changes
gmkumar2005 458979c
renames all followps to dashboard
gmkumar2005 c288430
Dashboard added to ui layer ; renamed allfollowups to dashboard except
gmkumar2005 7e6c5c7
reverted unwanted changes
gmkumar2005 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
38 changes: 38 additions & 0 deletions
38
codebrag-rest/src/main/scala/com/softwaremill/codebrag/rest/AllFollowupsServlet.scala
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,38 @@ | ||
package com.softwaremill.codebrag.rest | ||
|
||
import com.softwaremill.codebrag.service.user.Authenticator | ||
import org.scalatra.json.JacksonJsonSupport | ||
import org.bson.types.ObjectId | ||
import org.scalatra.NotFound | ||
import com.softwaremill.codebrag.dao.finders.followup.FollowupFinder | ||
import com.softwaremill.codebrag.dao.finders.views.SingleFollowupView | ||
import com.softwaremill.codebrag.usecases.reactions.FollowupDoneUseCase | ||
|
||
class AllFollowupsServlet(val authenticator: Authenticator, | ||
followupFinder: FollowupFinder, | ||
followupDoneUseCase: FollowupDoneUseCase) | ||
extends JsonServletWithAuthentication with JacksonJsonSupport { | ||
|
||
get("/") { | ||
haltIfNotAuthenticated() | ||
followupFinder.findAllFollowupsByCommitForAdmin() | ||
} | ||
|
||
get("/:id") { | ||
haltIfNotAuthenticated() | ||
val followupId = params("id") | ||
followupFinder.findFollowupforAdmin(new ObjectId(followupId)) match { | ||
case Right(followup) => followup | ||
case Left(msg) => NotFound(msg) | ||
} | ||
} | ||
|
||
delete("/:id") { | ||
haltIfNotAuthenticated() | ||
followupDoneUseCase.execute(user.id, new ObjectId(params("id"))) | ||
} | ||
} | ||
|
||
object AllFollowupsServlet { | ||
val MappingPath = "allfollowups" | ||
} |
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
32 changes: 32 additions & 0 deletions
32
codebrag-ui/app/scripts/followups/allfollowupDetailsCtrl.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,32 @@ | ||
angular.module('codebrag.allfollowups') | ||
|
||
.controller('AllFollowupDetailsCtrl', function ($stateParams, $state, $scope, allfollowupsService, commitsService) { | ||
|
||
var followupId = $stateParams.followupId; | ||
|
||
$scope.scrollTo = $stateParams.commentId; | ||
|
||
allfollowupsService.loadFollowupDetails(followupId).then(function(followup) { | ||
$scope.currentFollowup = followup; | ||
commitsService.commitDetails(followup.commit.sha, followup.commit.repoName).then(function(commit) { | ||
$scope.currentCommit = new codebrag.CurrentCommit(commit); | ||
|
||
}); | ||
}); | ||
|
||
$scope.markCurrentFollowupAsDone = function() { | ||
allfollowupsService.removeAndGetNext(followupId).then(function(nextFollowup) { | ||
goTo(nextFollowup); | ||
}); | ||
}; | ||
|
||
function goTo(nextFollowup) { | ||
if (_.isNull(nextFollowup)) { | ||
$state.transitionTo('allfollowups.list'); | ||
} else { | ||
$state.transitionTo('allfollowups.details', {followupId: nextFollowup.followupId, commentId: nextFollowup.lastReaction.reactionId}); | ||
} | ||
} | ||
|
||
|
||
}); |
28 changes: 28 additions & 0 deletions
28
codebrag-ui/app/scripts/followups/allfollowupListItemCtrl.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,28 @@ | ||
angular.module('codebrag.allfollowups') | ||
|
||
.controller('AllFollowupListItemCtrl', function ($scope, $state, $stateParams, allfollowupsService, $rootScope, events) { | ||
|
||
$scope.openFollowupDetails = function (followup) { | ||
if(_thisFollowupOpened(followup)) { | ||
$rootScope.$broadcast(events.scrollOnly); | ||
} else { | ||
$state.transitionTo('allfollowups.details', {followupId: followup.followupId, commentId: followup.lastReaction.reactionId}); | ||
} | ||
}; | ||
|
||
$scope.dismiss = function (followup) { | ||
allfollowupsService.removeAndGetNext(followup.followupId).then(function(nextFollowup) { | ||
if(nextFollowup) { | ||
$state.transitionTo('allfollowups.details', {followupId: nextFollowup.followupId, commentId: nextFollowup.lastReaction.reactionId}); | ||
} else { | ||
$state.transitionTo('allfollowups.list'); | ||
} | ||
}); | ||
}; | ||
|
||
function _thisFollowupOpened(followup) { | ||
return $state.current.name === 'allfollowups.details' && $state.params.followupId === followup.followupId; | ||
} | ||
|
||
|
||
}); |
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,22 @@ | ||
angular.module('codebrag.allfollowups') | ||
|
||
.controller('AllFollowupsCtrl', function ($scope, $http, allfollowupsService, pageTourService, events) { | ||
|
||
$scope.$on(events.allfollowupsTabOpened, initCtrl); | ||
|
||
|
||
$scope.pageTourForFollowupsVisible = function() { | ||
return pageTourService.stepActive('allfollowups') || pageTourService.stepActive('invites'); | ||
}; | ||
|
||
function initCtrl() { | ||
allfollowupsService.allFollowups().then(function(followups) { | ||
$scope.followupCommits = followups; | ||
}); | ||
$scope.hasFollowupsAvailable = allfollowupsService.hasFollowups; | ||
$scope.mightHaveFollowups = allfollowupsService.mightHaveFollowups; | ||
} | ||
|
||
initCtrl(); | ||
|
||
}); |
118 changes: 118 additions & 0 deletions
118
codebrag-ui/app/scripts/followups/allfollowupsService.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,118 @@ | ||
angular.module('codebrag.allfollowups') | ||
|
||
.factory('allfollowupsService', function($http, $rootScope, events) { | ||
|
||
var followupsListLocal = new codebrag.followups.LocalFollowupsList(); | ||
var listFetched = false; | ||
|
||
function allFollowups() { | ||
return _httpRequest('GET').then(function(response) { | ||
followupsListLocal.addAll(response.data.followupsByCommit); | ||
listFetched = true; | ||
return followupsListLocal.collection; | ||
}); | ||
} | ||
|
||
function removeAndGetNext(followupId, commitId) { | ||
return _httpRequest('DELETE', followupId, {unique: true, requestId: 'removeFollowup_' + followupId}).then(function() { | ||
triggerCounterDecrease(); | ||
var nextFollowup = followupsListLocal.removeOneAndGetNext(followupId, commitId); | ||
return nextFollowup; | ||
}); | ||
|
||
} | ||
|
||
function loadFollowupDetails(followupId) { | ||
return _httpRequest('GET', followupId).then(function(response) { | ||
return response.data; | ||
}); | ||
} | ||
|
||
function hasFollowups() { | ||
return followupsListLocal.hasFollowups(); | ||
} | ||
|
||
function mightHaveFollowups() { | ||
return !listFetched || followupsListLocal.hasFollowups() | ||
} | ||
|
||
function _httpRequest(method, id, config) { | ||
var followupsUrl = 'rest/allfollowups/' + (id || ''); | ||
var reqConfig = angular.extend(config || {}, {method: method, url: followupsUrl}); | ||
return $http(reqConfig); | ||
} | ||
|
||
function triggerCounterDecrease() { | ||
$rootScope.$broadcast(events.followupDone); | ||
} | ||
|
||
return { | ||
allFollowups: allFollowups, | ||
removeAndGetNext: removeAndGetNext, | ||
loadFollowupDetails: loadFollowupDetails, | ||
hasFollowups: hasFollowups, | ||
mightHaveFollowups: mightHaveFollowups | ||
}; | ||
|
||
}); | ||
|
||
var codebrag = codebrag || {}; | ||
codebrag.followups = codebrag.followups || {}; | ||
|
||
codebrag.followups.LocalFollowupsList = function(collection) { | ||
|
||
var self = this; | ||
|
||
this.collection = collection || []; | ||
|
||
this.addAll = function(newCollection) { | ||
this.collection.length = 0; | ||
Array.prototype.push.apply(this.collection, newCollection); | ||
}; | ||
|
||
function nextFollowup(commit, removeAtIndex) { | ||
var followupToReturn = null; | ||
var currentCommitIndex = self.collection.indexOf(commit); | ||
|
||
if (commit.followups[removeAtIndex]) { | ||
followupToReturn = commit.followups[removeAtIndex]; | ||
} else if (self.collection[currentCommitIndex + 1]) { | ||
followupToReturn = self.collection[currentCommitIndex + 1].followups[0]; | ||
} else if (removeAtIndex > 0) { | ||
followupToReturn = commit.followups[removeAtIndex - 1]; | ||
} else if (removeAtIndex === 0 && currentCommitIndex > 0) { | ||
var previousCommitFollowupsLength = self.collection[currentCommitIndex - 1].followups.length; | ||
followupToReturn = self.collection[currentCommitIndex - 1].followups[previousCommitFollowupsLength - 1]; | ||
} | ||
if (!commit.followups.length) { | ||
self.collection.splice(currentCommitIndex, 1); | ||
} | ||
return followupToReturn; | ||
} | ||
|
||
this.removeOneAndGetNext = function(followupId) { | ||
var currentCommit = _.find(this.collection, function(group) { | ||
return _.some(group.followups, function(followup) { | ||
return followup.followupId === followupId; | ||
}); | ||
}); | ||
var followupToRemove = _.find(currentCommit.followups, function(followup) { | ||
return followup.followupId === followupId; | ||
}); | ||
var indexToRemove = currentCommit.followups.indexOf(followupToRemove); | ||
currentCommit.followups.splice(indexToRemove, 1); | ||
return nextFollowup(currentCommit, indexToRemove); | ||
}; | ||
|
||
this.hasFollowups = function() { | ||
return this.collection.length > 0; | ||
}; | ||
|
||
this.followupsCount = function() { | ||
return _.reduce(this.collection, function(sum, followupsGroup) { | ||
return sum + followupsGroup.followups.length; | ||
}, 0); | ||
}; | ||
|
||
}; | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function should be renamed to
findFollowup
- we do not restrict to admins anymore, right?