User is able to leave an organization
## Problem Users can be [removed](https://gitlab.com/gitlab-org/gitlab/-/issues/435931 "Removing the organization user from the organization") from Organizations. Similarly, they should have a right to leave an Organization. ## Proposal - Add an option to `Leave Organization`. Where should this be located? - Leaving an Organization should remove a user as a member from all the groups and projects contained by the Organization. - User is warned about the consequences of leaving the Organization. - The user account stays intact. - As a result of leaving, the user loses member privileges for all the groups and projects contained in the Organization. - If the user is a member of more than 1 Organization, the Organization that the user left will not be available in the Organization switcher any longer. - If the user is a member of only 1 Organization and leaves that Organization, they are added to the default Organization instead. Add ellipse menu to organization homepage ![image.png](/uploads/008eb9c4bc736daf59d83d7911916be4/image.png) Clicking the ellipse opens a menu with an option to leave the organization ![image.png](/uploads/a6da16ee63d030509080c374e0856a98/image.png){width="309" height="143"} Clicking `Leave organization` opens a confirmation modal ![image.png](/uploads/2562de92f6c4f86f1f9dcdf2a172709a/image.png){width="613" height="232"} If the user is the sole owner of a group prevent leaving and display the following modal ![image.png](/uploads/a235b1075a1db087d928bc98e21ea0cc/image.png){width=615 height=194} If the user is the sole owner of an organization prevent leaving and display the following modal ![image](/uploads/c0cb70348a4bfe3af364acada2b92d0d/image.png) <details> <summary> Future iteration </summary> ![image](/uploads/70c0e998a0adfea803bd3b100d863c05/image.png) </details> ### Implementation plan 1. Add leave action to `app/assets/javascripts/vue_shared/components/list_actions/constants.js` 2. Render `app/assets/javascripts/vue_shared/components/list_actions/list_actions.vue` in `app/assets/javascripts/organizations/users/components/users_view.vue` by using the `user-actions` slot in `<users-table>` 3. Add `action: this.onActionLeave` and `text: `Leave organization` to leave action and then pass to `actions` prop 4. In `onActionLeave` open a `GlModal` 4. Check permissions added in https://gitlab.com/gitlab-org/gitlab/-/issues/441577 to determine what the modal should say. 5. If user confirms use GraphQL Mutation in https://gitlab.com/gitlab-org/gitlab/-/issues/423005 to remove the organization user
issue