Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue 287: Bugreporty liat do Jiry projektu Lepsie Sluzby #426

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ SENDINBLUE_API_KEY=
DISABLED_FEATURES=
RECAPTCHA_SITE_KEY=
RECAPTCHA_SECRET_KEY=
JIRA_USERNAME=
JIRA_PASSWORD=
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.7.2'
ruby '2.7.0'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0'
Expand Down Expand Up @@ -98,3 +98,6 @@ end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'hirb'

# https://github.com/slovensko-digital/navody.digital/issues/287
gem 'jira-ruby', :require => 'jira-ruby'
9 changes: 9 additions & 0 deletions app/controllers/feedbacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require "net/http"

class FeedbacksController < ApplicationController

def create
respond_to do |format|
if verify_recaptcha
Expand All @@ -13,11 +14,19 @@ def create
'entry.1623207670': params[:bug_what_were_you_doing],
'entry.480582804': params[:bug_what_went_wrong],
})
ReportFeedbackLepsieSluzbyJob.perform_later(feedback_params)
@message = 'Váš podnet bol odoslaný. Ďakujeme.'
else
@message = 'Prosím, potvrďte, že nie ste robot.'
end
format.js
end
end

private

def feedback_params
params.permit(:current_path, :feedback_type, :email, :bug_what_were_you_doing, :bug_what_went_wrong)
end

end
30 changes: 30 additions & 0 deletions app/jobs/report_feedback_lepsie_sluzby_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class ReportFeedbackLepsieSluzbyJob < ApplicationJob
queue_as :default

def perform(params)
fields = build_JIRA_fields(params)
LepsieSluzbyService.create_issue(fields)
end

private

def build_JIRA_fields(params)
fields = {
"summary" => "Reported from navody.digital",
"project" => {"key" => "SBX"},
"description" => %Q(
URL: #{params[:current_path]}
feedback type: #{params[:feedback_type]}
email: #{params[:email]}

what you were doing:
#{params[:bug_what_were_you_doing]}

what went wrong:
#{params[:bug_what_went_wrong]}
),
"issuetype"=>{"id"=>10002}
}
return fields
end
end
27 changes: 27 additions & 0 deletions app/services/lepsie_sluzby_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
class LepsieSluzbyService
class << self

def create_issue(fields)
issue = jira_client.Issue.build
issue.save({
"fields" => fields
})
end

private

def jira_client
JIRA::Client.new({
:username => ENV['JIRA_USERNAME'],
:password => ENV['JIRA_PASSWORD'],
:site => "https://lepsiesluzby.sk/",
:context_path => '/jira',
:auth_type => :basic,
:read_timeout => 120
})
end

end
end


