-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add organization settings #3324
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.
ee/api/test/test_organization.py
Outdated
) | ||
self.assertEqual(response.status_code, 400) | ||
self.assertTrue(Organization.objects.filter(id=org_id).exists()) | ||
self.assertEqual(response.status_code, 204) |
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.
If we can now leave the user, organization-less, maybe worth changing the test name here?
createOrganization: async (name: string) => await api.create('api/organizations/', { name }), | ||
createOrganization: async (name: string) => { | ||
const result = await api.create('api/organizations/', { name }) | ||
teamLogic.actions.loadCurrentTeam() |
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.
You're re-loading these endpoints, but there's still a listener that will cause a hard refresh, rendering this unused.
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.
I'll keep this as we'll be moving towards not requiring a hard refresh (#3421).
createOrganizationSuccess: () => { | ||
window.location.href = '/organization/members' | ||
}, | ||
}, | ||
renameCurrentOrganizationSuccess: () => { | ||
toast.success('Organization has been renamed') |
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.
Maybe it should be a larger question than the scope of this PR, but not showing an error message when something went wrong is not good UX.
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.
Ah, previously we relied on automatic API error toasts, but these got slashed and now lots of places in the UI are confusing because there's no info when something goes wrong…
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.
Maybe we need to start doing case-by-case error handling? Not entirely sure about the best approach here
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.
This is kind of pending #3525 and our overall approach to errors. I'm still for blanket catch-and-notify, unsure what (and whether) to do here.
<PageHeader | ||
title="Project Settings" | ||
caption={`Organize your analytics within the project. These settings only apply to ${ | ||
currentTeam?.name ?? '–' |
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.
how about a more applicable placeholder, "the current project"?
if (minimumAccessLevel === OrganizationMembershipLevel.Owner) { | ||
return 'This area is restricted to the organization owner.' | ||
} | ||
return `This area is restricted to organization ${OrganizationMembershipLevel[minimumAccessLevel]}s and up. Your level is only ${currentOrganization.membership_level}.` |
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.
Nit: think I would drop the only, maybe sounds a bit aggressive?
How about this empty state? |
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.
Some more feedback, feel free to disregard if you don't think it's useful.
- Tried deleting a project, got this server error.
django.db.utils.IntegrityError: update or delete on table "posthog_team" violates foreign key constraint "posthog_elementgroup_team_id_3ced0286_fk_posthog_team_id" on table "posthog_elementgroup"
- In terms of UX when you're deleting a project. After you click on delete, the buttons stay enabled and the modal can be dismissed. The toast says project is being deleted but then I get no confirmation. Further, if something went wrong I get no error message, the app just freezes there.
- The new avatar image on invites shows a
?
(presumably because first name is not set), we could use the email as a fallback.
ee/api/test/test_organization.py
Outdated
else: | ||
potential_err_message = f"Somehow did not delete the org as a level {level} (which is owner)" | ||
self.assertEqual(response.status_code, 204, potential_err_message) | ||
self.assertTrue(self.organization.name, "Woof") |
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.
If the organization is deleted, it shouldn't exist. I think you need to assert that the object does not exist in the DB (filtering by pk
). As an alternative you can assertRaises
calling object.refresh_from_db()
|
||
self.assertEqual(response_bis.status_code, 404, "Did not return a 404 on trying to delete a nonexistent org") | ||
|
||
def test_no_delete_organization_not_owning(self): |
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.
I would separate this into two tests, or remove the owner case altogether, makes the code confusing, and besides if the order of levels changes and owner
is not last, this will lead to weird results.
ee/api/test/test_organization.py
Outdated
self.assertTrue(self.organization.name, self.CONFIG_ORGANIZATION_NAME) | ||
else: | ||
potential_err_message = f"Somehow did not delete the org as a level {level} (which is owner)" | ||
self.assertEqual(response.status_code, 204, potential_err_message) |
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.
Maybe worth asserting that elements that should be cascade-deleted are removed too (e.g. OrgnizationMembership
s). Also, assert elements that should not be deleted (e.g. User
s)
okType: 'danger', | ||
okButtonProps: { | ||
// @ts-expect-error - data-attr works just fine despite not being in ButtonProps | ||
'data-attr': 'delete-organization-ok', |
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.
I think it's worth adding a custom event when an organization is deleted, we could include too number of projects, members, persons, and events?
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.
Alright, used get_analytics_metadata
for this. Without events though, as they are more difficult to compute across Postgres and CH.
Addressed all. I'll go ahead and merge. :) |
Changes
This reworks Organization Members to more robust Organization Settings.
Checklist