-
Notifications
You must be signed in to change notification settings - Fork 998
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #774 from errbit/refacor_issue_tracker
Refacorting issue tracker
- Loading branch information
Showing
19 changed files
with
314 additions
and
252 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
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 was deleted.
Oops, something went wrong.
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,31 @@ | ||
class Issue | ||
include ActiveModel::Model | ||
attr_accessor :problem, :user, :title, :body | ||
|
||
def intialize(problem: nil, user: nil, title: nil, body: nil) | ||
@problem, @user, @title, @body = problem, user, title, body | ||
end | ||
|
||
def issue_tracker | ||
problem.app.issue_tracker | ||
end | ||
|
||
def save | ||
if issue_tracker | ||
issue_tracker.tracker.errors.each do |k, err| | ||
errors.add k, err | ||
end | ||
return false if errors.present? | ||
|
||
url = issue_tracker.create_issue(title, body, user: user.as_document) | ||
problem.update_attributes(issue_link: url, issue_type: issue_tracker.tracker.class.label) | ||
else | ||
errors.add :base, "This app has no issue tracker setup." | ||
end | ||
|
||
errors.empty? | ||
rescue => ex | ||
errors.add :base, "There was an error during issue creation: #{ex.message}" | ||
false | ||
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,45 @@ | ||
[See this exception on Errbit](<%= app_problem_url problem.app, problem %> "See this exception on Errbit") | ||
<% if notice = problem.notices.first %> | ||
# <%= notice.message %> # | ||
## Summary ## | ||
<% if notice.request['url'].present? %> | ||
### URL ### | ||
[<%= notice.request['url'] %>](<%= notice.request['url'] %>)" | ||
<% end %> | ||
### Where ### | ||
<%= notice.where %> | ||
|
||
### Occured ### | ||
<%= notice.created_at.to_s(:micro) %> | ||
|
||
### Similar ### | ||
<%= (notice.problem.notices_count - 1).to_s %> | ||
|
||
## Params ## | ||
``` | ||
<%= pretty_hash(notice.params) %> | ||
``` | ||
|
||
## Session ## | ||
``` | ||
<%= pretty_hash(notice.session) %> | ||
``` | ||
|
||
## Backtrace ## | ||
``` | ||
<% notice.backtrace_lines.each do |line| %><%= line.number %>: <%= line.file_relative %> -> **<%= line.method %>** | ||
<% end %> | ||
``` | ||
|
||
## Environment ## | ||
|
||
<table> | ||
<% for key, val in notice.env_vars %> | ||
<tr> | ||
<td><%= key %>:</td> | ||
<td><%= val %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
- if app.issue_tracker_configured? || current_user.github_account? | ||
- if app.issue_tracker_configured? | ||
- if problem.issue_link.present? | ||
%span= link_to 'go to issue', problem.issue_link, :class => "#{problem.issue_type}_goto goto-issue" | ||
= link_to 'unlink issue', unlink_issue_app_problem_path(app, problem), :method => :delete, :data => { :confirm => "Unlink err issues?" }, :class => "unlink-issue" | ||
- elsif problem.issue_link == "pending" | ||
%span.disabled= link_to 'creating...', '#', :class => "#{problem.issue_type}_inactive create-issue" | ||
= link_to 'retry', create_issue_app_problem_path(app, problem), :method => :post | ||
- else | ||
- if app.issue_tracker_configured? && !app.issue_tracker.type_tracker.eql?('github') | ||
%span= link_to 'create issue', create_issue_app_problem_path(app, problem), :method => :post, :class => "#{app.issue_tracker.type_tracker}_create create-issue" | ||
- elsif app.github_repo? | ||
- if current_user.can_create_github_issues? | ||
%span= link_to 'create issue', create_issue_app_problem_path(app, problem, :tracker => 'user_github'), :method => :post, :class => "github_create create-issue" | ||
- elsif app.issue_tracker_configured? && app.issue_tracker.type_tracker.eql?('github') | ||
%span= link_to 'create issue', create_issue_app_problem_path(app, problem), :method => :post, :class => "github_create create-issue" | ||
%span= link_to 'create issue', create_issue_app_problem_path(app, problem), method: :post, class: "#{app.issue_tracker.type_tracker}_create create-issue" |
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
Oops, something went wrong.