Skip to content

WEB-4654 - Tags & Sites - #1985

Merged
henry-tp merged 40 commits into
feat/filter-enhancementsfrom
WEB-4654-tags
Aug 6, 2026
Merged

WEB-4654 - Tags & Sites#1985
henry-tp merged 40 commits into
feat/filter-enhancementsfrom
WEB-4654-tags

Conversation

@henry-tp

@henry-tp henry-tp commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description only references issue WEB-4654 and does not summarize the Tags and Sites filtering changes. Add a brief summary of the Tags and Sites filtering changes, including the new components, behavior, and tests.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title clearly identifies the main Tags and Sites filtering change and is concise.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch WEB-4654-tags

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.

@henry-tp
henry-tp requested a review from clintonium-119 July 21, 2026 21:35
import SiteFilterDropdown from '../components/SiteFilterDropdown';
import useIsClinicAdmin from '../useIsClinicAdmin';
import useClinicMetricsPageName from '../useClinicMetricsPageName';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Another adapter component, mapping the state setters of ClinicPatients to the API of the Dropdown

@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: 2

🧹 Nitpick comments (3)
app/pages/clinicworkspace/useClinicMetricsPageName.js (1)

7-14: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Exact-path matching will silently report Unknown as these filters get reused.

Any route variant (trailing slash, or reuse on /dashboard/tide) falls through to 'Unknown', degrading metric attribution rather than failing loudly. Consider prefix matching and adding the dashboard route as the components spread.

♻️ Sketch
-  switch (pathname) {
-    case '/clinic-workspace':
-    case '/clinic-workspace/patients':
-      return 'Population Health';
-
-    default:
-      return 'Unknown';
-  };
+  if (pathname.startsWith('/clinic-workspace')) return 'Population Health';
+
+  return 'Unknown';
🤖 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 `@app/pages/clinicworkspace/useClinicMetricsPageName.js` around lines 7 - 14,
Update the pathname handling in the clinic metrics page-name switch to use
prefix matching so trailing slashes and nested clinic-workspace routes resolve
to the existing “Population Health” label. Add the `/dashboard/tide` route
prefix to the same mapping, while preserving “Unknown” for unrelated paths.
app/pages/clinicworkspace/components/SiteFilterDropdown.js (1)

75-227: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

The two dropdowns are a copy/paste pair and are already drifting. Search filtering, pending selection, the zero-state checkbox, clear/apply + metrics, and the empty state are implemented twice with only the entity noun differing; the drift is already visible (the site-specific className on TagFilterDropdown.js line 179, and the redundant marginBottom that exists only in the site version). Extracting one parameterized dropdown (entity label, options selector, special zero-filter value, metric names, empty-state node) would keep future behavior changes in sync.

  • app/pages/clinicworkspace/components/SiteFilterDropdown.js#L75-L227: extract DropdownContent into a shared component and have this file supply only site-specific props (label, clinic?.sites, ZERO_SITES, site metric names, NoClinicSites).
  • app/pages/clinicworkspace/components/TagFilterDropdown.js#L78-L230: replace this duplicated DropdownContent with the shared component, supplying tag-specific props (clinic?.patientTags, ZERO_TAGS, tag metric names, NoClinicTags).

Non-blocking for this PR — reasonable to land the behavior first and follow up.

🤖 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 `@app/pages/clinicworkspace/components/SiteFilterDropdown.js` around lines 75 -
227, Extract the duplicated DropdownContent logic into a shared parameterized
component covering search, pending selection, zero-state handling, clear/apply
actions, metrics, and empty states. Update
app/pages/clinicworkspace/components/SiteFilterDropdown.js lines 75-227 to pass
site-specific label, clinic?.sites, ZERO_SITES, site metric names, and
NoClinicSites props; update
app/pages/clinicworkspace/components/TagFilterDropdown.js lines 78-230 to use
the shared component with clinic?.patientTags, ZERO_TAGS, tag metric names, and
NoClinicTags. Remove the duplicated implementations while preserving existing
behavior.
app/core/metricUtils.js (1)

2-2: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Drop the unused useLocation import from app/core/metricUtils.js.

The module does not call it, and keeping a router hook import in a standalone util unnecessarily ties trackMetric consumers to react-router-dom.

🤖 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 `@app/core/metricUtils.js` at line 2, Remove the unused useLocation import from
metricUtils.js, leaving trackMetric and the rest of the standalone utility
unchanged.
🤖 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
`@__tests__/unit/app/pages/clinicworkspace/components/SiteFilterDropdown.test.js`:
- Line 98: Update the implementation’s metric names for the clinic site filter
so the apply and clear actions use the same singular/plural wording, then adjust
the expectation around mockTrackMetric if needed to match the unified name.

In `@app/pages/clinicworkspace/components/TagFilterDropdown.js`:
- Line 179: Update the zero-tags row in the tag filter dropdown to use the same
tag-option className and corresponding key convention as the surrounding tag
rows, replacing the copied clinic-site-specific identifiers on the Box element.
Preserve the row’s layout and zero-tags behavior.

---

Nitpick comments:
In `@app/core/metricUtils.js`:
- Line 2: Remove the unused useLocation import from metricUtils.js, leaving
trackMetric and the rest of the standalone utility unchanged.

