Skip to content

Commit d111312

Browse files
committed
Merge branch 'v3.0.0' into devel
2 parents 3d50ecf + d82c337 commit d111312

29 files changed

+891
-394
lines changed

CHANGELOG.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,89 @@
22

33
## [Unreleased]
44

5+
## RELEASE 3.0.0-beta.18 - 2019-04-10
6+
### Fixed
7+
- Search - Enable PostgreSQL's CITEXT fields in search.
8+
9+
## RELEASE 3.0.0-beta.17 - 2019-04-04
10+
### Changed
11+
- Error Handling - Display an explicit error message if the envSecret is detected as missing or unknown during data a API request.
12+
13+
## RELEASE 3.0.0-beta.16 - 2019-03-29
14+
### Fixed
15+
- Security - Fix implementation of session token passed in headers while downloading collections records.
16+
17+
## RELEASE 3.0.0-beta.15 - 2019-03-27
18+
### Changed
19+
- Security - Do not pass session token in query params while downloading collections records.
20+
21+
## RELEASE 3.0.0-beta.14 - 2019-03-01
22+
### Fixed
23+
- Records Display - Restrict record data serialization based the schema collection fields in the #create and #update actions.
24+
25+
## RELEASE 3.0.0-beta.13 - 2019-02-28
26+
### Fixed
27+
- Records Display - Restrict record data serialization based the schema collection fields in the #show action.
28+
29+
## RELEASE 3.0.0-beta.12 - 2019-02-28
30+
### Fixed
31+
- Records Display - Ensure that the data is properly sent even if an attribute serialization happens for an unknown reason.
32+
33+
## RELEASE 3.0.0-beta.11 - 2019-02-27
34+
### Fixed
35+
- Filters - Fix resources display if filtered with associations conditions with the related columns hidden in the list. 🛡
36+
37+
## RELEASE 3.0.0-beta.10 - 2019-02-26
38+
### Fixed
39+
- Schema - Ensure that unhandled field types are not defined anymore in collections schemas. 🛡
40+
41+
## RELEASE 3.0.0-beta.9 - 2019-02-25
42+
### Fixed
43+
- Charts - Fix Value charts having filters on associations targeting a collection having with a custom table name. 🛡
44+
- Charts - Fix Value charts having filters on associations targeting a collection associated through multiple `belongs_to` association to the current resource. 🛡
45+
46+
## RELEASE 3.0.0-beta.8 - 2019-02-20
47+
### Fixed
48+
- Export - Fix broken export action. [Regression introduced in 3.0.0-beta.7]
49+
50+
## RELEASE 3.0.0-beta.7 - 2019-02-06
51+
### Fixed
52+
- Filters - Fix association filtering on collections having several associations targeting the same table.
53+
54+
## RELEASE 3.0.0-beta.6 - 2019-02-01
55+
### Added
56+
- Charts - Users can create "Leaderboard" charts.
57+
- Charts - Users can create "Objective" charts.
58+
- Technical - Add a new apimap property "relationship".
59+
60+
## RELEASE 3.0.0-beta.5 - 2019-01-30
61+
### Fixed
62+
- Validations - Remove badly set validations on Array fields.
63+
64+
## RELEASE 3.0.0-beta.4 - 2019-01-30
65+
### Fixed
66+
- Schema - Fix empty validations set in the schema file.
67+
68+
## RELEASE 3.0.0-beta.3 - 2019-01-30
69+
### Fixed
70+
- Build - Fix liana version set in the `.forestadmin-schema.json` meta.
71+
72+
## RELEASE 3.0.0-beta.2 - 2019-01-30
73+
### Fixed
74+
- Build - Fix liana version set in the `.forestadmin-schema.json` meta.
75+
76+
## RELEASE 3.0.0-beta.1 - 2019-01-30
77+
### Fixed
78+
- Build - Fix regressions in the build script.
79+
80+
## RELEASE 3.0.0-beta.0 - 2019-01-30
81+
### Added
82+
- Developer Experience - On start, create a `.forestadmin-schema.json` file that contains the schema definition.
83+
- Developer Experience - On production, load `.forestadmin-schema.json` for schema update.
84+
85+
### Changed
86+
- Schema - Developers can deactivate the automatic schema sending on server start (using `FOREST_DISABLE_AUTO_SCHEMA_APPLY` environment variable, deprecating `FOREST_DEACTIVATE_AUTOMATIC_APIMAP`).
87+
588
## RELEASE 2.15.8 - 2019-03-01
689
### Fixed
790
- Records Display - Restrict record data serialization based the schema collection fields in the #create and #update actions.

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
forest_liana (2.15.8)
4+
forest_liana (3.0.0.pre.beta.18)
55
arel-helpers
66
base32
77
bcrypt

