Move and rename type Plugin to RecommendedPlugin.
This commit is contained in:
parent
0229354da0
commit
542b26e346
|
@ -15,9 +15,9 @@ import { flatMapDeep, uniqBy } from 'lodash';
|
|||
*/
|
||||
import { CardDivider, PluginCardBody } from '~/marketing/components';
|
||||
import { useInstalledPlugins } from '~/marketing/hooks';
|
||||
import { RecommendedPlugin } from '~/marketing/types';
|
||||
import { getInAppPurchaseUrl } from '~/lib/in-app-purchase';
|
||||
import { createNoticesFromResponse } from '~/lib/notices';
|
||||
import { Plugin } from './types';
|
||||
import './DiscoverTools.scss';
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ import './DiscoverTools.scss';
|
|||
* 1. Get an array of unique subcategories from the list of plugins.
|
||||
* 2. Map the subcategories schema into tabs schema.
|
||||
*/
|
||||
const getTabs = ( plugins: Plugin[] ) => {
|
||||
const getTabs = ( plugins: RecommendedPlugin[] ) => {
|
||||
const pluginSubcategories = uniqBy(
|
||||
flatMapDeep( plugins, ( p ) => p.subcategories ),
|
||||
( subcategory ) => subcategory.slug
|
||||
|
@ -44,7 +44,7 @@ const getTabs = ( plugins: Plugin[] ) => {
|
|||
|
||||
type PluginsTabPanelType = {
|
||||
isLoading: boolean;
|
||||
plugins: Plugin[];
|
||||
plugins: RecommendedPlugin[];
|
||||
onInstallAndActivate: ( pluginSlug: string ) => void;
|
||||
};
|
||||
|
||||
|
@ -72,7 +72,7 @@ export const PluginsTabPanel = ( {
|
|||
*
|
||||
* @param plugin Plugin to be installed and activated.
|
||||
*/
|
||||
const installAndActivate = async ( plugin: Plugin ) => {
|
||||
const installAndActivate = async ( plugin: RecommendedPlugin ) => {
|
||||
setCurrentPlugin( plugin.product );
|
||||
|
||||
try {
|
||||
|
@ -103,7 +103,7 @@ export const PluginsTabPanel = ( {
|
|||
)
|
||||
);
|
||||
|
||||
const renderButton = ( plugin: Plugin ) => {
|
||||
const renderButton = ( plugin: RecommendedPlugin ) => {
|
||||
const buttonDisabled = !! currentPlugin || isLoading;
|
||||
|
||||
if ( plugin.direct_install ) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
|
|||
* Internal dependencies
|
||||
*/
|
||||
import { STORE_KEY } from '~/marketing/data/constants';
|
||||
import { Plugin } from './types';
|
||||
import { RecommendedPlugin } from '~/marketing/types';
|
||||
|
||||
const selector = 'getRecommendedPlugins';
|
||||
const category = 'marketing';
|
||||
|
@ -24,7 +24,8 @@ export const useRecommendedPlugins = () => {
|
|||
return useSelect( ( select ) => {
|
||||
const { getRecommendedPlugins, hasFinishedResolution } =
|
||||
select( STORE_KEY );
|
||||
const plugins = getRecommendedPlugins< Plugin[] >( category );
|
||||
const plugins =
|
||||
getRecommendedPlugins< RecommendedPlugin[] >( category );
|
||||
const isLoading = ! hasFinishedResolution( selector, [ category ] );
|
||||
|
||||
return {
|
||||
|
|
|
@ -8,7 +8,7 @@ type Tag = {
|
|||
name: string;
|
||||
};
|
||||
|
||||
export type Plugin = {
|
||||
export type RecommendedPlugin = {
|
||||
title: string;
|
||||
description: string;
|
||||
url: string;
|
|
@ -1 +1,2 @@
|
|||
export { InstalledPlugin } from './InstalledPlugin';
|
||||
export { RecommendedPlugin } from './RecommendedPlugin';
|
||||
|
|
Loading…
Reference in New Issue