diff --git a/apps/bissue/assets/images/icon.png b/apps/bissue/assets/images/icon.png new file mode 100644 index 0000000..cf34bef Binary files /dev/null and b/apps/bissue/assets/images/icon.png differ diff --git a/apps/bissue/assets/images/screenshot.png b/apps/bissue/assets/images/screenshot.png new file mode 100644 index 0000000..8583a89 Binary files /dev/null and b/apps/bissue/assets/images/screenshot.png differ diff --git a/apps/bissue/assets/views/button/overlay.hbs b/apps/bissue/assets/views/button/overlay.hbs new file mode 100644 index 0000000..2bfd2c1 --- /dev/null +++ b/apps/bissue/assets/views/button/overlay.hbs @@ -0,0 +1,23 @@ +

Edit the Issue Details

+{{#each tickets}} + {{#ticket}} +
    +
  1. + + +
  2. +
  3. + + +
  4. +
  5. + + +
  6. +
+ {{/ticket}} +{{/each}} + diff --git a/apps/bissue/bissue.rb b/apps/bissue/bissue.rb new file mode 100644 index 0000000..1c13018 --- /dev/null +++ b/apps/bissue/bissue.rb @@ -0,0 +1,66 @@ +module Bissue + module EventHandler + # Handle 'ticket.created' event + def ticket_created + return true + end + + # Handle all events + def all_events + return true + end + end +end + +module Bissue + module ActionHandler + def button + begin + response = create_bissue(payload.overlay.title, payload.overlay.status, payload.overlay.description) + html = comment_html(response) + comment_on_ticket(ticket, html) + rescue Exception => e + return [500, e.message] + end + [200, "Ticket sent to Bitbucket Issues"] + end + end +end + +module Bissue + require 'uri' + require 'json' + + class Base < SupportBeeApp::Base + # Settings + # bitbucket service need to be supported yet + # oauth :bitbucket, :required => true, :oauth_options => {:scope => "user,repo"} + string :accountname, :required => true, :label => 'Owner' + string :repo_slug, :required => true, :label => 'Repository' + + def validate + errors[:flash] = ["Please fill in all the required fields"] if settings.accountname.blank? or settings.repo_slug.blank? + errors.empty? ? true : false + end + + private + + def create_bissue(issue_title, issue_status, issue_description) + # Uncomment after adding bitbucket support + #token = settings.oauth_token_secret || settings.oauth_token + response = http_post "https://bitbucket.org/api/1.0/repositories/#{settings.accountname}/#{settings.repo_slug}/issues?access_token=#{token}" do |req| + req.body = {:title => issue_title, :status => issue_status, :content => URI.encode(issue_description)}.to_json + end + end + + def comment_html(response) + "Bitbucket Issue created!\n #{response.body['title']}" + end + + def comment_on_ticket(ticket, html) + ticket.comment(:html => html) + end + + end +end + diff --git a/apps/bissue/config.yml b/apps/bissue/config.yml new file mode 100644 index 0000000..013d8b7 --- /dev/null +++ b/apps/bissue/config.yml @@ -0,0 +1,29 @@ +name: Bissue +slug: bissue +access: public + +description: "This facilitates creating issue in bitbucket." + +category: Project Management + +tags: +- bitbucket +- issue forwarding + +developer: + name: Sagar Gugwad + email: saagar.gugwad@gmail.com + twitter: @geekgugi + github: geekgugi + +# The following config keys are used by Action Handlers +# Set button 'overlay' to true, if you want to have an overlay +# The valid values for screens are [ticket, all, unassigned, my, groups] +# Remove the following section if you do not want to define Action Handlers + +action: + button: + overlay: public + screens: + - ticket + label: Send To Bissue