Browse Source

refactor: remove EAInvite flag

liyasthomas 4 years ago
parent
commit
e82a4a1d23

+ 1 - 1
packages/hoppscotch-app/components/collections/ChooseType.vue

@@ -7,7 +7,7 @@
         :selected="true"
       />
       <SmartTab
-        v-if="currentUser && currentUser.eaInvited && !doc"
+        v-if="currentUser && !doc"
         :id="'team-collections'"
         :label="`${$t('collection.team_collections')}`"
       >

+ 2 - 2
packages/hoppscotch-app/components/teams/Add.vue

@@ -44,7 +44,7 @@ const {
   $toast,
 } = useContext()
 
-const $t = i18n.t.bind(i18n)
+const t = i18n.t.bind(i18n)
 
 defineProps<{
   show: boolean
@@ -66,7 +66,7 @@ const addNewTeam = () =>
       (err) => {
         // err is of type "invalid_name" | GQLError<Err>
         if (err === "invalid_name") {
-          $toast.error($t("team.name_length_insufficient").toString(), {
+          $toast.error(t("team.name_length_insufficient").toString(), {
             icon: "error_outline",
           })
         } else {

+ 7 - 0
packages/hoppscotch-app/components/teams/index.vue

@@ -36,6 +36,13 @@
           @edit-team="editTeam(team, team.id)"
         />
       </div>
+      <div
+        v-if="!myTeams.loading && E.isLeft(myTeams.data)"
+        class="flex items-center flex-col"
+      >
+        <i class="mb-4 material-icons">help_outline</i>
+        {{ $t("error.something_went_wrong") }}
+      </div>
     </div>
     <TeamsAdd :show="showModalAdd" @hide-modal="displayModalAdd(false)" />
     <!-- ¯\_(ツ)_/¯ -->

+ 0 - 6
packages/hoppscotch-app/helpers/teams/BackendUserInfo.ts

@@ -28,10 +28,6 @@ export interface UserInfo {
    * URL to the profile photo of the user (or null if none available)
    */
   photoURL: string | null
-  /**
-   * Whether the user has access to Early Access features
-   */
-  eaInvited: boolean
 }
 
 /**
@@ -65,7 +61,6 @@ async function updateUserInfo() {
             displayName
             email
             photoURL
-            eaInvited
           }
         }
       `,
@@ -76,7 +71,6 @@ async function updateUserInfo() {
       displayName: data.me.displayName,
       email: data.me.email,
       photoURL: data.me.photoURL,
-      eaInvited: data.me.eaInvited,
     })
   } catch (e) {
     currentUserInfo$.next(null)

+ 32 - 50
packages/hoppscotch-app/pages/profile.vue

@@ -47,9 +47,7 @@
                   <div class="flex items-center">
                     <SmartToggle
                       :on="SYNC_COLLECTIONS"
-                      @change="
-                        toggleSettings('syncCollections', !SYNC_COLLECTIONS)
-                      "
+                      @change="toggleSetting('syncCollections')"
                     >
                       {{ $t("settings.sync_collections") }}
                     </SmartToggle>
@@ -57,9 +55,7 @@
                   <div class="flex items-center">
                     <SmartToggle
                       :on="SYNC_ENVIRONMENTS"
-                      @change="
-                        toggleSettings('syncEnvironments', !SYNC_ENVIRONMENTS)
-                      "
+                      @change="toggleSetting('syncEnvironments')"
                     >
                       {{ $t("settings.sync_environments") }}
                     </SmartToggle>
@@ -67,7 +63,7 @@
                   <div class="flex items-center">
                     <SmartToggle
                       :on="SYNC_HISTORY"
-                      @change="toggleSettings('syncHistory', !SYNC_HISTORY)"
+                      @change="toggleSetting('syncHistory')"
                     >
                       {{ $t("settings.sync_history") }}
                     </SmartToggle>
@@ -75,11 +71,7 @@
                 </div>
               </section>
             </SmartTab>
-            <SmartTab
-              v-if="currentBackendUser && currentBackendUser.eaInvited"
-              :id="'teams'"
-              :label="$t('team.title')"
-            >
+            <SmartTab :id="'teams'" :label="$t('team.title')">
               <AppSection label="teams">
                 <Teams />
               </AppSection>
@@ -92,47 +84,37 @@
   </div>
 </template>
 
-<script lang="ts">
-import { defineComponent } from "@nuxtjs/composition-api"
-import { currentUserInfo$ } from "~/helpers/teams/BackendUserInfo"
+<script setup lang="ts">
+import {
+  ref,
+  useContext,
+  useMeta,
+  defineComponent,
+} from "@nuxtjs/composition-api"
 import { currentUser$ } from "~/helpers/fb/auth"
 import { useReadonlyStream } from "~/helpers/utils/composables"
-import { applySetting, SettingsType, useSetting } from "~/newstore/settings"
-import { KeysMatching } from "~/types/ts-utils"
+import { toggleSetting, useSetting } from "~/newstore/settings"
+
+const {
+  app: { i18n },
+} = useContext()
+
+const t = i18n.t.bind(i18n)
+
+const showLogin = ref(false)
 
+const SYNC_COLLECTIONS = useSetting("syncCollections")
+const SYNC_ENVIRONMENTS = useSetting("syncEnvironments")
+const SYNC_HISTORY = useSetting("syncHistory")
+const currentUser = useReadonlyStream(currentUser$, null)
+
+useMeta({
+  title: `${t("navigation.profile")} • Hoppscotch`,
+})
+</script>
+
+<script lang="ts">
 export default defineComponent({
-  setup() {
-    return {
-      SYNC_COLLECTIONS: useSetting("syncCollections"),
-      SYNC_ENVIRONMENTS: useSetting("syncEnvironments"),
-      SYNC_HISTORY: useSetting("syncHistory"),
-      currentUser: useReadonlyStream(currentUser$, currentUser$.value),
-      currentBackendUser: useReadonlyStream(
-        currentUserInfo$,
-        currentUserInfo$.value
-      ),
-    }
-  },
-  data() {
-    return {
-      showLogin: false,
-    }
-  },
-  head() {
-    return {
-      title: `${this.$t("navigation.profile")} • Hoppscotch`,
-    }
-  },
-  methods: {
-    applySetting<K extends keyof SettingsType>(key: K, value: SettingsType[K]) {
-      applySetting(key, value)
-    },
-    toggleSettings<K extends KeysMatching<SettingsType, boolean>>(
-      name: K,
-      value: SettingsType[K]
-    ) {
-      this.applySetting(name, value)
-    },
-  },
+  head: {},
 })
 </script>