Skip to content

Add existing invoice translations table to Invoice Translation tab#634

Open
tungleduyxyz wants to merge 1 commit into
masterfrom
kaui_7.29
Open

Add existing invoice translations table to Invoice Translation tab#634
tungleduyxyz wants to merge 1 commit into
masterfrom
kaui_7.29

Conversation

@tungleduyxyz

Copy link
Copy Markdown
Contributor

Summary

Previously, uploading an invoice translation only showed a success flash message — there was no way to see what translations had already been uploaded for a tenant.

This adds a table listing existing invoice translations to the "Invoice Translation" tab on the Admin Tenant show page, similar to the "Existing Overdue Config" / "Existing Plans" tables on the other tabs.

Changes

  • Kaui::AdminTenant.get_invoice_translations: lists all uploaded invoice translations for a tenant via KillBillClient::Model::Tenant.search_tenant_config('INVOICE_TRANSLATION_', ...). Kill Bill has no dedicated "list translations" endpoint, but translations are stored as per-tenant config entries keyed by INVOICE_TRANSLATION_<locale>, so the same prefix-search technique already used for get_tenant_plugin_config (PLUGIN_CONFIG_ prefix) applies here.
  • AdminTenantsController#show: fetches the translations map alongside the other tab data (catalog versions, overdue config, invoice template, etc.) using the existing promise/wait pattern.
  • _form_invoice_translation.erb: renders a table (styled consistently with the Overdue/Catalog tabs) listing each uploaded locale with a "View Source" toggle to inspect the translation properties content, above the existing upload form.
  • tenants.css: styles for the new table, matching the existing existing-*-table conventions.

Notes

  • There is no delete endpoint for individual invoice translations in Kill Bill (only overwrite via re-upload with deleteIfExists), so no delete action was added.

- List uploaded invoice translations per tenant via Kaui::AdminTenant.get_invoice_translations
  (uses KillBillClient::Model::Tenant.search_tenant_config with the
  INVOICE_TRANSLATION_ prefix, since Kill Bill has no dedicated list endpoint)
- Fetch translations in AdminTenantsController#show alongside other tab data
- Render a table above the upload form matching the existing Overdue/Catalog
  tab styling, with a View Source toggle per locale
@tungleduyxyz
tungleduyxyz requested a review from Copilot July 25, 2026 12:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds visibility into previously uploaded invoice translations on the Admin Tenant “Invoice Translation” tab by fetching tenant invoice-translation configs and rendering them in a styled table with expandable “View Source” rows.

Changes:

  • Add Kaui::AdminTenant.get_invoice_translations to list per-tenant INVOICE_TRANSLATION_<locale> config entries.
  • Fetch translations in AdminTenantsController#show using the existing promise/wait pattern.
  • Render “Existing Invoice Translations” table and styling on the Invoice Translation tab.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
app/views/kaui/admin_tenants/_form_invoice_translation.erb Adds table UI to list existing translations and toggle viewing raw content.
app/models/kaui/admin_tenant.rb Adds helper to search tenant config for invoice translation entries and build a locale->content map.
app/controllers/kaui/admin_tenants_controller.rb Fetches invoice translations alongside other tenant tab data.
app/assets/stylesheets/kaui/tenants.css Adds styles for the new translations table consistent with existing tables.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +11 to +16
<table id="existing-invoice-translations-for-tenants" class="existing-invoice-translations-table">
<span class='label'>
</span>
<% if @invoice_translations.blank? %>
No invoice translation defined for tenant
<% else %>
Comment on lines +28 to +36
<%= render "kaui/components/button/button", {
label: 'View Source',
variant: "outline-secondary d-inline-flex align-items-center gap-1",
type: "button",
html_class: "kaui-button custom-hover",
html_options: {
onclick: '$(this).blur(); $(this).closest("tr").next(".invoice-translation-source-row").toggle(); return false;'
}
} %>
Comment on lines +56 to +60
fetch_invoice_translations = promise do
Kaui::AdminTenant.get_invoice_translations(options)
rescue StandardError
@invoice_translations = {}
end
Comment on lines +85 to +89
@invoice_translations = begin
wait(fetch_invoice_translations)
rescue StandardError
{}
end
Comment on lines +30 to +33
raw_translations.each_with_object({}) do |e, hsh|
locale = e.key.gsub('INVOICE_TRANSLATION_', '')
hsh[locale] = e.values[0]
end
Comment on lines +651 to +654
.existing-invoice-translations-container .existing-invoice-translations-header {
display: flex;
align-items: start;
justify-content: space-between;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants