zendesk_apps_support 3.3.3 → 3.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8760acb02112cebac8b8daca8460f1faedad4e64
4
- data.tar.gz: 17b865646f23c21bcdc07a91e9b045107952e3ae
3
+ metadata.gz: c2cdd80ab3e773cb08066ad7b85e520150249eee
4
+ data.tar.gz: 2c2ed26d634b62778a2807c8122afca66929623d
5
5
  SHA512:
6
- metadata.gz: 63f2b79999d8f52ffb0653a3d59788dbb286c34ab8d7c346a03123997deb602459be6e99e5b7df86f82723775bdbde6cfaec33beffdc469a2f6fcdd4dc694a83
7
- data.tar.gz: 884dca14e438507f1034090774b9c51d5bce8b9079769095db5302cbb4f340868757e57e0e525a9e8bb53d85dbbc81fd63cb74f3127fd5fd9df0f06cc4899741
6
+ metadata.gz: 6bb71ca453c6f05e157e2a650bb435ae7efe0753d7426dc04baeba82dfe5f33dfeb6f910f14b1cea25d5c699c69ce28d2f65803def6f9fc72c9a06801d0726e7
7
+ data.tar.gz: 448acbd4700429e4ed500a5a3750452f63d38a3df43dd1b7a09fd48938b8ef0695fc2dcb0262bfefa793b11f9fc3920460793b29c2eabc0b21fd1e08dd21ce9a
@@ -97,6 +97,9 @@ en:
97
97
  version.
98
98
  locations_cant_be_urls: App locations must not be URLs for this framework
99
99
  version.
100
+ invalid_v1_location:
101
+ one: "%{invalid_locations} is an invalid location in framework v1."
102
+ other: "%{invalid_locations} are invalid locations in framework v1."
100
103
  warning:
101
104
  app_build:
102
105
  deprecated_version: You are targeting a deprecated version of the framework.
@@ -250,3 +250,11 @@ parts:
250
250
  key: "txt.apps.admin.error.app_build.locations_cant_be_urls"
251
251
  title: "The locations can't be URLs, but they were."
252
252
  value: "App locations must not be URLs for this framework version."
253
+ - translation:
254
+ key: "txt.apps.admin.error.app_build.invalid_v1_location.one"
255
+ title: "The location listed is not available in framework v1."
256
+ value: "%{invalid_locations} is an invalid location in framework v1."
257
+ - translation:
258
+ key: "txt.apps.admin.error.app_build.invalid_v1_location.other"
259
+ title: "The locations listed are not available in framework v1."
260
+ value: "%{invalid_locations} are invalid locations in framework v1."
@@ -2,7 +2,7 @@
2
2
  module ZendeskAppsSupport
3
3
  class Location
4
4
  extend ZendeskAppsSupport::Finders
5
- attr_reader :id, :name, :orderable, :product_code
5
+ attr_reader :id, :name, :orderable, :product_code, :v2_only
6
6
 
7
7
  def self.unique_ids
8
8
  @ids ||= Set.new
@@ -15,6 +15,7 @@ module ZendeskAppsSupport
15
15
  @name = attrs.fetch(:name)
16
16
  @orderable = attrs.fetch(:orderable)
17
17
  @product_code = attrs.fetch(:product_code)
18
+ @v2_only = attrs.fetch(:v2_only, product != Product::SUPPORT)
18
19
  end
19
20
 
20
21
  def product
@@ -35,11 +36,15 @@ module ZendeskAppsSupport
35
36
  Location.new(id: 6, orderable: true, name: 'organization_sidebar', product_code: Product::SUPPORT.code),
36
37
  Location.new(id: 7, orderable: false, name: 'background', product_code: Product::SUPPORT.code),
37
38
  Location.new(id: 8, orderable: true, name: 'chat_sidebar', product_code: Product::CHAT.code),
38
- Location.new(id: 9, orderable: false, name: 'modal', product_code: Product::SUPPORT.code),
39
- Location.new(id: 10, orderable: false, name: 'ticket_editor', product_code: Product::SUPPORT.code),
40
- Location.new(id: 11, orderable: false, name: 'nav_bar', product_code: Product::STANDALONE_CHAT.code),
39
+ Location.new(id: 9, orderable: false, name: 'modal', product_code: Product::SUPPORT.code,
40
+ v2_only: true),
41
+ Location.new(id: 10, orderable: false, name: 'ticket_editor', product_code: Product::SUPPORT.code,
42
+ v2_only: true),
43
+ Location.new(id: 11, orderable: false, name: 'nav_bar', product_code: Product::STANDALONE_CHAT.code,
44
+ v2_only: false),
41
45
  Location.new(id: 12, orderable: false, name: 'system_top_bar', product_code: Product::SUPPORT.code),
42
- Location.new(id: 13, orderable: false, name: 'system_top_bar', product_code: Product::STANDALONE_CHAT.code)
46
+ Location.new(id: 13, orderable: false, name: 'system_top_bar', product_code: Product::STANDALONE_CHAT.code,
47
+ v2_only: false)
43
48
  ].freeze
44
49
  end
45
50
  end
