Skip to content

[FEATURE] Leave Organization flow with sole-owner validation block #544

Description

@CRamsan

Status

Built, and appears to match requirements. This issue is mainly a verification/close-out pass, not new implementation,
unless the checks below turn up a real gap.

What's there

Implemented as an in-screen confirmation dialog on OrgDetailScreen (OrgDetailDialogState.ConfirmLeave), not a
separate screen — this matches edifikana/mockups/organization-detail.html, whose leave confirmation is an inline
modal, not a dedicated route.

  • UI: OrgDetailContent's LeaveButton is disabled when uiState.isSoleOwner, with caption "Transfer ownership
    before leaving" (OrgDetailScreen.kt).
  • Sole-owner detection: computed client-side in OrgDetailViewModel.initialize() from the member list
    (ownerCount == 1 && myMembership.role == OWNER).
  • Confirm flow: confirmLeaveOrganization() calls MembershipManager.leaveOrganization(orgId), navigates to
    SettingsDestination.MyOrganizationsDestination (clearing the back stack) on success, shows a snackbar on failure.
  • Backend independently enforces the same rule server-side (defense in depth, not just a client check):
    MembershipService.leaveOrganization() throws if isSoleOwner(orgId, callerId)
    (edifikana/back-end/.../service/MembershipService.kt).

Verification pass

  • Confirm OrgDetailViewModelTest covers: sole-owner disables the button, non-sole-owner leave success path,
    leave API failure path
  • Known gap to check: confirmLeaveOrganization() currently always navigates to MyOrganizationsDestination
    on success, regardless of how many organizations remain. Decide whether a user with zero remaining
    organizations after leaving should instead land on a Create/Join Organization flow — and check whether
    MyOrganizationsScreen even has an empty-state UI today (a scan of MyOrganizationsScreen.kt found none).
  • If the above check out, close as complete; otherwise file the specific gap as its own scoped fix

Files

  • edifikana/front-end/app/src/commonMain/.../features/settings/organizations/orgdetail/{OrgDetailScreen,OrgDetailViewModel,OrgDetailUIState}.kt
  • edifikana/front-end/app/src/commonMain/.../features/settings/organizations/myorganizations/MyOrganizationsScreen.kt
  • edifikana/back-end/src/main/kotlin/com/cramsan/edifikana/server/service/MembershipService.kt

Related

Parent: #392.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions