mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-25 17:24:48 +10:00
Implement #268
This commit is contained in:
@@ -547,6 +547,9 @@
|
|||||||
"sources": {
|
"sources": {
|
||||||
"create": "Create source",
|
"create": "Create source",
|
||||||
"createDesc": "Drop will use this source to access your game library, and make them available.",
|
"createDesc": "Drop will use this source to access your game library, and make them available.",
|
||||||
|
"deleteButton": "Delete source",
|
||||||
|
"deleteDesc": "Deleting \"{0}\" will cascade delete the library, all of its games, all of their versions, and all of their metadata. This action cannot be undone.",
|
||||||
|
"deleteTitle": "Delete library source?",
|
||||||
"desc": "Configure your library sources, where Drop will look for new games and versions to import.",
|
"desc": "Configure your library sources, where Drop will look for new games and versions to import.",
|
||||||
"documentationLink": "Documentation {arrow}",
|
"documentationLink": "Documentation {arrow}",
|
||||||
"edit": "Edit source",
|
"edit": "Edit source",
|
||||||
|
|||||||
@@ -347,30 +347,45 @@ function edit(index: number) {
|
|||||||
actionSourceOpen.value = true;
|
actionSourceOpen.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function deleteSource(index: number) {
|
function deleteSource(index: number) {
|
||||||
const source = sources.value[index];
|
const source = sources.value[index];
|
||||||
if (!source) return;
|
if (!source) return;
|
||||||
|
|
||||||
try {
|
createModal(
|
||||||
await $dropFetch("/api/v1/admin/library/sources", {
|
ModalType.Confirmation,
|
||||||
method: "DELETE",
|
{
|
||||||
body: { id: source.id },
|
title: t("library.admin.sources.deleteTitle"),
|
||||||
headers,
|
description: t("library.admin.sources.deleteDesc", [source.name]),
|
||||||
});
|
buttonText: t("library.admin.sources.deleteButton"),
|
||||||
} catch (e) {
|
},
|
||||||
createModal(
|
async (event, close) => {
|
||||||
ModalType.Notification,
|
if (event !== "confirm") return close();
|
||||||
{
|
|
||||||
title: t("errors.library.source.delete.title"),
|
|
||||||
description: t("errors.library.source.delete.desc", [
|
|
||||||
// @ts-expect-error attempt to display statusMessage on error
|
|
||||||
e?.statusMessage ?? t("errors.unknown"),
|
|
||||||
]),
|
|
||||||
},
|
|
||||||
(_, c) => c(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
sources.value.splice(index, 1);
|
try {
|
||||||
|
await $dropFetch("/api/v1/admin/library/sources", {
|
||||||
|
method: "DELETE",
|
||||||
|
body: { id: source.id },
|
||||||
|
headers,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
createModal(
|
||||||
|
ModalType.Notification,
|
||||||
|
{
|
||||||
|
title: t("errors.library.source.delete.title"),
|
||||||
|
description: t("errors.library.source.delete.desc", [
|
||||||
|
// @ts-expect-error attempt to display statusMessage on error
|
||||||
|
e?.statusMessage ?? t("errors.unknown"),
|
||||||
|
]),
|
||||||
|
},
|
||||||
|
(_, c) => c(),
|
||||||
|
);
|
||||||
|
return close();
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentIndex = sources.value.findIndex((s) => s.id === source.id);
|
||||||
|
if (currentIndex !== -1) sources.value.splice(currentIndex, 1);
|
||||||
|
close();
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user