- Do you want to request a feature or report a bug?
BUG
- What is the current behavior?
When I add a file with the same title as an existing one and my slug equals title, the existing file is overwritten.
- If the current behavior is a bug, please provide the steps to reproduce.
make sure your slug equals title. add a file, choose a title that is already used by another file, save.
you have overwritten the existing file
- What is the expected behavior?
Less urgent if #1069 were implemented.
- What is the expected behavior?
- either:
a new file is created (i.e. with counter to filename)- or:
a warning that the file cannot be saved as it needs a unique title
In my opinion, a warning is the most reasonable option until #445 is done. @erquhart @talves @Benaiah
@tech4him1 I agree, and a warning should be straightforward to implement.
Can I claim this?
@brianlmacdonald That would be great, thanks!
I agree, this should be a warning until #445 and
let the user decide how they want to resolve.
@brianlmacdonald Let me know if you have any questions on this.
@tech4him1 , yes, can you point me to the files I need to be looking at for this?
@brianlmacdonald The area where the slug is created from the file title is:
https://github.com/netlify/netlify-cms/blob/f948f7a4082bccaed837684ee4915c9038db7d4d/src/backends/backend.js#L242-L251
You could likely just throw an error there, and it would be caught in the action:
https://github.com/netlify/netlify-cms/blob/55f01e6f1da080b59c711cbc45703be28429a34c/src/actions/entries.js#L304-L322
I'm not sure if something else would need to be done when in Editorial Workflow mode, that would be something to test.
@tech4him1 As a starting point, I was thinking about calling this.getEntry(collection, slug) after line 248, and if the return object comes back with the data key as anything other than an empty object, meaning it it found a preexisting file with the same name, then it throws an error.
@brianlmacdonald That sounds reasonable enough to me. The entry data is probably already stored under entries.entities in Redux, but that is not guaranteed to have all the entries anyway (i.e. pagination), so I would go with getEntry.
@tech4him1 I got it working in regular mode-- it throws a nice error when you try to save with a duplicate filename. Is it possible to set up editorial workflow mode using the default test repo?
@brianlmacdonald No, you have to use a live repo for editorial workflow currently. (One way to do it is just creating a blank GitHub repo for testing -- it doesn't need to be connected to a Netlify site.)
Adding editorial workflow support to the test backend in #1225.
Re-opening, #1239 was reverted a while back.
Can I claim this issue?
@siddhant1 for sure! claimed label is still applied from before, but it now applies to you :)
@siddhant1 Are you still working on this?
I'm keen to get this issue fixed, so happy to lend a hand or take it over if you're no longer working on it. 馃榿
So sorry for the delay ! I am a beginner and will appreciate a helping hand to resolve this ! Thanks :)
I think this PR #1931 has a fix for this issue.
Great! Thanks @barthc
Most helpful comment
Can I claim this issue?