Skip to content

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

Merged
merged 6 commits into from
May 14, 2024
Merged

Conversation

aslilac
Copy link
Member

@aslilac aslilac commented May 13, 2024

The important bit of this change is in AuthContext.tsx and DashboardProvider.tsx:

  • AuthContext now exposes an organizationIds property, which is a list, rather than the organizationId 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.

@aslilac aslilac requested review from Emyrk and BrunoQuaresma May 13, 2024 20:58
Comment on lines +46 to +50
const [activeOrganizationId, setActiveOrganizationId] = useState(() =>
lastUsedOrganizationId && organizationIds.includes(lastUsedOrganizationId)
? lastUsedOrganizationId
: organizationIds[0],
);
Copy link
Member

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);
Copy link
Member

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!

Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma left a comment

Choose a reason for hiding this comment

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

Good changes 🙏

@aslilac aslilac merged commit a8a0be9 into main May 14, 2024
28 checks passed
@aslilac aslilac deleted the multi-org-state branch May 14, 2024 16:48
@github-actions github-actions bot locked and limited conversation to collaborators May 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants