Skip to content
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- The data view bottom bar groups the row count with the pagination controls, and the rows-per-page menu shows plain numbers instead of locale-grouped values like "1.000". Click the row range to change rows per page.
- Selecting a Redis namespace in the sidebar key tree now filters the open database view to that prefix, with paging, instead of opening a separate tab limited to one batch of keys. (#1701)

### Fixed
Expand Down
25 changes: 25 additions & 0 deletions TablePro/Models/Query/PaginationState+Display.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// PaginationState+Display.swift
// TablePro
//

import Foundation

extension PaginationState {
func rangeText(loadedRowCount: Int) -> String? {
if let total = totalRowCount, total > 0 {
let formattedTotal = total.formatted(.number.grouping(.automatic))
let prefix = isApproximateRowCount ? "~" : ""
return String(format: String(localized: "%d-%d of %@%@ rows"), rangeStart, rangeEnd, prefix, formattedTotal)
}
if currentPage > 1 || loadedRowCount >= pageSize {
let end = currentOffset + loadedRowCount
return String(format: String(localized: "%d-%d of ? rows"), rangeStart, end)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Guard empty unknown-total pages before formatting ranges

When an unknown-total table advances from a full page to a later page that returns no rows, currentPage > 1 is still true but loadedRowCount is 0, so this formats an inverted label such as 51-50 of ? rows in the page-size menu. That path is reachable because unknown totals allow Next whenever the previous page was full, and the old status text was hidden when snapshot.hasRows was false; clamp/suppress the range until rows are loaded or show an empty-page state instead.

Useful? React with 👍 / 👎.

}
return nil
}

static func pageSizeLabel(_ size: Int) -> String {
size.formatted(.number.grouping(.never))
}
}
23 changes: 14 additions & 9 deletions TablePro/Views/Components/PaginationControlsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,20 @@ struct PaginationControlsView: View {

var body: some View {
HStack(spacing: 8) {
pageSizeMenu
rangeMenu
navigationCluster
.fixedSize()
.layoutPriority(1)
}
}

// MARK: - Page Size Menu
// MARK: - Range / Page Size Menu

private var pageSizeMenu: some View {
private var rangeMenu: some View {
Menu {
Picker(String(localized: "Rows per page"), selection: pageSizeBinding) {
ForEach(Self.pageSizePresets, id: \.self) { size in
Text(size.formatted()).tag(size)
Text(PaginationState.pageSizeLabel(size)).tag(size)
}
}
.pickerStyle(.inline)
Expand All @@ -52,13 +54,16 @@ struct PaginationControlsView: View {
showCustomPopover = true
}
} label: {
Text(pageSizeLabel)
Text(rangeLabel)
.lineLimit(1)
.truncationMode(.middle)
.frame(minWidth: 60, alignment: .leading)
}
.menuStyle(.borderlessButton)
.fixedSize()
.controlSize(.small)
.help(String(localized: "Rows per page"))
.accessibilityLabel(String(localized: "Rows per page"))
.accessibilityLabel(rangeLabel)
.accessibilityHint(String(localized: "Rows per page"))
.overlay(alignment: .bottom) {
Color.clear
.frame(width: 0, height: 0)
Expand All @@ -72,8 +77,8 @@ struct PaginationControlsView: View {
Binding(get: { pagination.pageSize }, set: { onPageSizeChange($0) })
}

private var pageSizeLabel: String {
pagination.pageSize.formatted()
private var rangeLabel: String {
pagination.rangeText(loadedRowCount: loadedRowCount) ?? PaginationState.pageSizeLabel(pagination.pageSize)
}

// MARK: - Navigation
Expand Down
Loading
Loading