Skip to content

feat: implement admin improvements (sortable index, filter enhancements, Sequel support, auth hardening, CSV export, config validation)#69

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/explore-codebase-and-plan-improvements
Draft

feat: implement admin improvements (sortable index, filter enhancements, Sequel support, auth hardening, CSV export, config validation)#69
Copilot wants to merge 4 commits intomainfrom
copilot/explore-codebase-and-plan-improvements

Conversation

Copy link
Copy Markdown

Copilot AI commented May 2, 2026

Description

Implements a broad set of improvements to TinyAdmin covering interactive index sorting, richer filter types, a Sequel repository plugin, hardened authentication, CSV export, configuration validation, RBS coverage, and several bug fixes. CRUD write operations are excluded (deferred).

Sortable Column Headers (Section 2)

Index table headers are now <a> links that toggle ASC ▲ / DESC ▼. Sort params are validated against the known field list to prevent column injection.

Filter Enhancements (Section 3)

  • Range filterstype: :range renders a gte/lte input pair; apply_filters maps to WHERE col >= ? AND col <= ?
  • Multi-select filterstype: :select, multiple: true renders a multi-select; maps to IN (?)
  • Association filterstype: :association with association:, value_field:, label_field: populates a <select> from a related model

Sequel Repository (Section 4)

New TinyAdmin::Plugins::SequelRepository implements the full repository contract for Sequel datasets (field inference via db_schema, scalar/range/multi-select filters using Sequel expressions). BaseRepository now documents its contract in full and exposes a page_offset protected helper used by both AR and Sequel implementations.

Configuration Validation (Section 5)

Settings#load_settings now validates: unknown top-level keys, invalid section type: values, and missing required repository interface methods. Warnings by default; strict_config: true raises ArgumentError.

Authentication Hardening (Section 6)

  • BCryptSimpleAuth auto-detects $2b$/$2a$ hash prefix; SHA-512 kept for backward compat
  • Rate limiting – Session-based counter; configurable max_attempts (default 5) and lockout_seconds (default 300)
  • Username – Optional username: config; when set, login form must supply a matching param

CSV Export (Section 7)

New TinyAdmin::Actions::CsvExport collection action — respects field/attribute config, applies active filters, returns a text/csv attachment. Default row cap is 10,000 (configurable via max_export_limit:).

# Register as a collection action:
collection_actions:
  - csv_export: TinyAdmin::Actions::CsvExport

RBS (Section 8)

All new/changed classes have updated signatures: CsvExport, SequelRepository, SimpleAuth::BCRYPT_PREFIX, Index (show_link, sort_params), FiltersForm private helpers, Settings new constants/methods, BaseRepository#page_offset.

Bug Fixes (Section 10)

  • 10a – Index no longer renders a "Show" link when only: [:index]; show_link flows Router → Action → View
  • 10bStore#add_resource_section normalises only: values to symbols, removing the string/symbol dual-check in Router
  • 10cconfigure_from_file accepts reset: false to preserve prior programmatic settings
  • 10eWidgets raises ArgumentError for non-Phlex::HTML widget classes instead of silently skipping

Copilot AI and others added 4 commits May 2, 2026 16:03
Agent-Logs-Url: https://github.com/blocknotes/tiny_admin/sessions/701f4f0e-0369-4a49-ab32-a89eefb32223

Co-authored-by: blocknotes <6893256+blocknotes@users.noreply.github.com>
Agent-Logs-Url: https://github.com/blocknotes/tiny_admin/sessions/701f4f0e-0369-4a49-ab32-a89eefb32223

Co-authored-by: blocknotes <6893256+blocknotes@users.noreply.github.com>
- Section 2: Sortable column headers in Index (clickable links, ASC/DESC toggle, sanitization)
- Section 3a: Range filters (gte/lte pair inputs + ActiveRecord/Sequel filter handling)
- Section 3b: Multi-value select filters (multiple: true option + IN query)
- Section 3c: Association filters (related model dropdown)
- Section 4: SequelRepository plugin + BaseRepository contract docs + shared page_offset helper
- Section 5: Config validation (unknown keys, strict_config mode, section type, repo interface check)
- Section 6a: BCrypt support in SimpleAuth (auto-detect $2b$ prefix)
- Section 6b: Login rate limiting (session-based, max_attempts/lockout_seconds)
- Section 6c: Optional username support in SimpleAuth
- Section 7: CsvExport action (text/csv, Content-Disposition, filter-aware)
- Section 8: RBS signatures updated/added for all new code
- Section 10a: Fix Show link rendered when only: [:index]
- Section 10b: Normalize only: to symbols in Store
- Section 10c: configure_from_file reset: keyword
- Section 10e: Widgets raises ArgumentError for non-Phlex widgets

Note: Section 9 (per-request load_settings) and Section 10d (BasicApp auth plugin
deferred load) were investigated and reverted - class-level caching broke test
isolation, and deferred auth plugin loading broke Rack middleware setup timing.

Agent-Logs-Url: https://github.com/blocknotes/tiny_admin/sessions/701f4f0e-0369-4a49-ab32-a89eefb32223

Co-authored-by: blocknotes <6893256+blocknotes@users.noreply.github.com>
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