Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: preserve file name, support sharing multiple files #479

Merged
merged 8 commits into from
May 18, 2018

Conversation

lidel
Copy link
Member

@lidel lidel commented May 16, 2018

This PR implements #349 by switching to the latest js-ipfs-api which enables support for wrapWithDirectory option in ipfs.files.add.

UI Preview

I did not want to do a redesign so just added options at the bottom:
screenshot_50

Not sure if these labels are clear enough, any suggestions?

TODO before merge

Add

  • support sharing multiple files
  • add checkbox for controlling directory wrapping
  • add checkbox for controlling automatic pinning (added while we are at it)
  • add locale keys

Fix

  • disable controls when embedded node is used
  • solve FILE_TOO_LARGE error from mozilla/addons-linter caused by the size of the latest js-ipfs-api

Optional (can be a separate PR)

Implements #349 (for now only for external node)
@lidel lidel added the UX label May 16, 2018
This is a simple workaround that encourages factor-bundle to do a more
even split that keeps .js files under 4MB limit.
@lidel lidel changed the title [WIP] feat: preserve file name in Quick Upload feat: preserve file name in Quick Upload May 16, 2018
@lidel
Copy link
Member Author

lidel commented May 16, 2018

@alanshaw @olizilla UI is temporary, but is there anything that could be improved (eg. labels) before we merge it?

@lidel lidel mentioned this pull request May 17, 2018
11 tasks
Multiple files can be selected using Ctrl/Shift modifier.
@olizilla
Copy link
Member

"Preserve the filename when adding a single item" is good wording for the label, but it leads to the question, when would I not want that? I vote for just doing the right thing here (wrap) and not troubling the user with the decision, as per ipfs/ipfs-gui#15 (comment) I don't think wrapping by default would harm anyone here.

"Recursively Pin added data"... I think we just do this for all data the user adds. I don't see any harm in doing this and not asking the user.

@lidel
Copy link
Member Author

lidel commented May 17, 2018

@olizilla Yeah it may be just me 🙃, but I often share ephemeral images and text snippets that don't need a name (or have an ugly one that I'd have to change before sharing) nor persistence (I don't' care to keep it alive forever).

I agree, the defaults are sane, but I really want to give power user an option to opt-out without need of using commandline, so I just collapsed them under a tiny upload options » that reveals them on click:

screenshot_52

Or maybe even shorter:
screenshot_53

@olizilla
Copy link
Member

@lidel ok well, you are our archetype power user, and if it helps you, then I'm for it. Collapsing it by default is a good idea, best of both.

@olizilla
Copy link
Member

"Upload options" is good and clear.

@lidel lidel changed the title feat: preserve file name in Quick Upload feat: preserve file name, support sharing multiple files May 17, 2018
@olizilla
Copy link
Member

I'll give this a try now

@olizilla
Copy link
Member

Using unicode glyphs as icons always seems like a good idea, but the cross browser rendering issues will drive you mad. I have tried.

extra lefty ticks on FF on mac
screenshot 2018-05-18 11 06 17

no labels on Chrome on mac
screenshot 2018-05-18 11 09 53

@olizilla
Copy link
Member

@lidel i'll see if I can track down why the labels are missing on chrome.

@olizilla
Copy link
Member

@lidel ah, the chrome label issue went away after a rebuild. meh.

Now the labels are hidden by default, I'm thinking they can be more informative like

  • --wrap-with-directory Wrap files in a directory to preserve their filenames.
  • --pin Pin files so they are retained when performing garbage collection on your local IPFS repo.

See: https://ipfs.io/docs/commands/#ipfs-add for more info

@lidel
Copy link
Member Author

lidel commented May 18, 2018

Switched to pure CSS checkmark that should look the same everywhere, updated labels.
I don't want to focus on it too much as the screen will be redesigned anyway,
but it should look ok for now:
screenshot_55

@olizilla please check if it does not 🔥 on mac.
I'd like to merge this and release to beta ASAP :)

Copy link
Member

@olizilla olizilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍 minor tweaks and good to go. One query about the file opener loop.

'url': url
})
console.info('[ipfs-companion] successfully stored', path)
console.log('uploadResultHandler.file-' + result.indexOf(file), file)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove debug logging or add [ipfs-companion] prefix

console.log('uploadResultHandler.file-' + result.indexOf(file), file)
// open the wrapping directory (or the CID if wrapping was disabled)
if (result.length === 1 || file.path === '' || file.path === file.hash) {
await browser.tabs.create({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the expected behaviour here? If i add a single file and let it be wrapped, I'm seeing it open the directory not the file. If i add multiple, it shows the directory.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is correct.

If wrapping is enabled or you are uploading more than one file, it will always open wrapping directory (the default).
If wrapping is disabled and a single file is uploaded, it will be opened directly. (requires explicit opt-in from user via upload options).

I feel it is a good default for now:

  • Most of users want to keep file names and as a side effect will get a branded directory listing provided by gateway
    (Until we integrate ideas from https://github.com/tableflip/share-via-ipfs via separate PRs)
  • Uploaded file can be a .zip file and browser can't show that.
    (Opening the file itself will just close the tab and start the download, which makes it difficult for user to copy the URL)
  • Mobile users are not forced to download the data, they just get directory listing and decide what do do with it (open the specific file, copy link to directory, copy direct link to file etc)

`
}
return html`
<button class='f6 link dim bn bg-transparent moon-gray dib pa0 pointer ma0' style='color: #6ACAD1' onclick=${onExpandOptions}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an mt3 here to get the same vertical space when the button transitions to the options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants