-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Todos Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/2425 Tasks: - Prepare database - [X] Create a new table (`todos`) - Tasks Queue view - [X] Add a number icon showing the number of todos on the top right next to the new and logout button that will redirect the user to the todos page - [X] Add a chronological list of todos, with the 'Todos' tab active by default - [X] Add a 'Done' button to each todo - [x] Add filters (project, author, type, and action) - Todos generation - [X] When user issue/mr is assgined to someone - [x] When user is mentioned on (issues/mr's/comments) - Mark todo as `done` - [X] When clicks on the 'Done' button - [X] When edit issue/mr - [X] When left/edit a comment - [X] When reassign issue/mr - [X] When add/remove labels to issue/mr - [X] When issue/mr is closed - [X] When mr is merged - [X] When added an emoji - [X] When changed the issue/mr milestone * Screenshot: ![Screenshot_2016-02-20_12.45.57](/uploads/4b2554b1bde25aed3347e1ae41e8e0c0/Screenshot_2016-02-20_12.45.57.png) See merge request !2817
- Loading branch information
1 parent
b947661
commit 41f1b3d
Showing
46 changed files
with
1,633 additions
and
20 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
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,124 @@ | ||
/** | ||
* Dashboard Todos | ||
* | ||
*/ | ||
|
||
.navbar-nav { | ||
li { | ||
.badge.todos-pending-count { | ||
background-color: #7f8fa4; | ||
margin-top: -5px; | ||
} | ||
} | ||
} | ||
|
||
.todos { | ||
.panel { | ||
border-top: none; | ||
margin-bottom: 0; | ||
} | ||
} | ||
|
||
.todo-item { | ||
font-size: $gl-font-size; | ||
padding: $gl-padding-top 0 $gl-padding-top ($gl-avatar-size + $gl-padding-top); | ||
border-bottom: 1px solid $table-border-color; | ||
color: #7f8fa4; | ||
|
||
&.todo-inline { | ||
.avatar { | ||
position: relative; | ||
top: -2px; | ||
} | ||
|
||
.todo-title { | ||
line-height: 40px; | ||
} | ||
} | ||
|
||
a { | ||
color: #4c4e54; | ||
} | ||
|
||
.avatar { | ||
margin-left: -($gl-avatar-size + $gl-padding-top); | ||
} | ||
|
||
.todo-title { | ||
@include str-truncated(calc(100% - 174px)); | ||
font-weight: 600; | ||
|
||
.author_name { | ||
color: #333; | ||
} | ||
} | ||
|
||
.todo-body { | ||
margin-right: 174px; | ||
|
||
.todo-note { | ||
word-wrap: break-word; | ||
|
||
.md { | ||
color: #7f8fa4; | ||
font-size: $gl-font-size; | ||
|
||
p { | ||
color: #5c5d5e; | ||
} | ||
} | ||
|
||
pre { | ||
border: none; | ||
background: #f9f9f9; | ||
border-radius: 0; | ||
color: #777; | ||
margin: 0 20px; | ||
overflow: hidden; | ||
} | ||
|
||
.note-image-attach { | ||
margin-top: 4px; | ||
margin-left: 0px; | ||
max-width: 200px; | ||
float: none; | ||
} | ||
|
||
p:last-child { | ||
margin-bottom: 0; | ||
} | ||
} | ||
|
||
.todo-note-icon { | ||
color: #777; | ||
float: left; | ||
font-size: $gl-font-size; | ||
line-height: 16px; | ||
margin-right: 5px; | ||
} | ||
} | ||
|
||
&:last-child { border:none } | ||
} | ||
|
||
@media (max-width: $screen-xs-max) { | ||
.todo-item { | ||
padding-left: $gl-padding; | ||
|
||
.todo-title { | ||
white-space: normal; | ||
overflow: visible; | ||
max-width: 100%; | ||
} | ||
|
||
.avatar { | ||
display: none; | ||
} | ||
|
||
.todo-body { | ||
margin: 0; | ||
border-left: 2px solid #DDD; | ||
padding-left: 10px; | ||
} | ||
} | ||
} |
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,35 @@ | ||
class Dashboard::TodosController < Dashboard::ApplicationController | ||
before_action :find_todos, only: [:index, :destroy_all] | ||
|
||
def index | ||
@todos = @todos.page(params[:page]).per(PER_PAGE) | ||
end | ||
|
||
def destroy | ||
todo.done! | ||
|
||
respond_to do |format| | ||
format.html { redirect_to dashboard_todos_path, notice: 'Todo was successfully marked as done.' } | ||
format.js { render nothing: true } | ||
end | ||
end | ||
|
||
def destroy_all | ||
@todos.each(&:done) | ||
|
||
respond_to do |format| | ||
format.html { redirect_to dashboard_todos_path, notice: 'All todos were marked as done.' } | ||
format.js { render nothing: true } | ||
end | ||
end | ||
|
||
private | ||
|
||
def todo | ||
@todo ||= current_user.todos.find(params[:id]) | ||
end | ||
|
||
def find_todos | ||
@todos = TodosFinder.new(current_user, params).execute | ||
end | ||
end |
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,129 @@ | ||
# TodosFinder | ||
# | ||
# Used to filter Todos by set of params | ||
# | ||
# Arguments: | ||
# current_user - which user use | ||
# params: | ||
# action_id: integer | ||
# author_id: integer | ||
# project_id; integer | ||
# state: 'pending' or 'done' | ||
# type: 'Issue' or 'MergeRequest' | ||
# | ||
|
||
class TodosFinder | ||
NONE = '0' | ||
|
||
attr_accessor :current_user, :params | ||
|
||
def initialize(current_user, params) | ||
@current_user = current_user | ||
@params = params | ||
end | ||
|
||
def execute | ||
items = current_user.todos | ||
items = by_action_id(items) | ||
items = by_author(items) | ||
items = by_project(items) | ||
items = by_state(items) | ||
items = by_type(items) | ||
|
||
items | ||
end | ||
|
||
private | ||
|
||
def action_id? | ||
action_id.present? && [Todo::ASSIGNED, Todo::MENTIONED].include?(action_id.to_i) | ||
end | ||
|
||
def action_id | ||
params[:action_id] | ||
end | ||
|
||
def author? | ||
params[:author_id].present? | ||
end | ||
|
||
def author | ||
return @author if defined?(@author) | ||
|
||
@author = | ||
if author? && params[:author_id] != NONE | ||
User.find(params[:author_id]) | ||
else | ||
nil | ||
end | ||
end | ||
|
||
def project? | ||
params[:project_id].present? | ||
end | ||
|
||
def project | ||
return @project if defined?(@project) | ||
|
||
if project? | ||
@project = Project.find(params[:project_id]) | ||
|
||
unless Ability.abilities.allowed?(current_user, :read_project, @project) | ||
@project = nil | ||
end | ||
else | ||
@project = nil | ||
end | ||
|
||
@project | ||
end | ||
|
||
def type? | ||
type.present? && ['Issue', 'MergeRequest'].include?(type) | ||
end | ||
|
||
def type | ||
params[:type] | ||
end | ||
|
||
def by_action_id(items) | ||
if action_id? | ||
items = items.where(action: action_id) | ||
end | ||
|
||
items | ||
end | ||
|
||
def by_author(items) | ||
if author? | ||
items = items.where(author_id: author.try(:id)) | ||
end | ||
|
||
items | ||
end | ||
|
||
def by_project(items) | ||
if project? | ||
items = items.where(project: project) | ||
end | ||
|
||
items | ||
end | ||
|
||
def by_state(items) | ||
case params[:state] | ||
when 'done' | ||
items.done | ||
else | ||
items.pending | ||
end | ||
end | ||
|
||
def by_type(items) | ||
if type? | ||
items = items.where(target_type: type) | ||
end | ||
|
||
items | ||
end | ||
end |
Oops, something went wrong.