Move and rename type Plugin to RecommendedPlugin.

This commit is contained in:
Gan Eng Chin 2022-12-10 00:33:10 +08:00
parent 0229354da0
commit 542b26e346
No known key found for this signature in database
GPG Key ID: 94D5D972860ADB01
4 changed files with 10 additions and 8 deletions

View File

@ -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 ) {

View File

@ -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 {

View File

@ -8,7 +8,7 @@ type Tag = {
name: string;
};
export type Plugin = {
export type RecommendedPlugin = {
title: string;
description: string;
url: string;

View File

@ -1 +1,2 @@
export { InstalledPlugin } from './InstalledPlugin';
export { RecommendedPlugin } from './RecommendedPlugin';