ipfs-webui
ipfs-webui copied to clipboard
Add file overwrite confirmation
Whenever a file is moved to another folder, we don't check for the existence of a file with the same name & extension. Leading to potential unintentional overwriting.
To Reproduce Steps to reproduce the behavior:
- Have a
/dogs/oof.png
and/dogs/breeds/oof.png
- Drag the first one into the
breeds
folder - No confirmation modal is being used
We should ensure issues in https://github.com/ipfs/ipfs-webui/issues/1667 are addressed when we solve this
Note: This can probably reuse overwrite modal from https://github.com/ipfs-shipyard/ipfs-webui/issues/1667.
Proposed modal warnings to alleviate:
If only one file risks overwrite
- Icon is
stroke_attention
- Headline is
Overwrite file?
- Text is
You already have a file named (funny-cat.gif) in this directory. Are you sure you want to overwrite it? This action is permanent and cannot be reversed.
- Buttons are
Overwrite
andCancel
If multiple files risk overwrite
This one is just a first pass at conveying concepts, and would appreciate feedback from @lidel and @rafaelramalho19. Note that this approach doesn't give an option for iterating though the n files that would be overwritten and making a decision one by one -- it's an all-or-nothing. Would prefer the option to iterate, but don't want to block progress in order to create a more comprehensive solution.
- I like both, but the first one is more useful because it shows the name of a conflicting item.
- I think we iterate anyway? each item is copied separately via
ipfs files cp
- I think we iterate anyway? each item is copied separately via
- It may be safer to use
item
instead offile
– we could use the same text for files and directories instead of having two sets of strings. I believe we use "item" in other places already. - We will not display this dialog if the destination has the same name AND CID, so it may be useful to highlight that we ask user for decision because the underlying CID is different
- Perhaps something like
You already have an item named (funny-cat.gif) in this directory and it points at a different CID.
?
- Perhaps something like
@lidel So is correct that, if we are iterating and copying files separately, we'd never run into a circumstance like the one in the second screenshot? (That's awkward if someone drags 5000000000 files and 1/10 of those are same-named, but a subject for another issue.)
Good call on those other two points. LMK about the iteration thing and I can provide updated screenshots as necessary.
Correct. Code at files/actions.js#L282-L292 copies to proper MFS path after successful add. This because we want the same CID as in CLI (details in https://github.com/ipfs-shipyard/ipfs-webui/issues/676).
So we won't have use for the second screenshot.
I've been thinking about user interaction here and Overwrite-or-Cancel may be annoying if user does not mind fixing filenames later on their own. Appending CID to the filename could be a viable strategy for some users.
What if the first screenshot is augumented with additional button that provides less invasive resolution?
- Cancel – aborts the operation
- (needs name) – appends CID at the end of filename, so there is no conflict
- Overwrite – overwrites destination with new CID
@lidel How about ...
- Icon is
stroke_attention
- Headline is
Duplicate item name
- Text (note italics for item name) is
The destination directory already contains an item named (funny-cat.gif), but with a different CID. Do you want to overwrite the item in the destination directory, or rename the item you're moving by adding the last 4 characters of its CID to its name?
- Buttons are
Cancel
,Rename
, andOverwrite
LGTM! small nits:
- Can we make item name more prominent?
- Idea: if we use the same bold font as
Duplicate item name
text, then it will make is super easy to eyeball without reading entire text :)
- Idea: if we use the same bold font as
- Small worry:
Rename
may suggest that clicking on it will ask for alternative name (people only read buttons)- either we do that (instead of appending) or..
- rename
Rename
(:upside_down_face:) toMake unique
to avoid confusion?
@lidel Once more, with feeling. I think "Append" as a button name should work for visual scanning purposes. If this works for you, I'll update the specs accordingly in this issue and the other two related ones ... LMK.
@lidel was this feature ever merged, and if not, do we still want to do this?