glib-web 7.0.0.beta1 → 7.0.0

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/glib/auth/policy.rb +5 -1
  3. data/app/controllers/concerns/glib/auth/token_authenticatable.rb +37 -0
  4. data/app/controllers/concerns/glib/json/libs.rb +33 -0
  5. data/app/controllers/glib/api_controller.rb +52 -0
  6. data/app/helpers/glib/json_ui/view_builder/fields.rb +133 -4
  7. data/app/helpers/glib/json_ui/view_builder/panels.rb +8 -144
  8. data/app/jobs/glib/purge_unattached_job.rb +32 -0
  9. data/app/models/concerns/glib/snapshot_v2.rb +514 -0
  10. data/app/models/glib/model.rb +40 -0
  11. data/app/models/glib/plain_model.rb +23 -0
  12. data/app/models/snapshot_blob_reference.rb +20 -0
  13. data/app/views/json_ui/garage/tables/bulk_edit.json.jbuilder +6 -6
  14. data/app/views/json_ui/garage/test_page/_header.json.jbuilder +1 -1
  15. data/app/views/json_ui/garage/test_page/dialog.json.jbuilder +21 -0
  16. data/app/views/json_ui/garage/test_page/fields_change_trigger.json.jbuilder +128 -0
  17. data/app/views/json_ui/garage/test_page/fields_sign.json.jbuilder +49 -1
  18. data/app/views/json_ui/garage/test_page/panels_bulkEdit3.json.jbuilder +2 -2
  19. data/lib/generators/glib/snapshot_v2_generator.rb +54 -0
  20. data/lib/generators/templates/snapshot_v2/add_snapshot_v2_columns.rb +18 -0
  21. data/lib/generators/templates/snapshot_v2/create_snapshot_blob_references.rb +10 -0
  22. data/lib/glib/engine.rb +32 -0
  23. data/lib/glib/json_crawler/action_crawlers/forms_submit.rb +1 -1
  24. data/lib/glib/purge_unattached/config.rb +38 -0
  25. data/lib/glib/test/full_suite_rubocop.rb +87 -0
  26. data/lib/glib/test/rubocop_guards.rb +42 -0
  27. data/lib/glib/test_helpers.rb +9 -7
  28. data/lib/glib-web.rb +4 -2
  29. metadata +29 -3
  30. data/app/views/json_ui/garage/test_page/panels_bulkEdit2.json.jbuilder +0 -244
  31. data/lib/glib/test/changed_files_rubocop.rb +0 -55
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0.beta1
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -23,6 +23,20 @@ dependencies:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
25
  version: '8.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: activejob
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '8.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '8.0'
26
40
  - !ruby/object:Gem::Dependency
27
41
  name: pundit
28
42
  requirement: !ruby/object:Gem::Requirement
@@ -189,6 +203,7 @@ files:
189
203
  - app/controllers/concerns/glib/analytics/funnel.rb
190
204
  - app/controllers/concerns/glib/auth/policy.rb
191
205
  - app/controllers/concerns/glib/auth/response.rb
206
+ - app/controllers/concerns/glib/auth/token_authenticatable.rb
192
207
  - app/controllers/concerns/glib/form_stepper/controller.rb
193
208
  - app/controllers/concerns/glib/form_stepper/step.rb
194
209
  - app/controllers/concerns/glib/json/dynamic_text.rb
@@ -199,6 +214,7 @@ files:
199
214
  - app/controllers/concerns/glib/json/ui.rb
200
215
  - app/controllers/concerns/glib/json/validation.rb
201
216
  - app/controllers/concerns/glib/params/allowlist.rb
217
+ - app/controllers/glib/api_controller.rb
202
218
  - app/controllers/glib/blob_url_generators_controller.rb
203
219
  - app/controllers/glib/errors_controller.rb
204
220
  - app/controllers/glib/glib_direct_uploads_controller.rb
@@ -249,9 +265,11 @@ files:
249
265
  - app/helpers/glib/json_ui/view_builder/multimedia.rb
250
266
  - app/helpers/glib/json_ui/view_builder/panels.rb
251
267
  - app/helpers/glib/urls_helper.rb
268
+ - app/jobs/glib/purge_unattached_job.rb
252
269
  - app/models/concerns/glib/enum_humanization.rb
