Allow importing collections from gist
This commit is contained in:
@@ -14,15 +14,17 @@
|
||||
<div
|
||||
v-tooltip="{
|
||||
content:
|
||||
!fb.currentUser &&
|
||||
this.$store.state.postwoman.providerInfo.providerId !== 'github.com'
|
||||
? $t('login_with_github_to') + $t('create_secret_gist')
|
||||
: null,
|
||||
}"
|
||||
>
|
||||
<button class="icon" @click="readCollectionGist" v-close-popover>
|
||||
<i class="material-icons">code</i>
|
||||
<span>{{ $t("import_from_gist") }}</span>
|
||||
</button>
|
||||
<button
|
||||
:disabled="
|
||||
!fb.currentUser &&
|
||||
this.$store.state.postwoman.providerInfo.providerId !== 'github.com'
|
||||
"
|
||||
class="icon"
|
||||
@@ -153,6 +155,26 @@ export default {
|
||||
console.log(error)
|
||||
})
|
||||
},
|
||||
async readCollectionGist() {
|
||||
let gist = prompt(this.$t("enter_gist_url"))
|
||||
if (!gist) return
|
||||
await this.$axios
|
||||
.$get(`https://api.github.com/gists/${gist.split("/").pop()}`, {
|
||||
headers: {
|
||||
Accept: "application/vnd.github.v3+json",
|
||||
},
|
||||
})
|
||||
.then((response) => {
|
||||
let collections = JSON.parse(Object.values(response.files)[0].content)
|
||||
this.$store.commit("postwoman/replaceCollections", collections)
|
||||
this.fileImported()
|
||||
this.syncToFBCollections()
|
||||
})
|
||||
.catch((error) => {
|
||||
this.failedImport()
|
||||
console.log(error)
|
||||
})
|
||||
},
|
||||
hideModal() {
|
||||
this.$emit("hide-modal")
|
||||
},
|
||||
|
||||
@@ -297,5 +297,7 @@
|
||||
"select_environment": "Select environment",
|
||||
"login_with_github_to": "Login with GitHub to ",
|
||||
"create_secret_gist": "Create secret Gist",
|
||||
"gist_created": "Gist created"
|
||||
"gist_created": "Gist created",
|
||||
"import_from_gist": "Import from Gist",
|
||||
"enter_gist_url": "Enter Gist URL"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user