lanes 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/client/lanes/Config.coffee +3 -1
  4. data/client/lanes/access/screens/user-management/UserManagement.cjsx +2 -2
  5. data/client/lanes/components/grid/Body.cjsx +8 -1
  6. data/client/lanes/components/grid/EditingMixin.cjsx +5 -2
  7. data/client/lanes/components/grid/Grid.cjsx +1 -1
  8. data/client/lanes/components/grid/PopOverMixin.cjsx +1 -1
  9. data/client/lanes/components/grid/row-editor.scss +6 -0
  10. data/client/lanes/components/grid/styles.scss +1 -1
  11. data/client/lanes/components/record-finder/RecordFinder.cjsx +22 -16
  12. data/client/lanes/components/select-field/SelectField.cjsx +20 -27
  13. data/client/lanes/components/shared/DateTime.cjsx +12 -23
  14. data/client/lanes/components/shared/DisplayValue.cjsx +5 -10
  15. data/client/lanes/components/shared/FieldMixin.cjsx +107 -56
  16. data/client/lanes/components/shared/FieldWrapper.cjsx +59 -6
  17. data/client/lanes/components/shared/FormGroup.cjsx +3 -8
  18. data/client/lanes/components/shared/Helpers.coffee +1 -1
  19. data/client/lanes/components/shared/Icon.cjsx +1 -1
  20. data/client/lanes/components/shared/ImageAsset.cjsx +46 -0
  21. data/client/lanes/components/shared/Input.cjsx +5 -1
  22. data/client/lanes/components/shared/InputFieldMixin.cjsx +8 -27
  23. data/client/lanes/components/shared/NumberInput.cjsx +11 -4
  24. data/client/lanes/components/shared/RadioField.cjsx +18 -8
  25. data/client/lanes/components/shared/ScreenWrapper.cjsx +1 -1
  26. data/client/lanes/components/shared/TextArea.cjsx +15 -0
  27. data/client/lanes/components/shared/ToggleField.cjsx +11 -19
  28. data/client/lanes/components/shared/fields.scss +22 -76
  29. data/client/lanes/components/shared/{image-saver.scss → image-asset.scss} +1 -1
  30. data/client/lanes/components/shared/styles.scss +1 -1
  31. data/client/lanes/components/toolbar/RemoteChangeSets.cjsx +13 -10
  32. data/client/lanes/components/toolbar/changes-notification.scss +14 -1
  33. data/client/lanes/extension/Base.coffee +5 -1
  34. data/client/lanes/models/Asset.coffee +81 -0
  35. data/client/lanes/models/AssociationMap.coffee +14 -5
  36. data/client/lanes/models/AssociationProxy.coffee +9 -6
  37. data/client/lanes/models/Base.coffee +6 -3
  38. data/client/lanes/models/Collection.coffee +1 -3
  39. data/client/lanes/models/JobStatus.coffee +3 -0
  40. data/client/lanes/models/Query.coffee +3 -2
  41. data/client/lanes/models/Sync.coffee +6 -4
  42. data/client/lanes/react/mixins/Access.coffee +1 -1
  43. data/client/lanes/react/mixins/Data.coffee +33 -31
  44. data/client/lanes/screens/Commands.coffee +0 -1
  45. data/client/lanes/screens/Definitions.coffee +1 -1
  46. data/client/lanes/screens/SystemSettings.cjsx +23 -11
  47. data/client/lanes/screens/UserPreferences.cjsx +3 -2
  48. data/client/lanes/styles/bootstrap-custom-grid.scss +6 -4
  49. data/client/lanes/styles/fonts.scss +9 -0
  50. data/client/lanes/styles/global/styles.scss +1 -0
  51. data/client/lanes/styles/variables.scss +1 -1
  52. data/client/lanes/testing/Helpers.coffee +5 -3
  53. data/client/lanes/vendor/development/base.js +17206 -19211
  54. data/client/lanes/vendor/development/calendar.js +67 -471
  55. data/client/lanes/vendor/development/commons.js +21680 -19814
  56. data/client/lanes/vendor/development/helpers.js +40 -29
  57. data/client/lanes/vendor/development/toggle.js +22 -19
  58. data/client/lanes/vendor/development/widgets.js +2476 -2625
  59. data/client/lanes/vendor/production/base.js +19034 -21038
  60. data/client/lanes/vendor/production/calendar.js +67 -471
  61. data/client/lanes/vendor/production/commons.js +21369 -19136
  62. data/client/lanes/vendor/production/toggle.js +22 -19
  63. data/client/lanes/vendor/production/widgets.js +2476 -2625
  64. data/client/lanes/vendor/styles/widgets.scss +2 -0
  65. data/client/lanes/workspace/FirstRun.cjsx +69 -0
  66. data/client/lanes/workspace/Navbar.cjsx +4 -2
  67. data/client/lanes/workspace/ScreenView.cjsx +9 -1
  68. data/client/lanes/workspace/index.js +1 -0
  69. data/client/lanes/workspace/styles/screens.scss +11 -0
  70. data/config/database.yml +2 -2
  71. data/db/migrate/01_create_system_settings.rb +0 -1
  72. data/db/migrate/02_create_assets.rb +15 -0
  73. data/lanes.gemspec +25 -28
  74. data/lib/lanes/access/authentication_provider.rb +20 -7
  75. data/lib/lanes/access/role_collection.rb +9 -2
  76. data/lib/lanes/api/default_routes.rb +4 -4
  77. data/lib/lanes/api/formatted_reply.rb +15 -11
  78. data/lib/lanes/api/handlers/asset.rb +37 -0
  79. data/lib/lanes/api/request_wrapper.rb +18 -4
  80. data/lib/lanes/api/routing.rb +17 -6
  81. data/lib/lanes/api/updates.rb +1 -1
  82. data/lib/lanes/api.rb +1 -1
  83. data/lib/lanes/asset.rb +38 -0
  84. data/lib/lanes/concerns/all.rb +1 -1
  85. data/lib/lanes/concerns/asset_uploader.rb +60 -0
  86. data/lib/lanes/configuration.rb +1 -2
  87. data/lib/lanes/extension.rb +1 -1
  88. data/lib/lanes/logger.rb +26 -16
  89. data/lib/lanes/system_settings.rb +13 -8
  90. data/lib/lanes/version.rb +1 -1
  91. data/lib/lanes.rb +1 -0
  92. data/npm-build/base.js +1 -1
  93. data/npm-build/package.json +9 -9
  94. data/spec/command-reference-files/initial/Gemfile +1 -1
  95. data/spec/fixtures/logo.png +0 -0
  96. data/spec/lanes/components/grid/PopoverEditorSpec.coffee +48 -0
  97. data/spec/server/asset_spec.rb +34 -0
  98. data/spec/server/spec_helper.rb +14 -2
  99. metadata +118 -127
  100. data/client/lanes/components/shared/ControlLabel.cjsx +0 -45
  101. data/client/lanes/components/shared/ImageSaver.cjsx +0 -33
  102. data/client/lanes/models/SystemSettings.coffee +0 -0
  103. data/client/lanes/models/mixins/FileSupport.coffee +0 -60
  104. data/lib/lanes/api/handlers/file.rb +0 -26
  105. data/lib/lanes/concerns/image_uploader.rb +0 -42
@@ -97,7 +97,7 @@ module Lanes
97
97
  root_view: Lanes.config.root_view,
98
98
  csrf_token: view.session[:csrf],
99
99
  environment: Lanes.config.environment,
100
- system_settings: Lanes::SystemSettings.config.as_json,
100
+ system_settings: Lanes::SystemSettings.config.as_json(include: 'logo'),
101
101
  assets_path_prefix: Lanes.config.assets_path_prefix,
102
102
  controlling_extension: controlling.identifier,
103
103
  initial_workspace_screen_id: Lanes.config.initial_workspace_screen_id
data/lib/lanes/logger.rb CHANGED
@@ -26,22 +26,7 @@ module Lanes
26
26
 
27
27
  class << self
28
28
  def logger
29
- @logger ||= (
30
- if defined?(::Rails)
31
- Rails.logger
32
- else
33
- if Lanes.env.production?
34
- dest = if FileTest.writable?("log/production.log")
35
- "log/production.log"
36
- else
37
- STDOUT
38
- end
39
- ::Logger.new(dest)
40
- else
41
- ::Logger.new MultiDestinationLogger.new
42
- end
43
- end
44
- )
29
+ @logger ||= _create_logger
45
30
  end
46
31
 
47
32
  def logger=( logger )
@@ -64,10 +49,35 @@ module Lanes
64
49
  logger.debug '⚡ '*40
