Generalized frontend model store (#193)

This commit is contained in:
Gregory Schier
2025-03-31 11:56:17 -07:00
committed by GitHub
parent ce885c3551
commit f1757ae427
201 changed files with 2185 additions and 2865 deletions

View File

@@ -0,0 +1,29 @@
import type { AnyModel } from '@yaakapp-internal/models';
import { deleteModel, modelTypeLabel } from '@yaakapp-internal/models';
import { InlineCode } from '../components/core/InlineCode';
import { showConfirmDelete } from './confirm';
import { resolvedModelName } from './resolvedModelName';
export async function deleteModelWithConfirm(model: AnyModel | null): Promise<boolean> {
if (model == null ) {
console.warn('Tried to delete null model');
return false;
}
const confirmed = await showConfirmDelete({
id: 'delete-model-' + model.model,
title: 'Delete ' + modelTypeLabel(model),
description: (
<>
Permanently delete <InlineCode>{resolvedModelName(model)}</InlineCode>?
</>
),
});
if (!confirmed) {
return false;
}
await deleteModel(model);
return true;
}