Skip to content

Commit

Permalink
GH-1551 Return to base directory when clicking "Overview" (Resolve #1551
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dzikoysk committed Oct 31, 2022
1 parent 3322541 commit c8cc38d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
10 changes: 8 additions & 2 deletions reposilite-frontend/src/helpers/qualifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { watch, reactive } from 'vue'
import { useRoute } from 'vue-router'
import { useRoute, useRouter } from 'vue-router'
import { useSession } from '../store/session'

const qualifier = reactive({
Expand All @@ -35,6 +35,11 @@ watch(

export default function useQualifier() {
const route = useRoute()
const router = useRouter()

const redirectTo = (path) => {
router.push(path)
}

watch(
() => route.params.qualifier,
Expand All @@ -47,6 +52,7 @@ export default function useQualifier() {

return {
qualifier,
refreshQualifier
refreshQualifier,
redirectTo
}
}
18 changes: 16 additions & 2 deletions reposilite-frontend/src/pages/IndexPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<script setup>
import { computed, ref, watchEffect } from 'vue'
import { useSession } from '../store/session'
import useQualifier from '../helpers/qualifier'
import DefaultHeader from '../components/header/DefaultHeader.vue'
import FileBrowserView from '../components/browser/FileBrowserView.vue'
import ConsoleView from '../components/console/ConsoleView.vue'
Expand All @@ -37,6 +38,7 @@ const listOfTabs = [
]

const { isManager } = useSession()
const { redirectTo } = useQualifier()

const menuTabs = computed(() =>
listOfTabs
Expand All @@ -45,7 +47,16 @@ const menuTabs = computed(() =>
)

const selectedTab = ref(localStorage.getItem('selectedTab') || 'Overview')
watchEffect(() => localStorage.setItem('selectedTab', selectedTab.value))

watchEffect(() => {
localStorage.setItem('selectedTab', selectedTab.value)
})

const createTabClick = (newTab) => {
if (newTab == 'Overview') {
redirectTo('/')
}
}

const selectHomepage = () =>
selectedTab.value = 'Overview'
Expand All @@ -56,7 +67,10 @@ const selectHomepage = () =>
<DefaultHeader :logoClickCallback="selectHomepage" />
<div class="bg-gray-100 dark:bg-black overflow-y-visible">
<div class="container mx-auto <sm:px-0">
<Tabs v-model="selectedTab">
<Tabs
v-model="selectedTab"
@update:modelValue="createTabClick"
>
<Tab
v-for="(tab, i) in menuTabs"
class="item font-normal"
Expand Down

0 comments on commit c8cc38d

Please sign in to comment.