65
50
  end
66
51
 
52
+ private
53
+
54
+ def _create_logger
55
+ if defined?(::Rails)
56
+ Rails.logger
57
+ else
58
+ if Lanes.env.production?
59
+ dest = if FileTest.writable?("log/production.log")
60
+ "log/production.log"
61
+ else
62
+ STDOUT
63
+ end
64
+ logger = ::Logger.new(dest)
65
+ logger.level = ::Logger::WARN
66
+ logger
67
+ else
68
+ logger = ::Logger.new MultiDestinationLogger.new
69
+ logger.level = ::Logger::DEBUG
70
+ logger
71
+ end
72
+ end
73
+ end
74
+
75
+
67
76
  end
68
77
 
69
78
  Lanes.config.get(:environment) do | env |
70
79
  self.logger=nil # it'll be re-opened on next write
71
80
  end
72
81
 
82
+
73
83
  end
@@ -2,7 +2,7 @@ module Lanes
2
2
 
3
3
  class SystemSettings < Lanes::Model
4
4
 
5
- mount_uploader :logo, Lanes::Concerns::ImageUploader
5
+ has_one :logo, as: :owner, :class_name=>'Lanes::Asset', :dependent => :destroy
6
6
 
7
7
  class ExtensionSettings < OpenStruct
8
8
  def initialize(ext_id, settings)
@@ -14,11 +14,15 @@ module Lanes
14
14
  end
15
15
  def apply!
16
16
  CarrierWave.configure do |config|
17
- config.storage = Lanes.config.storage_type
18
- config.root = Lanes::Extensions.controlling
19
- .root_path.join('public/files').to_s
20
- config.asset_host = Lanes.config.api_path + '/file'
21
- config.fog_credentials = self.fog_credentials
17
+ config.storage = Lanes.config.storage_type.to_sym
18
+ config.root = lambda {
19
+ Lanes::Extensions.controlling
20
+ .root_path.join('public/files').to_s
21
+ }
22
+ config.asset_host = Lanes.config.api_path + '/asset'
23
+ if self.fog_credentials and Object.const_defined?(:Fog)
24
+ config.fog_credentials = self.fog_credentials
25
+ end
22
26
  config.ignore_integrity_errors = false
23
27
  config.ignore_processing_errors = false
24
28
  config.ignore_download_errors = false
@@ -61,7 +65,6 @@ module Lanes
61
65
  def clear_cache!(msg)
62
66
  Lanes.logger.debug "SystemSettings cache reset"
63
67
  Lanes::SystemSettings.instance_variable_set(:@config, nil)
64
- Lanes::Configuration.apply
65
68
  end
66
69
  end
67
70
 
@@ -69,7 +72,9 @@ module Lanes
69
72
  Lanes.redis_connection(cache:false).subscribe(
70
73
  'lanes-system-configuration-update') do |on|
71
74
  on.message do |channel, msg|
72
- Lanes::SystemSettings.clear_cache!(msg)
75
+ ActiveRecord::Base.connection_pool.with_connection do
76
+ Lanes::SystemSettings.clear_cache!(msg)
77
+ end
73
78
  end
74
79
  end
75
80
  end
data/lib/lanes/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Lanes
2
2
 
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
 
5
5
  end
data/lib/lanes.rb CHANGED
@@ -15,6 +15,7 @@ require_relative "lanes/concerns/all"
15
15
  require_relative "lanes/validators/all"
16
16
  require_relative "lanes/model"
17
17
  require_relative "lanes/system_settings"
18
+ require_relative "lanes/asset"
18
19
  require_relative "lanes/components"
