From 9718b11845d1e5fc25e93cd5f4ee5f9f53ef5cd2 Mon Sep 17 00:00:00 2001 From: Andres Sanabria Date: Tue, 3 Sep 2024 14:31:01 -0500 Subject: [PATCH 1/4] WIP on main fix: Identify plugin client component and log errors --- .../components/memories/plugins/plugins.tsx | 6 +--- .../components/plugins/indentify-plugin.tsx | 32 ++++++++++++++++--- frontend/src/components/shared/gleap.tsx | 2 -- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/memories/plugins/plugins.tsx b/frontend/src/components/memories/plugins/plugins.tsx index dd2b54f05..5225e1848 100644 --- a/frontend/src/components/memories/plugins/plugins.tsx +++ b/frontend/src/components/memories/plugins/plugins.tsx @@ -1,8 +1,6 @@ import { PluginsResult } from '@/src/types/memory.types'; import Markdown from 'markdown-to-jsx'; -import { Suspense } from 'react'; import IndentifyPlugin from '../../plugins/indentify-plugin'; -import IdentifyPluginLoader from '../../plugins/identify-plugin-loader'; import { ErrorBoundary } from 'next/dist/client/components/error-boundary'; import ErrorIdentifyPlugin from '../../plugins/error-identify-plugin'; @@ -19,9 +17,7 @@ export default function Plugins({ plugins }: PluginsProps) { return (
- }> - - +
diff --git a/frontend/src/components/plugins/indentify-plugin.tsx b/frontend/src/components/plugins/indentify-plugin.tsx index bcc3289a2..e0f837c6a 100644 --- a/frontend/src/components/plugins/indentify-plugin.tsx +++ b/frontend/src/components/plugins/indentify-plugin.tsx @@ -1,25 +1,47 @@ import { getCommunityPlugin } from '@/src/actions/plugins/get-community-plugins'; +import { CommunityPlugin } from '@/src/types/plugins/plugins.types'; import Image from 'next/image'; +import { useEffect, useState } from 'react'; +import ErrorIdentifyPlugin from './error-identify-plugin'; +import IdentifyPluginLoader from './identify-plugin-loader'; interface IndentifyPluginProps { pluginId: string; } -export default async function IndentifyPlugin({ pluginId }: IndentifyPluginProps) { - const pluginCommunity = await getCommunityPlugin(pluginId); - if (!pluginCommunity) throw new Error('Plugin not found'); +export default function IndentifyPlugin({ pluginId }: IndentifyPluginProps) { + const [pluginCommunity, setPluginCommunity] = useState( + undefined, + ); + const [loading, setLoading] = useState(true); + + useEffect(() => { + getCommunityPlugin(pluginId) + .then((plugin) => { + setPluginCommunity(plugin); + }) + .finally(() => setLoading(false)); + }, []); + + if (!pluginCommunity) { + return ; + } + + if (loading) { + return ; + } return (
{''}
-

{pluginCommunity.name}

+

{pluginCommunity?.name}

{pluginCommunity.description}

diff --git a/frontend/src/components/shared/gleap.tsx b/frontend/src/components/shared/gleap.tsx index 633824e36..86a29b4e1 100644 --- a/frontend/src/components/shared/gleap.tsx +++ b/frontend/src/components/shared/gleap.tsx @@ -3,8 +3,6 @@ import { FC, ReactNode, useEffect } from 'react'; import Gleap from 'gleap'; import envConfig from '@/src/constants/envConfig'; - - export const GleapInit: FC<{ children?: ReactNode }> = ({ children }) => { useEffect(() => { Gleap.initialize(envConfig.GLEAP_API_KEY ?? ''); From af79b0bcc1bc96b7e57ffbdb60aaec0408d98348 Mon Sep 17 00:00:00 2001 From: Andres Sanabria Date: Tue, 3 Sep 2024 14:34:23 -0500 Subject: [PATCH 2/4] fix: loading component first position --- frontend/src/components/plugins/indentify-plugin.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/plugins/indentify-plugin.tsx b/frontend/src/components/plugins/indentify-plugin.tsx index e0f837c6a..890e59bb2 100644 --- a/frontend/src/components/plugins/indentify-plugin.tsx +++ b/frontend/src/components/plugins/indentify-plugin.tsx @@ -23,13 +23,14 @@ export default function IndentifyPlugin({ pluginId }: IndentifyPluginProps) { .finally(() => setLoading(false)); }, []); + if (loading) { + return ; + } + if (!pluginCommunity) { return ; } - if (loading) { - return ; - } return (
From 7e51af9473a5fdf9d5af9271ef4ec58092674b5f Mon Sep 17 00:00:00 2001 From: Andres Sanabria Date: Tue, 3 Sep 2024 14:56:45 -0500 Subject: [PATCH 3/4] fix: plugin header height --- .../src/components/plugins/identify-plugin-loader.tsx | 4 ++-- frontend/src/components/plugins/indentify-plugin.tsx | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/plugins/identify-plugin-loader.tsx b/frontend/src/components/plugins/identify-plugin-loader.tsx index 85bc22e87..d6e1e63ab 100644 --- a/frontend/src/components/plugins/identify-plugin-loader.tsx +++ b/frontend/src/components/plugins/identify-plugin-loader.tsx @@ -2,8 +2,8 @@ import { OnePointCircle } from 'iconoir-react'; export default function IdentifyPluginLoader() { return ( -
-
+
+
diff --git a/frontend/src/components/plugins/indentify-plugin.tsx b/frontend/src/components/plugins/indentify-plugin.tsx index 890e59bb2..b959ed1f4 100644 --- a/frontend/src/components/plugins/indentify-plugin.tsx +++ b/frontend/src/components/plugins/indentify-plugin.tsx @@ -1,7 +1,7 @@ import { getCommunityPlugin } from '@/src/actions/plugins/get-community-plugins'; import { CommunityPlugin } from '@/src/types/plugins/plugins.types'; import Image from 'next/image'; -import { useEffect, useState } from 'react'; +import { Fragment, useEffect, useState } from 'react'; import ErrorIdentifyPlugin from './error-identify-plugin'; import IdentifyPluginLoader from './identify-plugin-loader'; @@ -26,14 +26,15 @@ export default function IndentifyPlugin({ pluginId }: IndentifyPluginProps) { if (loading) { return ; } - + if (!pluginCommunity) { return ; } return ( -
+ +
+ + ); } From d35cae2f83efa364f005a932b570bdcd01f2b3c0 Mon Sep 17 00:00:00 2001 From: Andres Sanabria Date: Tue, 3 Sep 2024 15:18:49 -0500 Subject: [PATCH 4/4] fix: plugins component last position --- frontend/src/components/memories/summary/sumary.tsx | 2 +- frontend/src/components/plugins/indentify-plugin.tsx | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/memories/summary/sumary.tsx b/frontend/src/components/memories/summary/sumary.tsx index 0336dccd5..191bdb4ad 100644 --- a/frontend/src/components/memories/summary/sumary.tsx +++ b/frontend/src/components/memories/summary/sumary.tsx @@ -18,13 +18,13 @@ export default function Summary({ memory }: SummaryProps) {

No overview available for this memory.

)}
- {memory.plugins_results.length > 0 && } {memory?.structured?.action_items?.length > 0 && ( )} {memory?.structured?.events?.length > 0 && ( )} + {memory.plugins_results.length > 0 && }
); } diff --git a/frontend/src/components/plugins/indentify-plugin.tsx b/frontend/src/components/plugins/indentify-plugin.tsx index b959ed1f4..f65be82ed 100644 --- a/frontend/src/components/plugins/indentify-plugin.tsx +++ b/frontend/src/components/plugins/indentify-plugin.tsx @@ -1,3 +1,5 @@ +'use client'; + import { getCommunityPlugin } from '@/src/actions/plugins/get-community-plugins'; import { CommunityPlugin } from '@/src/types/plugins/plugins.types'; import Image from 'next/image';