Frontend: stop using primevue confirm service

This commit is contained in:
Johannes Zellner
2024-05-01 14:17:44 +02:00
parent 8d9ecf3352
commit 130d8a1ba0
2 changed files with 33 additions and 40 deletions

View File

@@ -1,14 +1,10 @@
<template>
<ConfirmDialog/>
<router-view></router-view>
</template>
<script>
import ConfirmDialog from 'primevue/confirmdialog';
export default {
components: { ConfirmDialog },
data() {
return {
};

View File

@@ -101,8 +101,6 @@
import superagent from 'superagent';
import { marked } from 'marked';
import { useConfirm } from 'primevue/useconfirm';
import { Dialog, DirectoryView, TopBar, Breadcrumb, BottomBar, Button, InputDialog, MainLayout, Menu, FileUploader, Spinner } from 'pankow';
import Icon from 'pankow/components/Icon.vue';
import { sanitize, sleep } from 'pankow/utils';
@@ -352,32 +350,32 @@ export default {
return str;
}
this.$confirm.require({
header: this.$t('filemanager.removeDialog.reallyDelete'),
message: start_and_end(files.map((f) => f.name).join(', ')),
icon: '',
acceptClass: 'p-button-danger',
accept: async () => {
window.addEventListener('beforeunload', beforeUnloadListener, { capture: true });
this.$refs.deleteInProgressDialog.open();
for (let i in files) {
try {
await this.directoryModel.remove(this.directoryModel.buildFilePath(this.cwd, files[i].name));
} catch (e) {
console.error(`Failed to remove file ${files[i].name}:`, e);
}
}
await this.loadCwd();
this.$confirm.close();
window.removeEventListener('beforeunload', beforeUnloadListener, { capture: true });
this.$refs.deleteInProgressDialog.close();
}
const confirmed = await this.$refs.inputDialog.confirm({
message: this.$t('filemanager.removeDialog.reallyDelete'),
// message: start_and_end(files.map((f) => f.name).join(', ')),
confirmStyle: 'danger',
confirmLabel: this.$t('main.dialog.yes'),
rejectLabel: this.$t('main.dialog.no'),
modal: false
});
if (!confirmed) return;
window.addEventListener('beforeunload', beforeUnloadListener, { capture: true });
this.$refs.deleteInProgressDialog.open();
for (let i in files) {
try {
await this.directoryModel.remove(this.directoryModel.buildFilePath(this.cwd, files[i].name));
} catch (e) {
console.error(`Failed to remove file ${files[i].name}:`, e);
}
}
await this.loadCwd();
window.removeEventListener('beforeunload', beforeUnloadListener, { capture: true });
this.$refs.deleteInProgressDialog.close();
},
async renameHandler(file, newName) {
if (file.name === newName) return;
@@ -387,16 +385,17 @@ export default {
await this.loadCwd();
} catch (e) {
if (e.status === 409) {
this.$confirm.require({
const confirmed = await this.$refs.inputDialog.confirm({
message: this.$t('filemanager.renameDialog.reallyOverwrite'),
icon: '',
acceptClass: 'p-button-danger',
accept: async () => {
await this.directoryModel.rename(this.directoryModel.buildFilePath(this.cwd, file.name), sanitize(this.cwd + '/' + newName), true /* overwrite */);
await this.loadCwd();
this.$confirm.close();
}
confirmStyle: 'danger',
confirmLabel: this.$t('main.dialog.yes'),
rejectLabel: this.$t('main.dialog.no')
});
if (!confirmed) return;
await this.directoryModel.rename(this.directoryModel.buildFilePath(this.cwd, file.name), sanitize(this.cwd + '/' + newName), true /* overwrite */);
await this.loadCwd();
}
else console.error(`Failed to rename ${file} to ${newName}`, e);
}
@@ -512,8 +511,6 @@ export default {
}
},
async mounted() {
useConfirm();
const type = this.$route.params.type || 'app';
const resourceId = this.$route.params.resourceId;
const cwd = this.$route.params.cwd;