Skip to content

Commit b509134

Browse files
authored
Merge pull request #129 from iceljc/features/refine-chat-window
refine plugin page
2 parents 0eda07e + 9230f72 commit b509134

File tree

1 file changed

+34
-15
lines changed

1 file changed

+34
-15
lines changed

src/routes/page/plugin/plugin-list.svelte

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,44 @@
88
Row,
99
} from '@sveltestrap/sveltestrap';
1010
import { installPlugin, removePlugin } from '$lib/services/plugin-service';
11-
import { goto } from '$app/navigation';
11+
import Swal from 'sweetalert2/dist/sweetalert2.js';
12+
import "sweetalert2/src/sweetalert2.scss";
1213
1314
/** @type {import('$types').PluginDefModel[]} */
1415
export let plugins;
15-
16-
/**
16+
17+
/**
1718
* @param {string} id
19+
* @param {string} name
1820
* @param {boolean} enable
19-
*/
20-
async function handlePluginStatus(id, enable) {
21-
if (enable) {
22-
await installPlugin(id);
23-
} else {
24-
await removePlugin(id);
25-
}
26-
27-
// refresh page
28-
const path = window.location.pathname;
29-
goto('').then(() => goto(path));
21+
*/
22+
function handlePluginStatus(id, name, enable) {
23+
// @ts-ignore
24+
Swal.fire({
25+
title: 'Are you sure?',
26+
text: `We will ${enable ? 'install' : 'remove'} ${name}.`,
27+
icon: 'warning',
28+
showCancelButton: true,
29+
confirmButtonText: 'Yes',
30+
cancelButtonText: 'No'
31+
// @ts-ignore
32+
}).then((result) => {
33+
if (result.value) {
34+
if (enable) {
35+
installPlugin(id).then(() => {
36+
refresh();
37+
});
38+
} else {
39+
removePlugin(id).then(() => {
40+
refresh();
41+
})
42+
}
43+
}
44+
});
45+
}
46+
47+
function refresh() {
48+
window.location.reload();
3049
}
3150
</script>
3251

@@ -68,7 +87,7 @@
6887
<a href="page/setting#{item.settings_name}" class="btn btn-soft-success btn-sm">{$_('Settings')}</a>
6988
{/if}
7089
{#if !item.is_core}
71-
<button class="btn btn-soft-warning btn-sm" on:click={() => handlePluginStatus(item.id, !item.enabled)}>{item.enabled ? $_("Remove") : $_("Install")}</button>
90+
<button class="btn btn-soft-warning btn-sm" on:click={() => handlePluginStatus(item.id, item.name, !item.enabled)}>{item.enabled ? $_("Remove") : $_("Install")}</button>
7291
{/if}
7392
</div>
7493
</CardBody>

0 commit comments

Comments
 (0)