Feature/deletion button on status list item (#6079)

pull/5215/head
Toubi 2025-08-25 15:31:32 +02:00 committed by GitHub
parent bc2db2e36e
commit 8d3649966a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 61 additions and 2 deletions

View File

@ -22,6 +22,12 @@
<div class="title">{{ statusPage.title }}</div> <div class="title">{{ statusPage.title }}</div>
<div class="slug">/status/{{ statusPage.slug }}</div> <div class="slug">/status/{{ statusPage.slug }}</div>
</div> </div>
<div class="actions">
<button class="btn btn-danger delete-status-page" @click.stop.prevent="deleteDialog(statusPage.slug)">
<font-awesome-icon icon="trash" />
<span>{{ $t("Delete") }}</span>
</button>
</div>
</a> </a>
</template> </template>
<div v-else class="d-flex align-items-center justify-content-center my-3 spinner"> <div v-else class="d-flex align-items-center justify-content-center my-3 spinner">
@ -30,18 +36,22 @@
</div> </div>
</div> </div>
</transition> </transition>
<Confirm ref="confirmDelete" btn-style="btn-danger" :yes-text="$t('Yes')" :no-text="$t('No')" @yes="deleteStatusPage">
{{ $t("deleteStatusPageMsg") }}
</Confirm>
</template> </template>
<script> <script>
import Confirm from "../components/Confirm.vue";
import { getResBaseURL } from "../util-frontend"; import { getResBaseURL } from "../util-frontend";
export default { export default {
components: { components: {
Confirm
}, },
data() { data() {
return { return {
selectedStatusSlug: ""
}; };
}, },
computed: { computed: {
@ -62,6 +72,20 @@ export default {
} else { } else {
return getResBaseURL() + icon; return getResBaseURL() + icon;
} }
},
deleteDialog(slug) {
this.$data.selectedStatusSlug = slug;
this.$refs.confirmDelete.show();
},
deleteStatusPage() {
this.$root.getSocket().emit("deleteStatusPage", this.$data.selectedStatusSlug, (res) => {
if (res.ok) {
this.$root.toastSuccess(this.$t("successDeleted"));
window.location.reload();
} else {
this.$root.toastError(res.msg);
}
});
} }
}, },
}; };
@ -81,6 +105,10 @@ export default {
&:hover { &:hover {
background-color: $highlight-white; background-color: $highlight-white;
& .actions {
visibility: visible;
}
} }
&.active { &.active {
@ -98,6 +126,8 @@ export default {
} }
.info { .info {
flex: 1 1 auto;
.title { .title {
font-weight: bold; font-weight: bold;
font-size: 20px; font-size: 20px;
@ -107,6 +137,19 @@ export default {
font-size: 14px; font-size: 14px;
} }
} }
.actions {
visibility: hidden;
display: flex;
align-items: center;
.delete-status-page {
flex: 1 1 auto;
display: inline-flex;
align-items: center;
gap: 0.25rem;
}
}
} }
.dark { .dark {
@ -120,4 +163,20 @@ export default {
} }
} }
} }
@media (max-width: 770px) {
.item {
.actions {
visibility: visible;
.btn {
padding: 10px;
}
span {
display: none;
}
}
}
}
</style> </style>