Skip to content

Commit

Permalink
fix: replace current route after inserting workbook
Browse files Browse the repository at this point in the history
  • Loading branch information
nextchamp-saqib committed Nov 10, 2024
1 parent b2b9fc2 commit c91f35d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 7 additions & 3 deletions frontend/src2/components/Navbar.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<script setup lang="ts"></script>
<script setup lang="ts">
import { useRouter } from 'vue-router'
const router = useRouter()
</script>

<template>
<div
Expand All @@ -7,9 +11,9 @@
<div class="relative flex flex-1 items-center">
<div class="absolute left-0">
<slot name="left">
<router-link :to="{ path: '/' }">
<button @click="router.back()" class="flex items-center gap-1">
<img src="../assets/insights-logo-new.svg" alt="logo" class="h-7 rounded" />
</router-link>
</button>
</slot>
</div>
<div class="flex flex-1 items-center justify-center">
Expand Down
5 changes: 3 additions & 2 deletions frontend/src2/workbook/workbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import type {
export default function useWorkbook(name: string) {
const workbook = getWorkbookResource(name)

const router = useRouter()
workbook.onAfterInsert(() => {
window.location.href = window.location.href.replace(name, workbook.doc.name)
const href = window.location.href.replace(name, workbook.doc.name)
window.location.replace(href)
})
workbook.onAfterSave(() => createToast({ title: 'Saved', variant: 'success' }))

Expand All @@ -41,6 +41,7 @@ export default function useWorkbook(name: string) {
}
)

const router = useRouter()
function setActiveTab(type: 'query' | 'chart' | 'dashboard' | '', idx: number) {
router.replace(
type ? `/workbook/${workbook.name}/${type}/${idx}` : `/workbook/${workbook.name}`
Expand Down

0 comments on commit c91f35d

Please sign in to comment.