2023-06-16 13:30:08 +02:00
|
|
|
<script>
|
2023-06-20 16:02:53 +02:00
|
|
|
import { Input, notifications } from "@budibase/bbui"
|
2023-06-16 13:30:08 +02:00
|
|
|
import { goto } from "@roxi/routify"
|
|
|
|
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
|
|
|
import { apps } from "stores/portal"
|
|
|
|
import { API } from "api"
|
|
|
|
|
2024-02-22 16:00:16 +01:00
|
|
|
export let appId
|
|
|
|
export let appName
|
|
|
|
export let onDeleteSuccess = () => {
|
|
|
|
$goto("/builder")
|
|
|
|
}
|
|
|
|
|
|
|
|
let deleting = false
|
|
|
|
|
2023-06-16 13:30:08 +02:00
|
|
|
export const show = () => {
|
|
|
|
deletionModal.show()
|
|
|
|
}
|
|
|
|
|
|
|
|
export const hide = () => {
|
|
|
|
deletionModal.hide()
|
|
|
|
}
|
|
|
|
|
|
|
|
let deletionModal
|
|
|
|
let deletionConfirmationAppName
|
|
|
|
|
2024-02-22 16:00:16 +01:00
|
|
|
const copyName = () => {
|
|
|
|
deletionConfirmationAppName = appName
|
|
|
|
}
|
|
|
|
|
2023-06-16 13:30:08 +02:00
|
|
|
const deleteApp = async () => {
|
2024-02-22 16:00:16 +01:00
|
|
|
if (!appId) {
|
|
|
|
console.log("No app id provided")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
deleting = true
|
2023-06-16 13:30:08 +02:00
|
|
|
try {
|
2024-02-22 16:00:16 +01:00
|
|
|
await API.deleteApp(appId)
|
2023-06-16 13:30:08 +02:00
|
|
|
apps.load()
|
|
|
|
notifications.success("App deleted successfully")
|
2024-02-22 16:00:16 +01:00
|
|
|
onDeleteSuccess()
|
2023-06-16 13:30:08 +02:00
|
|
|
} catch (err) {
|
|
|
|
notifications.error("Error deleting app")
|
2024-02-22 16:00:16 +01:00
|
|
|
deleting = false
|
2023-06-16 13:30:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<ConfirmDialog
|
|
|
|
bind:this={deletionModal}
|
|
|
|
title="Delete app"
|
|
|
|
okText="Delete"
|
|
|
|
onOk={deleteApp}
|
|
|
|
onCancel={() => (deletionConfirmationAppName = null)}
|
2024-02-22 16:00:16 +01:00
|
|
|
disabled={deletionConfirmationAppName !== appName || deleting}
|
2023-06-16 13:30:08 +02:00
|
|
|
>
|
2024-02-22 16:00:16 +01:00
|
|
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
|
|
Are you sure you want to delete
|
|
|
|
<b class="app-name" on:click={copyName}>{appName}</b>?
|
2023-06-16 13:30:08 +02:00
|
|
|
<br />
|
|
|
|
Please enter the app name below to confirm.
|
|
|
|
<br /><br />
|
2024-02-22 16:00:16 +01:00
|
|
|
<Input bind:value={deletionConfirmationAppName} placeholder={appName} />
|
2023-06-16 13:30:08 +02:00
|
|
|
</ConfirmDialog>
|
2024-02-22 16:00:16 +01:00
|
|
|
|
|
|
|
<style>
|
|
|
|
.app-name {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
</style>
|