@@ -80,8 +80,11 @@ module ZendeskAppsSupport
80
80
  end
81
81
 
82
82
  def unknown_locations(host)
83
+ product = Product.find_by(name: host)
84
+
83
85
  if locations.key?(host)
84
- locations[host].keys.uniq - Location::LOCATIONS_AVAILABLE.map(&:name)
86
+ product_locations = Location.where(product_code: product.code)
87
+ locations[host].keys.uniq - product_locations.map(&:name)
85
88
  else
86
89
  []
87
90
  end
@@ -1,3 +1,4 @@
1
+ # rubocop:disable ModuleLength
1
2
  # frozen_string_literal: true
2
3
  require 'uri'
3
4
 
@@ -6,17 +7,29 @@ module ZendeskAppsSupport
6
7
  module Manifest
7
8
  RUBY_TO_JSON = ZendeskAppsSupport::Manifest::RUBY_TO_JSON
8
9
  REQUIRED_MANIFEST_FIELDS = RUBY_TO_JSON.select { |k| %i(author default_locale).include? k }.freeze
9
- OAUTH_REQUIRED_FIELDS = %w(client_id client_secret authorize_uri access_token_uri).freeze
10
+ OAUTH_REQUIRED_FIELDS = %w(client_id client_secret authorize_uri access_token_uri).freeze
10
11
  PARAMETER_TYPES = ZendeskAppsSupport::Manifest::Parameter::TYPES
11
12
 
12
- class <<self
13
+ class << self
13
14
  def call(package)
14
15
  return [ValidationError.new(:missing_manifest)] unless package.has_file?('manifest.json')
16
+
17
+ collate_manifest_errors(package)
18
+
19
+ rescue JSON::ParserError => e
20
+ return [ValidationError.new(:manifest_not_json, errors: e)]
21
+ end
22
+
23
+ private
24
+
25
+ def collate_manifest_errors(package)
15
26
  manifest = package.manifest
16
27
 
17
28
  errors = []
18
29
  errors << missing_keys_error(manifest)
19
30
  errors << oauth_error(manifest)
31
+ errors << boolean_error(manifest)
32
+ errors << default_locale_error(manifest, package)
20
33
 
21
34
  if manifest.marketing_only?
22
35
  errors << ban_parameters(manifest)
@@ -27,10 +40,6 @@ module ZendeskAppsSupport
27
40
  errors << name_as_parameter_name_error(manifest)
28
41
  errors << no_template_format_error(manifest)
29
42
  end
30
- errors << boolean_error(manifest)
31
- errors << default_locale_error(manifest, package)
32
-
33
- errors << ban_no_template(manifest) if manifest.iframe_only?
34
43
 
35
44
  if manifest.requirements_only? || manifest.marketing_only?
36
45
  errors << ban_location(manifest)
@@ -38,18 +47,17 @@ module ZendeskAppsSupport
38
47
  else
39
48
  errors << missing_location_error(package)
40
49
  errors << invalid_location_error(package)
50
+ errors << invalid_v1_location(package)
41
51
  errors << missing_framework_version(manifest)
42
52
  errors << location_framework_mismatch(manifest)
43
53
  errors << invalid_version_error(manifest, package)
44
54
  end
45
55
 
56
+ errors << ban_no_template(manifest) if manifest.iframe_only?
57
+
46
58
  errors.flatten.compact
47
- rescue JSON::ParserError => e
48
- return [ValidationError.new(:manifest_not_json, errors: e)]
49
59
  end
50
60
 
51
- private
52
-
53
61
  def boolean_error(manifest)
54
62
  booleans = %i(requirements_only marketing_only single_install signed_urls private)
55
63
  errors = []
@@ -178,6 +186,23 @@ module ZendeskAppsSupport
178
186
  errors
179
187
  end
180
188
 
189
+ def invalid_v1_location(package)
190
+ return unless package.manifest.framework_version &&
191
+ Gem::Version.new(package.manifest.framework_version) < Gem::Version.new('2')
192
+
193
+ invalid_locations = package.manifest.location_options
194
+ .map(&:location)
195
+ .compact
196
+ .select(&:v2_only)
197
+ .map(&:name)
198
+
199
+ unless invalid_locations.empty?
200
+ return ValidationError.new(:invalid_v1_location,
201
+ invalid_locations: invalid_locations.join(', '),
202
+ count: invalid_locations.length)
203
+ end
204
+ end
205
+
181
206
  def invalid_location_uri_error(package, path)
182
207
  return nil if path == ZendeskAppsSupport::Manifest::LEGACY_URI_STUB
183
208
  validation_error = ValidationError.new(:invalid_location_uri, uri: path)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk_apps_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.3
4
+ version: 3.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James A. Rosen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-12-21 00:00:00.000000000 Z
14
+ date: 2017-01-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: i18n
@@ -230,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  version: 1.3.6
231
231
  requirements: []
232
232
  rubyforge_project:
233
- rubygems_version: 2.6.8
233
+ rubygems_version: 2.5.1
234
234
  signing_key:
235
235
  specification_version: 4
236
236
  summary: Support to help you develop Zendesk Apps.