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 a button to the "Activity Bar Utilities" #111

Open
2 tasks
Tracked by #109
josephfusco opened this issue Apr 16, 2024 · 0 comments
Open
2 tasks
Tracked by #109

Add a button to the "Activity Bar Utilities" #111

josephfusco opened this issue Apr 16, 2024 · 0 comments
Labels
type: enhancement Improvements to existing functionality

Comments

@josephfusco
Copy link
Member

josephfusco commented Apr 16, 2024

Acceptance Criteria

  • registerActivityBarUtility() exists and is callable by 3rd party plugins
  • Function handles edge cases & invalid input

Technical Details

const { registerActivityBarUtility } = WPGRAPHQL_IDE;

registerActivityBarUtility( 'my-button', {
  title: 'My Button',
  label: 'My Button does x, y and z',
  icon: () => {}, // name of icon from supported icon library or custom Icon component
  onClick: () => {} // event callback for the button click
} );

If the GraphiQL schema refresh button was built as a plugin, it might look like this:

import { useSelect } from '@wordpress/data';

const { registerActivityBarUtility } = WPGRAPHQL_IDE;

registerActivityBarUtility( 'refresh-schema', {
  title: 'Refresh GraphQL Schema',
  label: 'Refresh the schema from the WPGraphQL endpoint and load it into the IDE',
  icon: () => <RefreshIcon />,
  onClick: () => {
    // access redux store and execute an action (pseudo code)
    useSelect( ( select ) => {
      return select( 'whatever-store-maintains-the-schema' ).fetchSchemaOrWhatever();
    });
  }
});

Image

The list of utilities should be maintained in the Redux store, so registering a utility should modify the list of utilities in the Redux store. Similar when you call registerBlockType in Gutenberg.

Reference

@josephfusco josephfusco mentioned this issue Apr 16, 2024
14 tasks
@josephfusco josephfusco added the type: enhancement Improvements to existing functionality label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Improvements to existing functionality
Projects
None yet
Development

No branches or pull requests

1 participant