Initial Firebase refactor pass
This commit is contained in:
@@ -64,18 +64,18 @@
|
||||
<div v-else class="row-wrapper">
|
||||
<div
|
||||
v-tooltip.bottom="{
|
||||
content: !fb.currentUser
|
||||
content: !currentUser
|
||||
? $t('login_with_github_to') + $t('create_secret_gist')
|
||||
: fb.currentUser.provider !== 'github.com'
|
||||
: currentUser.provider !== 'github.com'
|
||||
? $t('login_with_github_to') + $t('create_secret_gist')
|
||||
: null,
|
||||
}"
|
||||
>
|
||||
<button
|
||||
:disabled="
|
||||
!fb.currentUser
|
||||
!currentUser
|
||||
? true
|
||||
: fb.currentUser.provider !== 'github.com'
|
||||
: currentUser.provider !== 'github.com'
|
||||
? true
|
||||
: false
|
||||
"
|
||||
@@ -113,7 +113,7 @@
|
||||
|
||||
<script>
|
||||
import Mustache from "mustache"
|
||||
import { fb } from "~/helpers/fb"
|
||||
import { currentUser$ } from "~/helpers/fb/auth"
|
||||
import DocsTemplate from "~/assets/md/docs.md"
|
||||
import folderContents from "~/assets/md/folderContents.md"
|
||||
import folderBody from "~/assets/md/folderBody.md"
|
||||
@@ -121,13 +121,17 @@ import folderBody from "~/assets/md/folderBody.md"
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
fb,
|
||||
collectionJSON: "[]",
|
||||
items: [],
|
||||
docsMarkdown: "",
|
||||
selected: [],
|
||||
}
|
||||
},
|
||||
subscriptions() {
|
||||
return {
|
||||
currentUser: currentUser$,
|
||||
}
|
||||
},
|
||||
head() {
|
||||
return {
|
||||
title: `Documentation • Hoppscotch`,
|
||||
@@ -147,7 +151,7 @@ export default {
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: `token ${fb.currentUser.accessToken}`,
|
||||
Authorization: `token ${this.currentUser.accessToken}`,
|
||||
Accept: "application/vnd.github.v3+json",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -6,10 +6,11 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fb } from "~/helpers/fb"
|
||||
<script lang="ts">
|
||||
import Vue from "vue"
|
||||
import { isSignInWithEmailLink, signInWithEmailLink } from "~/helpers/fb/auth"
|
||||
|
||||
export default {
|
||||
export default Vue.extend({
|
||||
data() {
|
||||
return {
|
||||
signingInWithEmail: false,
|
||||
@@ -17,14 +18,18 @@ export default {
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
if (fb.isSignInWithEmailLink(window.location.href)) {
|
||||
if (isSignInWithEmailLink(window.location.href)) {
|
||||
this.signingInWithEmail = true
|
||||
|
||||
let email = window.localStorage.getItem("emailForSignIn")
|
||||
|
||||
if (!email) {
|
||||
email = window.prompt("Please provide your email for confirmation")
|
||||
email = window.prompt(
|
||||
"Please provide your email for confirmation"
|
||||
) as string
|
||||
}
|
||||
await fb
|
||||
.signInWithEmailLink(email, window.location.href)
|
||||
|
||||
await signInWithEmailLink(email, window.location.href)
|
||||
.then(() => {
|
||||
window.localStorage.removeItem("emailForSignIn")
|
||||
this.$router.push({ path: "/" })
|
||||
@@ -38,5 +43,5 @@ export default {
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -775,12 +775,7 @@ import runTestScriptWithVariables from "~/helpers/postwomanTesting"
|
||||
import parseTemplateString from "~/helpers/templating"
|
||||
import { tokenRequest, oauthRedirect } from "~/helpers/oauth"
|
||||
import { cancelRunningRequest, sendNetworkRequest } from "~/helpers/network"
|
||||
import { fb } from "~/helpers/fb"
|
||||
import {
|
||||
hasPathParams,
|
||||
addPathParamsToVariables,
|
||||
getQueryParams,
|
||||
} from "~/helpers/requestParams"
|
||||
import { hasPathParams, addPathParamsToVariables, getQueryParams } from "~/helpers/requestParams"
|
||||
import { parseUrlAndPath } from "~/helpers/utils/uri"
|
||||
import { httpValid } from "~/helpers/utils/valid"
|
||||
import {
|
||||
@@ -820,7 +815,6 @@ export default {
|
||||
showSaveRequestModal: false,
|
||||
editRequest: {},
|
||||
activeSidebar: true,
|
||||
fb,
|
||||
customMethod: false,
|
||||
files: [],
|
||||
filenames: "",
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div v-if="currentUser && currentUser.eaInvited">
|
||||
<div v-if="currentBackendUser && currentBackendUser.eaInvited">
|
||||
<Teams />
|
||||
</div>
|
||||
|
||||
<AppSection ref="account" :label="$t('account')" no-legend>
|
||||
<div class="flex flex-col">
|
||||
<label>{{ $t("account") }}</label>
|
||||
<div v-if="fb.currentUser">
|
||||
<div v-if="currentUser">
|
||||
<button class="icon">
|
||||
<img
|
||||
v-if="fb.currentUser.photoURL"
|
||||
:src="fb.currentUser.photoURL"
|
||||
v-if="currentUser.photoURL"
|
||||
:src="currentUser.photoURL"
|
||||
class="w-6 h-6 rounded-full material-icons"
|
||||
/>
|
||||
<i v-else class="material-icons">account_circle</i>
|
||||
<span>
|
||||
{{ fb.currentUser.displayName || $t("nothing_found") }}
|
||||
{{ currentUser.displayName || $t("nothing_found") }}
|
||||
</span>
|
||||
</button>
|
||||
<br />
|
||||
<button class="icon">
|
||||
<i class="material-icons">email</i>
|
||||
<span>
|
||||
{{ fb.currentUser.email || $t("nothing_found") }}
|
||||
{{ currentUser.email || $t("nothing_found") }}
|
||||
</span>
|
||||
</button>
|
||||
<br />
|
||||
@@ -58,7 +58,7 @@
|
||||
</SmartToggle>
|
||||
</p>
|
||||
|
||||
<p v-if="fb.currentSettings.length !== 3">
|
||||
<p v-if="isSyncDisabled">
|
||||
<button @click="initSettings">
|
||||
<i class="material-icons">sync</i>
|
||||
<span>{{ $t("turn_on") + " " + $t("sync") }}</span>
|
||||
@@ -214,7 +214,6 @@
|
||||
<script lang="ts">
|
||||
import Vue from "vue"
|
||||
import { hasExtensionInstalled } from "../helpers/strategies/ExtensionStrategy"
|
||||
import { fb } from "~/helpers/fb"
|
||||
import {
|
||||
getSettingSubject,
|
||||
applySetting,
|
||||
@@ -223,6 +222,7 @@ import {
|
||||
} from "~/newstore/settings"
|
||||
import type { KeysMatching } from "~/types/ts-utils"
|
||||
import { currentUserInfo$ } from "~/helpers/teams/BackendUserInfo"
|
||||
import { currentUser$ } from "~/helpers/fb/auth"
|
||||
|
||||
type SettingsType = typeof defaultSettings
|
||||
|
||||
@@ -234,7 +234,6 @@ export default Vue.extend({
|
||||
: null,
|
||||
|
||||
doneButton: '<i class="material-icons">done</i>',
|
||||
fb,
|
||||
|
||||
SYNC_COLLECTIONS: true,
|
||||
SYNC_ENVIRONMENTS: true,
|
||||
@@ -247,6 +246,9 @@ export default Vue.extend({
|
||||
PROXY_ENABLED: true,
|
||||
|
||||
showEmail: false,
|
||||
|
||||
currentBackendUser: null,
|
||||
currentUser: null,
|
||||
}
|
||||
},
|
||||
subscriptions() {
|
||||
@@ -268,7 +270,8 @@ export default Vue.extend({
|
||||
SYNC_HISTORY: getSettingSubject("syncHistory"),
|
||||
|
||||
// Teams feature flag
|
||||
currentUser: currentUserInfo$,
|
||||
currentBackendUser: currentUserInfo$,
|
||||
currentUser: currentUser$,
|
||||
}
|
||||
},
|
||||
head() {
|
||||
@@ -283,6 +286,9 @@ export default Vue.extend({
|
||||
key: this.PROXY_KEY,
|
||||
}
|
||||
},
|
||||
isSyncDisabled(): boolean {
|
||||
return this.SYNC_COLLECTIONS && this.SYNC_ENVIRONMENTS && this.SYNC_HISTORY
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
proxySettings: {
|
||||
@@ -311,13 +317,6 @@ export default Vue.extend({
|
||||
value: SettingsType[K]
|
||||
) {
|
||||
this.applySetting(name, value)
|
||||
|
||||
if (name === "syncCollections" && value) {
|
||||
this.syncCollections()
|
||||
}
|
||||
if (name === "syncEnvironments" && value) {
|
||||
this.syncEnvironments()
|
||||
}
|
||||
},
|
||||
initSettings() {
|
||||
applySetting("syncHistory", true)
|
||||
@@ -336,30 +335,6 @@ export default Vue.extend({
|
||||
1000
|
||||
)
|
||||
},
|
||||
// TODO: Use the new collection store
|
||||
syncCollections(): void {
|
||||
if (fb.currentUser !== null && this.SYNC_COLLECTIONS) {
|
||||
if (this.$store.state.postwoman.collections)
|
||||
fb.writeCollections(
|
||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.collections)),
|
||||
"collections"
|
||||
)
|
||||
if (this.$store.state.postwoman.collectionsGraphql)
|
||||
fb.writeCollections(
|
||||
JSON.parse(
|
||||
JSON.stringify(this.$store.state.postwoman.collectionsGraphql)
|
||||
),
|
||||
"collectionsGraphql"
|
||||
)
|
||||
}
|
||||
},
|
||||
syncEnvironments(): void {
|
||||
if (fb.currentUser !== null && this.SYNC_ENVIRONMENTS) {
|
||||
fb.writeEnvironments(
|
||||
JSON.parse(JSON.stringify(this.$store.state.postwoman.environments))
|
||||
)
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user