Murali-group / GraphSpace

The interactive graph sharing website.
http://graphspace.org
GNU General Public License v2.0
30 stars 41 forks source link

Fork functionality #385

Open jahandaniyal opened 6 years ago

jahandaniyal commented 6 years ago

Purpose

This patch fixes #336 - Allow users to fork/clone a graph.

Feature Details

  1. Fork Graph Tab is not visible for Anonymous Users.
  2. There is a separate tab available to Signed-in Users for viewing Forked Graphs.
  3. Signed-in User can Fork all Public graphs and graph(s) shared with them in some group(s).
  4. User can choose a name for the forked graph or leave the name field empty to use the default name.
  5. Notification of successful fork and error both displayed in the Graph page.
  6. Deleting a particular Forked graph will remove its parent-to-fork graph relationship entry from the database.
  7. Deleting a Parent Graph will remove all parent-to-fork graph(s) relationship entries from the database. The Forked graphs will now behave just like Owned Graphs.

Approach

Forking option is only available for public and shared graphs not owned by the current User. I have created the Fork REST Api to handle Forking requests. User can send an add fork request using the Fork POST method. Graph details and JSON data is passed along with the request body. I am checking for user authentication and allowing only GET and POST requests from the user. For saving a fork I am using the following approach : From the request body I extract and store the ID of the graph as parent_graph_id, then I create a new graph using the existing add_graph functionality. When a new graph has been created I will insert a record in the _graphfork table with the graph_id of the new graph just created and the parent_graph_id.

Populating Index Page tables : Forked Graph index page is populated in a way similar to Public Graphs. Index pages of all graphs are populated using the Graph search feature, for example, in case of public graphs parameter is_public is passed to the search function. For forked graphs I am using the parameter is_forked. I have used this approach because a forked graph can also be considered as an Owned Graph therefore it needs a way to be found using the Graph API's search endpoint.

TEST CASES

  1. Try to Fork public/shared graph. \ Observation : Works without any issues.
  2. Forked Graph Tab.\ Observation : Forked graph tab is not visible for anonymous users. It is visible only for signed-in users
  3. Forked Graph table \ Observation : Shows the forked graphs list correctly in the UI.
  4. Delete a Forked Graph \ Observation : The graph is removed from the database and Owned/Forked Graph table. parent_to_fork entry is erased from graph_fork table in the database.
  5. Delete a Parent Graph \ Observation : Parent Graph is removed from the database. All parent_to_fork entries are erased from graph_fork table in the database. This operations does not remove the Forked Graphs from the database, it only erases the parent_to_fork relationship information.
  6. Fork Button Behavior \ Observation : Displays the number of times the Parent Graph has been forked (Pending). Hidden for all Owned/Private Graphs. Disabled after a successful Fork operation.

ezgif-3-3900458602

Open Questions and Pre-Merge TODOs

Learning

Describe the research stage

Links to blog posts, patterns, libraries or addons used to solve this problem

Blog Posts

jahandaniyal commented 6 years ago

Forked GraphSpace Manual repo and installed API Workbench on Atom. Will build GraphSpace Manual right now and add the documentation for both PRs immediately.