Skip to content

Commit

Permalink
Marks the commands APIs as stable (#50691)
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad authored May 17, 2023
1 parent 9018b15 commit 2452a92
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 16 deletions.
16 changes: 16 additions & 0 deletions packages/commands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ Undocumented declaration.

Undocumented declaration.

### useCommand

Attach a command to the Global command menu.

_Parameters_

- _command_ `import('../store/actions').WPCommandConfig`: command config.

### useCommandLoader

Attach a command loader to the Global command menu.

_Parameters_

- _loader_ `import('../store/actions').WPCommandLoaderConfig`: command loader config.

<!-- END TOKEN(Autogenerated API docs) -->

## Contributing to this package
Expand Down
2 changes: 2 additions & 0 deletions packages/commands/src/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export { CommandMenu } from './components/command-menu';
export { privateApis } from './private-apis';
export { default as useCommand } from './hooks/use-command';
export { default as useCommandLoader } from './hooks/use-command-loader';
4 changes: 0 additions & 4 deletions packages/commands/src/private-apis.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/pri
/**
* Internal dependencies
*/
import { default as useCommand } from './hooks/use-command';
import { default as useCommandLoader } from './hooks/use-command-loader';
import { default as useCommandContext } from './hooks/use-command-context';
import { store } from './store';

Expand All @@ -19,8 +17,6 @@ export const { lock, unlock } =

export const privateApis = {};
lock( privateApis, {
useCommand,
useCommandLoader,
useCommandContext,
store,
} );
9 changes: 1 addition & 8 deletions packages/core-commands/src/add-post-type-commands.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
/**
* WordPress dependencies
*/
import { privateApis } from '@wordpress/commands';
import { useCommand } from '@wordpress/commands';
import { __ } from '@wordpress/i18n';
import { plus } from '@wordpress/icons';

/**
* Internal dependencies
*/
import { unlock } from './lock-unlock';

const { useCommand } = unlock( privateApis );

export function useAddPostTypeCommands() {
useCommand( {
name: 'core/add-new-post',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { privateApis } from '@wordpress/commands';
import { useCommandLoader } from '@wordpress/commands';
import { __ } from '@wordpress/i18n';
import { useMemo } from '@wordpress/element';
import { useSelect } from '@wordpress/data';
Expand All @@ -15,7 +15,6 @@ import { getQueryArg, addQueryArgs, getPath } from '@wordpress/url';
*/
import { unlock } from './lock-unlock';

const { useCommandLoader } = unlock( privateApis );
const { useHistory } = unlock( routerPrivateApis );

const icons = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { useDispatch } from '@wordpress/data';
import { __ } from '@wordpress/i18n';
import { trash, backup } from '@wordpress/icons';
import { privateApis as commandsPrivateApis } from '@wordpress/commands';
import { useCommandLoader } from '@wordpress/commands';
import { privateApis as routerPrivateApis } from '@wordpress/router';

/**
Expand All @@ -16,7 +16,6 @@ import isTemplateRemovable from '../../utils/is-template-removable';
import isTemplateRevertable from '../../utils/is-template-revertable';
import { unlock } from '../../private-apis';

const { useCommandLoader } = unlock( commandsPrivateApis );
const { useHistory } = unlock( routerPrivateApis );

function useEditModeCommandLoader() {
Expand Down

0 comments on commit 2452a92

Please sign in to comment.