uptick / react-keyed-file-browser

Folder based file browser given a flat keyed list of objects, powered by React.
MIT License
301 stars 144 forks source link

How to add a file action #96

Closed jestrickler closed 4 years ago

jestrickler commented 4 years ago

I am interested in adding an action to copy the selected file's url to the clipboard. I see where you can pass an actionRenderer through the browser props, but I am unclear on how to get ahold of the DefaultAction for existing actions (as it doesn't appear to be exported), or to extend it to add my custom action. Can you provide any pointers?

scaredcat commented 4 years ago

Hi @jestrickler the default actionRenderer lives here https://github.com/uptick/react-keyed-file-browser/blob/master/src/actions/default.js but it isn't exported.

In your situation you can make a copy of this file in your project and pass it in as the actionRenderer prop. You can then modify the component to display a copy to clipboard button inside of the if here https://github.com/uptick/react-keyed-file-browser/blob/aa6d24ec597ba22af8f19e4255c0f1b31e5b2b79/src/actions/default.js#L33 that handles logic of adding the selected files to the clipboard

jestrickler commented 4 years ago

Ok, I can approach it from that angle. Thanks, and thanks for the nice react component!