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

Close all folders programmatically or on files change #48

Open
dguayrobotiq opened this issue Jan 23, 2019 · 5 comments
Open

Close all folders programmatically or on files change #48

dguayrobotiq opened this issue Jan 23, 2019 · 5 comments

Comments

@dguayrobotiq
Copy link

Is there a way to close the file browser folders when its files change? Or anyway to do it programmatically?

@abogadotoast
Copy link

abogadotoast commented Jan 29, 2019

Yes.

One way that you could do this is with this.setState().

There are four properties for every item within the array that must be set.

Key - How the program generates the name and folder of the file. If you provide a key of "abc/def.jpg", the script will create a folder "abc" with file "def.jpg". Similarly, if you just provide "def.jpg", then no folder gets displayed on the front end, even if the URL has a folder.
Modified - A datetime formatted by moment.js. moment(YOUR_DATE_HERE) is how this works
Size - A file size in an integer.
URL - The full file path to the file (e.g. "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png")

The JSON for the following is templated in a fashion similar to the following example. This is an array with one object, but more objects mean more links on the list.

files: [{key: "def.jpg", modified: Moment("2019/01/01"), size: 26048, url: "https://www.google.com"}]

If the files change, you've likely used the onCreateFiles, onCreateFolder, onMoveFile, or onDeleteFile hooks.

I would put something like

{
const oldFiles = this.state['files'];
this.setState({files: []})
this.setState(files: oldFiles);
}

into the change hooks that you use. (Most hooks are optional.)

Failing that, I'm not certain. But that should flush the state, collapse and destroy all the folders on the frontend, and then immediately bring back the old state.

@zer0pool
Copy link

@dguayrobotiq
Did you find how to do it?
Thanks

@dguayrobotiq
Copy link
Author

@zentrapool sorry we finally made our own solution to have more flexible behaviors

@ziaulrehman40
Copy link
Contributor

@dguayrobotiq by any chance did you open sourced that solution? 😄

@dguay
Copy link

dguay commented May 14, 2020

@ziaulrehman40 Sorry we did not

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

No branches or pull requests

5 participants