You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 componentonClick: ()=>{}// 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)=>{returnselect('whatever-store-maintains-the-schema').fetchSchemaOrWhatever();});}});
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.
Acceptance Criteria
registerActivityBarUtility()
exists and is callable by 3rd party pluginsTechnical Details
If the GraphiQL schema refresh button was built as a plugin, it might look like this:
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
The text was updated successfully, but these errors were encountered: