Skip to content

feat(filters): add reusable file type and date filters - #4107

Merged
shepilov merged 3 commits into
masterfrom
feat/sharings-file-type-filter
Jul 29, 2026
Merged

shepilov merged 3 commits into
masterfrom
feat/sharings-file-type-filter

Conversation

@shepilov

@shepilov shepilov commented Jul 28, 2026

Copy link
Copy Markdown
Member

Summary

  • Add reusable file type and date filters using existing Drive categories and preset date ranges.
  • Add inline clear behavior to the shared filter control.
  • Add English, French, Russian, and Vietnamese labels and component behavior tests.

Summary by CodeRabbit

  • New Features
    • Added a file type filter with localized options (folders, documents, spreadsheets, presentations, photos, PDFs, videos, archives, audio, drawings, shortcuts).
    • Added a localized “Modification date” filter with preset ranges (today, last 7 days, last month, this year).
  • Bug Fixes
    • Improved filter display for active selections and enhanced accessibility.
    • Added clear controls for active filters.
  • Tests
    • Added unit tests covering both file type and date filter behaviors, including opening/selection and clear actions.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds localized date and file-type filters with centralized options, icons, selection handling, and clearing. Extends the shared Filter component with an optional clear button and updated layout. Adds English, French, Russian, and Vietnamese translations, re-exports the filters, centralizes MIME icon mappings, and includes interaction tests for option selection and clearing.

Possibly related PRs

Suggested reviewers: doubleface, rezk2ll, lethemanh, jf-cozy

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding reusable file type and date filters.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/sharings-file-type-filter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@shepilov
shepilov marked this pull request as ready for review July 28, 2026 15:09
@bundlemon

bundlemon Bot commented Jul 28, 2026

Copy link
Copy Markdown

BundleMon

Unchanged files (18)
Status Path Size Limits
static/resource/(hash).js
336.09KB -
services/qualificationMigration.js
275.6KB -
services/dacc.js
255.74KB -
static/js/main.(hash).js
57.96KB -
static/js/lib-react.(hash).js
43.88KB -
static/js/public.(hash).js
27.12KB -
static/js/lib-polyfill.(hash).js
22.76KB -
static/js/lib-router.(hash).js
21.92KB -
static/js/intents.(hash).js
18.1KB -
static/css/main.(hash).css
13.99KB -
static/js/async/(chunkId).(hash).js
7.5KB -
manifest.webapp
6.02KB -
static/css/public.(hash).css
2.71KB -
static/js/(chunkId).(hash).js
2.08KB -
index.html
822B -
public/index.html
772B -
intents/index.html
679B -
assets/manifest.json
185B -

Total files change +3B 0%

Groups updated (1)
Status Path Size Limits
**/*.js
6.15MB (+1.79KB +0.03%) -
Unchanged groups (2)
Status Path Size Limits
**/*.{png,svg,ico}
2.16MB -
**/*.css
73.58KB -

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/Filters/FileTypeFilter.jsx`:
- Around line 47-49: Update handleChange in FileTypeFilter so selecting the
mobileOptions reset entry with an empty value invokes onClear instead of
onChange. Preserve the existing onChange behavior for non-empty file type
values, ensuring the reset clears the active filter state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 55a2429d-0f63-4fdd-a419-15aeeb24bbc8

📥 Commits

Reviewing files that changed from the base of the PR and between a548992 and 576569c.

📒 Files selected for processing (9)
  • src/components/Filters/FileTypeFilter.jsx
  • src/components/Filters/FileTypeFilter.spec.jsx
  • src/components/Filters/Filter.jsx
  • src/components/Filters/fileTypes.js
  • src/components/Filters/index.js
  • src/locales/en.json
  • src/locales/fr.json
  • src/locales/ru.json
  • src/locales/vi.json

Comment thread src/components/Filters/FileTypeFilter.jsx
@shepilov shepilov changed the title feat: add reusable file type filter feat(filters): add reusable file type filter Jul 28, 2026
option: {
display: 'flex',
alignItems: 'center',
gap: theme.spacing(1)

@zatteo zatteo Jul 29, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@JF-Cozy we should have u-gap-xx utility classes no?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes we should, someone tried to implement it a loooooooog time ago in cozy-ui. It's not really used, but can helps in some cases, so, yes 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The PR is still open for u-g-half(8px) cozy/cozy-ui#2281

@JF-Cozy JF-Cozy Jul 29, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes it will be merged asap. But we can go with gap: theme.spacing(1) without using u-classes if you are in a hurry, we didn't have u-gap for 4 years, it's not a big deal :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I merged it, so as you want, either you can remove totally this to use u-flex u-flex-items-center u-g-half or go like this


export function findFileTypeOption(value) {
return FILE_TYPE_OPTIONS.find(option => option.value === value) ?? null
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

May we can mutualize something with src/lib/getMimeTypeIcon.jsto avoid multiplying type to icon map?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yep, I think we can't use it as is, becouse we don't have but we can extract category-to-icon map

codescene-delta-analysis[bot]

This comment was marked as outdated.

@shepilov
shepilov force-pushed the feat/sharings-file-type-filter branch from 17bd462 to 746a4ed Compare July 29, 2026 09:04
codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/Filters/DateFilter.jsx`:
- Around line 54-64: Update handleChange in DateFilter so selecting the blank
mobile option routes through onClear instead of calling onChange with an empty
string; continue passing known date-range values to onChange unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 416aa962-5438-4dd1-8f7b-b798aee7392c

📥 Commits

Reviewing files that changed from the base of the PR and between ab7f3e5 and 746a4ed.

📒 Files selected for processing (12)
  • src/components/Filters/DateFilter.jsx
  • src/components/Filters/DateFilter.spec.jsx
  • src/components/Filters/FileTypeFilter.jsx
  • src/components/Filters/FileTypeFilter.spec.jsx
  • src/components/Filters/Filter.jsx
  • src/components/Filters/fileTypes.js
  • src/components/Filters/index.js
  • src/lib/getMimeTypeIcon.js
  • src/locales/en.json
  • src/locales/fr.json
  • src/locales/ru.json
  • src/locales/vi.json
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/locales/en.json
  • src/components/Filters/FileTypeFilter.spec.jsx
  • src/components/Filters/index.js
  • src/locales/ru.json
  • src/lib/getMimeTypeIcon.js
  • src/components/Filters/fileTypes.js
  • src/components/Filters/Filter.jsx

Comment on lines +54 to +64
const mobileOptions = [
{
label: t('filters.date.label'),
value: ''
},
...options
]

const handleChange = event => {
onChange(event.target.value)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Route the mobile placeholder through onClear.

Selecting the blank mobile option currently invokes onChange(''), although value only accepts a known date range (or null). This can leave the parent with an invalid empty-string state instead of clearing the filter.

Proposed fix
   const handleChange = event => {
-    onChange(event.target.value)
+    const nextValue = event.target.value
+    if (nextValue === '') {
+      onClear()
+      return
+    }
+    onChange(nextValue)
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const mobileOptions = [
{
label: t('filters.date.label'),
value: ''
},
...options
]
const handleChange = event => {
onChange(event.target.value)
}
const mobileOptions = [
{
label: t('filters.date.label'),
value: ''
},
...options
]
const handleChange = event => {
const nextValue = event.target.value
if (nextValue === '') {
onClear()
return
}
onChange(nextValue)
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/Filters/DateFilter.jsx` around lines 54 - 64, Update
handleChange in DateFilter so selecting the blank mobile option routes through
onClear instead of calling onChange with an empty string; continue passing known
date-range values to onChange unchanged.

@shepilov
shepilov force-pushed the feat/sharings-file-type-filter branch from 746a4ed to db240c3 Compare July 29, 2026 09:16
@shepilov shepilov changed the title feat(filters): add reusable file type filter feat(filters): add reusable file type and date filters Jul 29, 2026

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Gates Passed
3 Quality Gates Passed

See analysis details in CodeScene

Quality Gate Profile: The Bare Minimum
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@shepilov
shepilov merged commit ce266cb into master Jul 29, 2026
7 checks passed
@shepilov
shepilov deleted the feat/sharings-file-type-filter branch July 29, 2026 11:59
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.

3 participants