19
20
  require_relative "lanes/extension"
20
21
  require_relative "lanes/screen"
data/npm-build/base.js CHANGED
@@ -23,7 +23,7 @@ Lanes.log = require('loglevel');
23
23
  Lanes.Vendor.ld = require('lodash');
24
24
  var spf = require('sprintf-js');
25
25
 
26
- Lanes.Vendor.React.__spread = Lanes.Vendor.ld.assign;
26
+
27
27
 
28
28
  Lanes.Vendor.ld.mixin(require('lodash-inflection'));
29
29
 
@@ -6,18 +6,18 @@
6
6
  "version": "0.1.0",
7
7
  "main": "vendor.js",
8
8
  "dependencies": {
9
- "ampersand-collection": "~1.6",
10
- "ampersand-collection-lodash-mixin": "~1.0",
9
+ "ampersand-collection": "~2.0",
10
+ "ampersand-collection-lodash-mixin": "~4.0",
11
11
  "ampersand-dom": "~1.5",
12
- "ampersand-rest-collection": "~5.0",
12
+ "ampersand-rest-collection": "~6.0",
13
13
  "ampersand-state": "~5.0",
14
14
  "ampersand-events": "~2.0",
15
- "ampersand-filtered-subcollection": "~2.0",
15
+ "ampersand-filtered-subcollection": "~3.0",
16
16
  "big.js": "~3.1",
17
17
  "classnames": "~2.2",
18
18
  "dayz": "0.6.3",
19
19
  "get-object-path": "~0.0.3",
20
- "history": "^2.0.1",
20
+ "history": "^2.1.0",
21
21
  "lodash": "^4.6.1",
22
22
  "lodash-inflection": "^1.3.2",
23
23
  "loglevel": "1.4.0",
@@ -26,13 +26,13 @@
26
26
  "object-assign": "^4.0.1",
27
27
  "react": "*",
28
28
  "react-addons-test-utils": "^15.0",
29
- "react-bootstrap": "^0.28.5",
29
+ "react-bootstrap": "^0.29.4",
30
30
  "react-component-resizable": "git://github.com/justinanastos/react-component-resizable#8c995a6a624fee7f9651e18c6177f79d41244898",
31
31
  "react-deep-force-update": "^2.0.1",
32
32
  "react-dom": "^15.0",
33
- "react-list": "^0.7.16",
33
+ "react-list": "^0.7.18",
34
34
  "react-toggle": "^2.1.0",
35
- "react-widgets": "^3.3.0",
35
+ "react-widgets": "^3.3.1",
36
36
  "rsvp": "~3.2",
37
37
  "sorty": "^1.2.2",
38
38
  "sprintf-js": "^1.0.3",
@@ -51,7 +51,7 @@
51
51
  "less": "^2.6.1",
52
52
  "less-loader": "^2.2.3",
53
53
  "url-loader": "^0.5.7",
54
- "webpack": "^1.12.14"
54
+ "webpack": "^1.13.0"
55
55
  },
56
56
  "jshintConfig": {
57
57
  "asi": false,
@@ -3,7 +3,7 @@ source 'https://rubygems.org'
3
3
  # For development while Lanes is evolving track master branch
4
4
  gem "lanes", github: 'argosity/lanes', branch: 'master'
5
5
 
6
- # gem "lanes", '0.3.0'
6
+ # gem "lanes", '0.4.0'
7
7
 
8
8
  gem "rake"
9
9
  gem 'puma'
Binary file
@@ -0,0 +1,48 @@
1
+ #= require lanes/components/grid
2
+
3
+ COLLECTION_DATA = [
4
+ {id:1, code:'TEST1', name: 'Nathan Stitt', notes: 'swell guy'}
5
+ {id:2, code:'TEST2', name: 'Nathan Stitt', notes: 'Dupe of id #1'}
6
+ ]
7
+
8
+ ROW_DATA = _.map COLLECTION_DATA, (r) -> _.values(r)
9
+
10
+ Model = Lanes.Test.defineModel(
11
+ props: {id: 'integer', code: 'string', name: 'string', notes: 'string'}
12
+ )
13
+
14
+ LAST_ROW_SELECTOR = '.grid-body .r:last-child'
15
+ ADD_ROW_SELECTOR = 'button.add-row'
16
+
17
+ describe "Lanes.Components.Grid.PopoverEditor", ->
18
+
19
+ beforeEach (done) ->
20
+ @query = new Lanes.Models.Query(
21
+ fields: [ 'id', 'code', 'name', 'notes' ], src: Model
22
+ )
23
+ Lanes.Test.syncSucceedWith(ROW_DATA)
24
+ @query.ensureLoaded().then(done)
25
+ @grid = LT.renderComponent(LC.Grid, props: {
26
+ editor: Lanes.Components.Grid.PopoverEditor
27
+ query: @query, allowCreate: true
28
+ })
29
+
30
+ it "edits", (done) ->
31
+ _.dom(@grid).qs(LAST_ROW_SELECTOR).click(clientX: 5)
32
+ editor = Lanes.Test.Utils.findRenderedComponentWithType(
33
+ @grid, Lanes.Components.Grid.PopoverEditor
34
+ )
35
+ _.dom(editor).qs('.field:nth-of-type(3) input').setValue('BOB')
36
+ _.dom(editor).qs('.btn.save').click()
37
+ expect( @query.results.rowAt(1)[2] ).toEqual('BOB')
38
+ done()
39
+
40
+ it 'adds row', (done) ->
41
+ _.dom(@grid).qs(ADD_ROW_SELECTOR).click()
42
+ editor = Lanes.Test.Utils.findRenderedComponentWithType(
43
+ @grid, Lanes.Components.Grid.PopoverEditor
44
+ )
45
+ _.dom(editor).qs('.field:nth-of-type(3) input').setValue('BOB')
46
+ _.dom(editor).qs('.btn.save').click()
47
+ expect( @query.results.rowAt(0)[2] ).toEqual('BOB')
48
+ done()
@@ -0,0 +1,34 @@
1
+ require_relative "spec_helper"
2
+ require "lanes/cli"
3
+ require "find"
4
+
5
+ class Lanes::AssetTest < Lanes::TestCase
6
+
7
+ include TestingModels
8
+
9
+ def setup
10
+ TestModel.has_one :asset, as: :owner, :class_name=>'Lanes::Asset'
11
+ @model = TestModel.new
12
+ end
13
+
14
+ def test_saveing_image
15
+ @model.build_asset(file: fixtures_path.join('logo.png').open)
16
+ assert @model.save
17
+ assert_equal @model.asset.as_json['metadata'], {
18
+ 'content_type' => 'image/png',
19
+ 'width' => 500,
20
+ 'height' => 223,
21
+ 'size' => 49172
22
+ }
23
+ end
24
+
25
+ def test_saving_blob
26
+ @model.build_asset(file: fixtures_path.join('system_settings.yml').open)
27
+ assert @model.save
28
+ assert_equal @model.asset.as_json['metadata'], {
29
+ 'content_type' => 'text/x-yaml',
30
+ 'size' => 1
31
+ }
32
+ end
33
+
34
+ end
@@ -11,7 +11,15 @@ module TestingModels
11
11
  include ActiveRecordMocks::IncludeMe
12
12
 
13
13
  def around(&block)
14
- self.with_testing_models(&block)
14
+ cw_root = CarrierWave.root
15
+ begin
16
+ Dir.mktmpdir('lanes-cw-root') do | dir |
17
+ CarrierWave.root = dir
18
+ self.with_testing_models(&block)
19
+ end
20
+ ensure
21
+ CarrierWave.root = cw_root
22
+ end
15
23
  end
16
24
 
17
25
  def with_testing_models
@@ -59,6 +67,10 @@ module TestingModels
59
67
 
60
68
  end
61
69
 
62
- class TestCase < ActiveSupport::TestCase
70
+ class Lanes::TestCase
71
+
72
+ def fixtures_path
73
+ Pathname.new(__FILE__).dirname.join("..","fixtures").expand_path
74
+ end
63
75
 
64
76
  end