aboutsummaryrefslogtreecommitdiff
path: root/src/components/importer/importer.js
diff options
context:
space:
mode:
authorHJ <30-hj@users.noreply.git.pleroma.social>2019-04-29 18:15:58 +0000
committerHJ <30-hj@users.noreply.git.pleroma.social>2019-04-29 18:15:58 +0000
commitd94fdd0617057f17a677e7e409f65021afc9d124 (patch)
tree3f9b0d96d1d76eedd59fd7de353be0ae668b796c /src/components/importer/importer.js
parent6d1d09bcc05f4476c7efad1980e656683db2e5c3 (diff)
parenta793835566d478503f4cadf7970ad62476dd75ac (diff)
Merge branch '220-import-export-blocks-mutes' into 'develop'
Allow import/export of blocks See merge request pleroma/pleroma-fe!717
Diffstat (limited to 'src/components/importer/importer.js')
-rw-r--r--src/components/importer/importer.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/components/importer/importer.js b/src/components/importer/importer.js
new file mode 100644
index 00000000..c5f9e4d2
--- /dev/null
+++ b/src/components/importer/importer.js
@@ -0,0 +1,53 @@
+const Importer = {
+ props: {
+ submitHandler: {
+ type: Function,
+ required: true
+ },
+ submitButtonLabel: {
+ type: String,
+ default () {
+ return this.$t('importer.submit')
+ }
+ },
+ successMessage: {
+ type: String,
+ default () {
+ return this.$t('importer.success')
+ }
+ },
+ errorMessage: {
+ type: String,
+ default () {
+ return this.$t('importer.error')
+ }
+ }
+ },
+ data () {
+ return {
+ file: null,
+ error: false,
+ success: false,
+ submitting: false
+ }
+ },
+ methods: {
+ change () {
+ this.file = this.$refs.input.files[0]
+ },
+ submit () {
+ this.dismiss()
+ this.submitting = true
+ this.submitHandler(this.file)
+ .then(() => { this.success = true })
+ .catch(() => { this.error = true })
+ .finally(() => { this.submitting = false })
+ },
+ dismiss () {
+ this.success = false
+ this.error = false
+ }
+ }
+}
+
+export default Importer