Skip to content

Commit

Permalink
feat: using podman-desktop modals instead of custom one
Browse files Browse the repository at this point in the history
Signed-off-by: axel7083 <[email protected]>
  • Loading branch information
axel7083 committed Feb 1, 2024
1 parent 92b40e2 commit cb791a2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 40 deletions.
14 changes: 12 additions & 2 deletions packages/backend/src/studio-api-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,18 @@ export class StudioApiImpl implements StudioAPI {
return this.catalogManager.getCatalog();
}

async deleteLocalModel(modelId: string): Promise<void> {
await this.modelsManager.deleteLocalModel(modelId);
async requestRemoveLocalModel(modelId: string): Promise<void> {
const modelInfo = this.modelsManager.getLocalModelInfo(modelId);

podmanDesktopApi.window.showWarningMessage(

Check failure on line 121 in packages/backend/src/studio-api-impl.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / windows-2022

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check failure on line 121 in packages/backend/src/studio-api-impl.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / ubuntu-22.04

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check failure on line 121 in packages/backend/src/studio-api-impl.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / macos-12

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
`Are you sure you want to delete ${modelId} ? The following files will be removed from disk "${modelInfo.file}".`,
'Confirm',
'Cancel'

Check warning on line 124 in packages/backend/src/studio-api-impl.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / windows-2022

Missing trailing comma

Check warning on line 124 in packages/backend/src/studio-api-impl.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / ubuntu-22.04

Missing trailing comma

Check warning on line 124 in packages/backend/src/studio-api-impl.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / macos-12

Missing trailing comma
).then((result: string) => {
if(result === 'Confirm') {
this.modelsManager.deleteLocalModel(modelId);

Check failure on line 127 in packages/backend/src/studio-api-impl.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / windows-2022

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check failure on line 127 in packages/backend/src/studio-api-impl.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / ubuntu-22.04

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check failure on line 127 in packages/backend/src/studio-api-impl.ts

View workflow job for this annotation

GitHub Actions / linter, formatters and unit tests / macos-12

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
}
});
}

async getModelsDirectory(): Promise<string> {
Expand Down
41 changes: 4 additions & 37 deletions packages/frontend/src/lib/table/model/ModelColumnActions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@ import { faTrash } from "@fortawesome/free-solid-svg-icons";
import { faFolderOpen } from "@fortawesome/free-solid-svg-icons";
import ListItemButtonIcon from "../../button/ListItemButtonIcon.svelte";
import { studioClient } from "/@/utils/client";
import Modal from "../../Modal.svelte";
import Button from "../../button/Button.svelte";
export let object: ModelInfo;
let deleteConfirmVisible: boolean = false;
function deleteModel() {
deleteConfirmVisible= true;
}
async function goDeleteModel() {
await studioClient.deleteLocalModel(object.id);
deleteConfirmVisible= false;
const deleteModel = () => {
studioClient.requestRemoveLocalModel(object.id).catch((err) => {
console.error(`Something went wrong while trying to delete model ${String(err)}.`);
})
}
function openModelFolder() {
Expand All @@ -37,29 +30,3 @@ function openModelFolder() {
title="Delete Model"
enabled={!object.state}
/>

{#if deleteConfirmVisible}
<Modal
on:close="{() => {
deleteConfirmVisible = false;
}}">
<div class="flex items-center justify-between bg-black px-5 py-4 border-b-2 border-violet-700">
<h1 class="text-xl font-bold">Delete a model</h1>

<button class="hover:text-gray-300 px-2 py-1" on:click="{() => deleteConfirmVisible = false}">
<i class="fas fa-times" aria-hidden="true"></i>
</button>
</div>
<div class="bg-charcoal-600 p-5 h-full flex flex-col justify-items-center">
<span class="pb-3">The folder on disk containing the model will be deleted, it contains:</span>
<ul class="list-disc ml-8 space-y-2">
<li>{object.file?.file}</li>
</ul>

<div class="pt-5 grid grid-cols-2 gap-10 place-content-center w-full">
<Button type="primary" on:click="{() => goDeleteModel()}">Delete</Button>
<Button type="secondary" on:click="{() => deleteConfirmVisible = false}">Cancel</Button>
</div>
</div>
</Modal>
{/if}
2 changes: 1 addition & 1 deletion packages/shared/src/StudioAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export abstract class StudioAPI {
/**
* Delete the folder containing the model from local storage
*/
abstract deleteLocalModel(modelId: string): Promise<void>;
abstract requestRemoveLocalModel(modelId: string): Promise<void>;
abstract startPlayground(modelId: string): Promise<void>;
abstract stopPlayground(modelId: string): Promise<void>;
abstract askPlayground(modelId: string, prompt: string): Promise<number>;
Expand Down

0 comments on commit cb791a2

Please sign in to comment.