-
Notifications
You must be signed in to change notification settings - Fork 896
chore: expose all organization ids from AuthContext #13268
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
Conversation
const [activeOrganizationId, setActiveOrganizationId] = useState(() => | ||
lastUsedOrganizationId && organizationIds.includes(lastUsedOrganizationId) | ||
? lastUsedOrganizationId | ||
: organizationIds[0], | ||
); |
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.
Talked to @aslilac, we are not going to introduce the concept of "Default Org" to the FE. It is a stop gap on the backend to accommodate features like group sync, role sync, SCIM, etc. Those features need to be upgraded to not rely on default org.
If a deployment exists with more than 1 org, this is no more broken than it currently is today.
if (!organizationIds.includes(id)) { | ||
throw new ReferenceError("Invalid organization ID"); | ||
} | ||
localStorage.setItem(`user:${user.id}.lastUsedOrganizationId`, id); |
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.
Smart assigning to a user!
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.
Good changes 🙏
The important bit of this change is in AuthContext.tsx and DashboardProvider.tsx:
AuthContext
now exposes anorganizationIds
property, which is a list, rather than theorganizationId
property, which was a single ID.DashboardContext
is now responsible for managing the state around which organization should be "active" in the app.The rest is just "to whom it may concern" updates to accommodate those changes.
Also, some of these usages of
organizationId
are almost certainly incorrect, but I'd rather audit all of that in a separate PR.