Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't show amount of hidden files when showing hidden files #204

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

jelly
Copy link
Member

@jelly jelly commented Jan 24, 2024

When a user wants to see all files regardless of if they are hidden files show the item count without (X hidden items).

src/sidebar.jsx Outdated
@@ -139,6 +139,8 @@ export const SidebarPanelDetails = ({
}, [path, selected]);

const Dialogs = useDialogs();
const hidden_item_count = currentDirectory.items_cnt.hidden;
const item_count = showHidden ? currentDirectory.items_cnt.all + hidden_item_count : currentDirectory.items_cnt.all;
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure about the logic here? The existing code already included the hidden items in the overall count (and indeed item_cnt.all sounds like it contains them). Adding them again here might be wrong. Probably you would actually want to subtract them?

Copy link
Member Author

Choose a reason for hiding this comment

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

I checked and all is all except hidden which is super confusing. Do you want me to refactor this all now?

src/sidebar.jsx Outdated
currentDirectory.items_cnt.all,
cockpit.format("($0 hidden)", currentDirectory.items_cnt.hidden)
item_count,
showHidden ? "" : cockpit.format("($0 hidden)", hidden_item_count)
Copy link
Member

Choose a reason for hiding this comment

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

This should be translated with ngettext. "hidden" might be declined differently depending on the number.

src/sidebar.jsx Outdated
@@ -154,10 +156,10 @@ export const SidebarPanelDetails = ({
{cockpit.format(
cockpit.ngettext(
"$0 item $1", "$0 items $1",
Copy link
Member

Choose a reason for hiding this comment

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

The way these strings get pasted together is pretty confusing. Of course there's no two-dimensional ngettext(), so we're going to have to do some kind of pasting, but I think I'd prefer if it looked something like:

  let str = ngettext("$0 item", "$0 items", visible_count);
  if (!showHidden)
    str += " " + ngettext("($0 hidden)", "($0 hidden)", hidden_count)

Copy link
Member

Choose a reason for hiding this comment

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

In fact, we could turn it around and use the translation of the "hidden" part to do the pasting — since it's the one that's only done conditionally.

If you do that, then please write a translator comment about it.

When a user wants to see all files regardless of if they are hidden files
show the item count without (X hidden items).
Copy link
Member

@allisonkarlitskaya allisonkarlitskaya left a comment

Choose a reason for hiding this comment

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

Looks good.

@jelly jelly merged commit db0023a into cockpit-project:main Jan 31, 2024
12 checks passed
@jelly jelly deleted the hide-hidden-items branch January 31, 2024 16:00
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