maestrano-connector-rails 2.0.0.pre.RC9 → 2.0.0.pre.RC10
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 +4 -4
- data/CHANGELOG.md +10 -0
- data/VERSION +1 -1
- data/app/models/maestrano/connector/rails/organization.rb +1 -1
- data/lib/generators/connector/templates/home_controller.rb +10 -16
- data/lib/generators/connector/templates/home_index.haml +18 -18
- data/lib/generators/connector/templates/oauth_controller.rb +5 -7
- data/maestrano-connector-rails.gemspec +2 -2
- data/spec/models/organization_spec.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b84ee19b8cb4c3c76c762e3fdc902cc59e5e2ec6
|
4
|
+
data.tar.gz: 8b828b5c3cdf10bcf1e7b65ff3991ad3f5cbc224
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94dbd9143e6e01e37180ecf7ac329d56f1c3b88d28afc9cdb30a41c44dad5c3e1e0e884b24e2341effbfa1bb7b39b04620966300d86e62fb65e8fccb98154bf3
|
7
|
+
data.tar.gz: 689d3157aa9a71533bbe9915e4a4005f2c9b4250f897452ba80a76bdccc3a8ceaf4b04d6ad96006d4829556a08734a81316f6c6fe9437200f0e1e358633ab67f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 2.0.0
|
2
|
+
|
3
|
+
### Features
|
4
|
+
* Configuration driven from the [Maestrano Developer Platform](https://dev-platform.maestrano.com)
|
5
|
+
|
6
|
+
### Migration guide
|
7
|
+
* Follow migration steps up to framework version 1.5.0
|
8
|
+
* Replace ocurrences of `@organizations` with `current_organization` in `home_index.haml`
|
9
|
+
* Developer Platform registration to be detailed
|
10
|
+
|
1
11
|
## 1.5.0
|
2
12
|
|
3
13
|
### Breaking changes
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.pre.
|
1
|
+
2.0.0.pre.RC10
|
@@ -38,7 +38,7 @@ module Maestrano::Connector::Rails
|
|
38
38
|
validates :name, presence: true
|
39
39
|
validates :tenant, presence: true
|
40
40
|
validates :uid, uniqueness: {scope: :tenant}
|
41
|
-
validates :oauth_uid, uniqueness: {message: 'This account has already been linked'}
|
41
|
+
validates :oauth_uid, uniqueness: {allow_blank: true, message: 'This account has already been linked'}
|
42
42
|
|
43
43
|
#===================================
|
44
44
|
# Serialized field
|
@@ -1,25 +1,19 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
class HomeController < ApplicationController
|
3
|
-
def index
|
4
|
-
@organization = current_organization
|
5
|
-
@displayable_synchronized_entities = @organization.displayable_synchronized_entities if @organization
|
6
|
-
end
|
7
|
-
|
8
3
|
def update
|
9
|
-
|
10
|
-
return redirect_to(:back) unless organization && is_admin?(current_user, organization)
|
4
|
+
return redirect_to(:back) unless is_admin
|
11
5
|
|
12
6
|
# Update list of entities to synchronize
|
13
|
-
|
14
|
-
|
7
|
+
current_organization.synchronized_entities.keys.each do |entity|
|
8
|
+
current_organization.synchronized_entities[entity] = params[entity.to_s].present?
|
15
9
|
end
|
16
|
-
|
17
|
-
|
18
|
-
trigger_sync =
|
19
|
-
|
10
|
+
current_organization.sync_enabled = current_organization.synchronized_entities.values.any?
|
11
|
+
current_organization.enable_historical_data(params['historical-data'].present?)
|
12
|
+
trigger_sync = current_organization.sync_enabled && current_organization.sync_enabled_changed?
|
13
|
+
current_organization.save
|
20
14
|
|
21
15
|
# Trigger sync only if the sync has been enabled
|
22
|
-
start_synchronization
|
16
|
+
start_synchronization if trigger_sync
|
23
17
|
|
24
18
|
redirect_to(:back)
|
25
19
|
end
|
@@ -38,8 +32,8 @@ class HomeController < ApplicationController
|
|
38
32
|
|
39
33
|
private
|
40
34
|
|
41
|
-
def start_synchronization
|
42
|
-
Maestrano::Connector::Rails::SynchronizationJob.perform_later(
|
35
|
+
def start_synchronization
|
36
|
+
Maestrano::Connector::Rails::SynchronizationJob.perform_later(current_organization.id, {})
|
43
37
|
flash[:info] = 'Congrats, you\'re all set up! Your data are now being synced'
|
44
38
|
end
|
45
39
|
end
|
@@ -6,8 +6,8 @@
|
|
6
6
|
.col-md-10.col-md-offset-2
|
7
7
|
%h2 ApplicationName Connector
|
8
8
|
%p
|
9
|
-
-if
|
10
|
-
Link your company <strong>#{
|
9
|
+
-if current_organization
|
10
|
+
Link your company <strong>#{current_organization.name} (#{current_organization.uid})</strong> to ApplicationName to get your business in synch. Check the status of your connection on this screen.
|
11
11
|
-else
|
12
12
|
Link your account to ApplicationName to get your business in synch. Check the status of your connection on this screen.
|
13
13
|
|
@@ -18,29 +18,29 @@
|
|
18
18
|
.col-md-12.alert.alert-warning
|
19
19
|
Only administrators can modify the application settings
|
20
20
|
|
21
|
-
.row.link-step{class: "#{
|
21
|
+
.row.link-step{class: "#{current_organization.oauth_uid ? 'done' : 'todo'}"}
|
22
22
|
.col-md-1.text-center.link-step-number
|
23
23
|
%span.badge.link-step-badge
|
24
24
|
1
|
25
25
|
.col-md-6.link-step-description
|
26
26
|
%h
|
27
|
-
- if
|
28
|
-
Your ApplicationName account <strong>#{
|
27
|
+
- if current_organization.oauth_uid
|
28
|
+
Your ApplicationName account <strong>#{current_organization.oauth_name} (#{current_organization.oauth_uid})</strong> is currently linked
|
29
29
|
- else
|
30
30
|
Your ApplicationName account is not linked
|
31
31
|
.col-md-2.col-md-offset-3.text-center.link-step-action
|
32
|
-
- if
|
33
|
-
= link_to "Disconnect", signout_omniauth_path(organization_id:
|
32
|
+
- if current_organization.oauth_uid
|
33
|
+
= link_to "Disconnect", signout_omniauth_path(organization_id: current_organization.id), class: "btn btn-warning btn-lg #{is_admin ? '' : 'disabled'}"
|
34
34
|
- else
|
35
35
|
- if is_admin
|
36
|
-
= link_to "Link to ApplicationName", "/auth/ApplicationName/request?org_uid=#{
|
36
|
+
= link_to "Link to ApplicationName", "/auth/ApplicationName/request?org_uid=#{current_organization.uid}", class: 'btn btn-warning btn-lg'
|
37
37
|
%br
|
38
38
|
%small If you don’t have an account #{link_to 'create yours here', Maestrano::Connector::Rails::External.create_account_link(current_organization || nil)}
|
39
39
|
|
40
40
|
.spacer1
|
41
41
|
|
42
|
-
.row.link-step{class: "#{(
|
43
|
-
= form_tag home_update_path(id:
|
42
|
+
.row.link-step{class: "#{(current_organization.sync_enabled && current_organization.synchronized_entities.values.any?) ? 'done' : 'todo'}"}
|
43
|
+
= form_tag home_update_path(id: current_organization.id), method: :put do
|
44
44
|
.col-md-1.text-center.link-step-number
|
45
45
|
%span.badge.link-step-badge 2
|
46
46
|
.col-md-9.link-step-description
|
@@ -55,7 +55,7 @@
|
|
55
55
|
.spacer1
|
56
56
|
.row
|
57
57
|
.col-md-11.col-md-offset-1
|
58
|
-
-
|
58
|
+
- current_organization.displayable_synchronized_entities.each do |k, v|
|
59
59
|
.row.sync-entity
|
60
60
|
.col-md-1.link-step-action
|
61
61
|
%input{type: "checkbox", id: "#{k}", name: "#{k}", checked: v[:value]}
|
@@ -66,7 +66,7 @@
|
|
66
66
|
#{v[:connec_name]}
|
67
67
|
-if is_admin
|
68
68
|
.col-md-3.text-right
|
69
|
-
- if v &&
|
69
|
+
- if v && current_organization.oauth_uid && current_organization.sync_enabled
|
70
70
|
= link_to 'Force a synchronization', home_synchronize_path(opts: {only_entities: [k.to_s]}), method: :post, class: 'btn btn-warning btn-sm', title: "Force a synchronization for #{v[:external_name]} only", 'data-toggle' => 'tooltip', 'data-placement' => 'right'
|
71
71
|
|
72
72
|
.spacer2
|
@@ -77,18 +77,18 @@
|
|
77
77
|
.col-md-4.col-md-offset-1
|
78
78
|
%label{:for => 'historical-data'} Synchronize my historical data
|
79
79
|
.col-md-1
|
80
|
-
%input{type: 'checkbox', id: 'historical-data', name: 'historical-data', checked:
|
80
|
+
%input{type: 'checkbox', id: 'historical-data', name: 'historical-data', checked: current_organization.historical_data, onchange: 'historicalDataDisplay();', disabled: current_organization.historical_data}
|
81
81
|
.col-md-6
|
82
|
-
%small#historical-data-display-unchecked{style: "display: #{
|
83
|
-
%small#historical-data-display-checked{style: "display: #{
|
82
|
+
%small#historical-data-display-unchecked{style: "display: #{current_organization.historical_data ? 'none' : 'block'}"} Only data created after #{(current_organization.date_filtering_limit && current_organization.date_filtering_limit.utc || Time.now.utc).to_formatted_s(:long_ordinal)} will be synchronized
|
83
|
+
%small#historical-data-display-checked{style: "display: #{!current_organization.historical_data ? 'none' : 'block'}"}
|
84
84
|
Synchronizing your historical data will share all data in ApplicationName. This action is not reversible. Want to know more? Check #{link_to 'here', 'https://maestrano.atlassian.net/wiki/display/UKB/How+Connec%21+manages+Historical+Data+Sharing'}
|
85
|
-
|
85
|
+
|
86
86
|
.spacer1
|
87
87
|
.row
|
88
88
|
.col-md-2.col-md-offset-10.text-center.link-step-action
|
89
|
-
=submit_tag "#{
|
89
|
+
=submit_tag "#{current_organization.sync_enabled ? 'Update' : 'Start synchronizing!'}", class: "btn btn-lg btn-warning #{current_organization.oauth_uid ? '' : 'disabled'} text-sm"
|
90
90
|
|
91
|
-
-if
|
91
|
+
-if current_organization.oauth_uid && current_organization.sync_enabled
|
92
92
|
.spacer2
|
93
93
|
.row
|
94
94
|
.col-md-4.col-md-offset-4.text-center
|
@@ -14,19 +14,17 @@ class OauthController < ApplicationController
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def create_omniauth
|
17
|
-
|
18
|
-
organization = Maestrano::Connector::Rails::Organization.find_by_uid_and_tenant(org_uid, current_user.tenant)
|
19
|
-
|
20
|
-
return redirect_to root_url unless organization && is_admin?(current_user, organization)
|
17
|
+
return redirect_to root_url unless is_admin
|
21
18
|
|
22
19
|
# TODO
|
23
|
-
# Update
|
20
|
+
# Update current_organization with oauth params
|
24
21
|
# Should at least set oauth_uid, oauth_token and oauth_provider
|
25
22
|
end
|
26
23
|
|
27
24
|
def destroy_omniauth
|
28
|
-
|
29
|
-
|
25
|
+
return redirect_to root_url unless is_admin
|
26
|
+
|
27
|
+
current_organization.clear_omniauth
|
30
28
|
|
31
29
|
redirect_to root_url
|
32
30
|
end
|
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: maestrano-connector-rails 2.0.0.pre.
|
5
|
+
# stub: maestrano-connector-rails 2.0.0.pre.RC10 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "maestrano-connector-rails"
|
9
|
-
s.version = "2.0.0.pre.
|
9
|
+
s.version = "2.0.0.pre.RC10"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
@@ -31,6 +31,12 @@ describe Maestrano::Connector::Rails::Organization do
|
|
31
31
|
organization2 = build(:organization, oauth_provider: 'myapp', oauth_uid: 'ABC')
|
32
32
|
expect(organization2).not_to be_valid
|
33
33
|
end
|
34
|
+
|
35
|
+
it 'allows several organizations without oauth UID' do
|
36
|
+
organization1 = create(:organization, oauth_provider: 'myapp', oauth_uid: nil)
|
37
|
+
organization2 = build(:organization, oauth_provider: 'myapp', oauth_uid: nil)
|
38
|
+
expect(organization2).to be_valid
|
39
|
+
end
|
34
40
|
end
|
35
41
|
|
36
42
|
describe "instance methods" do
|