Skip to content

Phase 5: Populate User/Role Selectors in Share Dialog #203

@kevalyq

Description

@kevalyq

Problem

The Secret Sharing UI (Phase 4, PR #202) currently has empty arrays for users and roles in the ShareDialog:

<ShareDialog
  secretId={id}
  users={[]}  // ❌ Empty - selector shows no options
  roles={[]}  // ❌ Empty - selector shows no options
  open={shareDialogOpen}
  onClose={() => setShareDialogOpen(false)}
  onSuccess={refreshShares}
/>

This makes the share feature partially non-functional - users cannot select anyone to share with.

Root Cause

Frontend has no way to fetch available users/roles. Backend API endpoints missing:

  • GET /api/v1/users - List all users in the organization
  • GET /api/v1/roles - List all roles

Solution

Backend (api repo)

Create API endpoints (tracked in api#206):

  • GET /api/v1/users - Returns array of {id, name, email}
  • GET /api/v1/roles - Returns array of {id, name, description}

Frontend (this repo)

  1. Create API service (src/services/userApi.ts):

    export async function fetchUsers(): Promise<User[]>
    export async function fetchRoles(): Promise<Role[]>
  2. Fetch on SecretDetail mount:

    const [availableUsers, setAvailableUsers] = useState<User[]>([]);
    const [availableRoles, setAvailableRoles] = useState<Role[]>([]);
    
    useEffect(() => {
      const loadShareOptions = async () => {
        const [users, roles] = await Promise.all([
          fetchUsers(),
          fetchRoles()
        ]);
        setAvailableUsers(users);
        setAvailableRoles(roles);
      };
      loadShareOptions();
    }, []);
  3. Pass to ShareDialog:

    <ShareDialog
      users={availableUsers}
      roles={availableRoles}
      // ...
    />

Testing

  • Unit tests for userApi.ts (mock fetch)
  • Integration test: verify ShareDialog receives non-empty arrays
  • E2E test: open dialog, verify users/roles appear in selector

Dependencies

  • Backend: api#206 (API endpoints must be implemented first)
  • Frontend: This issue (blocked until backend ready)

Priority

Medium - Feature is implemented but not fully functional. Current workaround: Users can still revoke shares and see who has access.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    💡 Ideas

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions