Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@
<%- end -%>
</div>
</div>
<%- else -%>
<div class="alert alert-info insufficient-balance">
<%= t('dashboard.balance_no_warnings_html', threshold: Configuration.balance_threshold.to_i) %>
</div>
<%- end -%>
1 change: 1 addition & 0 deletions apps/dashboard/config/locales/en-CA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ en-CA:
back: Back
balance_additional_message: Consider requesting additional %{balanace_units}
balance_message: "%{units_balance} is %{value}"
balance_no_warnings_html: "No projects are within the %{threshold} day balance warning threshold."
balance_reload_message_html: Reload page to see updated balance. Balances are updated daily.<br>Last update was %{last_update}
balance_warning_prefix_html: "%{units_balance} warning for"
batch_connect_apps_menu_title: Interactive Apps
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ en:
back: Back
balance_additional_message: Consider requesting additional %{balanace_units}
balance_message: "%{units_balance} is %{value}"
balance_no_warnings_html: "No projects are within the %{threshold} day balance warning threshold."
balance_reload_message_html: Reload page to see updated balance. Balances are updated daily.<br>Last update was %{last_update}
balance_warning_prefix_html: "%{units_balance} warning for"
batch_connect_apps_menu_title: Interactive Apps
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/config/locales/fr-CA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fr-CA:
back: Retour
balance_additional_message: Envisagez de demander %{balanace_units} supplémentaires
balance_message: "%{units_balance} est %{value}"
balance_no_warnings_html: "Aucun projet n’est dans le seuil d’avertissement de solde de %{threshold} jours."
balance_reload_message_html: 'Rechargez la page pour voir le solde mis à jour. Les soldes sont mis à jour quotidiennement.<br>Dernière mise à jour : %{last_update}'
balance_warning_prefix_html: "%{units_balance} avertissement pour"
batch_connect_apps_menu_title: Applications interactives
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/config/locales/ja_JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ja_JP:
back: 戻る
balance_additional_message: 追加の%{balanace_units}をリクエストすることを検討してください
balance_message: "%{units_balance}は%{value}です"
balance_no_warnings_html: "%{threshold} 日の残高警告しきい値の範囲内にあるプロジェクトはありません。"
balance_reload_message_html: ページを再読み込みして、更新された残高を確認してください。残高は毎日更新されます。<br>最終更新は %{last_update} でした。
balance_warning_prefix_html: "%{units_balance} の警告"
batch_connect_apps_menu_title: インタラクティブアプリ
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/config/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ zh-CN:
back: 返回
balance_additional_message: 考虑申请额外的 %{balanace_units}
balance_message: "%{units_balance} 是 %{value}"
balance_no_warnings_html: "没有项目处于 %{threshold} 天余额警告阈值范围内。"
balance_reload_message_html: 重新加载页面以查看更新后的余额。 余额每天更新。<br>最后一次更新是 %{last_update}
balance_warning_prefix_html: "%{units_balance} 警告"
batch_connect_apps_menu_title: 交互式应用
Expand Down
46 changes: 46 additions & 0 deletions apps/dashboard/test/integration/balance_warnings_views_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require 'test_helper'

class BalanceWarningsViewsTest < ActionDispatch::IntegrationTest
setup do
stub_user
stub_user_configuration({})
end

test 'shows informational message when there are no balance warnings' do
with_balance_file([{ project: 'PZS0708', user: 'me', value: 20 }]) do |path|
with_modified_env('OOD_BALANCE_PATH' => path, 'OOD_BALANCE_THRESHOLD' => '10') do
get '/'
assert_response :success
assert_select 'div.alert.alert-info.insufficient-balance'
end
end
end

test 'shows danger alert when there is a balance warning' do
with_balance_file([{ project: 'PZS0708', user: 'me', value: 0 }]) do |path|
with_modified_env('OOD_BALANCE_PATH' => path, 'OOD_BALANCE_THRESHOLD' => '10') do
get '/'
assert_response :success
assert_select 'div.alert.alert-danger.insufficient-balance'
end
end
end

private

def with_balance_file(balances)
Tempfile.open(%w[balance .json]) do |f|
f.write(
{
version: 1,
timestamp: 1234567890,
config: { unit: 'RU', project_type: 'project' },
balances: balances
}.to_json
)
f.flush

yield f.path
end
end
end
Loading