In `@app/pages/clinicworkspace/components/SiteFilterDropdown.js`:
- Around line 75-227: Extract the duplicated DropdownContent logic into a shared
parameterized component covering search, pending selection, zero-state handling,
clear/apply actions, metrics, and empty states. Update
app/pages/clinicworkspace/components/SiteFilterDropdown.js lines 75-227 to pass
site-specific label, clinic?.sites, ZERO_SITES, site metric names, and
NoClinicSites props; update
app/pages/clinicworkspace/components/TagFilterDropdown.js lines 78-230 to use
the shared component with clinic?.patientTags, ZERO_TAGS, tag metric names, and
NoClinicTags. Remove the duplicated implementations while preserving existing
behavior.

In `@app/pages/clinicworkspace/useClinicMetricsPageName.js`:
- Around line 7-14: Update the pathname handling in the clinic metrics page-name
switch to use prefix matching so trailing slashes and nested clinic-workspace
routes resolve to the existing “Population Health” label. Add the
`/dashboard/tide` route prefix to the same mapping, while preserving “Unknown”
for unrelated paths.
🪄 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: 506fab81-2b7c-4605-85e1-4c0c50e518ee

📥 Commits

Reviewing files that changed from the base of the PR and between 7ac0870 and a3dedb5.

⛔ Files ignored due to path filters (1)
  • app/core/icons/tagIcon.svg is excluded by !**/*.svg
📒 Files selected for processing (13)
  • __tests__/unit/app/pages/clinicworkspace/ClinicPatients.test.js
  • __tests__/unit/app/pages/clinicworkspace/clinicPatientsFilters/FilterBySites.test.js
  • __tests__/unit/app/pages/clinicworkspace/clinicPatientsFilters/FilterByTags.test.js
  • __tests__/unit/app/pages/clinicworkspace/components/SiteFilterDropdown.test.js
  • __tests__/unit/app/pages/clinicworkspace/components/TagFilterDropdown.test.js
  • app/core/metricUtils.js
  • app/pages/clinicworkspace/ClinicPatients.js
  • app/pages/clinicworkspace/clinicPatientsFilters/FilterBySites.js
  • app/pages/clinicworkspace/clinicPatientsFilters/FilterByTags.js
  • app/pages/clinicworkspace/components/SiteFilterDropdown.js
  • app/pages/clinicworkspace/components/TagFilterDropdown.js
  • app/pages/clinicworkspace/useClinicMetricsPageName.js
  • app/pages/clinicworkspace/useIsClinicAdmin.js

Comment thread app/pages/clinicworkspace/components/TagFilterDropdown.js Outdated
@tidepool-org tidepool-org deleted a comment from coderabbitai Bot Aug 6, 2026

@clintonium-119 clintonium-119 left a comment

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.

Great job splitting this all apart. No major issues - just a bunch of small changes requested in the comments

Comment thread app/core/metricUtils.js Outdated
@@ -1,3 +1,4 @@
import appContext from '../bootstrap';
import { useLocation } from 'react-router-dom';

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.

Suggested change
import { useLocation } from 'react-router-dom';

Suggest removing this unused import.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +7 to +14
switch (pathname) {
case '/clinic-workspace':
case '/clinic-workspace/patients':
return 'Population Health';

default:
return 'Unknown';
};

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.

Suggested change
switch (pathname) {
case '/clinic-workspace':
case '/clinic-workspace/patients':
return 'Population Health';
default:
return 'Unknown';
};
if (pathname.startsWith('/clinic-workspace')) return 'Population Health';
return 'Unknown';

Consider prefix matching to avoid any variants, like trailing slashes falling through to the 'Unknown' case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated to match your suggested implementation: 909ff85

import get from 'lodash/get';
import includes from 'lodash/includes';

const useIsClinicAdmin = () => {

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.

Nice reuseable hook :)

There is an isClinicAdmin in clinicadmin.js that may be able to leverage this as well.

@henry-tp henry-tp Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops, that was the intention - to replace all access points. I missed this spot. 909ff85

The logic to calculate isClinicAdmin diverges between the two implementations. I double checked with claude which seems to think that they arrive at the same value. So I think we're good.

/>
);
};

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.

Suggest adding propTypes for exported components.

Copy link
Copy Markdown
Contributor Author

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

Choose a reason for hiding this comment

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

Suggest adding propTypes for exported components.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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


describe('SiteFilterDropdown', () => {
let store;
let wrapper;

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.

Suggested change
let wrapper;

Remove unused import.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +32 to +33
const setActiveFilters = jest.fn();
const setShowClinicPatientTagsDialog = jest.fn();

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.

Suggested change
const setActiveFilters = jest.fn();
const setShowClinicPatientTagsDialog = jest.fn();

Remove unused imports.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

import { thunk } from 'redux-thunk';
import { MemoryRouter } from 'react-router-dom';

import * as actions from '@app/redux/actions';

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.

Suggested change
import * as actions from '@app/redux/actions';

Remove unused imports.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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


describe('TagFilterDropdown', () => {
let store;
let wrapper;

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.

Suggested change
let wrapper;

Remove unused imports.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +32 to +33
const setActiveFilters = jest.fn();
const setShowClinicPatientTagsDialog = jest.fn();

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.

Suggested change
const setActiveFilters = jest.fn();
const setShowClinicPatientTagsDialog = jest.fn();

Remove unused imports.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@henry-tp
henry-tp requested a review from clintonium-119 August 6, 2026 17:04

@clintonium-119 clintonium-119 left a comment

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.

Changes LGTM!

Base automatically changed from WEB-4654-filter-bar to feat/filter-enhancements August 6, 2026 21:09
@henry-tp
henry-tp merged commit 08a49c8 into feat/filter-enhancements Aug 6, 2026
3 checks passed
@henry-tp
henry-tp deleted the WEB-4654-tags branch August 6, 2026 21:09
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