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 ability to use additional Toolbar buttons on the Gallery #751

Closed
wants to merge 1 commit into from

Conversation

oilee80
Copy link

@oilee80 oilee80 commented Mar 15, 2018

In a 3rd party JS file you can add a new Component that will be rendered

import React, { Component, PropTypes } from 'react';

class NewButton extends Component {
    render() {
        return (
          <button
            className="btn btn-secondary font-icon-sync btn--icon-xl"
            type="button"
          >
            <span className="btn__text btn__title">Button Label<span>
          </button>
        )
    }
}

window.assetAdmin = window.assetAdmin || {};
window.assetAdmin.gallery = window.assetAdmin.gallery || {};
window.assetAdmin.gallery.extraToolbarButtons = window.assetAdmin.gallery.extraToolbarButtons || [];
window.assetAdmin.gallery.extraToolbarButtons.push(NewButton);

In a 3rd party JS file you can add a new Component that will be rendered

```js
import React, { Component, PropTypes } from 'react';

class NewButton extends Component {
    render() {
        return (
          <button
            className="btn btn-secondary font-icon-sync btn--icon-xl"
            type="button"
          >
            <span className="btn__text btn__title">Button Label<span>
          </button>
        )
    }
}

window.assetAdmin = window.assetAdmin || {};
window.assetAdmin.gallery = window.assetAdmin.gallery || {};
window.assetAdmin.gallery.extraToolbarButtons = window.assetAdmin.gallery.extraToolbarButtons || [];
window.assetAdmin.gallery.extraToolbarButtons.push(NewButton);
```
@flamerohr
Copy link
Contributor

Sorry, but you can add extra buttons through Injector https://docs.silverstripe.org/en/4/developer_guides/customising_the_admin_interface/reactjs_redux_and_graphql/#transforming-services-using-middleware

I don't agree with using globals to add extra Components either, this will end up cluttering the global namespace greatly

@flamerohr flamerohr closed this Mar 15, 2018
@flamerohr
Copy link
Contributor

For reference, the work to enable adding new buttons to toolbar is here #712

@oilee80 oilee80 deleted the extra-gallery-buttons branch May 18, 2018 11:55
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