From cb791a2f0fcb58ac1ed1d5f02f2efc3d641f161b Mon Sep 17 00:00:00 2001 From: axel7083 <42176370+axel7083@users.noreply.github.com> Date: Thu, 1 Feb 2024 14:06:51 +0100 Subject: [PATCH] feat: using podman-desktop modals instead of custom one Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com> --- packages/backend/src/studio-api-impl.ts | 14 ++++++- .../lib/table/model/ModelColumnActions.svelte | 41 ++----------------- packages/shared/src/StudioAPI.ts | 2 +- 3 files changed, 17 insertions(+), 40 deletions(-) diff --git a/packages/backend/src/studio-api-impl.ts b/packages/backend/src/studio-api-impl.ts index f6742e6b8..0e14835b4 100644 --- a/packages/backend/src/studio-api-impl.ts +++ b/packages/backend/src/studio-api-impl.ts @@ -115,8 +115,18 @@ export class StudioApiImpl implements StudioAPI { return this.catalogManager.getCatalog(); } - async deleteLocalModel(modelId: string): Promise { - await this.modelsManager.deleteLocalModel(modelId); + async requestRemoveLocalModel(modelId: string): Promise { + const modelInfo = this.modelsManager.getLocalModelInfo(modelId); + + podmanDesktopApi.window.showWarningMessage( + `Are you sure you want to delete ${modelId} ? The following files will be removed from disk "${modelInfo.file}".`, + 'Confirm', + 'Cancel' + ).then((result: string) => { + if(result === 'Confirm') { + this.modelsManager.deleteLocalModel(modelId); + } + }); } async getModelsDirectory(): Promise { diff --git a/packages/frontend/src/lib/table/model/ModelColumnActions.svelte b/packages/frontend/src/lib/table/model/ModelColumnActions.svelte index 74fc37869..7c3de78a4 100644 --- a/packages/frontend/src/lib/table/model/ModelColumnActions.svelte +++ b/packages/frontend/src/lib/table/model/ModelColumnActions.svelte @@ -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() { @@ -37,29 +30,3 @@ function openModelFolder() { title="Delete Model" enabled={!object.state} /> - -{#if deleteConfirmVisible} - -
-

Delete a model

- - -
-
- The folder on disk containing the model will be deleted, it contains: -
    -
  • {object.file?.file}
  • -
- -
- - -
-
-
-{/if} diff --git a/packages/shared/src/StudioAPI.ts b/packages/shared/src/StudioAPI.ts index 07c81f97b..032206aee 100644 --- a/packages/shared/src/StudioAPI.ts +++ b/packages/shared/src/StudioAPI.ts @@ -19,7 +19,7 @@ export abstract class StudioAPI { /** * Delete the folder containing the model from local storage */ - abstract deleteLocalModel(modelId: string): Promise; + abstract requestRemoveLocalModel(modelId: string): Promise; abstract startPlayground(modelId: string): Promise; abstract stopPlayground(modelId: string): Promise; abstract askPlayground(modelId: string, prompt: string): Promise;