Allow importing collections from gist
This commit is contained in:
@@ -14,15 +14,17 @@
|
|||||||
<div
|
<div
|
||||||
v-tooltip="{
|
v-tooltip="{
|
||||||
content:
|
content:
|
||||||
!fb.currentUser &&
|
|
||||||
this.$store.state.postwoman.providerInfo.providerId !== 'github.com'
|
this.$store.state.postwoman.providerInfo.providerId !== 'github.com'
|
||||||
? $t('login_with_github_to') + $t('create_secret_gist')
|
? $t('login_with_github_to') + $t('create_secret_gist')
|
||||||
: null,
|
: null,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
|
<button class="icon" @click="readCollectionGist" v-close-popover>
|
||||||
|
<i class="material-icons">code</i>
|
||||||
|
<span>{{ $t("import_from_gist") }}</span>
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
:disabled="
|
:disabled="
|
||||||
!fb.currentUser &&
|
|
||||||
this.$store.state.postwoman.providerInfo.providerId !== 'github.com'
|
this.$store.state.postwoman.providerInfo.providerId !== 'github.com'
|
||||||
"
|
"
|
||||||
class="icon"
|
class="icon"
|
||||||
@@ -153,6 +155,26 @@ export default {
|
|||||||
console.log(error)
|
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() {
|
hideModal() {
|
||||||
this.$emit("hide-modal")
|
this.$emit("hide-modal")
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -297,5 +297,7 @@
|
|||||||
"select_environment": "Select environment",
|
"select_environment": "Select environment",
|
||||||
"login_with_github_to": "Login with GitHub to ",
|
"login_with_github_to": "Login with GitHub to ",
|
||||||
"create_secret_gist": "Create secret Gist",
|
"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