Skip to content

Commit 846e6fb

Browse files
ThenkeiGuillaumeCiscoforest-botSteveBunlonSeyZ
authored
chore: merge master into beta (#494)
* fix: fix time based graph when timezone is different with database (#476) * chore(release): 6.4.1 [skip ci] ## [6.4.1](v6.4.0...v6.4.1) (2021-06-01) ### Bug Fixes * fix time based graph when timezone is different with database ([#476](#476)) ([5d9fb89](5d9fb89)) * feat(schema): move some meta data under stack attribute to prevent blocking scenarios on DWO (#469) * chore(release): 6.5.0 [skip ci] # [6.5.0](v6.4.1...v6.5.0) (2021-06-03) ### Features * **schema:** move some meta data under stack attribute to prevent blocking scenarios on DWO ([#469](#469)) ([76aa754](76aa754)) * Fix broken image links in the README * fix: allow smart action endpoints to start with slashes * chore(release): 6.5.1 [skip ci] ## [6.5.1](v6.5.0...v6.5.1) (2021-06-08) ### Bug Fixes * allow smart action endpoints to start with slashes ([d4f6a61](d4f6a61)) * allow smart action endpoints to start with slashes ([cf6c6a9](cf6c6a9)) * style: fix alt text in README (#484) * feat: include role in the user data inside the request (#478) * chore(release): 6.6.0 [skip ci] # [6.6.0](v6.5.1...v6.6.0) (2021-06-09) ### Features * include role in the user data inside the request ([#478](#478)) ([0a34716](0a34716)) * fix: support permissions infos with ruby < 2.7 (#486) * chore(release): 6.6.1 [skip ci] ## [6.6.1](v6.6.0...v6.6.1) (2021-06-10) ### Bug Fixes * support permissions infos with ruby < 2.7 ([#486](#486)) ([a611271](a611271)) * fix: stats permissions should be retrieved only one time per team (#489) * fix: stats permissions should be retrieved only one time per team * chore: fix the version of semantic-release (#492) * chore(release): 6.6.2 [skip ci] ## [6.6.2](v6.6.1...v6.6.2) (2021-06-16) ### Bug Fixes * stats permissions should be retrieved only one time per team ([#489](#489)) ([c2e9104](c2e9104)) Co-authored-by: Cisco Guillaume <[email protected]> Co-authored-by: Forest Bot <[email protected]> Co-authored-by: SteveBunlon <[email protected]> Co-authored-by: Sandro Munda <[email protected]> Co-authored-by: Sliman <[email protected]> Co-authored-by: slimane <[email protected]> Co-authored-by: Olessya KOROVINA <[email protected]> Co-authored-by: Guillaume Gautreau <[email protected]>
1 parent 67e429f commit 846e6fb

File tree

15 files changed

+120
-51
lines changed

15 files changed

+120
-51
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ jobs:
8383
- name: Semantic Release
8484
uses: cycjimmy/semantic-release-action@v2
8585
id: semantic
86+
with:
87+
semantic_version: 17.3.0
8688
env:
8789
GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
8890
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

CHANGELOG.md

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
## [6.6.2](https://github.com/ForestAdmin/forest-rails/compare/v6.6.1...v6.6.2) (2021-06-16)
2+
3+
4+
### Bug Fixes
5+
6+
* stats permissions should be retrieved only one time per team ([#489](https://github.com/ForestAdmin/forest-rails/issues/489)) ([c2e9104](https://github.com/ForestAdmin/forest-rails/commit/c2e9104ebf32deeb3e5676706fdcbaae5de34869))
7+
8+
## [6.6.1](https://github.com/ForestAdmin/forest-rails/compare/v6.6.0...v6.6.1) (2021-06-10)
9+
10+
11+
### Bug Fixes
12+
13+
* support permissions infos with ruby < 2.7 ([#486](https://github.com/ForestAdmin/forest-rails/issues/486)) ([a611271](https://github.com/ForestAdmin/forest-rails/commit/a611271e709bb6a9ed0d3ebccfb64b6eea1d324d))
14+
15+
# [6.6.0](https://github.com/ForestAdmin/forest-rails/compare/v6.5.1...v6.6.0) (2021-06-09)
16+
17+
18+
### Features
19+
20+
* include role in the user data inside the request ([#478](https://github.com/ForestAdmin/forest-rails/issues/478)) ([0a34716](https://github.com/ForestAdmin/forest-rails/commit/0a347165897aa118e486895e55f4b29ba7fb888b))
21+
22+
## [6.5.1](https://github.com/ForestAdmin/forest-rails/compare/v6.5.0...v6.5.1) (2021-06-08)
23+
24+
25+
### Bug Fixes
26+
27+
* **dependency:** now using forestadmin-jsonapi-serializers instead of the jsonapi-serializers gem ([#475](https://github.com/ForestAdmin/forest-rails/issues/475)) ([3feea36](https://github.com/ForestAdmin/forest-rails/commit/3feea36b3b578638f3ad7c16ebab8e457a68d71f))
28+
29+
30+
### BREAKING CHANGES
31+
32+
* **dependency:** Switch from jsonapi-serializers to forestadmin-jsonapi-serializers to serialize data to the JSONAPI format, mainly to avoid conflict with the jsonapi-serializer library
33+
* allow smart action endpoints to start with slashes ([d4f6a61](https://github.com/ForestAdmin/forest-rails/commit/d4f6a618aeea72364b0e7511545b67fbbfb17c99))
34+
* allow smart action endpoints to start with slashes ([cf6c6a9](https://github.com/ForestAdmin/forest-rails/commit/cf6c6a96498e6813e4b7ccaa56cacd9abefc332f))
35+
136
# [7.0.0-beta.2](https://github.com/ForestAdmin/forest-rails/compare/v7.0.0-beta.1...v7.0.0-beta.2) (2021-06-07)
237

338

@@ -11,17 +46,22 @@
1146
* **hooks:** fields parameters on hook function is no longer a map of field, it is now an array.
1247
change hook is no longer choosen by the field name, field need to have hook defined inside it definition by addin a props hook.
1348

14-
# [7.0.0-beta.1](https://github.com/ForestAdmin/forest-rails/compare/v6.4.1-beta.1...v7.0.0-beta.1) (2021-06-01)
1549

1650

17-
### Bug Fixes
51+
# [6.5.0](https://github.com/ForestAdmin/forest-rails/compare/v6.4.1...v6.5.0) (2021-06-03)
1852

19-
* **dependency:** now using forestadmin-jsonapi-serializers instead of the jsonapi-serializers gem ([#475](https://github.com/ForestAdmin/forest-rails/issues/475)) ([3feea36](https://github.com/ForestAdmin/forest-rails/commit/3feea36b3b578638f3ad7c16ebab8e457a68d71f))
2053

54+
### Features
2155

22-
### BREAKING CHANGES
56+
* **schema:** move some meta data under stack attribute to prevent blocking scenarios on DWO ([#469](https://github.com/ForestAdmin/forest-rails/issues/469)) ([76aa754](https://github.com/ForestAdmin/forest-rails/commit/76aa7540300f75b0ea1d00ec3b60e4976b7d800e))
2357

24-
* **dependency:** Switch from jsonapi-serializers to forestadmin-jsonapi-serializers to serialize data to the JSONAPI format, mainly to avoid conflict with the jsonapi-serializer library
58+
# [7.0.0-beta.1](https://github.com/ForestAdmin/forest-rails/compare/v6.4.1-beta.1...v7.0.0-beta.1) (2021-06-01)
59+
## [6.4.1](https://github.com/ForestAdmin/forest-rails/compare/v6.4.0...v6.4.1) (2021-06-01)
60+
61+
62+
### Bug Fixes
63+
64+
* fix time based graph when timezone is different with database ([#476](https://github.com/ForestAdmin/forest-rails/issues/476)) ([5d9fb89](https://github.com/ForestAdmin/forest-rails/commit/5d9fb8903ae53615dd1789bdebbc4d9c7d6f4576))
2565

2666
# [6.4.0](https://github.com/ForestAdmin/forest-rails/compare/v6.3.8...v6.4.0) (2021-05-26)
2767

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ This project has been designed with scalability in mind to fit requirements from
3434
## How it works
3535

3636
<p align="center" style="margin: 60px 0">
37-
<img width="100%" src="https://www.forestadmin.com/public/img/rails/schemas/schema-1.png" alt="Howitworks">
37+
<img width="100%" src="https://forest-assets.s3.amazonaws.com/Github+README+assets/howitworks.png" alt="Howitworks">
3838
</p>
3939

4040
Forest Admin consists of two components:
@@ -55,23 +55,23 @@ All of your CRUD operations are natively supported. The API automatically
5555
supports your data models' validation and allows you to easily extend or
5656
override any API routes' with your very own custom logic.
5757

58-
<img src="https://www.forestadmin.com/public/img/illustrations-dev/screens/ForestWebsite20-CRUD.jpg" alt="CRUD">
58+
<img src="https://forest-assets.s3.amazonaws.com/Github+README+assets/crud.jpeg" alt="CRUD">
5959

6060
### Search & Filters
6161

6262
Forest Admin has a built-in search allowing you to run basic queries to
6363
retrieve your application's data. Set advanced filters based on fields and
6464
relationships to handle complex search use cases.
6565

66-
<img src="https://www.forestadmin.com/public/img/illustrations-dev/screens/ForestWebsite20-Search.jpg" alt="Search and Filters">
66+
<img src="https://forest-assets.s3.amazonaws.com/Github+README+assets/search+filters.jpeg" alt="Search and Filters">
6767

6868
### Sorting & Pagination
6969

7070
Sorting and pagination features are natively handled by the Admin API. We're
7171
continuously optimizing how queries are run in order to display results faster
7272
and reduce the load of your servers.
7373

74-
<img src="https://www.forestadmin.com/public/img/illustrations-dev/screens/ForestWebsite20-Sorting.jpg" alt="Sorting and Pagination">
74+
<img src="https://forest-assets.s3.amazonaws.com/Github+README+assets/sorting+pagination.jpeg" alt="Sorting and Pagination">
7575

7676
### Custom action
7777

@@ -80,49 +80,49 @@ a custom logic. With virtually no limitations, you can extend the way you
8080
manipulate data and trigger actions (e.g. refund a customer, apply a coupon,
8181
ban a user, etc.)
8282

83-
<img src="https://www.forestadmin.com/public/img/illustrations-dev/screens/ForestWebsite20-Custom.jpg" alt="Sorting and Pagination">
83+
<img src="https://forest-assets.s3.amazonaws.com/Github+README+assets/custom+actions.jpeg" alt="Custom action">
8484

8585
### Export
8686

8787
Sometimes you need to export your data to a good old fashioned CSV. Yes, we
8888
know this can come in handy sometimes :-)
8989

90-
<img src="https://www.forestadmin.com/public/img/illustrations-dev/screens/ForestWebsite20-Export.jpg" alt="Export">
90+
<img src="https://forest-assets.s3.amazonaws.com/Github+README+assets/exports.jpeg" alt="Export">
9191

9292
### Segments
9393

9494
Get in app access to a subset of your application data by doing a basic search
9595
or typing an SQL query or implementing an API route.
9696

97-
<img src="https://www.forestadmin.com/public/img/illustrations-dev/screens/ForestWebsite20-Segments.jpg" alt="Segments">
97+
<img src="https://forest-assets.s3.amazonaws.com/Github+README+assets/segments.jpeg" alt="Segments">
9898

9999
### Dashboards
100100

101101
Forest Admin is able to tap into your actual data to chart out your metrics
102102
using a simple UI panel, a SQL query or a custom API call.
103103

104-
<img src="https://www.forestadmin.com/public/img/illustrations-dev/screens/ForestWebsite20-Dashboard.jpg" alt="Dashboard">
104+
<img src="https://forest-assets.s3.amazonaws.com/Github+README+assets/dashboards.jpeg" alt="Dashboard">
105105

106106
### WYSIWYG
107107

108108
The WYSIWYG interface saves you a tremendous amount of frontend development
109109
time using drag'n'drop as well as advanced widgets to build customizable views.
110110

111-
<img src="https://www.forestadmin.com/public/img/illustrations-dev/screens/ForestWebsite20-Wysiwyg.jpg" alt="WYSIWYG">
111+
<img src="https://forest-assets.s3.amazonaws.com/Github+README+assets/wysiwyg.jpeg" alt="WYSIWYG">
112112

113113
### Custom HTML/JS/CSS
114114

115115
Code your own views using JS, HTML, and CSS to display your application data in
116116
a more appropriate way (e.g. Kanban, Map, Calendar, Gallery, etc.).
117117

118-
<img src="https://www.forestadmin.com/public/img/illustrations-dev/screens/ForestWebsite20-CustomHTML.jpg" alt="Custom views">
118+
<img src="https://forest-assets.s3.amazonaws.com/Github+README+assets/smart+views.jpeg" alt="Custom views">
119119

120120
### Team-based permissions
121121

122122
Without any lines of code, manage directly from the UI who has access or can
123123
act on which data using a team-based permission system.
124124

125-
<img src="https://www.forestadmin.com/public/img/illustrations-dev/screens/ForestWebsite20-Teams.jpg" alt="Team based permissions">
125+
<img src="https://forest-assets.s3.amazonaws.com/Github+README+assets/teams.jpeg" alt="Team based permissions">
126126

127127
### Third-party integrations
128128

@@ -131,21 +131,21 @@ application’s data and providing it directly to your Admin Panel. All your
131131
actions can be performed at the same place, bringing additional intelligence to
132132
your Admin Panel and ensuring consistency.
133133

134-
<img src="https://www.forestadmin.com/public/img/illustrations-dev/screens/ForestWebsite20-3rdParty.jpg" alt="Third-party integrations">
134+
<img src="https://forest-assets.s3.amazonaws.com/Github+README+assets/integrations.jpeg" alt="Third-party integrations">
135135

136136
### Notes & Comments
137137

138138
Assign your teammates to specific tasks, leave a note or simply comment a
139139
record, thereby simplifying collaboration all across your organization.
140140

141-
<img src="https://www.forestadmin.com/public/img/illustrations-dev/screens/ForestWebsite20-Notes.jpg" alt="Notes and Comments">
141+
<img src="https://forest-assets.s3.amazonaws.com/Github+README+assets/notes+comments.jpeg" alt="Notes and Comments">
142142

143143
### Activity logs
144144

145145
Monitor each action executed and follow the trail of modification on any data
146146
with an extensive activity log system.
147147

148-
<img src="https://www.forestadmin.com/public/img/illustrations-dev/screens/ForestWebsite20-Activity.jpg" alt="Activity logs">
148+
<img src="https://forest-assets.s3.amazonaws.com/Github+README+assets/activity+logs.jpeg" alt="Activity logs">
149149

150150
## How to contribute
151151

app/controllers/forest_liana/smart_actions_controller.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,8 @@ def find_resource(collection_name)
5757

5858
# smart action permissions are retrieved from the action's endpoint and http_method
5959
def get_smart_action_request_info
60-
endpoint = request.fullpath
61-
# Trim starting '/'
62-
endpoint[0] = '' if endpoint[0] == '/'
6360
{
64-
endpoint: endpoint,
61+
endpoint: request.fullpath,
6562
http_method: request.request_method
6663
}
6764
end

app/services/forest_liana/apimap_sorter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def perform
9393
end
9494
end
9595

96+
@apimap['meta']['stack'] = reorder_keys_basic(@apimap['meta']['stack'])
9697
@apimap['meta'] = reorder_keys_basic(@apimap['meta'])
9798
@apimap
9899
rescue => exception

app/services/forest_liana/line_stat_getter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def get_format
2323
end
2424

2525
def perform
26-
value = get_resource().eager_load(@includes)
26+
value = get_resource().joins(@includes)
2727

2828
unless @params[:filters].blank?
2929
value = FiltersParser.new(@params[:filters], value, @params[:timezone]).apply_filters

app/services/forest_liana/permissions_checker.rb

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module ForestLiana
22
class PermissionsChecker
33
@@permissions_cached = Hash.new
4-
@@scopes_cached = Hash.new
4+
@@renderings_cached = Hash.new
55
@@roles_acl_activated = false
66
# TODO: handle cache scopes per rendering
77
@@expiration_in_seconds = (ENV['FOREST_PERMISSIONS_EXPIRATION_IN_SECONDS'] || 3600).to_i
@@ -39,13 +39,16 @@ def fetch_permissions
3939
permissions['data'] = ForestLiana::PermissionsFormatter.convert_to_new_format(permissions['data'], @rendering_id)
4040
@@permissions_cached[@rendering_id] = permissions
4141
end
42+
43+
# NOTICE: Add stats permissions to the RenderingPermissions
44+
permissions['data']['renderings'][@rendering_id]['stats'] = permissions['stats']
4245
add_scopes_to_cache(permissions)
4346
end
4447

4548
def add_scopes_to_cache(permissions)
4649
permissions['data']['renderings'].keys.each { |rendering_id|
47-
@@scopes_cached[rendering_id] = permissions['data']['renderings'][rendering_id]
48-
@@scopes_cached[rendering_id]['last_fetch'] = Time.now
50+
@@renderings_cached[rendering_id] = permissions['data']['renderings'][rendering_id]
51+
@@renderings_cached[rendering_id]['last_fetch'] = Time.now
4952
} if permissions['data']['renderings']
5053
end
5154

@@ -59,8 +62,6 @@ def is_allowed
5962
return stat_with_parameters_allowed?
6063
end
6164

62-
63-
6465
if permissions && permissions[@collection_name] &&
6566
permissions[@collection_name]['collection']
6667
if @permission_name === 'actions'
@@ -83,21 +84,25 @@ def is_allowed
8384
end
8485

8586
def get_scope_in_permissions
86-
@@scopes_cached[@rendering_id] &&
87-
@@scopes_cached[@rendering_id][@collection_name] &&
88-
@@scopes_cached[@rendering_id][@collection_name]['scope']
87+
@@renderings_cached[@rendering_id] &&
88+
@@renderings_cached[@rendering_id][@collection_name] &&
89+
@@renderings_cached[@rendering_id][@collection_name]['scope']
8990
end
9091

9192
def scope_cache_expired?
92-
return true unless @@scopes_cached[@rendering_id] && @@scopes_cached[@rendering_id]['last_fetch']
93+
return true unless @@renderings_cached[@rendering_id] && @@renderings_cached[@rendering_id]['last_fetch']
9394

94-
elapsed_seconds = date_difference_in_seconds(Time.now, @@scopes_cached[@rendering_id]['last_fetch'])
95+
elapsed_seconds = date_difference_in_seconds(Time.now, @@renderings_cached[@rendering_id]['last_fetch'])
9596
elapsed_seconds >= @@expiration_in_seconds
9697
end
9798

9899
# This will happen only on rolesACLActivated (as scope cache will always be up to date on disabled)
99100
def refresh_scope_cache
100101
permissions = ForestLiana::PermissionsGetter::get_permissions_for_rendering(@rendering_id, rendering_specific_only: true)
102+
103+
# NOTICE: Add stats permissions to the RenderingPermissions
104+
permissions['data']['renderings'][@rendering_id]['stats'] = permissions['stats']
105+
101106
add_scopes_to_cache(permissions)
102107
end
103108

@@ -112,12 +117,12 @@ def get_permissions_content
112117
end
113118

114119
def get_live_query_permissions_content
115-
permissions = get_permissions
120+
permissions = @@renderings_cached[@rendering_id]
116121
permissions && permissions['stats'] && permissions['stats']['queries']
117122
end
118123

119124
def get_stat_with_parameters_content(statPermissionType)
120-
permissions = get_permissions
125+
permissions = @@renderings_cached[@rendering_id]
121126
permissions && permissions['stats'] && permissions['stats'][statPermissionType]
122127
end
123128

@@ -177,7 +182,7 @@ def stat_with_parameters_allowed?
177182
return false unless pool_permissions
178183

179184
# NOTICE: equivalent to Object.values in js & removes nil values
180-
array_permission_infos = @query_request_info.values.filter_map{ |x| x unless x.nil? }
185+
array_permission_infos = @query_request_info.values.select{ |x| !x.nil? }
181186

182187
# NOTICE: Is there any pool_permissions containing the array_permission_infos
183188
return pool_permissions.any? {
@@ -201,7 +206,7 @@ def have_permissions_expired?
201206
# Used only for testing purpose
202207
def self.empty_cache
203208
@@permissions_cached = Hash.new
204-
@@scopes_cached = Hash.new
209+
@@renderings_cached = Hash.new
205210
@@roles_acl_activated = false
206211
@@expiration_in_seconds = (ENV['FOREST_PERMISSIONS_EXPIRATION_IN_SECONDS'] || 3600).to_i
207212
end

app/services/forest_liana/token.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def self.create_token(user, rendering_id)
1919
first_name: user['first_name'],
2020
last_name: user['last_name'],
2121
team: user['teams'][0],
22+
role: user['role'],
2223
rendering_id: rendering_id,
2324
exp: expiration_in_seconds()
2425
}, ForestLiana.auth_secret, 'HS256')

app/services/forest_liana/utils/beta_schema_utils.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def self.find_action_from_endpoint(collection_name, endpoint, http_method)
66

77
return nil unless collection
88

9-
collection.actions.find { |action| action.endpoint == endpoint && action.http_method == http_method }
9+
collection.actions.find { |action| (action.endpoint == endpoint || "/#{action.endpoint}" == endpoint) && action.http_method == http_method }
1010
end
1111
end
1212
end

lib/forest_liana/bootstrapper.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,12 @@ def namespace_duplicated_models
203203

204204
def setup_forest_liana_meta
205205
ForestLiana.meta = {
206-
database_type: database_type,
207206
liana: 'forest-rails',
208207
liana_version: ForestLiana::VERSION,
209-
orm_version: Gem.loaded_specs["activerecord"].version.version
208+
stack: {
209+
database_type: database_type,
210+
orm_version: Gem.loaded_specs["activerecord"].version.version,
211+
}
210212
}
211213
end
212214

0 commit comments

Comments
 (0)