Hubs-Foundation / Spoke

Easily create custom 3D environments
Other
655 stars 256 forks source link

Add "Save as" functionality to create copies of scenes #812

Open emclaren opened 5 years ago

emclaren commented 5 years ago

It would be nice to be able to take a scene I already have, save a new version and modify it so the original stays untouched. Currently, users can export and import a spoke file, but it would be nice if there was an easier way.

Either a "Save as" button inside the project, or maybe a "Duplicate" button in the project thumbnail dropdown (see screenshot).

Screen Shot 2019-10-24 at 11 22 01 AM
tharun208 commented 5 years ago

Hi @misslivirose, If the button is as a thumbnail dropdown, we don't have much context about the project ( e.g current editor screen in-state). So, can we keep that inside the project? Looking forward to your comments on this.

robertlong commented 5 years ago

@tharun208 Actually I think we can do this in the ProjectsPage in addition to the Save As option that you added to the editor menu.

Take a look at the createProject function in Api.js https://github.com/mozilla/Spoke/blob/master/src/api/Api.js#L418

We can load the project file using the url returned from the projects API: https://dev.reticulum.io/api/v1/projects and then create a new project using that JSON and whatever new name we want to give it.

tharun208 commented 5 years ago

sure @robertlong Will Add these changes and raise a PR

tharun208 commented 5 years ago

But @robertlong, If we use the above API means we need to have the thumbnail image of the scene because it is required by the createProject API

robertlong commented 5 years ago

@tharun208 yeah that is also returned by the https://dev.reticulum.io/api/v1/projects API. Rather than reusing the same thumbnail, I'd make a copy by downloading the file and reuploading. We should probably just have a server endpoint that does this, but until then we could implement it this way.

Here's an example response from that API endpoint:

{
  "projects": [
    {
      "name": "Tutorial",
      "project_id": "example",
      "project_url": "https://hubs-upload-cdn.com/files/example.json",
      "thumbnail_url": "https://hubs-upload-cdn.com/files/example.jpg"
    }
  ]
}
tharun208 commented 5 years ago

So right now we will be copying the same project_url and thumbnail_url and reusing it? @robertlong