-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[ENG-580] feat: allow orgs to be cleared in Role org selector #16464
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: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,7 @@ export default function RoleOrgSelector(props: RoleOrgSelectorProps) { | |
|
|
||
| const [selectedOrganizations, setSelectedOrganizations] = useState< | ||
| Organization[] | ||
| >([]); | ||
| >(currentOrganizations || []); | ||
|
Comment on lines
45
to
+47
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify whether selectedOrganizations is synchronized after mount.
rg -n -C3 'useState<\s*Organization\[\]\s*>\(|setSelectedOrganizations\(|useEffect\(' src/components/Common/RoleOrgSelector.tsx
rg -n -C3 'RoleOrgSelector|currentOrganizations|value=' src/pages/Admin/TagConfig/TagConfigForm.tsxRepository: ohcnetwork/care_fe Length of output: 4171 🏁 Script executed: cat -n src/components/Common/RoleOrgSelector.tsxRepository: ohcnetwork/care_fe Length of output: 14712 Line 45–47: The initial state from Suggested fix const [selectedOrganizations, setSelectedOrganizations] = useState<
Organization[]
>(currentOrganizations || []);
+
+ useEffect(() => {
+ if (value && value.length > 0) {
+ const resolvedOrganizations = value
+ .map((id) => currentOrganizations?.find((org) => org.id === id))
+ .filter((org): org is Organization => Boolean(org));
+ setSelectedOrganizations(resolvedOrganizations);
+ return;
+ }
+ setSelectedOrganizations(currentOrganizations || []);
+ }, [value, currentOrganizations]);🤖 Prompt for AI Agents |
||
| const [currentSelection, setCurrentSelection] = useState<Organization | null>( | ||
| null, | ||
| ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,9 +75,9 @@ export interface TagConfigRequest { | |
| status: TagStatus; | ||
| parent?: string | null; | ||
| resource: TagResource; | ||
| organization?: string; | ||
| organization: string | null; | ||
| facility?: string; | ||
| facility_organization?: string; | ||
| facility_organization: string | null; | ||
|
Comment on lines
+78
to
+80
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Search for backend TagConfig serializer/model validation that may need to handle the new required-nullable contract
# Search for TagConfig model/serializer definitions
rg -n -C5 -i 'class.*tagconfig.*(serializer|model|viewset)' --type py
# Search for organization field validation
rg -n -C3 'organization.*field|facility_organization.*field' --type py -g '*tag*config*'Repository: ohcnetwork/care_fe Length of output: 211 🏁 Script executed: # First, locate and examine the tagConfig.ts file
fd -n "tagConfig.ts" -t fRepository: ohcnetwork/care_fe Length of output: 293 🏁 Script executed: # Check the context around lines 78-80 in the tagConfig file
if [ -f "src/types/emr/tagConfig/tagConfig.ts" ]; then
cat -n "src/types/emr/tagConfig/tagConfig.ts" | sed -n '70,90p'
fiRepository: ohcnetwork/care_fe Length of output: 753 🏁 Script executed: # Search for TagConfigRequest usage in mutations and queries
rg -n "TagConfigRequest" -t ts -t tsx -C 3Repository: ohcnetwork/care_fe Length of output: 90 🏁 Script executed: # Look for API endpoint definitions for tag config
rg -n "tag_config" -t ts -t tsx -A 2 -B 2 -g "*Api.ts"Repository: ohcnetwork/care_fe Length of output: 90 🏁 Script executed: # Check git history for changes to this interface
git log -p --follow -S "organization: string | null" -- "src/types/emr/tagConfig/tagConfig.ts" | head -100Repository: ohcnetwork/care_fe Length of output: 44 🏁 Script executed: # Search for TagConfigRequest usage in mutations and queries
rg "TagConfigRequest" -t ts -A 3 -B 3Repository: ohcnetwork/care_fe Length of output: 2651 🏁 Script executed: # Look for form usage or mutation definitions related to tag config
rg -i "tagconfig" -t ts -l | head -20Repository: ohcnetwork/care_fe Length of output: 1059 🏁 Script executed: # Check API route definitions for tag config
rg "tag_config" -t ts --max-count 20Repository: ohcnetwork/care_fe Length of output: 3707 🏁 Script executed: # View TagConfigForm to see how the payload is constructed, particularly organization and facility_organization fields
cat -n "src/pages/Admin/TagConfig/TagConfigForm.tsx" | head -150Repository: ohcnetwork/care_fe Length of output: 5816 🏁 Script executed: # See more of the TagConfigForm to understand the form structure and how organization/facility_organization are handled
cat -n "src/pages/Admin/TagConfig/TagConfigForm.tsx" | sed -n '1,250p'Repository: ohcnetwork/care_fe Length of output: 9717 🏁 Script executed: # Continue viewing the form to see organization and facility_organization field rendering
cat -n "src/pages/Admin/TagConfig/TagConfigForm.tsx" | sed -n '250,400p'Repository: ohcnetwork/care_fe Length of output: 6074 🏁 Script executed: # Check the git history to see if organization/facility_organization were changed from optional to required-nullable
git log --oneline -20 -- "src/types/emr/tagConfig/tagConfig.ts"Repository: ohcnetwork/care_fe Length of output: 134 🏁 Script executed: # Check the specific change in the git commit to see what changed from previous state
git show f826b8cf -- "src/types/emr/tagConfig/tagConfig.ts" | head -100Repository: ohcnetwork/care_fe Length of output: 2738 🏁 Script executed: # Also check the full diff of that commit
git show f826b8cf --statRepository: ohcnetwork/care_fe Length of output: 50374 🏁 Script executed: # Let's verify if this file existed before this commit or if it's truly new
git log --all --full-history -- "src/types/emr/tagConfig/tagConfig.ts" | head -50Repository: ohcnetwork/care_fe Length of output: 1751 🏁 Script executed: # Check the parent commit to see if the file existed before
git show f826b8cf^:src/types/emr/tagConfig/tagConfig.ts 2>&1 | head -20Repository: ohcnetwork/care_fe Length of output: 102 🏁 Script executed: # Check if this is truly a new file or if it was modified
git log --diff-filter=A -- "src/types/emr/tagConfig/tagConfig.ts"Repository: ohcnetwork/care_fe Length of output: 260 🏁 Script executed: # Let's look at the parent commit to see what existed before
git show 01dad4c040aca11befba547f2e4a0a9ebffbaa41:src/types/emr/tagConfig/tagConfig.ts 2>&1 | head -100Repository: ohcnetwork/care_fe Length of output: 2478 🏁 Script executed: # Let's verify the form data handling one more time to ensure null serialization is correct
cat -n "src/pages/Admin/TagConfig/TagConfigForm.tsx" | sed -n '177,196p'Repository: ohcnetwork/care_fe Length of output: 807 Verify backend API compatibility with required-nullable organization fields. This change alters the API contract: The form data construction confirms the payload will always include both fields:
Ensure the backend endpoints ( 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| export function getTagHierarchyDisplay( | ||
|
|
||
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.
useStateonly consumes its initializer on the very first render. InTagConfigForm,existingConfigis fetched asynchronously, socurrentOrganizationsis[]at the timeRoleOrgSelectormounts. By the time the query resolves andcurrentOrganizationschanges to[existingConfig.organization],selectedOrganizationsis already frozen at[].FacilityOrganizationSelectoralready solves this with a dedicateduseEffect(lines 292–305) that callssetSelectedOrganizations(resolvedOrganizations)whenevervalueorcurrentOrganizationschanges.RoleOrgSelectorneeds the same pattern; without it, the organization selector appears empty when opening the edit drawer for an existing tag config, even though the underlying form value is correctly set.