253
270
  - app/models/concerns/glib/enum_symbolization.rb
254
271
  - app/models/concerns/glib/nilify_blanks.rb
272
+ - app/models/concerns/glib/snapshot_v2.rb
255
273
  - app/models/concerns/glib/soft_deletable.rb
256
274
  - app/models/glib/active_storage/attachment.rb
257
275
  - app/models/glib/active_storage/blob.rb
@@ -259,8 +277,11 @@ files:
259
277
  - app/models/glib/country_list.rb
260
278
  - app/models/glib/dummy_job_application.rb
261
279
  - app/models/glib/dynamic_text_record.rb
280
+ - app/models/glib/model.rb
281
+ - app/models/glib/plain_model.rb
262
282
  - app/models/glib/state_list.rb
263
283
  - app/models/glib/text.rb
284
+ - app/models/snapshot_blob_reference.rb
264
285
  - app/policies/glib/application_policy.rb
265
286
  - app/validators/email_typo_validator.rb
266
287
  - app/validators/email_validator.rb
@@ -433,6 +454,7 @@ files:
433
454
  - app/views/json_ui/garage/test_page/duplicate_names.json.jbuilder
434
455
  - app/views/json_ui/garage/test_page/fields.json.jbuilder
435
456
  - app/views/json_ui/garage/test_page/fields_captcha.json.jbuilder
457
+ - app/views/json_ui/garage/test_page/fields_change_trigger.json.jbuilder
436
458
  - app/views/json_ui/garage/test_page/fields_creditCard.json.jbuilder
437
459
  - app/views/json_ui/garage/test_page/fields_date_time.json.jbuilder
438
460
  - app/views/json_ui/garage/test_page/fields_dynamicSelect.json.jbuilder
@@ -475,7 +497,6 @@ files:
475
497
  - app/views/json_ui/garage/test_page/multimedia_video.json.jbuilder
476
498
  - app/views/json_ui/garage/test_page/pagination.json.jbuilder
477
499
  - app/views/json_ui/garage/test_page/panels.json.jbuilder
478
- - app/views/json_ui/garage/test_page/panels_bulkEdit2.json.jbuilder
479
500
  - app/views/json_ui/garage/test_page/panels_bulkEdit3.json.jbuilder
480
501
  - app/views/json_ui/garage/test_page/popovers.json.jbuilder
481
502
  - app/views/json_ui/garage/test_page/progressCircle.json.jbuilder
@@ -532,12 +553,15 @@ files:
532
553
  - config/routes.rb
533
554
  - lib/active_storage/service/glib_s3_service.rb
534
555
  - lib/generators/glib/install_generator.rb
556
+ - lib/generators/glib/snapshot_v2_generator.rb
535
557
  - lib/generators/templates/20191017062519_create_texts.rb
536
558
  - lib/generators/templates/20191024063257_add_scope_to_texts.rb
537
559
  - lib/generators/templates/20191112095018_add_lang_to_texts.rb
538
560
  - lib/generators/templates/20191126071051_create_active_storage_tables.active_storage.rb
539
561
  - lib/generators/templates/database.yml
540
562
  - lib/generators/templates/dynamic_text.rb
563
+ - lib/generators/templates/snapshot_v2/add_snapshot_v2_columns.rb
564
+ - lib/generators/templates/snapshot_v2/create_snapshot_blob_references.rb
541
565
  - lib/glib-web.rb
542
566
  - lib/glib/all_helpers.rb
543
567
  - lib/glib/crypt/utils.rb
@@ -564,6 +588,7 @@ files:
564
588
  - lib/glib/last_resort_unit_test.rb
565
589
  - lib/glib/mailer_tester.rb
566
590
  - lib/glib/non_http_integration_test.rb
591
+ - lib/glib/purge_unattached/config.rb
567
592
  - lib/glib/rubocop.rb
568
593
  - lib/glib/rubocop/cops/json_ui/base_nested_parameter.rb
569
594
  - lib/glib/rubocop/cops/json_ui/nested_action_parameter.rb
@@ -571,8 +596,9 @@ files:
571
596
  - lib/glib/rubocop/cops/localize.rb
572
597
  - lib/glib/rubocop/cops/test_name_parentheses.rb
573
598
  - lib/glib/snapshot.rb
