From 9b4b55929b5835c2d5dfa4d3a8f89cc167aa126d Mon Sep 17 00:00:00 2001 From: Luca Stocchi <49404737+lstocchi@users.noreply.github.com> Date: Tue, 16 Apr 2024 09:43:55 +0200 Subject: [PATCH] feat: add warning banner to recipe page (#881) * feat: add warning to recipe page Signed-off-by: lstocchi * fix: format after rebase Signed-off-by: Jeff MAURY * fix: unit tests Signed-off-by: Jeff MAURY --------- Signed-off-by: lstocchi Signed-off-by: Jeff MAURY Co-authored-by: Jeff MAURY --- .../src/lib/ContentDetailsLayout.svelte | 53 ++++++++++--------- packages/frontend/src/pages/Recipe.spec.ts | 6 ++- packages/frontend/src/pages/Recipe.svelte | 17 ++++++ 3 files changed, 51 insertions(+), 25 deletions(-) diff --git a/packages/frontend/src/lib/ContentDetailsLayout.svelte b/packages/frontend/src/lib/ContentDetailsLayout.svelte index 034f1967a..4043717f3 100644 --- a/packages/frontend/src/lib/ContentDetailsLayout.svelte +++ b/packages/frontend/src/lib/ContentDetailsLayout.svelte @@ -8,33 +8,38 @@ const toggle = () => { }; -
-
- +
+
+
-
-
-
-
-
- {detailsTitle} - +
+
+ +
+
+
+
+
+
+ {detailsTitle} + +
+
-
-
-
- +
+ +
diff --git a/packages/frontend/src/pages/Recipe.spec.ts b/packages/frontend/src/pages/Recipe.spec.ts index cb160c491..7d73b5fcf 100644 --- a/packages/frontend/src/pages/Recipe.spec.ts +++ b/packages/frontend/src/pages/Recipe.spec.ts @@ -33,6 +33,7 @@ const mocks = vi.hoisted(() => { getApplicationsStateMock: vi.fn(), getLocalRepositoriesMock: vi.fn(), getTasksMock: vi.fn(), + getModelsInfo: vi.fn(), }; }); @@ -62,6 +63,7 @@ vi.mock('../utils/client', async () => { pullApplication: mocks.pullApplicationMock, telemetryLogUsage: mocks.telemetryLogUsageMock, getApplicationsState: mocks.getApplicationsStateMock, + getModelsInfo: mocks.getModelsInfo, }, rpcBrowser: { subscribe: () => { @@ -179,6 +181,7 @@ test('should display recipe information', async () => { vi.mocked(catalogStore).catalog = readable(initialCatalog); mocks.getApplicationsStateMock.mockResolvedValue([]); mocks.getPullingStatusesMock.mockResolvedValue([]); + mocks.getModelsInfo.mockResolvedValue([]); render(Recipe, { recipeId: 'recipe 1', }); @@ -192,6 +195,7 @@ test('should display updated recipe information', async () => { const customCatalog = writable(initialCatalog); vi.mocked(catalogStore).catalog = customCatalog; mocks.getPullingStatusesMock.mockResolvedValue([]); + mocks.getModelsInfo.mockResolvedValue([]); render(Recipe, { recipeId: 'recipe 1', }); @@ -209,7 +213,7 @@ test('should send telemetry data', async () => { vi.mocked(catalogStore).catalog = readable(initialCatalog); mocks.getPullingStatusesMock.mockResolvedValue([]); mocks.pullApplicationMock.mockResolvedValue(undefined); - + mocks.getModelsInfo.mockResolvedValue([]); render(Recipe, { recipeId: 'recipe 1', }); diff --git a/packages/frontend/src/pages/Recipe.svelte b/packages/frontend/src/pages/Recipe.svelte index 30b423cd6..ef7072f0f 100644 --- a/packages/frontend/src/pages/Recipe.svelte +++ b/packages/frontend/src/pages/Recipe.svelte @@ -10,6 +10,10 @@ import RecipeModels from './RecipeModels.svelte'; import { catalog } from '/@/stores/catalog'; import RecipeDetails from '/@/lib/RecipeDetails.svelte'; import ContentDetailsLayout from '../lib/ContentDetailsLayout.svelte'; +import type { ContainerConnectionInfo } from '@shared/src/models/IContainerConnectionInfo'; +import ContainerConnectionStatusInfo from '../lib/notification/ContainerConnectionStatusInfo.svelte'; +import { modelsInfo } from '../stores/modelsInfo'; +import { checkContainerConnectionStatus } from '../utils/connectionUtils'; export let recipeId: string; @@ -18,6 +22,12 @@ $: recipe = $catalog.recipes.find(r => r.id === recipeId); $: categories = $catalog.categories; let selectedModelId: string; $: selectedModelId = recipe?.models?.[0] ?? ''; +let connectionInfo: ContainerConnectionInfo | undefined; +$: if ($modelsInfo && selectedModelId) { + checkContainerConnectionStatus($modelsInfo, selectedModelId, 'recipe') + .then(value => (connectionInfo = value)) + .catch((e: unknown) => console.log(String(e))); +} // Send recipe info to telemetry let recipeTelemetry: string | undefined = undefined; @@ -44,6 +54,13 @@ function setSelectedModel(modelId: string) { + + {#if connectionInfo} +
+ +
+ {/if} +