Skip to content

Commit ce1fb32

Browse files
committed
feat: add close modal functionality to JobInfoPopup and integrate with JobsList
1 parent 94d693c commit ce1fb32

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

custom/JobInfoPopup.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="flex flex-col w-full min-w-96">
2+
<div class="flex flex-col w-full min-w-96 mt-2">
33
<div class="flex items-center mb-1">
44
<div class="flex flex-col items-start justify-end h-12">
55
<h2 class="text-lg font-semibold dark:text-white">{{ job.name }}</h2>
@@ -11,9 +11,19 @@
1111
</Tooltip>
1212
</div>
1313
<div class="ml-auto flex flex-col items-start justify-end h-12">
14-
<div class="flex items-center">
14+
<div class="flex items-center mr-6">
1515
<p class=" text-gray-800 dark:text-white h-full"> {{ t('Progress:') }} <span class="font-semibold" >{{ job.progress }}%</span></p>
1616
<StateToIcon :job="job" />
17+
<button
18+
@click="closeModal()"
19+
type="button"
20+
class="absolute top-2 right-2 text-lightDialogCloseButton bg-transparent hover:bg-lightDialogCloseButtonHoverBackground hover:text-lightDialogCloseButtonHover rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:text-darkDialogCloseButton dark:hover:bg-darkDialogCloseButtonHoverBackground dark:hover:text-darkDialogCloseButtonHover"
21+
>
22+
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
23+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
24+
</svg>
25+
<span class="sr-only">{{ t('Close Modal') }}</span>
26+
</button>
1727
</div>
1828
<Tooltip v-if="job.finishedAt">
1929
<p class="text-xs text-gray-600 dark:text-gray-200 h-full"> {{ t('Finished:') }} {{ getTimeAgoString(new Date(job.finishedAt)) }}</p>
@@ -68,6 +78,7 @@ const props = defineProps<{
6878
meta: {
6979
pluginInstanceId: string;
7080
};
81+
closeModal: () => void;
7182
}>();
7283
7384
async function cancelJob() {

custom/JobsList.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div class="w-1vw md:w-64 bg-white border border-gray-200 dark:bg-gray-800 dark:border-gray-600 rounded-md">
33
<Modal
4+
ref="modalRef"
45
class="p-4"
56
v-for="job in props.jobs" :key="job.id"
67
:beforeCloseFunction="onBeforeOpen"
@@ -31,6 +32,7 @@
3132
<JobInfoPopup
3233
:job="job"
3334
:meta="meta"
35+
:closeModal="closeModal"
3436
/>
3537
</Modal>
3638

@@ -46,6 +48,26 @@ import JobInfoPopup from './JobInfoPopup.vue';
4648
import StateToIcon from './StateToIcon.vue';
4749
import { ref } from 'vue';
4850
51+
const modalRef = ref<any>(null);
52+
53+
function closeModal() {
54+
const m = modalRef.value;
55+
if (!m) return;
56+
57+
if (typeof m.close === 'function') {
58+
m.close();
59+
return;
60+
}
61+
62+
if (Array.isArray(m)) {
63+
m.forEach((inst: any) => {
64+
if (inst?.close && typeof inst.close === 'function') {
65+
inst.close();
66+
}
67+
});
68+
}
69+
}
70+
4971
const props = defineProps<{
5072
jobs: IJob[];
5173
closeDropdown: () => void;

0 commit comments

Comments
 (0)