574
- - lib/glib/test/changed_files_rubocop.rb
599
+ - lib/glib/test/full_suite_rubocop.rb
575
600
  - lib/glib/test/parallel_coverage.rb
601
+ - lib/glib/test/rubocop_guards.rb
576
602
  - lib/glib/test_helpers.rb
577
603
  - lib/glib/time_freezable_mailer.rb
578
604
  - lib/glib/time_returning_mailer.rb
@@ -1,244 +0,0 @@
1
- json.title 'Test Page (Panels Bulk Edit 2)'
2
-
3
- page = json_ui_page json
4
-
5
- options = [{ text: 'yes', value: 'yes' }, { text: 'no', value: 'no' }]
6
- source_options = ['Generators', 'Power Station', 'Solar Panels'].map do |source|
7
- { text: source, value: source }
8
- end
9
-
10
- default_headers = [
11
- { text: 'Month', id: 'month', importable: true, tooltip: { text: 'Month', placement: 'top' } },
12
- { text: 'Electricity usage', id: 'electricity_usage', importable: true },
13
- { text: 'Gas usage', id: 'gas_usage', importable: true },
14
- { text: 'Sources', id: 'sources', importable: true },
15
- { text: 'Compliant', id: 'compliant', importable: true }
16
- ]
17
-
18
- default_cells = [
19
- ->(view) do
20
- view.fields_number width: 'matchParent'
21
- end,
22
- ->(view) do
23
- view.fields_number width: 'matchParent'
24
- end,
25
- ->(view) do
26
- view.fields_number width: 'matchParent'
27
- end,
28
- ->(view) do
29
- view.fields_select width: 'matchParent', options: source_options, multiple: true
30
- end,
31
- ->(view) do
32
- view.fields_select width: 'matchParent', options: options
33
- end
34
- ]
35
-
36
- [
37
- { text: 'Month', id: 'month', importable: true },
38
- { text: 'Usage (kWh)', id: 'electricity_usage', importable: true },
39
- { text: 'Usage (Therms)', id: 'gas_usage', importable: true }
40
- ]
41
-
42
- [
43
- ->(view) do
44
- view.fields_number width: 120
45
- end,
46
- ->(view) do
47
- view.fields_number width: 140
48
- end,
49
- ->(view) do
50
- view.fields_number width: 140
51
- end
52
- ]
53
-
54
- import_settings = { submitUrl: json_ui_garage_url(path: 'forms/bulk_edit_post2'), paramName: 'user' }
55
-
56
- render 'json_ui/garage/test_page/header', json: json, page: page
57
-
58
- page.body(
59
- childViews: ->(body) do
60
- body.panels_responsive(
61
- padding: glib_json_padding_body,
62
- childViews: ->(res) do
63
- res.h2 text: 'Overview'
64
- res.p text: 'panels_bulkEdit2 renders an editable grid with import-backed rows and bulk submission events.'
65
- res.spacer height: 12
66
- res.hr width: 'matchParent'
67
- res.h2 text: 'Basic example'
68
- res.spacer height: 8
69
- res.panels_horizontal(
70
- align: 'middle',
71
- childViews: ->(horizontal) do
72
- horizontal.label text: 'Loaded: '
73
- horizontal.label id: 'bulk_edit_loaded_count', text: '0'
74
- horizontal.spacer width: 12
75
- horizontal.label text: 'Selected: '
76
- horizontal.label id: 'bulk_edit_selected_count', text: '0'
77
- horizontal.spacer width: 12
78
- horizontal.chip id: 'bulk_edit_succeeded_count', styleClass: 'success', text: 'Uploaded: 0', displayed: false
79
- end
80
- )
81
- res.spacer height: 8
82
- res.panels_bulkEdit2(
83
- id: 'bulk_edit_main',
84
- width: 'matchParent',
85
- paramNameForRowId: 'row_id',
86
- # Files with more data rows than this are rejected wholesale with an
87
- # error dialog (the header row doesn't count).
88
- maxRows: 3,
89
- import: import_settings,
90
- viewHeaders: default_headers,
91
- viewCells: default_cells,
92
- onCellChange: ->(action) do
93
- action.snackbars_alert debug: true, paramName: 'message', fieldName: 'row'
94
- end,
95
- onSubmitStart: ->(action) do
96
- action.runMultiple(
97
- childActions: ->(multiple) do
98
- multiple.logics_set targetId: 'bulk_edit_submit_top', data: { disabled: true }
99
- multiple.logics_set targetId: 'bulk_edit_submit_bottom', data: { disabled: true }
100
- multiple.logics_set targetId: 'bulk_edit_cancel', data: { displayed: true }
101
- end
102
- )
103
- end,
104
- onSubmitEnd: ->(action) do
105
- action.runMultiple(
106
- childActions: ->(multiple) do
107
- multiple.logics_set targetId: 'bulk_edit_submit_top', data: { disabled: false }
108
- multiple.logics_set targetId: 'bulk_edit_submit_bottom', data: { disabled: false }
109
- multiple.logics_set targetId: 'bulk_edit_cancel', data: { displayed: false }
110
- end
111
- )
112
- end,
113
- onRowsLoad: ->(action) do
114
- action.runMultiple(
115
- debug: true,
116
- fieldName: 'data',
117
- childActions: ->(multiple) do
118
- multiple.logics_set(
119
- targetId: 'bulk_edit_loaded_count',
120
- debug: true,
121
- paramName: 'variables',
122
- fieldName: 'data',
123
- conditionalData: {
124
- text: { "count": [{ "var": 'data.loadedRows' }] }
125
- }
126
- )
127
- multiple.logics_set targetId: 'bulk_edit_submit_top', data: { displayed: true }
128
- multiple.logics_set targetId: 'bulk_edit_submit_bottom', data: { displayed: true }
129
- end
130
- )
131
- end,
132
- onRowsSelect: ->(action) do
133
- action.logics_set(
134
- targetId: 'bulk_edit_selected_count',
135
- debug: true,
136
- paramName: 'variables',
137
- fieldName: 'data',
138
- conditionalData: {
139
- text: { "count": [{ "var": 'data.selectedRows' }] }
140
- }
141
- )
142
- end,
143
- onRowsSucceed: ->(action) do
144
- action.logics_set(
145
- targetId: 'bulk_edit_succeeded_count',
146
- debug: true,
147
- paramName: 'variables',
148
- fieldName: 'data',
149
- conditionalData: {
150
- text: {
151
- "printf": [
152
- 'Uploaded: {0}',
153
- { "count": [{ "var": 'data.succeededRows' }] }
154
- ]
155
- },
156
- displayed: true
157
- }
158
- )
159
- end
160
- )
161
- res.spacer height: 12
162
- res.panels_flow(
163
- innerPadding: { bottom: 0 },
164
- childViews: ->(flow) do
165
- flow.button(
166
- id: 'bulk_edit_submit_top',
167
- text: 'Submit (top)',
168
- displayed: false,
169
- onClick: ->(action) do
170
- action.forms_submit targetId: 'bulk_edit_main'
171
- end
172
- )
173
- flow.spacer width: 8
174
- flow.button(
175
- id: 'bulk_edit_submit_bottom',
176
- text: 'Submit (bottom)',
177
- displayed: false,
178
- onClick: ->(action) do
179
- action.forms_submit targetId: 'bulk_edit_main'
180
- end
181
- )
182
- flow.spacer width: 8
183
- flow.button(
184
- id: 'bulk_edit_cancel',
185
- text: 'Cancel import',
186
- displayed: false,
187
- onClick: ->(action) do
188
- action.components_invoke targetId: 'bulk_edit_main', name: 'cancelImport'
189
- end
190
- )
191
- end
192
- )
193
- res.spacer height: 12
194
- res.hr width: 'matchParent'
195
- # res.h2 text: 'Variants/props'
196
- # res.spacer height: 8
197
- # res.panels_flow innerPadding: { bottom: 0 }, childViews: ->(flow) do
198
- # flow.button text: 'Default columns', onClick: ->(action) do
199
- # action.logics_set targetId: 'bulk_edit_main', data: { viewHeaders: default_headers, viewCells: default_cells }
200
- # end
201
- # flow.spacer width: 8
202
- # flow.button text: 'Compact columns', onClick: ->(action) do
203
- # action.logics_set targetId: 'bulk_edit_main', data: { viewHeaders: compact_headers, viewCells: compact_cells }
204
- # end
205
- # flow.spacer width: 8
206
- # flow.button text: 'Reset counts', onClick: ->(action) do
207
- # action.runMultiple childActions: ->(multiple) do
208
- # multiple.logics_set targetId: 'bulk_edit_loaded_count', data: { text: '0' }
209
- # multiple.logics_set targetId: 'bulk_edit_selected_count', data: { text: '0' }
210
- # multiple.logics_set targetId: 'bulk_edit_succeeded_count', data: { text: 'Uploaded: 0', displayed: false }
211
- # end
212
- # end
213
- # end
214
- # res.spacer height: 12
215
- # res.hr width: 'matchParent'
216
- res.h2 text: 'Actions/events'
217
- res.spacer height: 8
218
- res.panels_flow(
219
- innerPadding: { bottom: 0 },
220
- childViews: ->(flow) do
221
- flow.button(
222
- text: 'Submit (forms_submit)',
223
- onClick: ->(action) do
224
- action.forms_submit targetId: 'bulk_edit_main'
225
- end
226
- )
227
- flow.spacer width: 8
228
- flow.button(
229
- text: 'Cancel import (invoke)',
230
- onClick: ->(action) do
231
- action.components_invoke targetId: 'bulk_edit_main', name: 'cancelImport'
232
- end
233
- )
234
- end
235
- )
236
- res.spacer height: 12
237
- res.hr width: 'matchParent'
238
- res.h2 text: 'Edge/advanced'
239
- res.spacer height: 8
240
- res.label text: 'Swap to compact headers then try editing rows before submitting.'
241
- end
242
- )
243
- end
244
- )
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'English'
4
- require 'shellwords'
5
-
6
- module Glib
7
- module Test
8
- # Fast RuboCop guard for the subset-run workflow.
9
- #
10
- # Lives in glib-web's test helper so any project that includes
11
- # `Glib::TestHelpers` into `ActiveSupport::TestCase` picks it up. Minitest
12
- # runs all loaded test classes on every invocation, so this fires on every
13
- # `rails test` — but it lints ONLY the files you have changed in the
14
- # working tree (unstaged + staged + untracked). That keeps it fast and
15
- # fails the run the moment an edited file has an offense.
16
- #
17
- # Skip with `SKIP_CHANGED_RUBOCOP=1` during tight debug loops. Auto-skips
18
- # on CI because gem caches put thousands of vendored `.rb` files into the
19
- # working tree (the "working-tree diff == your edits" premise breaks).
20
- class ChangedFilesRubocop < ::ActiveSupport::TestCase
21
- # Extensions RuboCop targets by default (see its AllCops/Include). We
22
- # rely on `--force-exclusion` to honour the project's AllCops/Exclude.
23
- RUBOCOP_EXTENSIONS = %w[.rb .rake .jbuilder .gemspec].freeze
24
-
25
- def test_changed_files_are_rubocop_clean
26
- skip 'opted out via SKIP_CHANGED_RUBOCOP' if ENV['SKIP_CHANGED_RUBOCOP'] == '1'
27
- skip 'CI lints every file separately; this guard is for local working-tree edits' if ENV['CI']
28
-
29
- files = changed_ruby_files
30
- # IMPORTANT: never call rubocop with zero paths — it would lint the whole repo.
31
- skip 'no changed Ruby files in the working tree' if files.empty?
32
-
33
- output = `bundle exec rubocop --force-exclusion --format simple #{files.shelljoin} 2>&1`
34
-
35
- assert(
36
- $CHILD_STATUS.success?,
37
- 'RuboCop offenses in files you changed (fix them with `rubocop -a`):' \
38
- "\n\n#{output}"
39
- )
40
- end
41
-
42
- private
43
- def changed_ruby_files
44
- # `git status --porcelain` covers unstaged, staged, and untracked in
45
- # one spawn. Each line is `XY PATH` (or `XY ORIG -> PATH` for
46
- # renames); PATH starts at index 3. Deleted files are dropped by the
47
- # File.file? check below (no on-disk entry to lint).
48
- `git status --porcelain`
49
- .split("\n")
50
- .filter_map { |line| line[3..]&.split(' -> ')&.last }
51
- .select { |path| RUBOCOP_EXTENSIONS.include?(File.extname(path)) && File.file?(path) }
52
- end
53
- end
54
- end
55
- end