PluginProbe
Extendify / 3.0.6
Extendify v3.0.6
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Assist / components / dashboard / Recommendations.jsx

Recommendations.jsx in Extendify 3.0.6, at src/Assist/components/dashboard/Recommendations.jsx

66 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { RecommendationCard } from '@assist/components/dashboard/RecommendationCard';
2 import { isAtLeastNDaysAgo } from '@assist/lib/recommendations';
3 import { safeParseJson } from '@shared/lib/parsing';
4 import { __ } from '@wordpress/i18n';
5
6 const siteCreatedAt = window.extSharedData?.siteCreatedAt ?? '';
7 const recommendations =
8 safeParseJson(window.extSharedData.resourceData)?.recommendations || [];
9 const plugins =
10 window.extSharedData?.activePlugins?.map((plugin) => plugin.split('/')[0]) ||
11 [];
12
13 const getRecommendations = () =>
14 recommendations
15 // Filter out recs that have pluginExclusions, and the plugin is already installed
16 .filter((rec) =>
17 rec?.pluginExclusions?.length
18 ? rec?.pluginExclusions?.every(
19 (dep) => !plugins.find((plugin) => plugin === dep)?.length,
20 )
21 : true,
22 )
23 // Filter out recs where there is a plugin dep, and the plugin is not installed
24 .filter((rec) =>
25 rec?.pluginDepSlugs?.length
26 ? rec?.pluginDepSlugs?.every(
27 (dep) => plugins.find((plugin) => plugin === dep)?.length,
28 )
29 : true,
30 )
31 .sort((a, b) => b.priority - a.priority)
32 // filter out recs based on the showAfterDay field
33 .filter((rec) =>
34 // Only show recommendations after the number of days set in rec.showAfterDay
35 isAtLeastNDaysAgo(siteCreatedAt, rec?.showAfterDay ?? 0) ? rec : false,
36 );
37
38 export const Recommendations = () => {
39 const filteredRecommendations = getRecommendations();
40
41 if (!filteredRecommendations?.length) return;
42
43 return (
44 <div
45 data-test="assist-recommendations-module"
46 id="assist-recommendations-module"
47 className="h-full w-full rounded-sm border border-gray-300 bg-white p-5 text-base lg:p-8"
48 >
49 <h2 className="mb-4 mt-0 text-lg font-semibold">
50 {__('Website Tools & Plugins', 'extendify-local')}
51 </h2>
52 <div
53 className="grid gap-y-3 md:grid-cols-3 md:gap-3"
54 data-test="assist-recommendations-module-list"
55 >
56 {filteredRecommendations.map((recommendation) => (
57 <RecommendationCard
58 key={recommendation.slug}
59 recommendation={recommendation}
60 />
61 ))}
62 </div>
63 </div>
64 );
65 };
66