Skip to content
Snippets Groups Projects
Verified Commit d199f12f authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Support deleting icons for a workflow version

#61
parent 45416c11
No related branches found
No related tags found
1 merge request!55Resolve "Support private Git Repositories"
...@@ -4,6 +4,7 @@ import type { WorkflowVersion } from "@/client/workflow"; ...@@ -4,6 +4,7 @@ import type { WorkflowVersion } from "@/client/workflow";
import { WorkflowVersionService } from "@/client/workflow"; import { WorkflowVersionService } from "@/client/workflow";
import { onMounted, ref, reactive, computed } from "vue"; import { onMounted, ref, reactive, computed } from "vue";
import { Modal, Toast } from "bootstrap"; import { Modal, Toast } from "bootstrap";
import FontAwesomeIcon from "@/components/FontAwesomeIcon.vue";
// Constants // Constants
// ============================================================================= // =============================================================================
...@@ -39,9 +40,11 @@ const iconUpdate = reactive<{ ...@@ -39,9 +40,11 @@ const iconUpdate = reactive<{
const formState = reactive<{ const formState = reactive<{
loading: boolean; loading: boolean;
validated: boolean; validated: boolean;
uploadIcon: boolean;
}>({ }>({
loading: false, loading: false,
validated: false, validated: false,
uploadIcon: true,
}); });
// Computed Properties // Computed Properties
...@@ -60,7 +63,6 @@ const emit = defineEmits<{ ...@@ -60,7 +63,6 @@ const emit = defineEmits<{
// Functions // Functions
// ============================================================================= // =============================================================================
function resetForm() { function resetForm() {
modalClosed();
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
iconElement.value!.src = props.version.icon_url ?? ""; iconElement.value!.src = props.version.icon_url ?? "";
if (iconInputElement.value != undefined) { if (iconInputElement.value != undefined) {
...@@ -70,6 +72,7 @@ function resetForm() { ...@@ -70,6 +72,7 @@ function resetForm() {
function modalClosed() { function modalClosed() {
formState.validated = false; formState.validated = false;
resetForm();
} }
function iconChanged() { function iconChanged() {
...@@ -95,10 +98,10 @@ function updateIcon() { ...@@ -95,10 +98,10 @@ function updateIcon() {
}, },
) )
.then((icon_url) => { .then((icon_url) => {
formState.uploadIcon = true;
emit("icon-updated", props.version, icon_url); emit("icon-updated", props.version, icon_url);
successToast?.show(); successToast?.show();
updateIconModal?.hide(); updateIconModal?.hide();
resetForm();
}) })
.catch((error) => { .catch((error) => {
console.error(error); console.error(error);
...@@ -109,6 +112,26 @@ function updateIcon() { ...@@ -109,6 +112,26 @@ function updateIcon() {
} }
} }
function deleteIcon() {
formState.loading = true;
WorkflowVersionService.workflowVersionDeleteWorkflowVersionIcon(
props.version.workflow_id,
props.version.git_commit_hash,
)
.then(() => {
formState.uploadIcon = false;
emit("icon-deleted", props.version);
successToast?.show();
updateIconModal?.hide();
})
.catch((error) => {
console.error(error);
})
.finally(() => {
formState.loading = false;
});
}
// Lifecycle Events // Lifecycle Events
// ============================================================================= // =============================================================================
onMounted(() => { onMounted(() => {
...@@ -128,7 +151,10 @@ onMounted(() => { ...@@ -128,7 +151,10 @@ onMounted(() => {
:id="'successToast-' + randomIDSuffix" :id="'successToast-' + randomIDSuffix"
> >
<div class="d-flex"> <div class="d-flex">
<div class="toast-body">Successfully updated Workflow</div> <div v-if="formState.uploadIcon" class="toast-body">
Successfully uploaded icon
</div>
<div v-else class="toast-body">Successfully deleted icon</div>
<button <button
type="button" type="button"
class="btn-close btn-close-white me-2 m-auto" class="btn-close btn-close-white me-2 m-auto"
...@@ -150,6 +176,13 @@ onMounted(() => { ...@@ -150,6 +176,13 @@ onMounted(() => {
>{{ props.workflowName }}@{{ props.version.version }}</span >{{ props.workflowName }}@{{ props.version.version }}</span
> >
</template> </template>
<template v-slot:extra-button v-if="props.version.icon_url">
<font-awesome-icon
icon="fa-solid fa-trash"
class="cursor-pointer delete-icon"
@click="deleteIcon()"
/>
</template>
<template v-slot:body> <template v-slot:body>
<form <form
ref="iconUpdateForm" ref="iconUpdateForm"
...@@ -208,4 +241,12 @@ img { ...@@ -208,4 +241,12 @@ img {
max-height: 64px; max-height: 64px;
max-width: 64px; max-width: 64px;
} }
.delete-icon {
color: var(--bs-secondary) !important;
}
.delete-icon:hover {
color: var(--bs-danger) !important;
}
</style> </style>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment