Skip to content
Snippets Groups Projects
Links.vue 3.5 KiB
Newer Older
<template>
  <ul class="nav nav-tabs">
    <li role="presentation" v-bind:class="{ active: $route.name === 'home' }">
      <router-link to="/"> Home </router-link>
    </li>
    <li role="presentation" v-bind:class="{ active: $route.name === 'about' }">
      <router-link to="/about"> About </router-link>
HongKee Moon's avatar
HongKee Moon committed
    <!--<li role="presentation" v-bind:class="{ active: $route.name === 'condensates' }">-->
    <!--<router-link to="/condensates">-->
    <!--Condensates-->
    <!--</router-link>-->
HongKee Moon's avatar
HongKee Moon committed
    <!--</li>-->
    <!--<li role="presentation" v-bind:class="{ active: $route.name === 'browse' }">-->
    <!--<router-link to="/browse">-->
    <!--Browse-->
    <!--</router-link>-->
    <li
      role="presentation"
      v-bind:class="{ active: $route.name === 'biomolecular' }"
    >
      <router-link to="/biomolecular"> Biomolecular Condensates </router-link>
    <li
      role="presentation"
      v-bind:class="{ active: $route.name === 'synthetic' }"
    >
      <router-link to="/synthetic"> Synthetic Condensates </router-link>
HongKee Moon's avatar
HongKee Moon committed
    </li>
HongKee Moon's avatar
HongKee Moon committed
    <!--<li role="presentation" v-bind:class="{ active: $route.name === 'condensate_example' }">-->
    <!--<router-link to="/condensate_example">-->
HongKee Moon's avatar
HongKee Moon committed
    <!--</router-link>-->
    <!--</li>-->
    <!--<li role="presentation" v-bind:class="{ active: $route.name === 'protein_example' }">-->
    <!--<router-link to="/protein_example">-->
    <!--Protein Example-->
    <!--</router-link>-->
HongKee Moon's avatar
HongKee Moon committed
    <!--</li>-->
    <li
      role="presentation"
      v-bind:class="{ active: $route.name === 'statistics' }"
    >
      <router-link to="/statistics"> Statistics </router-link>
    <li
      role="presentation"
      v-bind:class="{ active: $route.name === 'encyclopedia' }"
    >
      <router-link to="/encyclopedia"> Encyclopedia </router-link>
        v-show="userData !== null && (userRole === 'Contributor' || userRole === 'Maintainer')"
        role="presentation"
        v-bind:class="{ active: $route.name === 'updateItems' }"
      <router-link to="/updateItems"> Update Items</router-link>
    </li>
    <li
        v-show="userData !== null"
        role="presentation"
        v-bind:class="{ active: $route.name === 'profile' }">
      <router-link to="/profile"> Profile </router-link>
moon's avatar
moon committed
    </li>
    <li v-show="userData !== null" role="presentation">
moon's avatar
moon committed
      <router-link to="/login" v-on:click.native="signOut">
moon's avatar
moon committed
      </router-link>
    </li>
    <li
      v-show="userData === null"
      role="presentation"
      v-bind:class="{ active: $route.name === 'login' }"
    >
      <router-link to="/login"> Login </router-link>
moon's avatar
moon committed
    </li>
  </ul>
</template>

<script>
export default {
  name: "Links",
moon's avatar
moon committed
  data() {
    return {
      // userData: this.$store.getters['User/userData']
moon's avatar
moon committed
  },
  methods: {
    signOut() {
      const vm = this;
      window.localStorage.removeItem("jwt");
      window.localStorage.removeItem("userData");
      window.localStorage.removeItem("roleName");
      vm.$store.dispatch("User/logOut");
      vm.$router.push("/login");
    },
moon's avatar
moon committed
  },
  computed: {
    userData: function () {
      return this.$store.getters["User/userData"];
    userRole: function () {
      return this.$store.getters["User/userRole"];
    },
  mounted: function () {
moon's avatar
moon committed

    // console.log(vm.userData)
    // console.log(this.$route.name)
    // if(vm.userData !== null) {
    //   vm.$router.push('/profile')
    // }
  },
};
</script>