Skip to content

Commit 9b4b559

Browse files
lstocchijeffmaury
andauthored
feat: add warning banner to recipe page (#881)
* feat: add warning to recipe page Signed-off-by: lstocchi <[email protected]> * fix: format after rebase Signed-off-by: Jeff MAURY <[email protected]> * fix: unit tests Signed-off-by: Jeff MAURY <[email protected]> --------- Signed-off-by: lstocchi <[email protected]> Signed-off-by: Jeff MAURY <[email protected]> Co-authored-by: Jeff MAURY <[email protected]>
1 parent 484d4b9 commit 9b4b559

File tree

3 files changed

+51
-25
lines changed

3 files changed

+51
-25
lines changed

packages/frontend/src/lib/ContentDetailsLayout.svelte

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,38 @@ const toggle = () => {
88
};
99
</script>
1010

11-
<div class="grid w-full overflow-y-auto lg:grid-cols-[1fr_auto] max-lg:grid-cols-[auto]">
12-
<div class="p-5 inline-grid">
13-
<slot name="content" />
11+
<div class="flex flex-col w-full overflow-y-auto">
12+
<div class="p-5">
13+
<slot name="header" />
1414
</div>
15-
<div class="inline-grid max-lg:order-first">
16-
<div class="max-lg:w-full max-lg:min-w-full" class:w-[375px]="{open}" class:min-w-[375px]="{open}">
17-
<div
18-
class:hidden="{!open}"
19-
class:block="{open}"
20-
class="h-fit lg:bg-charcoal-800 lg:rounded-l-md lg:mt-5 lg:py-4 max-lg:block"
21-
aria-label="{`${detailsLabel} panel`}">
22-
<div class="flex flex-col px-4 space-y-4 mx-auto">
23-
<div class="w-full flex flex-row justify-between max-lg:hidden">
24-
<span class="text-base">{detailsTitle}</span>
25-
<button on:click="{toggle}" aria-label="{`hide ${detailsLabel}`}"
26-
><i class="fas fa-angle-right text-gray-900"></i></button>
15+
<div class="grid w-full lg:grid-cols-[1fr_auto] max-lg:grid-cols-[auto]">
16+
<div class="p-5 inline-grid">
17+
<slot name="content" />
18+
</div>
19+
<div class="inline-grid max-lg:order-first">
20+
<div class="max-lg:w-full max-lg:min-w-full" class:w-[375px]="{open}" class:min-w-[375px]="{open}">
21+
<div
22+
class:hidden="{!open}"
23+
class:block="{open}"
24+
class="h-fit lg:bg-charcoal-800 lg:rounded-l-md lg:mt-5 lg:py-4 max-lg:block"
25+
aria-label="{`${detailsLabel} panel`}">
26+
<div class="flex flex-col px-4 space-y-4 mx-auto">
27+
<div class="w-full flex flex-row justify-between max-lg:hidden">
28+
<span class="text-base">{detailsTitle}</span>
29+
<button on:click="{toggle}" aria-label="{`hide ${detailsLabel}`}"
30+
><i class="fas fa-angle-right text-gray-900"></i></button>
31+
</div>
32+
<slot name="details" />
2733
</div>
28-
<slot name="details" />
2934
</div>
30-
</div>
31-
<div
32-
class:hidden="{open}"
33-
class:block="{!open}"
34-
class="bg-charcoal-800 mt-5 p-4 rounded-md h-fit max-lg:hidden"
35-
aria-label="{`toggle ${detailsLabel}`}">
36-
<button on:click="{toggle}" aria-label="{`show ${detailsLabel}`}"
37-
><i class="fas fa-angle-left text-gray-900"></i></button>
35+
<div
36+
class:hidden="{open}"
37+
class:block="{!open}"
38+
class="bg-charcoal-800 mt-5 p-4 rounded-md h-fit max-lg:hidden"
39+
aria-label="{`toggle ${detailsLabel}`}">
40+
<button on:click="{toggle}" aria-label="{`show ${detailsLabel}`}"
41+
><i class="fas fa-angle-left text-gray-900"></i></button>
42+
</div>
3843
</div>
3944
</div>
4045
</div>

packages/frontend/src/pages/Recipe.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const mocks = vi.hoisted(() => {
3333
getApplicationsStateMock: vi.fn(),
3434
getLocalRepositoriesMock: vi.fn(),
3535
getTasksMock: vi.fn(),
36+
getModelsInfo: vi.fn(),
3637
};
3738
});
3839

