Class: PlanMyStuff::Issues::LinksController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- PlanMyStuff::Issues::LinksController
- Defined in:
- app/controllers/plan_my_stuff/issues/links_controller.rb
Overview
CRUD for ticket relationships: :related (metadata-backed) and :blocked_by / :parent / :sub_ticket / :duplicate_of (native GitHub APIs). Backs the links panel on the issue show view.
POST /issues/:issue_id/links -> create (adds a link) DELETE /issues/:issue_id/links/:id -> destroy (removes a link)
Constant Summary collapse
- NATIVE_DISPATCH =
{ 'related' => { add: :add_related!, remove: :remove_related! }, 'blocked_by' => { add: :add_blocker!, remove: :remove_blocker! }, 'sub_ticket' => { add: :add_sub_issue!, remove: :remove_sub_issue! }, 'parent' => { add: :set_parent!, remove: :remove_parent! }, 'duplicate_of' => { add: :mark_duplicate! }, }.freeze
Instance Method Summary collapse
-
#create ⇒ Object
POST /issues/:issue_id/links.
-
#destroy ⇒ Object
DELETE /issues/:issue_id/links/:id.
Instance Method Details
#create ⇒ Object
POST /issues/:issue_id/links
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/plan_my_stuff/issues/links_controller.rb', line 22 def create type = link_params[:type].to_s unless dispatch_allowed?(type, :add) (plan_my_stuff.issue_path(params[:issue_id], repo: params[:repo])) return end issue = PMS::Issue.find(params[:issue_id].to_i, repo: params[:repo]) link = add_link(issue, type) flash[:success] = "Linked #{link}" redirect_to(plan_my_stuff.issue_path(params[:issue_id], repo: params[:repo])) rescue PMS::ValidationError, ActiveModel::ValidationError, ArgumentError => e flash[:error] = e. redirect_to(plan_my_stuff.issue_path(params[:issue_id], repo: params[:repo])) end |
#destroy ⇒ Object
DELETE /issues/:issue_id/links/:id
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/plan_my_stuff/issues/links_controller.rb', line 40 def destroy type, repo, number = parse_composite_id(params[:id]) unless dispatch_allowed?(type, :remove) (plan_my_stuff.issue_path(params[:issue_id], repo: params[:repo])) return end issue = PMS::Issue.find(params[:issue_id].to_i, repo: params[:repo]) remove_link(issue, type, repo: repo, number: number) flash[:success] = "Unlinked #{repo}##{number}" redirect_to(plan_my_stuff.issue_path(params[:issue_id], repo: params[:repo])) rescue PMS::ValidationError, ActiveModel::ValidationError, ArgumentError => e flash[:error] = e. redirect_to(plan_my_stuff.issue_path(params[:issue_id], repo: params[:repo])) end |