# frozen_string_literal: true

module Neetob
  class CLI
    module MonthlyAudit
      module InstancesAndAddons
        module Honeybadger
          class SetupCorrectlyForApps < CLI::Base
            def initialize
              super()
            end

            def run
              ui.success "### 3.4.1. [Manual] Checking whether Honeybadger is correctly set up for apps"
              ui.info "#### Please manually check and add Yes/No for all the following checks on the Honeybadger dashboard for the apps listed in the table below:"
              ui.info "- Settings > General > Project Settings > Enable notifications for production is turned on"
              ui.info "- Settings > Alerts & integrations > This project's integrations > GitHub is integrated to the correct project repo."
              ui.info "- Settings > Alerts & integrations > This project's integrations > GitHub > Edit > Error Events > Automatically create an issue when an error occurs and Automatically re-open issues are turned on"
              ui.info "- Settings > Alerts & integrations > This project's integrations > Slack is integrated to the correct project channel in #neeto-health workspace"
              ui.info "- Please add comments if any for the checks below in the Comments column in the table"
              ui.info "- Finally, set Audit Passed as Yes only if all the checks are passed for the app, otherwise set it as No, and add a comment in the Comments column"

              apps_data = [
                [
                  "App",
                  "Enable Notifications for production is turned on",
                  "GitHub is integrated to the correct project repo",
                  "Automatically create GitHub issue and automatically re-open issue is turned on",
                  "Slack is integrated to the correct project channel in #neeto-health workspace",
                  "Comments",
                  "Audit Passed"
                ]
              ]
              ui.info("\n")
              (
                Neetob::CLI::Sre::Base::APPS_LIST[:neetodeploy] +
                Neetob::CLI::Sre::Base::APPS_LIST[:heroku]
              ).select { |app| app.include?("production") }.each do |app|

                apps_data << [app, nil, nil, nil, nil, nil, nil]
              end
              ui.print_table(apps_data)
            end
          end
        end
      end
    end
  end
end