Module: Dradis::Plugins::Mappings::Ticketing::FieldsAndSources

Extended by:
ActiveSupport::Concern
Defined in:
app/controllers/concerns/dradis/plugins/mappings/ticketing/fields_and_sources.rb

Overview

Shared by ticketing integrations' MappingsControllers (e.g. Jira, VSTS, ServiceNow) to list Dradis Report Templates as mapping sources. Distinct from Dradis::Plugins::Mappings::Base, which handles the opposite direction (mapping inbound upload data into Dradis fields).

Instance Method Summary collapse

Instance Method Details

#set_rtp_fieldsObject



18
19
20
21
22
23
# File 'app/controllers/concerns/dradis/plugins/mappings/ticketing/fields_and_sources.rb', line 18

def set_rtp_fields
  @rtp_fields = ReportTemplateProperties.all.filter_map do |rtp|
    next if rtp.issue_fields.count == 0
    [rtp.id, rtp.issue_fields.map(&:name)]
  end.to_h
end

#set_rtp_fields_and_sourcesObject



13
14
15
16
# File 'app/controllers/concerns/dradis/plugins/mappings/ticketing/fields_and_sources.rb', line 13

def set_rtp_fields_and_sources
  set_rtp_fields
  set_sources
end

#set_sourcesObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/concerns/dradis/plugins/mappings/ticketing/fields_and_sources.rb', line 25

def set_sources
  @sources = ReportTemplateProperties.all.group_by(&:plugin_name).map do |plugin_name, rtps|
    mapped_rtps = rtps.map do |rtp|
      suffix = ''
      options = {}
      if rtp.issue_fields.count == 0
        suffix = ' (no issue fields)'
        options = { disabled: 'disabled' }
      end
      [rtp.title + suffix, rtp.id, options]
    end
    [plugin_name.titleize, mapped_rtps]
  end
end