-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Block Directory: Return inactive plugins in search results (#23688)
* Block Directory: Return inactive plugins with block directory results * Active a an inactive block plugin if we see a plugin URL The plugin URL will only exist if the plugin is already installed, so we can use that to activate that plugin. We can also use this link for uninstallation, so we make sure to add it into the block object when installing a plugin. * Add links to mocked plugin response * Fix mocked test data * Fix notice in install test
- Loading branch information
Showing
5 changed files
with
174 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/block-directory/src/store/utils/get-plugin-url.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Get the plugin's direct API link out of a block-directory response. | ||
* | ||
* @param {Object} block The block object | ||
* | ||
* @return {string} The plugin URL, if exists. | ||
*/ | ||
export default function getPluginUrl( block ) { | ||
if ( ! block ) { | ||
return false; | ||
} | ||
const link = block.links[ 'wp:plugin' ] || block.links.self; | ||
if ( link && link.length ) { | ||
return link[ 0 ].href; | ||
} | ||
return false; | ||
} |
Oops, something went wrong.