Files
STARTLINER/src/components/InstallButton.vue
2025-04-04 14:37:16 +00:00

52 lines
1.1 KiB
Vue

<script setup lang="ts">
import Button from 'primevue/button';
import { invoke } from '../invoke';
import { usePkgStore } from '../stores';
import { Package } from '../types';
import { pkgKey } from '../util';
const pkgs = usePkgStore();
const props = defineProps({
pkg: Object as () => Package,
});
const remove = async () => {
if (props.pkg === undefined) {
return;
}
await invoke('delete_package', {
key: pkgKey(props.pkg),
});
};
</script>
<template>
<Button
v-if="pkg?.loc && !pkg?.js.busy"
rounded
icon="pi pi-trash"
severity="danger"
aria-label="remove"
size="small"
class="self-center ml-4"
style="width: 2rem; height: 2rem"
:loading="pkg?.js.busy"
v-on:click="remove()"
/>
<Button
v-else
rounded
icon="pi pi-plus"
severity="success"
aria-label="install"
size="small"
class="self-center ml-4"
style="width: 2rem; height: 2rem"
:loading="pkg?.js.busy"
v-on:click="async () => await pkgs.install(pkg)"
/>
</template>