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

Add Refresh ability on the Gallery & Toolbar #784

Closed
wants to merge 2 commits into from

Conversation

oilee80
Copy link

@oilee80 oilee80 commented May 18, 2018

Adds a new handleRefreshPage method to AssetAdmin JS which is then passed into the Gallery component and from there the GalleryToolbar

It works by passing updating the variables passed via GraphQL to include a random cache_buster. Just asking it to make the same request again doesn't work as the variables are the same so the response was being returned from an internal cache in the apollo-client

NOTE: Needing to add this so that a "sync" button (https://github.com/MadeHQ/silverstripe-cloudinary) that causes assets on the server to update from a third party store can then get the updates without having to navigate into and out of folders or close and then re-open the asset browser

Adds a new `handleRefreshPage` method to AssetAdmin JS which is then
passed into the `Gallery` component and from there the `GalleryToolbar`

It works by passing updating the variables passed via GraphQL to include
a random `cache_buster`. Just asking it to make the same request again
doesn't work as the variables are the same so the response was being
returned from an internal cache in the apollo-client
oilee80 added a commit to MadeHQ/silverstripe-cloudinary that referenced this pull request May 18, 2018
@oilee80
Copy link
Author

oilee80 commented May 22, 2018

Hiya @unclecheese, @flamerohr
Just checking if you could merge this in or if there is a better way to refresh the Gallery without closing and re-opening after the server has updated

@unclecheese
Copy link

Hi, @oilee80. This seems to be a domain-specific concern related to your Cloudinary module.

What you can do, ideally on the 4.2 release, is add this behaviour with Injector. The Gallery toolbar is now extensible due to @blueo 's work, and you can add arbitrary actions into it. Further, with SS 4.2 now shipping with Apollo 2.5, you'll be afforded a better API for refreshing query state rather than using a cachbuster workaround.

Either myself or @flamerohr can help you out with that in a separate discussion (maybe Slack?), but in the interim, a good starting point is the docs here: https://docs.silverstripe.org/en/4/developer_guides/customising_the_admin_interface/reactjs_redux_and_graphql/

@unclecheese
Copy link

Relevant PR/discussion. #712

@flamerohr
Copy link
Contributor

Apollo provides a refetch callback which forces a new request to be made, I don't remember the specifics at the moment, but I remember it was called readFiles() in either the AssetAdmin or Gallery props.

Highly recommend checking out the Injector work and see if that can be utilised for your refresh button :)

@oilee80
Copy link
Author

oilee80 commented May 24, 2018

Hi @unclecheese, @flamerohr, Thanks for the info about forceFetch: true I gave it a try at the top level of the readFilesQuery but I'm unable to see how to control this from an Toolbar button. It appears as though much of the PR would still be required but instead of using the cacheBuster parameter it would just use the forceFetch instead.

NOTE: I'm making use of the Injector to add the new button to the gallery toolbar

@maxime-rainville
Copy link
Contributor

Sounds like this PR is no longer needed or that there's a better way of achieving the stated goal.

Shall we close it?

@unclecheese
Copy link

Closing as it seems to be domain-specific and we haven't had any follow-up from the author.

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.

4 participants