kaui 4.0.10 → 4.0.11
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/app/controllers/kaui/admin_allowed_users_controller.rb +17 -2
- data/app/controllers/kaui/refunds_controller.rb +1 -0
- data/app/controllers/kaui/role_definitions_controller.rb +31 -1
- data/app/views/kaui/admin_allowed_users/_form.html.erb +18 -2
- data/app/views/kaui/refunds/_form.html.erb +1 -1
- data/config/locales/en.yml +3 -3
- data/lib/kaui/error_handler.rb +22 -12
- data/lib/kaui/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7328709e0c330b84f3e47b4041cf55aa61bf98c7ac80dbb9b2d199b71c3d1f7a
|
|
4
|
+
data.tar.gz: 27b7f69cdb1e950cd327ac7c31141a76ae6c07e7e063d5ccd6d66c020a4fe612
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e7e3008686fb14493dca39a5adcda76d6032c0a8ba23cbf76971dac4829d59ae275a34779d3450aaf7babead74924a66a968cfc07579e74bcd6669763681a632
|
|
7
|
+
data.tar.gz: 9195fcbb008a972b2a8e4b6dbee1b471662e5f30623910ea5b4abe290957f726b8c620c56c82df742ef43587b08f006a7c9d65825833938f01e98a666e3605fe
|
|
@@ -15,8 +15,16 @@ module Kaui
|
|
|
15
15
|
def new
|
|
16
16
|
@allowed_user = Kaui::AllowedUser.new
|
|
17
17
|
@is_killbill_managed = true
|
|
18
|
-
|
|
19
18
|
@roles = []
|
|
19
|
+
|
|
20
|
+
# Restore form state if returning from role creation
|
|
21
|
+
return unless params[:user_context].present?
|
|
22
|
+
|
|
23
|
+
context = params[:user_context]
|
|
24
|
+
@allowed_user.kb_username = context[:kb_username]
|
|
25
|
+
@allowed_user.description = context[:description]
|
|
26
|
+
@roles = context[:roles].to_s.split(',').reject(&:blank?)
|
|
27
|
+
@external_checked = context[:external] == '1'
|
|
20
28
|
end
|
|
21
29
|
|
|
22
30
|
def create
|
|
@@ -59,7 +67,14 @@ module Kaui
|
|
|
59
67
|
@allowed_user = Kaui::AllowedUser.find(params.require(:id))
|
|
60
68
|
@is_killbill_managed = killbill_managed?(@allowed_user, options_for_klient)
|
|
61
69
|
|
|
62
|
-
|
|
70
|
+
# Use roles from context if returning from role creation, otherwise fetch from KB
|
|
71
|
+
if params[:user_context].present?
|
|
72
|
+
context = params[:user_context]
|
|
73
|
+
@roles = context[:roles].to_s.split(',').reject(&:blank?)
|
|
74
|
+
@allowed_user.description = context[:description] if context[:description].present?
|
|
75
|
+
else
|
|
76
|
+
@roles = roles_for_user(@allowed_user)
|
|
77
|
+
end
|
|
63
78
|
end
|
|
64
79
|
|
|
65
80
|
def update
|
|
@@ -28,6 +28,7 @@ module Kaui
|
|
|
28
28
|
|
|
29
29
|
item = KillBillClient::Model::InvoiceItem.new
|
|
30
30
|
item.invoice_item_id = ii[0]
|
|
31
|
+
item.description = params.dig(:descriptions, ii[0])
|
|
31
32
|
# If we tried to do a partial item adjustment, we pass the value, if not we don't send any value and let the system
|
|
32
33
|
# decide what is the maximum amount we can have on that item
|
|
33
34
|
item.amount = ii[1].to_f == original_item.amount ? nil : ii[1]
|
|
@@ -4,6 +4,17 @@ module Kaui
|
|
|
4
4
|
class RoleDefinitionsController < Kaui::EngineController
|
|
5
5
|
def new
|
|
6
6
|
@role_definition = Kaui::RoleDefinition.new
|
|
7
|
+
|
|
8
|
+
# Store user form context if coming from user creation/edit
|
|
9
|
+
return unless params[:return_to_user].present?
|
|
10
|
+
|
|
11
|
+
session[:role_return_context] = {
|
|
12
|
+
kb_username: params[:kb_username],
|
|
13
|
+
description: params[:description],
|
|
14
|
+
roles: params[:roles],
|
|
15
|
+
external: params[:external],
|
|
16
|
+
allowed_user_id: params[:allowed_user_id]
|
|
17
|
+
}
|
|
7
18
|
end
|
|
8
19
|
|
|
9
20
|
def create
|
|
@@ -13,7 +24,26 @@ module Kaui
|
|
|
13
24
|
|
|
14
25
|
begin
|
|
15
26
|
@role_definition = @role_definition.create(current_user.kb_username, params[:reason], params[:comment], options_for_klient)
|
|
16
|
-
|
|
27
|
+
|
|
28
|
+
# Check if we need to return to user form with the new role
|
|
29
|
+
return_context = session.delete(:role_return_context)
|
|
30
|
+
if return_context.present?
|
|
31
|
+
# Add the new role to the existing roles
|
|
32
|
+
existing_roles = return_context[:roles].to_s.split(',').reject(&:blank?)
|
|
33
|
+
existing_roles << @role_definition.role unless existing_roles.include?(@role_definition.role)
|
|
34
|
+
return_context[:roles] = existing_roles.join(',')
|
|
35
|
+
|
|
36
|
+
# Redirect back to user form (new or edit)
|
|
37
|
+
if return_context[:allowed_user_id].present? && return_context[:allowed_user_id] != ''
|
|
38
|
+
redirect_to edit_admin_allowed_user_path(return_context[:allowed_user_id], user_context: return_context),
|
|
39
|
+
notice: "Role '#{@role_definition.role}' was successfully created"
|
|
40
|
+
else
|
|
41
|
+
redirect_to new_admin_allowed_user_path(user_context: return_context),
|
|
42
|
+
notice: "Role '#{@role_definition.role}' was successfully created"
|
|
43
|
+
end
|
|
44
|
+
else
|
|
45
|
+
redirect_to admin_allowed_users_path, notice: 'Role was successfully created'
|
|
46
|
+
end
|
|
17
47
|
rescue StandardError => e
|
|
18
48
|
flash.now[:error] = "Error while creating role: #{as_string(e)}"
|
|
19
49
|
render action: :new
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<div class="col-sm-9">
|
|
6
6
|
<div class="checkbox">
|
|
7
7
|
<label for="external" class="d-flex align-items-center gap-2 control-label">
|
|
8
|
-
<%= check_box_tag :external, '1', false, disabled: !@allowed_user.id.blank?, id: 'external', class: "pt-2" %>
|
|
8
|
+
<%= check_box_tag :external, '1', @external_checked || false, disabled: !@allowed_user.id.blank?, id: 'external', class: "pt-2" %>
|
|
9
9
|
Managed externally (LDAP, Okta, etc.)?
|
|
10
10
|
</label>
|
|
11
11
|
</div>
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
</div>
|
|
39
39
|
<%= hidden_field_tag :roles, @roles.join(','), id: 'roles-hidden' %>
|
|
40
40
|
|
|
41
|
-
<%= link_to
|
|
41
|
+
<%= link_to '#', class: "border-button custom-hover add-role-button", id: "add-role-link", data: { base_url: new_role_definition_path } do %>
|
|
42
42
|
<%= image_tag("kaui/modal/plus.svg", width: 16, height: 16) %>
|
|
43
43
|
<% end %>
|
|
44
44
|
</div>
|
|
@@ -78,6 +78,22 @@
|
|
|
78
78
|
<%= javascript_tag do %>
|
|
79
79
|
$(document).ready(function() {
|
|
80
80
|
|
|
81
|
+
// Handle add role button click - pass current form state
|
|
82
|
+
$('#add-role-link').click(function(e) {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
var baseUrl = $(this).data('base-url');
|
|
85
|
+
var params = {
|
|
86
|
+
return_to_user: '1',
|
|
87
|
+
kb_username: $('#allowed_user_kb_username').val(),
|
|
88
|
+
description: $('#allowed_user_description').val(),
|
|
89
|
+
roles: $('#roles-hidden').val(),
|
|
90
|
+
external: $('#external').is(':checked') ? '1' : '0',
|
|
91
|
+
allowed_user_id: '<%= @allowed_user.id %>'
|
|
92
|
+
};
|
|
93
|
+
var queryString = $.param(params);
|
|
94
|
+
window.location.href = baseUrl + '?' + queryString;
|
|
95
|
+
});
|
|
96
|
+
|
|
81
97
|
$('#external').change(function() {
|
|
82
98
|
is_killbill_managed();
|
|
83
99
|
});
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
<div class="col-sm-9 checkbox-label">
|
|
48
48
|
<label for="<%= "cb_adj_#{ii.invoice_item_id}" %>" class="d-flex align-items-center gap-2 mb-1">
|
|
49
49
|
<input type="checkbox" id="<%= "cb_adj_#{ii.invoice_item_id}" %>">
|
|
50
|
-
<%= Kaui.refund_invoice_description.call(index, ii, bundle_result) %>
|
|
50
|
+
<%= text_field_tag "descriptions[#{ii.invoice_item_id}]", Kaui.refund_invoice_description.call(index, ii, bundle_result), id: "desc_#{ii.invoice_item_id}", class: 'form-control' %>
|
|
51
51
|
</label>
|
|
52
52
|
<%= text_field_tag "adjustments[#{ii.invoice_item_id}]", index, id: "tf_adj_#{ii.invoice_item_id}", value: ii.amount, class: 'form-control checkbox-label' %>
|
|
53
53
|
</div>
|
data/config/locales/en.yml
CHANGED
|
@@ -18,9 +18,9 @@ en:
|
|
|
18
18
|
custom_field_uuid_exist_in_invoice_payment_db: "UUID do exist in INVOICE PAYMENT object database."
|
|
19
19
|
custom_field_uuid_do_not_exist_in_db: "UUID do not exist in object database."
|
|
20
20
|
custom_field_uuid_exist_in_invoice_item_db: "UUID do exist in INVOICE ITEMS object database."
|
|
21
|
-
immediate: "
|
|
22
|
-
start_of_term: "
|
|
23
|
-
end_of_term: "
|
|
21
|
+
immediate: "IMMEDIATE"
|
|
22
|
+
start_of_term: "START_OF_TERM"
|
|
23
|
+
end_of_term: "END_OF_TERM"
|
|
24
24
|
billing_policy: "Billing Policy"
|
|
25
25
|
new_account_id_or_external_key: "New account id or external key"
|
|
26
26
|
object_invalid_dont_exist: "Object type INVALID or object id do not exist."
|
data/lib/kaui/error_handler.rb
CHANGED
|
@@ -7,31 +7,41 @@ module Kaui
|
|
|
7
7
|
|
|
8
8
|
included do
|
|
9
9
|
rescue_from(StandardError) do |error|
|
|
10
|
-
|
|
10
|
+
error_message = "Error: #{as_string(error)}"
|
|
11
11
|
try_to_redirect_to_account_path = !params[:controller].ends_with?('accounts')
|
|
12
|
-
perform_redirect_after_error(redirect: try_to_redirect_to_account_path)
|
|
12
|
+
perform_redirect_after_error(redirect: try_to_redirect_to_account_path, error:, error_message:)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
rescue_from(ActionController::ParameterMissing) do |parameter_missing_exception|
|
|
16
16
|
log_rescue_error parameter_missing_exception
|
|
17
|
-
|
|
18
|
-
perform_redirect_after_error
|
|
17
|
+
error_message = "Required parameter missing: #{parameter_missing_exception.param}"
|
|
18
|
+
perform_redirect_after_error(error: parameter_missing_exception, error_message:)
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
rescue_from(KillBillClient::API::ResponseError) do |killbill_exception|
|
|
22
|
-
|
|
22
|
+
error_message = "Error while communicating with the Kill Bill server: #{as_string(killbill_exception)}"
|
|
23
23
|
try_to_redirect_to_account_path = !killbill_exception.is_a?(KillBillClient::API::Unauthorized) && !(killbill_exception.is_a?(KillBillClient::API::NotFound) && params[:controller].ends_with?('accounts'))
|
|
24
|
-
perform_redirect_after_error(redirect: try_to_redirect_to_account_path)
|
|
24
|
+
perform_redirect_after_error(redirect: try_to_redirect_to_account_path, error: killbill_exception, error_message:)
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def perform_redirect_after_error(redirect: true)
|
|
28
|
+
def perform_redirect_after_error(error:, error_message:, redirect: true)
|
|
29
29
|
account_id = nested_hash_value(params.permit!.to_h, :account_id)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
home_path = kaui_engine.home_path
|
|
31
|
+
redirect_path = if redirect && account_id.present?
|
|
32
|
+
kaui_engine.account_path(account_id)
|
|
33
|
+
else
|
|
34
|
+
home_path
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
redirect_path_without_query = redirect_path.to_s.split('?').first
|
|
38
|
+
already_on_redirect_target = request.path == redirect_path_without_query
|
|
39
|
+
already_on_home = params[:controller].to_s.ends_with?('home') && action_name == 'index'
|
|
40
|
+
|
|
41
|
+
raise error if already_on_redirect_target || (redirect_path == home_path && already_on_home)
|
|
42
|
+
|
|
43
|
+
flash[:error] = error_message
|
|
44
|
+
redirect_to redirect_path
|
|
35
45
|
end
|
|
36
46
|
end
|
|
37
47
|
end
|
data/lib/kaui/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kaui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.0.
|
|
4
|
+
version: 4.0.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kill Bill core team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-03-
|
|
11
|
+
date: 2026-03-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionpack
|