Add existing invoice translations table to Invoice Translation tab#634
Open
tungleduyxyz wants to merge 1 commit into
Open
Add existing invoice translations table to Invoice Translation tab#634tungleduyxyz wants to merge 1 commit into
tungleduyxyz wants to merge 1 commit into
Conversation
- 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
Contributor
There was a problem hiding this comment.
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_translationsto list per-tenantINVOICE_TRANSLATION_<locale>config entries. - Fetch translations in
AdminTenantsController#showusing 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 viaKillBillClient::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 byINVOICE_TRANSLATION_<locale>, so the same prefix-search technique already used forget_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 existingexisting-*-tableconventions.Notes
deleteIfExists), so no delete action was added.