-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: details page for disk images #866
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
<script lang="ts"> | ||
import { router } from 'tinro'; | ||
import type { BootcBuildInfo } from '/@shared/src/models/bootc'; | ||
|
||
export let object: BootcBuildInfo; | ||
|
||
function openDetails() { | ||
router.goto(`/details/${btoa(object.id)}/summary`); | ||
} | ||
</script> | ||
|
||
<div class="text-[var(--pd-table-body-text-highlight)] overflow-hidden text-ellipsis"> | ||
{object.image}:{object.tag} | ||
</div> | ||
<button class="hover:cursor-pointer flex flex-col max-w-full" on:click={() => openDetails()}> | ||
<div class="text-[var(--pd-table-body-text-highlight)] max-w-full overflow-hidden text-ellipsis"> | ||
{object.image}:{object.tag} | ||
</div> | ||
</button> |
66 changes: 66 additions & 0 deletions
66
packages/frontend/src/lib/disk-image/DiskImageDetails.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/********************************************************************** | ||
* Copyright (C) 2024 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
***********************************************************************/ | ||
import '@testing-library/jest-dom/vitest'; | ||
|
||
import { render, screen } from '@testing-library/svelte'; | ||
import { beforeEach, expect, test, vi } from 'vitest'; | ||
import { bootcClient } from '/@/api/client'; | ||
|
||
import DiskImageDetails from './DiskImageDetails.svelte'; | ||
import type { BootcBuildInfo } from '/@shared/src/models/bootc'; | ||
import { tick } from 'svelte'; | ||
|
||
const image: BootcBuildInfo = { | ||
id: 'id1', | ||
image: 'my-image', | ||
imageId: 'image-id', | ||
tag: 'latest', | ||
engineId: 'podman', | ||
type: ['ami'], | ||
folder: '/bootc', | ||
}; | ||
|
||
vi.mock('/@/api/client', async () => { | ||
return { | ||
bootcClient: { | ||
listHistoryInfo: vi.fn(), | ||
}, | ||
rpcBrowser: { | ||
subscribe: () => { | ||
return { | ||
unsubscribe: () => {}, | ||
}; | ||
}, | ||
}, | ||
}; | ||
}); | ||
|
||
beforeEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
test('Confirm renders disk image details', async () => { | ||
vi.mocked(bootcClient.listHistoryInfo).mockResolvedValue([image]); | ||
|
||
render(DiskImageDetails, { id: btoa(image.id) }); | ||
|
||
// allow UI time to update | ||
await tick(); | ||
|
||
expect(screen.getByText(image.image + ':' + image.tag)).toBeInTheDocument(); | ||
}); |
65 changes: 65 additions & 0 deletions
65
packages/frontend/src/lib/disk-image/DiskImageDetails.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,65 @@ | ||||
<script lang="ts"> | ||||
import { DetailsPage, Tab } from '@podman-desktop/ui-svelte'; | ||||
import { router } from 'tinro'; | ||||
import DiskImageIcon from '/@/lib/DiskImageIcon.svelte'; | ||||
import DiskImageDetailsBuild from './DiskImageDetailsBuild.svelte'; | ||||
import Route from '../Route.svelte'; | ||||
import DiskImageDetailsSummary from './DiskImageDetailsSummary.svelte'; | ||||
import { onMount } from 'svelte'; | ||||
import type { BootcBuildInfo } from '/@shared/src/models/bootc'; | ||||
import { getTabUrl, isTabSelected } from '../upstream/Util'; | ||||
import { historyInfo } from '/@/stores/historyInfo'; | ||||
|
||||
export let id: string; | ||||
|
||||
let diskImage: BootcBuildInfo; | ||||
|
||||
let detailsPage: DetailsPage; | ||||
|
||||
onMount(() => { | ||||
const actualId = atob(id); | ||||
console.log('id: ' + actualId); | ||||
console.log('hist: ' + historyInfo.subscribe.length); | ||||
return historyInfo.subscribe(value => { | ||||
const matchingImage = value.find(image => image.id === actualId); | ||||
console.log('match: ' + matchingImage?.id); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed. |
||||
if (matchingImage) { | ||||
try { | ||||
diskImage = matchingImage; | ||||
} catch (err) { | ||||
console.error(err); | ||||
} | ||||
} else if (detailsPage) { | ||||
// the disk image has been deleted | ||||
goToHomePage(); | ||||
} | ||||
}); | ||||
}); | ||||
|
||||
export function goToHomePage(): void { | ||||
router.goto('/'); | ||||
} | ||||
</script> | ||||
|
||||
<DetailsPage | ||||
bind:this={detailsPage} | ||||
title="{diskImage?.image}:{diskImage?.tag}" | ||||
breadcrumbLeftPart="Bootable Containers" | ||||
breadcrumbRightPart="Disk Image Details" | ||||
breadcrumbTitle="Go back to homepage" | ||||
onclose={goToHomePage} | ||||
onbreadcrumbClick={goToHomePage}> | ||||
<DiskImageIcon slot="icon" size="30px" /> | ||||
<svelte:fragment slot="tabs"> | ||||
<Tab title="Summary" selected={isTabSelected($router.path, 'summary')} url={getTabUrl($router.path, 'summary')} /> | ||||
<Tab title="Build Log" selected={isTabSelected($router.path, 'build')} url={getTabUrl($router.path, 'build')} /> | ||||
</svelte:fragment> | ||||
<svelte:fragment slot="content"> | ||||
<Route path="/summary" breadcrumb="Summary"> | ||||
<DiskImageDetailsSummary image={diskImage} /> | ||||
</Route> | ||||
<Route path="/build" breadcrumb="Build Log"> | ||||
<DiskImageDetailsBuild folder={diskImage?.folder} /> | ||||
</Route> | ||||
</svelte:fragment> | ||||
</DetailsPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.