-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### What does this PR do? * Adds a webview build page * Uses the last deployed bootc build as the "previous selection" for the page * Added tests for the webview * Fixed current tests identified when adding new tsconfig ### Screenshot / video of UI <!-- If this PR is changing UI, please include screenshots or screencasts showing the difference --> ### What issues does this PR fix or reference? <!-- Include any related issues from Podman Desktop repository (or from another issue tracker). --> Closes #141 ### How to test this PR? <!-- Please explain steps to reproduce --> 1. `yarn watch` in this extension directory 2. `cd podman-desktop` 3. `yarn watch --extension-folder ../bootc/packages/backend` 4. Press the bootc icon on the left that should be appear, and start a build via the shown webview. Signed-off-by: Charlie Drage <[email protected]>
- Loading branch information
Showing
39 changed files
with
3,899 additions
and
414 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/********************************************************************** | ||
* 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 * as podmanDesktopApi from '@podman-desktop/api'; | ||
import type { ImageInfo } from '@podman-desktop/api'; | ||
import type { BootcApi } from '@shared/src/BootcAPI'; | ||
import type { BootcBuildInfo } from '@shared/src/models/bootc'; | ||
import { buildDiskImage } from './build-disk-image'; | ||
import { History } from './history'; | ||
|
||
export class BootcApiImpl implements BootcApi { | ||
private history: History; | ||
|
||
constructor(private readonly extensionContext: podmanDesktopApi.ExtensionContext) { | ||
this.history = new History(extensionContext.storagePath); | ||
} | ||
|
||
async buildImage(build: BootcBuildInfo): Promise<void> { | ||
return buildDiskImage(build, this.history); | ||
} | ||
|
||
async selectOutputFolder(): Promise<string> { | ||
const path = await podmanDesktopApi.window.showOpenDialog({ | ||
title: 'Select output folder', | ||
selectors: ['openDirectory'], | ||
}); | ||
if (path && path.length > 0) { | ||
return path[0].fsPath; | ||
} | ||
return ''; | ||
} | ||
|
||
async listBootcImages(): Promise<ImageInfo[]> { | ||
let images: ImageInfo[] = []; | ||
try { | ||
const retrieveImages = await podmanDesktopApi.containerEngine.listImages(); | ||
images = retrieveImages.filter(image => { | ||
if (image.Labels) { | ||
return image.Labels['bootc'] ?? image.Labels['containers.bootc']; | ||
} | ||
}); | ||
} catch (err) { | ||
await podmanDesktopApi.window.showErrorMessage(`Error listing images: ${err}`); | ||
console.error('Error listing images: ', err); | ||
} | ||
return images; | ||
} | ||
|
||
async listHistoryInfo(): Promise<BootcBuildInfo[]> { | ||
try { | ||
// Load the file so it retrieves the latest information. | ||
await this.history.loadFile(); | ||
} catch (err) { | ||
await podmanDesktopApi.window.showErrorMessage( | ||
`Error loading history from ${this.extensionContext.storagePath}, error: ${err}`, | ||
); | ||
console.error('Error loading history: ', err); | ||
} | ||
return this.history.getHistory(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
build | ||
*.config.js | ||
__mocks__ | ||
coverage |
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,13 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"node": false | ||
}, | ||
"extends": ["../../.eslintrc.json"], | ||
"rules": { | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-floating-promises": "off", | ||
"@typescript-eslint/no-empty-function": "off", | ||
"no-undef": "off" | ||
} | ||
} |
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,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0" /> | ||
<title>BootC Extension</title> | ||
</head> | ||
<body class="overflow-auto text-white"> | ||
<div id="app"></div> | ||
<script type="module" src="./src/main.ts"></script> | ||
</body> | ||
</html> |
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,58 @@ | ||
{ | ||
"name": "frontend", | ||
"displayName": "frontend UI", | ||
"description": "Frontend UI for the bootc extension", | ||
"version": "0.4.0-next", | ||
"type": "module", | ||
"scripts": { | ||
"preview": "vite preview", | ||
"build": "vite build", | ||
"test": "vitest run --coverage", | ||
"test:watch": "vitest watch --coverage", | ||
"format:check": "prettier --check \"src/**/*.ts\"", | ||
"format:fix": "prettier --write \"src/**/*.{ts,svelte}\"", | ||
"lint:check": "eslint . --ext js,ts,tsx", | ||
"lint:fix": "eslint . --fix --ext js,ts,tsx", | ||
"watch": "vite --mode development build -w" | ||
}, | ||
"dependencies": { | ||
"@podman-desktop/ui-svelte": "^0.0.202402292013-ac00cea0d", | ||
"svelte-preprocess": "^5.1.3", | ||
"tinro": "^0.6.12" | ||
}, | ||
"devDependencies": { | ||
"@fortawesome/fontawesome-free": "^6.5.1", | ||
"@fortawesome/free-brands-svg-icons": "^6.5.1", | ||
"@fortawesome/free-regular-svg-icons": "^6.5.1", | ||
"@fortawesome/free-solid-svg-icons": "^6.5.1", | ||
"@podman-desktop/api": "^0.0.202402080712-0f5d4ce", | ||
"@podman-desktop/ui-svelte": "^0.0.202402292013-ac00cea0d", | ||
"@sveltejs/vite-plugin-svelte": "3.0.1", | ||
"@tailwindcss/typography": "^0.5.10", | ||
"@testing-library/dom": "^9.3.3", | ||
"@testing-library/jest-dom": "^6.2.0", | ||
"@testing-library/svelte": "^4.0.5", | ||
"@testing-library/user-event": "^14.5.1", | ||
"@tsconfig/svelte": "^5.0.2", | ||
"@types/humanize-duration": "^3.27.4", | ||
"@types/node": "^20.11.17", | ||
"@typescript-eslint/eslint-plugin": "6.15.0", | ||
"@typescript-eslint/parser": "^6.21.0", | ||
"autoprefixer": "^10.4.17", | ||
"filesize": "^10.1.0", | ||
"humanize-duration": "^3.31.0", | ||
"jsdom": "^23.2.0", | ||
"moment": "^2.30.1", | ||
"postcss": "^8.4.35", | ||
"postcss-load-config": "^5.0.2", | ||
"prettier": "^3.1.1", | ||
"prettier-plugin-svelte": "^3.1.2", | ||
"svelte": "4.2.8", | ||
"svelte-fa": "^3.0.4", | ||
"svelte-markdown": "^0.4.1", | ||
"svelte-preprocess": "^5.1.3", | ||
"tailwindcss": "^3.4.1", | ||
"vite": "^5.1.1", | ||
"vitest": "^1.1.0" | ||
} | ||
} |
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,25 @@ | ||
/********************************************************************** | ||
* 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 | ||
***********************************************************************/ | ||
|
||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
'postcss-import': {}, | ||
autoprefixer: {}, | ||
}, | ||
}; |
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,30 @@ | ||
<script lang="ts"> | ||
import './app.css'; | ||
import '@fortawesome/fontawesome-free/css/all.min.css'; | ||
import { router } from 'tinro'; | ||
import Route from './lib/Route.svelte'; | ||
import Build from './Build.svelte'; | ||
import { onMount } from 'svelte'; | ||
import { getRouterState } from './api/client'; | ||
router.mode.hash(); | ||
let isMounted = false; | ||
onMount(() => { | ||
// Load router state on application startup | ||
const state = getRouterState(); | ||
router.goto(state.url); | ||
isMounted = true; | ||
}); | ||
</script> | ||
|
||
<Route path="/*" breadcrumb="Home" isAppMounted="{isMounted}" let:meta> | ||
<main class="flex flex-col w-screen h-screen overflow-hidden bg-charcoal-700"> | ||
<div class="flex flex-row w-full h-full overflow-hidden"> | ||
<Route path="/" breadcrumb="Build"> | ||
<Build /> | ||
</Route> | ||
</div> | ||
</main> | ||
</Route> |
Oops, something went wrong.