Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import warning and setting overwrite default off #2078

Merged
merged 3 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/swagger/collections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2487,6 +2487,8 @@ components:
type: string
import.subscribe:
type: string
import.subscribeWarning:
type: string
import.title:
type: string
import.upload:
Expand Down
59 changes: 34 additions & 25 deletions frontend/src/views/Import.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<b-loading :active="isLoading" />

<section v-if="isFree()" class="wrap">
<form @submit.prevent="onSubmit" class="box">
<form @submit.prevent="onUpload" class="box">
<div>
<div class="columns">
<div class="column">
Expand Down Expand Up @@ -93,36 +93,17 @@
</h5>
<p>{{ $t('import.instructionsHelp') }}</p>
<br />
<blockquote className="csv-example">
<code className="csv-headers">
<span>email,</span>
<span>name,</span>
<span>attributes</span>
</code>
<blockquote class="csv-example">
<code class="csv-headers"> <span>email,</span> <span>name,</span> <span>attributes</span></code>
</blockquote>

<hr />

<h5 class="title is-size-6">
{{ $t('import.csvExample') }}
</h5>
<blockquote className="csv-example">
<code className="csv-headers">
<span>email,</span>
<span>name,</span>
<span>attributes</span>
</code><br />
<code className="csv-row">
<span>[email protected],</span>
<span>"User One",</span>
<span>"{""age"": 42, ""planet"": ""Mars""}"</span>
</code><br />
<code className="csv-row">
<span>[email protected],</span>
<span>"User Two",</span>
<span>"{""age"": 24, ""job"": ""Time Traveller""}"</span>
</code>
</blockquote>

<pre class="csv-example" v-text="example" />
</div>
</section><!-- upload //-->

Expand Down Expand Up @@ -175,8 +156,9 @@ export default Vue.extend({
subStatus: 'unconfirmed',
delim: ',',
lists: [],
overwrite: true,
overwrite: false,
file: null,
example: '',
},

// Initial page load still has to wait for the status API to return
Expand Down Expand Up @@ -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() {
this.isProcessing = true;

Expand Down Expand Up @@ -336,6 +344,7 @@ export default Vue.extend({
},

mounted() {
this.renderExample();
this.pollStatus();

const ids = this.$utils.parseQueryIDs(this.$route.query.list_id);
Expand Down
1 change: 1 addition & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
"import.recordsCount": "{num} / {total} records",
"import.stopImport": "Stop import",
"import.subscribe": "Subscribe",
"import.subscribeWarning":"Overwriting will re-subscribe unusbscribed e-mails. Continue?",
"import.title": "Import subscribers",
"import.upload": "Upload",
"lists.confirmDelete": "Are you sure? This does not delete subscribers.",
Expand Down