Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

[Back End] Leave Option for Collaborator in Notebooks #43

@chrisdedman

Description

@chrisdedman

Objective

Currently, when a collaborator is added to a notebook, it can not leave or delete the notebook. Only the user who has ownership of that notebook can delete a collaborator. The goal of this update will be to give the user the option to leave the notebook when they are a collaborator.

Design

In the notebook setting, we currently have a delete button to delete a notebook. When a collaborator is added to a notebook, this collaborator does not have ownership of this notebook. So, does not have the authorization to delete this notebook. The idea is to have the delete notebook option changed to a "leave" option when the user is a collaborator in that notebook.

Possible Implementation

A new function will be added to the back end of the collaboration resolver. This function will use the existing function to fetch the user ID and remove them from the current notebook, similar to the delete collaborator. A new schema will be needed as well that does not check the collaborator's ownership. This schema can be similar to the delete collaborator's current schema.

@desc "Leave a collaboration"
field :leave_collaboration, :collaborator do
    arg(:notebook_id, non_null(:id))
    arg(:user_id, non_null(:id))

    middleware Speakeasy.LoadResource, fn(%{notebook_id: notebook_id}) -> 
        Cursif.Notebooks.get_notebook!(notebook_id) 
    end
    middleware Speakeasy.Authz, {Cursif.Notebooks, :collaborator}

    resolve(&Collaborators.leave_collaboration/2)
end

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

📋 Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions