This patch fixes #336 - Allow users to fork/clone a graph.
Feature Details
Fork Graph Tab is not visible for Anonymous Users.
There is a separate tab available to Signed-in Users for viewing Forked Graphs.
Signed-in User can Fork all Public graphs and graph(s) shared with them in some group(s).
User can choose a name for the forked graph or leave the name field empty to use the default name.
Notification of successful fork and error both displayed in the Graph page.
Deleting a particular Forked graph will remove its parent-to-fork graph relationship entry from the database.
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.
Changes in the Database : Added _graph_forktable with the following fields - graph_id, and parent_graph_id.
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
Try to Fork public/shared graph. \
Observation : Works without any issues.
Forked Graph Tab.\
Observation : Forked graph tab is not visible for anonymous users. It is visible only for signed-in users
Forked Graph table \
Observation : Shows the forked graphs list correctly in the UI.
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.
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.
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.
Open Questions and Pre-Merge TODOs
[ ] Use github checklists. When solved, check the box and explain the answer.
Learning
Describe the research stage
Links to blog posts, patterns, libraries or addons used to solve this problem
Blog Posts
How to Pull Request Github Repo with Learning focused Pull Request Template.
Forked GraphSpace Manual repo and installed API Workbench on Atom.
Will build GraphSpace Manual right now and add the documentation for both PRs immediately.
Purpose
This patch fixes #336 - Allow users to fork/clone a graph.
Feature Details
parent-to-fork
graph relationship entry from the database.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 asparent_graph_id
, then I create a new graph using the existingadd_graph
functionality. When a new graph has been created I will insert a record in the _graphfork table with thegraph_id
of the new graph just created and theparent_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 parameteris_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
parent_to_fork
entry is erased fromgraph_fork
table in the database.parent_to_fork
entries are erased fromgraph_fork
table in the database. This operations does not remove the Forked Graphs from the database, it only erases theparent_to_fork
relationship information.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