feat(core,fuse,gui): show a sync issue on its node in the file browser

A refused change was only on the Sync page. A folder listing now carries
each node's issue (by local id, so a file not yet on Drive has it too),
and the browser's badge ranks it first, folders included, with the
issue's explanation as its tooltip. The event sampler publishes Files
when the set of issues changes, so the badge comes and goes with it.
This commit is contained in:
nvrl committed 2026-10-05 01:06:03 +02:00
1 parent 9dfe4c5450
commit a8ed6060af
25 files changed
+390 -251

No files matched your search

+1
View File
@@ -46,6 +46,7 @@
.badge-pinned { color: var(--success-color); }
.badge-cached { color: var(--success-color); }
.badge-cloud { color: color-mix(in srgb, currentColor 55%, transparent); }
.badge-issue { color: var(--error-color); }
.browser-statusbar { background-color: alpha(currentColor, 0.025); }
scale.browser-status-meter trough { min-width: 104px; min-height: 6px; }
.bulk-bar { padding: 6px 8px; border-radius: 12px; background: color-mix(in srgb, var(--accent-bg-color) 12%, transparent); }
+26 -4
View File
@@ -2495,9 +2495,13 @@ pub(crate) fn start_upload(ui: &Rc<Ui>, sources: Vec<String>) {
}
/// The sync-state badge for an entry: `(icon, css-class)`, or `None` for folders
/// (which carry no per-file cache state). Pinned (kept offline) ranks above merely
/// (which carry no per-file cache state). A sync issue ranks first, on folders
/// too: the change waits for the user. Pinned (kept offline) ranks above merely
/// cached (downloaded, evictable); everything else is online-only.
pub(crate) fn badge_for(entry: &DirEntry) -> Option<(&'static str, &'static str)> {
if entry.issue.is_some() {
return Some(("dialog-warning-symbolic", "badge-issue"));
}
if entry.is_dir {
return None;
}
@@ -2513,9 +2517,11 @@ pub(crate) fn badge_for(entry: &DirEntry) -> Option<(&'static str, &'static str)
/// Paint `badge` to reflect the entry's sync state (see [`badge_for`]). Clears any
/// prior colour class first, since list factories recycle cells.
pub(crate) fn apply_badge(badge: &gtk4::Image, entry: &DirEntry) {
for class in ["badge-pinned", "badge-cached", "badge-cloud"] {
for class in ["badge-pinned", "badge-cached", "badge-cloud", "badge-issue"] {
badge.remove_css_class(class);
}
let issue = entry.issue.map(super::locations::issue_text);
badge.set_tooltip_text(issue.as_deref());
match badge_for(entry) {
Some((icon, class)) => {
badge.set_icon_name(Some(icon));
@@ -2915,6 +2921,7 @@ pub(crate) fn repaint_search(ui: &Rc<Ui>, hits: &[SearchHit]) {
shared_by_unverified: false,
trashed_at: 0,
trashed_from: None,
issue: None,
})
.collect();
sort_entries(&mut entries, ui.browser.view.get());
@@ -2952,11 +2959,11 @@ fn listing_summary(files: usize, folders: usize, file_bytes: u64) -> String {
#[cfg(test)]
mod tests {
use super::{
MoveTarget, hit_location, listing_summary, move_target_allowed,
MoveTarget, badge_for, hit_location, listing_summary, move_target_allowed,
show_thumbnail_build_progress, sort_entries,
};
use pdfs_core::config::{FileSort, FilesView};
use pdfs_core::control::{DirEntry, ThumbnailBuildStatus};
use pdfs_core::control::{DirEntry, SyncIssue, ThumbnailBuildStatus};
fn entry(name: &str, is_dir: bool, size: u64, modified: i64) -> DirEntry {
DirEntry {
@@ -2974,6 +2981,7 @@ mod tests {
shared_by_unverified: false,
trashed_at: 0,
trashed_from: None,
issue: None,
}
}
@@ -2981,6 +2989,20 @@ mod tests {
entries.iter().map(|e| e.name.as_str()).collect()
}
#[test]
fn a_sync_issue_shows_on_the_node_before_its_cache_state() {
let mut file = entry("a.txt", false, 1, 0);
file.pinned = true;
assert_eq!(badge_for(&file).unwrap().1, "badge-pinned");
file.issue = Some(SyncIssue::Quota);
assert_eq!(badge_for(&file).unwrap().1, "badge-issue");
let mut folder = entry("d", true, 0, 0);
assert_eq!(badge_for(&folder), None);
folder.issue = Some(SyncIssue::Missing);
assert_eq!(badge_for(&folder).unwrap().1, "badge-issue");
}
#[test]
fn a_search_hit_location_is_its_parent_folder() {
assert_eq!(hit_location("Work/Old/a.txt"), "Work/Old");
+1 -1
View File
@@ -727,7 +727,7 @@ fn queue_row(ui: &Rc<Ui>, op: &PendingOpInfo, now: i64) -> adw::ActionRow {
/// What a sync issue means and what the user can do about it. The change stays
/// queued either way.
fn issue_text(issue: SyncIssue) -> String {
pub(crate) fn issue_text(issue: SyncIssue) -> String {
match issue {
SyncIssue::Quota => gettext(
"Your Proton Drive storage is full. Free up space or upgrade your plan, and this change uploads on its own.",
@@ -618,6 +618,7 @@ pub(crate) fn shared_item_as_entry(item: &SharedItem) -> DirEntry {
shared_by_unverified: false,
trashed_at: 0,
trashed_from: None,
issue: None,
}
}
+1
View File
@@ -533,6 +533,7 @@ mod tests {
shared_by_unverified: false,
trashed_at,
trashed_from: from.map(str::to_string),
issue: None,
}
}