61 changes: 7 additions & 54 deletions app/views/components/_feedbackbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
<span class="sdn-feedbackbar__yes" data-module="sdn-appear-link" data-appear="sdn-feedbackbar-thanks" data-disappear="sdn-feedbackbar-useful">
<a href="#" id="ga-feedback-useful" class="sdn-feedbackbar__link">Áno</a>
</span>
<span class="sdn-feedbackbar__no" data-module="sdn-appear-link" data-appear="sdn-feedbackbar-form-no" data-disappear="sdn-feedbackbar-container">
<span class="sdn-feedbackbar__no" data-module="sdn-appear-link" data-appear="sdn-feedbackbar-form-foundbug" data-disappear="sdn-feedbackbar-container">
<a href="#" id="ga-feedback-not-useful" class="sdn-feedbackbar__link">Nie</a>
</span>
</span>
</div>
<div id="sdn-feedbackbar-thanks" class="sdn-appear-link-hide">
Expand All @@ -24,61 +23,11 @@
</span>
</div>
</div>
<div id="sdn-feedbackbar-form-yes" class="sdn-feedbackbar__form govuk-!-padding-4 sdn-appear-link-hide">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h3 class="govuk-heading-m">Ešte posledný krok</h3>
</div>
<div class="govuk-grid-column-one-third" style="text-align:right">
<a href="#" data-module="sdn-appear-link" data-appear="sdn-feedbackbar-container" data-disappear="sdn-feedbackbar-form-yes">Zatvoriť</a>
</div>
</div>
<%= form_with url: feedbacks_path do |form| %>
<%= hidden_field_tag :feedback_type, 'Useful' %>
<%= hidden_field_tag :current_path, request.fullpath %>
<div class="govuk-form-group">
<%= recaptcha_tags hl: 'sk' %>
</div>
<%= form.submit 'Odoslať', class: 'govuk-button', data: { 'disable-with': 'Odosielam...' } %>
<p class="govuk-body feedback-submitted-feedback govuk-!-padding-left-4 govuk-!-padding-top-2 govuk-!-display-inline-block"></p>
<% end %>
</div>
<div id="sdn-feedbackbar-form-no" class="sdn-feedbackbar__form govuk-!-padding-4 sdn-appear-link-hide">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h3 class="govuk-heading-m">Pomôžte nám zlepšiť Návody.Digital</h3>
</div>
<div class="govuk-grid-column-one-third" style="text-align:right">
<a href="#" data-module="sdn-appear-link" data-appear="sdn-feedbackbar-container" data-disappear="sdn-feedbackbar-form-no">Zatvoriť</a>
</div>
</div>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= form_with url: feedbacks_path do |form| %>
<%= hidden_field_tag :feedback_type, 'Not useful' %>
<%= hidden_field_tag :current_path, request.fullpath %>
<div class="govuk-form-group">
<%= label_tag :not_useful_detail, 'Čo by ste chceli na tejto stránke zmeniť?', class: 'govuk-label' %>
<%= text_area_tag :not_useful_detail, nil, class: 'govuk-textarea', rows: 3, required: true %>
</div>
<div class="govuk-form-group">
<%= label_tag :email, 'Vaša e-mailová adresa', class: 'govuk-label' %>
<%= email_field_tag :email, @__current_user&.email, class: 'govuk-input govuk-!-width-two-thirds' %>
</div>
<div class="govuk-form-group">
<%= recaptcha_tags hl: 'sk' %>
</div>
<%= form.submit 'Odoslať', class: 'govuk-button', data: { "disable-with": "Odosielam..." } %>
<p class="govuk-body feedback-submitted-feedback govuk-!-padding-left-4 govuk-!-padding-top-2 govuk-!-display-inline-block"></p>
<% end %>
</div>
</div>
</div>
<div id="sdn-feedbackbar-form-foundbug" class="sdn-feedbackbar__form govuk-!-padding-4 sdn-appear-link-hide">
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds govuk-!-margin-bottom-4">
<h3 class="govuk-heading-m">Nahlásenie chyby</h3>
<p class="govuk-body">Pomocou tohto formuláru môžete nahlásiť chybu v návode, alebo na stránke. Neuvádzajte prosím svoje osobné údaje.</p>
<h3 class="govuk-heading-m">Pomôžte nám zlepšiť Návody.Digital</h3>
<p class="govuk-body">Pomocou tohto formuláru môžete nahlásiť nedostatok v návode alebo na stránke.</p>
</div>
<div class="govuk-grid-column-one-third" style="text-align:right">
<a href="#" data-module="sdn-appear-link" data-appear="sdn-feedbackbar-container" data-disappear="sdn-feedbackbar-form-foundbug">Zatvoriť</a>
Expand All @@ -97,6 +46,10 @@
<%= label_tag :bug_what_went_wrong, 'Čo sa nepodarilo?', class: 'govuk-label' %>
<%= text_area_tag :bug_what_went_wrong, nil, class: 'govuk-textarea', rows: 3, required: true %>
</div>
<div class="govuk-form-group">
<%= label_tag :email, 'Vaša e-mailová adresa', class: 'govuk-label' %>
<%= email_field_tag :email, @__current_user&.email, class: 'govuk-input govuk-!-width-two-thirds' %>
</div>
<div class="govuk-form-group">
<%= recaptcha_tags hl: 'sk' %>
</div>
Expand Down