diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-21 21:06:26 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-21 21:06:26 +0300 |
commit | 7aada820a908502f40080274fb181281afd44615 (patch) | |
tree | e82fbe264cb5d410fce7acea0a7fd74a962952ba /app | |
parent | b5ad06174bb1de39438c90847abb86ac6988e944 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/boards/models/list.js | 26 | ||||
-rw-r--r-- | app/graphql/mutations/todos/base.rb | 6 | ||||
-rw-r--r-- | app/graphql/mutations/todos/mark_all_done.rb | 35 | ||||
-rw-r--r-- | app/graphql/types/mutation_type.rb | 1 | ||||
-rw-r--r-- | app/services/todo_service.rb | 5 |
5 files changed, 59 insertions, 14 deletions
diff --git a/app/assets/javascripts/boards/models/list.js b/app/assets/javascripts/boards/models/list.js index 34e0d0a83ea..f6a1718155d 100644 --- a/app/assets/javascripts/boards/models/list.js +++ b/app/assets/javascripts/boards/models/list.js @@ -93,7 +93,7 @@ class List { entityType = 'milestone_id'; } - return gl.boardService + return boardsStore .createList(entity.id, entityType) .then(res => res.data) .then(data => { @@ -111,14 +111,14 @@ class List { boardsStore.state.lists.splice(index, 1); boardsStore.updateNewListDropdown(this.id); - gl.boardService.destroyList(this.id).catch(() => { + boardsStore.destroyList(this.id).catch(() => { // TODO: handle request error }); } update() { const collapsed = !this.isExpanded; - return gl.boardService.updateList(this.id, this.position, collapsed).catch(() => { + return boardsStore.updateList(this.id, this.position, collapsed).catch(() => { // TODO: handle request error }); } @@ -147,7 +147,7 @@ class List { this.loading = true; } - return gl.boardService + return boardsStore .getIssuesForList(this.id, data) .then(res => res.data) .then(data => { @@ -168,7 +168,7 @@ class List { this.addIssue(issue, null, 0); this.issuesSize += 1; - return gl.boardService + return boardsStore .newIssue(this.id, issue) .then(res => res.data) .then(data => this.onNewIssueResponse(issue, data)); @@ -276,7 +276,7 @@ class List { this.issues.splice(oldIndex, 1); this.issues.splice(newIndex, 0, issue); - gl.boardService.moveIssue(issue.id, null, null, moveBeforeId, moveAfterId).catch(() => { + boardsStore.moveIssue(issue.id, null, null, moveBeforeId, moveAfterId).catch(() => { // TODO: handle request error }); } @@ -287,7 +287,7 @@ class List { }); this.issues.splice(newIndex, 0, ...issues); - gl.boardService + boardsStore .moveMultipleIssues({ ids: issues.map(issue => issue.id), fromListId: null, @@ -299,15 +299,13 @@ class List { } updateIssueLabel(issue, listFrom, moveBeforeId, moveAfterId) { - gl.boardService - .moveIssue(issue.id, listFrom.id, this.id, moveBeforeId, moveAfterId) - .catch(() => { - // TODO: handle request error - }); + boardsStore.moveIssue(issue.id, listFrom.id, this.id, moveBeforeId, moveAfterId).catch(() => { + // TODO: handle request error + }); } updateMultipleIssues(issues, listFrom, moveBeforeId, moveAfterId) { - gl.boardService + boardsStore .moveMultipleIssues({ ids: issues.map(issue => issue.id), fromListId: listFrom.id, @@ -359,7 +357,7 @@ class List { if (this.issuesSize > 1) { const moveBeforeId = this.issues[1].id; - gl.boardService.moveIssue(issue.id, null, null, null, moveBeforeId); + boardsStore.moveIssue(issue.id, null, null, null, moveBeforeId); } } } diff --git a/app/graphql/mutations/todos/base.rb b/app/graphql/mutations/todos/base.rb index b6c7b320be1..2a72019fbac 100644 --- a/app/graphql/mutations/todos/base.rb +++ b/app/graphql/mutations/todos/base.rb @@ -9,6 +9,12 @@ module Mutations GitlabSchema.object_from_id(id) end + def map_to_global_ids(ids) + return [] if ids.blank? + + ids.map { |id| to_global_id(id) } + end + def to_global_id(id) ::URI::GID.build(app: GlobalID.app, model_name: Todo.name, model_id: id, params: nil).to_s end diff --git a/app/graphql/mutations/todos/mark_all_done.rb b/app/graphql/mutations/todos/mark_all_done.rb new file mode 100644 index 00000000000..5694985717c --- /dev/null +++ b/app/graphql/mutations/todos/mark_all_done.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Mutations + module Todos + class MarkAllDone < ::Mutations::Todos::Base + graphql_name 'TodosMarkAllDone' + + authorize :update_user + + field :updated_ids, + [GraphQL::ID_TYPE], + null: false, + description: 'Ids of the updated todos' + + def resolve + authorize!(current_user) + + updated_ids = mark_all_todos_done + + { + updated_ids: map_to_global_ids(updated_ids), + errors: [] + } + end + + private + + def mark_all_todos_done + return [] unless current_user + + TodoService.new.mark_all_todos_as_done_by_user(current_user) + end + end + end +end diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb index a45f3629621..2408dc7fd1b 100644 --- a/app/graphql/types/mutation_type.rb +++ b/app/graphql/types/mutation_type.rb @@ -22,6 +22,7 @@ module Types mount_mutation Mutations::Notes::Destroy mount_mutation Mutations::Todos::MarkDone mount_mutation Mutations::Todos::Restore + mount_mutation Mutations::Todos::MarkAllDone end end diff --git a/app/services/todo_service.rb b/app/services/todo_service.rb index 2299a02fea1..e7bcca1a38d 100644 --- a/app/services/todo_service.rb +++ b/app/services/todo_service.rb @@ -174,6 +174,11 @@ class TodoService mark_todos_as_done(todos, current_user) end + def mark_all_todos_as_done_by_user(current_user) + todos = TodosFinder.new(current_user).execute + mark_todos_as_done(todos, current_user) + end + # When user marks some todos as pending def mark_todos_as_pending(todos, current_user) update_todos_state(todos, current_user, :pending) |