@@ -62,6 +63,7 @@ vi.mock('../utils/client', async () => {
6263
pullApplication: mocks.pullApplicationMock,
6364
telemetryLogUsage: mocks.telemetryLogUsageMock,
6465
getApplicationsState: mocks.getApplicationsStateMock,
66+
getModelsInfo: mocks.getModelsInfo,
6567
},
6668
rpcBrowser: {
6769
subscribe: () => {
@@ -179,6 +181,7 @@ test('should display recipe information', async () => {
179181
vi.mocked(catalogStore).catalog = readable<ApplicationCatalog>(initialCatalog);
180182
mocks.getApplicationsStateMock.mockResolvedValue([]);
181183
mocks.getPullingStatusesMock.mockResolvedValue([]);
184+
mocks.getModelsInfo.mockResolvedValue([]);
182185
render(Recipe, {
183186
recipeId: 'recipe 1',
184187
});
@@ -192,6 +195,7 @@ test('should display updated recipe information', async () => {
192195
const customCatalog = writable<ApplicationCatalog>(initialCatalog);
193196
vi.mocked(catalogStore).catalog = customCatalog;
194197
mocks.getPullingStatusesMock.mockResolvedValue([]);
198+
mocks.getModelsInfo.mockResolvedValue([]);
195199
render(Recipe, {
196200
recipeId: 'recipe 1',
197201
});
@@ -209,7 +213,7 @@ test('should send telemetry data', async () => {
209213
vi.mocked(catalogStore).catalog = readable<ApplicationCatalog>(initialCatalog);
210214
mocks.getPullingStatusesMock.mockResolvedValue([]);
211215
mocks.pullApplicationMock.mockResolvedValue(undefined);
212-
216+
mocks.getModelsInfo.mockResolvedValue([]);
213217
render(Recipe, {
214218
recipeId: 'recipe 1',
215219
});

packages/frontend/src/pages/Recipe.svelte

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import RecipeModels from './RecipeModels.svelte';
1010
import { catalog } from '/@/stores/catalog';
1111
import RecipeDetails from '/@/lib/RecipeDetails.svelte';
1212
import ContentDetailsLayout from '../lib/ContentDetailsLayout.svelte';
13+
import type { ContainerConnectionInfo } from '@shared/src/models/IContainerConnectionInfo';
14+
import ContainerConnectionStatusInfo from '../lib/notification/ContainerConnectionStatusInfo.svelte';
15+
import { modelsInfo } from '../stores/modelsInfo';
16+
import { checkContainerConnectionStatus } from '../utils/connectionUtils';
1317
1418
export let recipeId: string;
1519
@@ -18,6 +22,12 @@ $: recipe = $catalog.recipes.find(r => r.id === recipeId);
1822
$: categories = $catalog.categories;
1923
let selectedModelId: string;
2024
$: selectedModelId = recipe?.models?.[0] ?? '';
25+
let connectionInfo: ContainerConnectionInfo | undefined;
26+
$: if ($modelsInfo && selectedModelId) {
27+
checkContainerConnectionStatus($modelsInfo, selectedModelId, 'recipe')
28+
.then(value => (connectionInfo = value))
29+
.catch((e: unknown) => console.log(String(e)));
30+
}
2131
2232
// Send recipe info to telemetry
2333
let recipeTelemetry: string | undefined = undefined;
@@ -44,6 +54,13 @@ function setSelectedModel(modelId: string) {
4454
</svelte:fragment>
4555
<svelte:fragment slot="content">
4656
<ContentDetailsLayout detailsTitle="AI App Details" detailsLabel="application details">
57+
<svelte:fragment slot="header">
58+
{#if connectionInfo}
59+
<div class="mx-5">
60+
<ContainerConnectionStatusInfo connectionInfo="{connectionInfo}" background="dark" />
61+
</div>
62+
{/if}
63+
</svelte:fragment>
4764
<svelte:fragment slot="content">
4865
<Route path="/">
4966
<MarkdownRenderer source="{recipe?.readme}" />

0 commit comments

Comments
 (0)