app/controllers/forest_liana/application_controller.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
module ForestLiana
55
class ApplicationController < ForestLiana::BaseController
6+
REGEX_COOKIE_SESSION_TOKEN = /forest_session_token=([^;]*)/;
7+
68
def self.papertrail?
79
Object.const_get('PaperTrail::Version').is_a?(Class) rescue false
810
end
@@ -56,11 +58,13 @@ def serialize_models(records, options = {}, fields_searched = [])
5658

5759
def authenticate_user_from_jwt
5860
begin
59-
if request.headers['Authorization'] || params['sessionToken']
61+
if request.headers
6062
if request.headers['Authorization']
6163
token = request.headers['Authorization'].split.second
62-
else
63-
token = params['sessionToken']
64+
# NOTICE: Necessary for downloads authentication.
65+
elsif request.headers['cookie']
66+
match = REGEX_COOKIE_SESSION_TOKEN.match(request.headers['cookie'])
67+
token = match[1] if match && match[1]
6468
end
6569

6670
@jwt_decoded_token = JWT.decode(token, ForestLiana.auth_secret, true,

app/controllers/forest_liana/base_controller.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def reject_unauthorized_ip
2020
end
2121
end
2222
rescue ForestLiana::Errors::ExpectedError => exception
23-
exception.display_error
2423
error_data = JSONAPI::Serializer.serialize_errors([{
2524
status: exception.error_code,
2625
detail: exception.message

app/controllers/forest_liana/sessions_controller.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ def process_login(
8282

8383
render(serializer: nil, json: nil, status: :internal_server_error)
8484
else
85+
# NOTICE: Set a cookie to ensure secure authentication using export feature.
86+
# NOTICE: The token is empty at first authentication step if the 2FA option is active.
87+
response.set_cookie("forest_session_token", reponse_data[:token]) if reponse_data[:token]
88+
8589
render(json: reponse_data, serializer: nil)
8690
end
8791
end

app/models/forest_liana/model/action.rb

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,68 @@ class ForestLiana::Model::Action
44
include ActiveModel::Serialization
55
extend ActiveModel::Naming
66

7-
# TODO: Remove :global option when we remove the deprecation warning.
8-
attr_accessor :id, :name, :endpoint, :http_method, :fields, :redirect,
9-
:global, :type, :download
7+
attr_accessor :id, :name, :base_url, :endpoint, :http_method, :fields, :redirect,
8+
:type, :download
109

1110
def initialize(attributes = {})
11+
if attributes.key?(:global)
12+
FOREST_LOGGER.error "REMOVED OPTION: The support for Smart Action \"global\" option is now " \
13+
"removed. Please set \"type: 'global'\" instead of \"global: true\" for the " \
14+
"\"#{attributes[:name]}\" Smart Action."
15+
end
16+
17+
18+
if attributes.key?(:type) && !['bulk', 'global', 'single'].include?(attributes[:type])
19+
FOREST_LOGGER.warn "Please set a valid Smart Action type (\"bulk\", \"global\" or " \
20+
"\"single\") for the \"#{attributes[:name]}\" Smart Action."
21+
end
22+
1223
attributes.each do |name, value|
1324
send("#{name}=", value)
1425
end
26+
27+
@fields ||= []
28+
29+
has_fields_without_name = false
30+
31+
@fields.delete_if do |field|
32+
if field.key?(:field)
33+
false
34+
else
35+
has_fields_without_name = true
36+
true
37+
end
38+
end
39+
40+
@fields.map! do |field|
41+
if field.key?(:isRequired)
42+
FOREST_LOGGER.warn "DEPRECATION WARNING: isRequired on field \"#{field[:field]}\" is deprecated. Please use is_required."
43+
field[:is_required] = !!field[:isRequired]
44+
field.delete(:isRequired)
45+
end
46+
47+
field[:type] = "String" unless field.key?(:type)
48+
field[:default_value] = nil unless field.key?(:default_value)
49+
field[:enums] = nil unless field.key?(:enums)
50+
field[:is_required] = false unless field.key?(:is_required)
51+
field[:reference] = nil unless field.key?(:reference)
52+
field[:description] = nil unless field.key?(:description)
53+
field[:widget] = nil unless field.key?(:widget)
54+
field
55+
end
56+
57+
if has_fields_without_name
58+
FOREST_LOGGER.warn "Please set a name to all your \"#{@name}\" Smart Action fields " \
59+
"(Smart Actions fields without name are ignored)."
60+
end
61+
62+
dasherized_name = @name.downcase.gsub!(" ", "-") unless @name.nil?
63+
@endpoint ||= "forest/actions/#{dasherized_name}" unless dasherized_name.nil?
64+
@http_method ||= "POST"
65+
@redirect ||= nil
66+
@base_url ||= nil
67+
@type ||= "bulk"
68+
@download ||= false
1569
end
1670

1771
def persisted?

app/models/forest_liana/model/collection.rb

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,49 @@ class ForestLiana::Model::Collection
55
extend ActiveModel::Naming
66

77
attr_accessor :name, :fields, :actions, :segments, :only_for_relationships,
8-
:is_virtual, :is_read_only, :is_searchable, :display_name, :icon,
8+
:is_virtual, :is_read_only, :is_searchable, :icon,
99
:integration, :pagination_type, :search_fields,
1010
# TODO: Remove once lianas prior to 2.0.0 are not supported anymore.
1111
:name_old
1212

1313
def initialize(attributes = {})
14-
@actions = []
15-
@segments = []
16-
@is_searchable = true
17-
@is_read_only = false
18-
@search_fields = nil
19-
2014
attributes.each do |name, value|
2115
send("#{name}=", value)
2216
end
17+
18+
init_properties_with_default
19+
end
20+
21+
def init_properties_with_default
22+
@name_old ||= @name
23+
@is_virtual ||= false
24+
@icon ||= nil
25+
@is_read_only ||= false
26+
@is_searchable = true if @is_searchable.nil?
27+
@only_for_relationships ||= false
28+
@pagination_type ||= "page"
29+
@search_fields ||= nil
30+
@fields ||= []
31+
@actions ||= []
32+
@segments ||= []
33+
34+
@fields = @fields.map do |field|
35+
field[:type] = "String" unless field.key?(:type)
36+
field[:default_value] = nil unless field.key?(:default_value)
37+
field[:enums] = nil unless field.key?(:enums)
38+
field[:integration] = nil unless field.key?(:integration)
39+
field[:is_filterable] = true unless field.key?(:is_filterable)
40+
field[:is_read_only] = false unless field.key?(:is_read_only)
41+
field[:is_required] = false unless field.key?(:is_required)
42+
field[:is_sortable] = true unless field.key?(:is_sortable)
43+
field[:is_virtual] = false unless field.key?(:is_virtual)
44+
field[:reference] = nil unless field.key?(:reference)
45+
field[:inverse_of] = nil unless field.key?(:inverse_of)
46+
field[:relationship] = nil unless field.key?(:relationship)
47+
field[:widget] = nil unless field.key?(:widget)
48+
field[:validations] = nil unless field.key?(:validations)
49+
field
50+
end
2351
end
2452

2553
def persisted?
@@ -32,13 +60,13 @@ def id
3260

3361
def fields_smart_belongs_to
3462
fields.select do |field|
35-
field[:'is-virtual'] && field[:type] == 'String' && !field[:reference].nil?
63+
field[:'is_virtual'] && field[:type] == 'String' && !field[:reference].nil?
3664
end
3765
end
3866

3967
def string_smart_fields_names
4068
fields
41-
.select { |field| field[:'is-virtual'] && field[:type] == 'String' }
69+
.select { |field| field[:'is_virtual'] && field[:type] == 'String' }
4270
.map { |field| field[:field].to_s }
4371
end
4472
end

app/models/forest_liana/model/segment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def initialize(attributes = {}, &block)
1010
attributes.each do |name, value|
1111
send("#{name}=", value)
1212
end
13-
13+
1414
@where = block if block
1515
end
1616

app/serializers/forest_liana/action_serializer.rb

Lines changed: 0 additions & 21 deletions
This file was deleted.

app/serializers/forest_liana/collection_serializer.rb

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)