Skip to content

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

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft

Conversation

grantfitzsimmons
Copy link
Member

@grantfitzsimmons grantfitzsimmons commented Jul 1, 2025

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"'

    image
  • 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

@github-project-automation github-project-automation bot moved this to 📋Back Log in General Tester Board Jul 1, 2025
@grantfitzsimmons grantfitzsimmons changed the base branch from main to issue-6841 July 1, 2025 01:58
@grantfitzsimmons grantfitzsimmons requested a review from Copilot July 1, 2025 03:57
Copy link
Contributor

@Copilot Copilot AI left a 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 and rankThresholdDescription keys to localization dictionary
  • Defines a rankThreshold preference (with renderer) for multiple table types
  • Replaces old getPref usage with userPreferences.use in Tree.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 for rankThreshold. 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",

@grantfitzsimmons grantfitzsimmons marked this pull request as ready for review July 1, 2025 04:14
@grantfitzsimmons grantfitzsimmons requested a review from a team July 1, 2025 04:17
@CarolineDenis
Copy link
Contributor

CarolineDenis commented Jul 1, 2025

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.
Feature works for me 👍

@grantfitzsimmons
Copy link
Member Author

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.

Fixed in the latest commit. Can you take another look?

Triggered by 86a8e33 on branch refs/heads/issue-6843
Base automatically changed from issue-6841 to main July 2, 2025 23:29
@grantfitzsimmons
Copy link
Member Author

image

Using the API to grab all the ranks for the other trees (other than taxontreedefitem) returns all tree ranks from all disciplines–

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
    }
}

@grantfitzsimmons grantfitzsimmons marked this pull request as draft July 3, 2025 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📋Back Log
Development

Successfully merging this pull request may close these issues.

Move TreeEditor.Rank.Threshold.* to User Preferences
3 participants