Code refator and fix bug form validate#79
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves the Kanaui analytics UI behavior and UX around dashboards and report configuration by fixing the default dashboard report selection, adding client-side report form validation, improving AJAX error handling for JSON endpoints, and moving UI strings into i18n.
Changes:
- Fix dashboard default report fallback so a single configured report still renders dashboard controls and charts.
- Add client-side validation to prevent invalid report configurations (Source name requires exactly one of Source or SQL query).
- Improve error/success messaging: return JSON errors for JSON requests, render backend error messages in the chart area, and render report success notices inline; move fixed UI strings to i18n and clean up flash container markup/CSS.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| config/locales/en.bootstrap.yml | Adds kanaui.* i18n keys for labels, notices, and error messages used by updated views/controllers. |
| app/views/kanaui/reports/new.html.erb | Switches the “Add new report” title to i18n. |
| app/views/kanaui/reports/edit.html.erb | Switches the “Update report” title to i18n. |
| app/views/kanaui/reports/index.html.erb | Adds an inline notice area and replaces hardcoded labels with i18n lookups. |
| app/views/kanaui/reports/_reports_table.html.erb | Replaces table headers/actions/modal labels with i18n lookups. |
| app/views/kanaui/reports/_form.html.erb | Adds i18n labels/help text plus inline JS to validate Source name vs Source/SQL query configuration. |
| app/views/kanaui/layouts/kanaui_application.html.erb | Refactors flash rendering markup and fixes malformed closing div. |
| app/views/kanaui/dashboard/index.html.erb | Moves “SQL query” advanced control link label to i18n. |
| app/controllers/kanaui/reports_controller.rb | Refactors success notices into a helper flow and exposes an inline notice value for the index page. |
| app/controllers/kanaui/engine_controller.rb | Returns JSON error bodies for JSON requests (instead of redirecting to HTML), using i18n for the base message. |
| app/controllers/kanaui/dashboard_controller.rb | Adjusts default report selection to fall back to the first report when only one is available. |
| app/assets/stylesheets/kanaui/kanaui.css | Adds styling for the flash container and inline report notice spacing. |
| app/assets/javascripts/kanaui/kiddo/kiddo_initialize.js | Parses JSON error responses and renders escaped backend error messages inside the chart area. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+46
to
+55
| def report_notice_from_params | ||
| notice_key = params[:report_notice].presence | ||
| return nil if notice_key.blank? | ||
|
|
||
| I18n.t("kanaui.reports.notices.#{notice_key}", default: nil) | ||
| end | ||
|
|
||
| def redirect_to_index_with_notice(notice_key) | ||
| redirect_to action: :index, report_notice: notice_key | ||
| end |
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.
Related issue: #36
Summary of changes made:
SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON