-
Notifications
You must be signed in to change notification settings - Fork 37
Migrate Rank.Threshold
to User Preferences
#6844
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the legacy TreeEditor.Rank.Threshold
remote preference into the new user‐preferences system.
- Adds
rankThreshold
andrankThresholdDescription
keys to localization dictionary - Defines a
rankThreshold
preference (with renderer) for multiple table types - Replaces old
getPref
usage withuserPreferences.use
inTree.tsx
- Introduces a new
ThresholdRank
renderer and related fetch logic
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
localization/preferences.ts | Added localization entries for rank threshold and its description |
components/TreeView/Tree.tsx | Swapped getPref for userPreferences.use and removed import |
components/Preferences/UserDefinitions.tsx | Inserted rankThreshold pref definitions across tables |
components/Preferences/Renderers.tsx | Added ThresholdRank renderer and fetch helper |
components/InitialContext/tests/snapshots/remotePrefs.test.ts.snap | Snapshot updated with unexpected key |
Comments suppressed due to low confidence (2)
specifyweb/frontend/js_src/lib/localization/preferences.ts:131
- Only
en-us
is provided forrankThreshold
. Consider adding translations for other supported locales to ensure a complete localization.
rankThreshold: {
specifyweb/frontend/js_src/lib/components/InitialContext/tests/snapshots/remotePrefs.test.ts.snap:53
- The snapshot now includes
TaxonTreeEditor.DisplayAuthor
but no code change adds or fetches this key. Verify if this line should be removed or if the test/setup needs updating.
"TaxonTreeEditor.DisplayAuthor": "true",
specifyweb/frontend/js_src/lib/components/Preferences/Renderers.tsx
Outdated
Show resolved
Hide resolved
specifyweb/frontend/js_src/lib/components/Preferences/Renderers.tsx
Outdated
Show resolved
Hide resolved
specifyweb/frontend/js_src/lib/components/Preferences/UserDefinitions.tsx
Show resolved
Hide resolved
…s.tsx Co-authored-by: Copilot <[email protected]>
This reverts commit e7c7afe.
specifyweb/frontend/js_src/lib/components/Preferences/Renderers.tsx
Outdated
Show resolved
Hide resolved
The items in the rank list in the pref are not in the same order than in the trees. We might want to change that. |
Suggested by @CarolineDenis
Fixed in the latest commit. Can you take another look? |
Triggered by 86a8e33 on branch refs/heads/issue-6843
![]() Using the API to grab all the ranks for the other trees (other than http://localhost/api/specify/geographytreedefitem/ {
"objects": [
{
"id": 1,
"fullnameseparator": ", ",
"isenforced": true,
"isinfullname": false,
"name": "Earth",
"rankid": 0,
"remarks": null,
"textafter": null,
"textbefore": null,
"timestampcreated": "2018-11-09T12:00:27",
"timestampmodified": "2018-11-09T12:00:27",
"title": "Earth",
"version": 1,
"createdbyagent": null,
"modifiedbyagent": null,
"parent": null,
"treedef": "/api/specify/geographytreedef/1/",
"treeentries": "/api/specify/geography/?definitionitem=1",
"children": "/api/specify/geographytreedefitem/?parent=1",
"resource_uri": "/api/specify/geographytreedefitem/1/"
},
{
"id": 2,
"fullnameseparator": ", ",
"isenforced": true,
"isinfullname": false,
"name": "Continent",
"rankid": 100,
"remarks": null,
"textafter": null,
"textbefore": null,
"timestampcreated": "2018-11-09T12:00:27",
"timestampmodified": "2018-11-09T12:00:27",
"title": "Continent",
"version": 0,
"createdbyagent": null,
"modifiedbyagent": null,
"parent": "/api/specify/geographytreedefitem/1/",
"treedef": "/api/specify/geographytreedef/1/",
"treeentries": "/api/specify/geography/?definitionitem=2",
"children": "/api/specify/geographytreedefitem/?parent=2",
"resource_uri": "/api/specify/geographytreedefitem/2/"
},
{
"id": 3,
"fullnameseparator": ", ",
"isenforced": true,
"isinfullname": false,
"name": "Country",
"rankid": 200,
"remarks": null,
"textafter": null,
"textbefore": null,
"timestampcreated": "2018-11-09T12:00:27",
"timestampmodified": "2018-11-09T12:00:27",
"title": "Country",
"version": 0,
"createdbyagent": null,
"modifiedbyagent": null,
"parent": "/api/specify/geographytreedefitem/2/",
"treedef": "/api/specify/geographytreedef/1/",
"treeentries": "/api/specify/geography/?definitionitem=3",
"children": "/api/specify/geographytreedefitem/?parent=3",
"resource_uri": "/api/specify/geographytreedefitem/3/"
},
{
"id": 4,
"fullnameseparator": ", ",
"isenforced": true,
"isinfullname": true,
"name": "State",
"rankid": 300,
"remarks": null,
"textafter": null,
"textbefore": null,
"timestampcreated": "2018-11-09T12:00:27",
"timestampmodified": "2018-11-09T12:00:27",
"title": "State",
"version": 0,
"createdbyagent": null,
"modifiedbyagent": null,
"parent": "/api/specify/geographytreedefitem/3/",
"treedef": "/api/specify/geographytreedef/1/",
"treeentries": "/api/specify/geography/?definitionitem=4",
"children": "/api/specify/geographytreedefitem/?parent=4",
"resource_uri": "/api/specify/geographytreedefitem/4/"
},
{
"id": 5,
"fullnameseparator": ", ",
"isenforced": true,
"isinfullname": true,
"name": "County",
"rankid": 400,
"remarks": null,
"textafter": null,
"textbefore": null,
"timestampcreated": "2018-11-09T12:00:27",
"timestampmodified": "2018-11-09T12:00:27",
"title": "County",
"version": 0,
"createdbyagent": null,
"modifiedbyagent": null,
"parent": "/api/specify/geographytreedefitem/4/",
"treedef": "/api/specify/geographytreedef/1/",
"treeentries": "/api/specify/geography/?definitionitem=5",
"children": "/api/specify/geographytreedefitem/?parent=5",
"resource_uri": "/api/specify/geographytreedefitem/5/"
},
{
"id": 6,
"fullnameseparator": ", ",
"isenforced": true,
"isinfullname": false,
"name": "Earth",
"rankid": 0,
"remarks": null,
"textafter": null,
"textbefore": null,
"timestampcreated": "2019-04-01T15:10:44",
"timestampmodified": "2019-04-01T15:10:44",
"title": "Earth",
"version": 1,
"createdbyagent": "/api/specify/agent/1686/",
"modifiedbyagent": null,
"parent": null,
"treedef": "/api/specify/geographytreedef/2/",
"treeentries": "/api/specify/geography/?definitionitem=6",
"children": "/api/specify/geographytreedefitem/?parent=6",
"resource_uri": "/api/specify/geographytreedefitem/6/"
},
{
"id": 7,
"fullnameseparator": ", ",
"isenforced": true,
"isinfullname": false,
"name": "Continent",
"rankid": 100,
"remarks": null,
"textafter": null,
"textbefore": null,
"timestampcreated": "2019-04-01T15:10:44",
"timestampmodified": "2019-04-01T15:10:44",
"title": "Continent",
"version": 0,
"createdbyagent": "/api/specify/agent/1686/",
"modifiedbyagent": null,
"parent": "/api/specify/geographytreedefitem/6/",
"treedef": "/api/specify/geographytreedef/2/",
"treeentries": "/api/specify/geography/?definitionitem=7",
"children": "/api/specify/geographytreedefitem/?parent=7",
"resource_uri": "/api/specify/geographytreedefitem/7/"
},
{
"id": 8,
"fullnameseparator": ", ",
"isenforced": true,
"isinfullname": true,
"name": "Country",
"rankid": 200,
"remarks": null,
"textafter": null,
"textbefore": null,
"timestampcreated": "2019-04-01T15:10:44",
"timestampmodified": "2019-04-01T15:10:44",
"title": "Country",
"version": 0,
"createdbyagent": "/api/specify/agent/1686/",
"modifiedbyagent": null,
"parent": "/api/specify/geographytreedefitem/7/",
"treedef": "/api/specify/geographytreedef/2/",
"treeentries": "/api/specify/geography/?definitionitem=8",
"children": "/api/specify/geographytreedefitem/?parent=8",
"resource_uri": "/api/specify/geographytreedefitem/8/"
},
{
"id": 9,
"fullnameseparator": ", ",
"isenforced": true,
"isinfullname": true,
"name": "State",
"rankid": 300,
"remarks": null,
"textafter": null,
"textbefore": null,
"timestampcreated": "2019-04-01T15:10:44",
"timestampmodified": "2019-04-01T15:10:44",
"title": "State",
"version": 0,
"createdbyagent": "/api/specify/agent/1686/",
"modifiedbyagent": null,
"parent": "/api/specify/geographytreedefitem/8/",
"treedef": "/api/specify/geographytreedef/2/",
"treeentries": "/api/specify/geography/?definitionitem=9",
"children": "/api/specify/geographytreedefitem/?parent=9",
"resource_uri": "/api/specify/geographytreedefitem/9/"
},
{
"id": 10,
"fullnameseparator": ", ",
"isenforced": true,
"isinfullname": true,
"name": "County",
"rankid": 400,
"remarks": null,
"textafter": null,
"textbefore": null,
"timestampcreated": "2019-04-01T15:10:44",
"timestampmodified": "2019-04-01T15:10:44",
"title": "County",
"version": 0,
"createdbyagent": "/api/specify/agent/1686/",
"modifiedbyagent": null,
"parent": "/api/specify/geographytreedefitem/9/",
"treedef": "/api/specify/geographytreedef/2/",
"treeentries": "/api/specify/geography/?definitionitem=10",
"children": "/api/specify/geographytreedefitem/?parent=10",
"resource_uri": "/api/specify/geographytreedefitem/10/"
}
],
"meta": {
"limit": 20,
"offset": 0,
"total_count": 10
}
} |
Triggered by 5d91e20 on branch refs/heads/issue-6843
Fixes #6843
This PR removes the dependence on the
TreeEditor.Rank.Threshold
remote preference in favor of using the User Preferences system.This does not migrate the existing value for this field, and it will instead need to be updated manually to reflect the collection's preference. The default value for all trees is to show the count of all nodes, but this might be undesirable.
ThresholdOptions.mov
Testing Instructions
Go to User Preferences
Verify that under each tree there is an option to configure the "Show object count"'
Verify that the ranks returned are correct for the current collection's tree(s)
Select a rank from each tree
Verify that the counts for all nodes under that level are shown in the tree
Test this across all current trees and verify the behavior