mirror of
https://github.com/knadh/listmonk.git
synced 2025-11-09 17:22:26 +08:00
Make import overwrite off by default and add warning (#2078)
* Move CSV example rendering to code to get around breaking auto-formatter. * Improve overwrite confirmation logic. --------- Co-authored-by: Kailash Nadh <kailash@nadh.in>
This commit is contained in:
parent
39e1a0344e
commit
b0f3891629
3 changed files with 37 additions and 25 deletions
|
|
@ -2487,6 +2487,8 @@ components:
|
||||||
type: string
|
type: string
|
||||||
import.subscribe:
|
import.subscribe:
|
||||||
type: string
|
type: string
|
||||||
|
import.subscribeWarning:
|
||||||
|
type: string
|
||||||
import.title:
|
import.title:
|
||||||
type: string
|
type: string
|
||||||
import.upload:
|
import.upload:
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
<b-loading :active="isLoading" />
|
<b-loading :active="isLoading" />
|
||||||
|
|
||||||
<section v-if="isFree()" class="wrap">
|
<section v-if="isFree()" class="wrap">
|
||||||
<form @submit.prevent="onSubmit" class="box">
|
<form @submit.prevent="onUpload" class="box">
|
||||||
<div>
|
<div>
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
|
@ -93,12 +93,8 @@
|
||||||
</h5>
|
</h5>
|
||||||
<p>{{ $t('import.instructionsHelp') }}</p>
|
<p>{{ $t('import.instructionsHelp') }}</p>
|
||||||
<br />
|
<br />
|
||||||
<blockquote className="csv-example">
|
<blockquote class="csv-example">
|
||||||
<code className="csv-headers">
|
<code class="csv-headers"> <span>email,</span> <span>name,</span> <span>attributes</span></code>
|
||||||
<span>email,</span>
|
|
||||||
<span>name,</span>
|
|
||||||
<span>attributes</span>
|
|
||||||
</code>
|
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
@ -106,23 +102,8 @@
|
||||||
<h5 class="title is-size-6">
|
<h5 class="title is-size-6">
|
||||||
{{ $t('import.csvExample') }}
|
{{ $t('import.csvExample') }}
|
||||||
</h5>
|
</h5>
|
||||||
<blockquote className="csv-example">
|
|
||||||
<code className="csv-headers">
|
<pre class="csv-example" v-text="example" />
|
||||||
<span>email,</span>
|
|
||||||
<span>name,</span>
|
|
||||||
<span>attributes</span>
|
|
||||||
</code><br />
|
|
||||||
<code className="csv-row">
|
|
||||||
<span>user1@mail.com,</span>
|
|
||||||
<span>"User One",</span>
|
|
||||||
<span>"{""age"": 42, ""planet"": ""Mars""}"</span>
|
|
||||||
</code><br />
|
|
||||||
<code className="csv-row">
|
|
||||||
<span>user2@mail.com,</span>
|
|
||||||
<span>"User Two",</span>
|
|
||||||
<span>"{""age"": 24, ""job"": ""Time Traveller""}"</span>
|
|
||||||
</code>
|
|
||||||
</blockquote>
|
|
||||||
</div>
|
</div>
|
||||||
</section><!-- upload //-->
|
</section><!-- upload //-->
|
||||||
|
|
||||||
|
|
@ -175,8 +156,9 @@ export default Vue.extend({
|
||||||
subStatus: 'unconfirmed',
|
subStatus: 'unconfirmed',
|
||||||
delim: ',',
|
delim: ',',
|
||||||
lists: [],
|
lists: [],
|
||||||
overwrite: true,
|
overwrite: false,
|
||||||
file: null,
|
file: null,
|
||||||
|
example: '',
|
||||||
},
|
},
|
||||||
|
|
||||||
// Initial page load still has to wait for the status API to return
|
// Initial page load still has to wait for the status API to return
|
||||||
|
|
@ -295,6 +277,32 @@ export default Vue.extend({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
renderExample() {
|
||||||
|
const h = 'email, name, attributes\n'
|
||||||
|
+ 'user1 @mail.com, "User One", "{""age"": 42, ""planet"": ""Mars""}"\n'
|
||||||
|
+ 'user2 @mail.com, "User Two", "{""age"": 24, ""job"": ""Time Traveller""}"';
|
||||||
|
|
||||||
|
this.example = h;
|
||||||
|
},
|
||||||
|
|
||||||
|
resetForm() {
|
||||||
|
this.form.mode = 'subscribe';
|
||||||
|
this.form.overwrite = false;
|
||||||
|
this.form.file = null;
|
||||||
|
this.form.lists = [];
|
||||||
|
this.form.subStatus = 'unconfirmed';
|
||||||
|
this.form.delim = ',';
|
||||||
|
},
|
||||||
|
|
||||||
|
onUpload() {
|
||||||
|
if (this.form.mode === 'subscribe' && this.form.overwrite) {
|
||||||
|
this.$utils.confirm(this.$t('import.subscribeWarning'), this.onSubmit, this.resetForm);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.onSubmit();
|
||||||
|
},
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
this.isProcessing = true;
|
this.isProcessing = true;
|
||||||
|
|
||||||
|
|
@ -336,6 +344,7 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
|
this.renderExample();
|
||||||
this.pollStatus();
|
this.pollStatus();
|
||||||
|
|
||||||
const ids = this.$utils.parseQueryIDs(this.$route.query.list_id);
|
const ids = this.$utils.parseQueryIDs(this.$route.query.list_id);
|
||||||
|
|
|
||||||
|
|
@ -259,6 +259,7 @@
|
||||||
"import.recordsCount": "{num} / {total} records",
|
"import.recordsCount": "{num} / {total} records",
|
||||||
"import.stopImport": "Stop import",
|
"import.stopImport": "Stop import",
|
||||||
"import.subscribe": "Subscribe",
|
"import.subscribe": "Subscribe",
|
||||||
|
"import.subscribeWarning":"Overwriting will re-subscribe unusbscribed e-mails. Continue?",
|
||||||
"import.title": "Import subscribers",
|
"import.title": "Import subscribers",
|
||||||
"import.upload": "Upload",
|
"import.upload": "Upload",
|
||||||
"lists.confirmDelete": "Are you sure? This does not delete subscribers.",
|
"lists.confirmDelete": "Are you sure? This does not delete subscribers.",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue