Browse Source

feat(gui-v2): use useSidebar with storageKey

pull/3174/head
Wing-Kam Wong 2 years ago
parent
commit
497c87c94c
  1. 8
      packages/nc-gui-v2/components/smartsheet/sidebar/toolbar/AddRow.vue
  2. 7
      packages/nc-gui-v2/components/smartsheet/sidebar/toolbar/DeleteTable.vue
  3. 7
      packages/nc-gui-v2/components/smartsheet/sidebar/toolbar/Reload.vue

8
packages/nc-gui-v2/components/smartsheet/sidebar/toolbar/AddRow.vue

@ -1,14 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { inject, ref } from '#imports'
import { RightSidebarInj } from '~/context'
const emits = defineEmits(['addRow']) const emits = defineEmits(['addRow'])
const { isOpen } = useSidebar({ storageKey: 'nc-right-sidebar' })
const sidebarOpen = inject(RightSidebarInj, ref(true))
</script> </script>
<template> <template>
<a-tooltip :placement="sidebarOpen ? 'bottomRight' : 'left'"> <a-tooltip :placement="isOpen ? 'bottomRight' : 'left'">
<template #title> {{ $t('activity.addRow') }} </template> <template #title> {{ $t('activity.addRow') }} </template>
<div class="nc-sidebar-right-item hover:after:bg-primary/75 group"> <div class="nc-sidebar-right-item hover:after:bg-primary/75 group">

7
packages/nc-gui-v2/components/smartsheet/sidebar/toolbar/DeleteTable.vue

@ -1,16 +1,15 @@
<script setup lang="ts"> <script setup lang="ts">
import { inject, ref, useTable } from '#imports' import { MetaInj, inject, useTable } from '#imports'
import { MetaInj, RightSidebarInj } from '~/context'
const meta = inject(MetaInj)! const meta = inject(MetaInj)!
const { deleteTable } = useTable() const { deleteTable } = useTable()
const sidebarOpen = inject(RightSidebarInj, ref(true)) const { isOpen } = useSidebar({ storageKey: 'nc-right-sidebar' })
</script> </script>
<template> <template>
<a-tooltip :placement="sidebarOpen ? 'bottomRight' : 'left'"> <a-tooltip :placement="isOpen ? 'bottomRight' : 'left'">
<template #title> {{ $t('activity.deleteTable') }} </template> <template #title> {{ $t('activity.deleteTable') }} </template>
<div class="nc-sidebar-right-item hover:after:bg-red-500 group"> <div class="nc-sidebar-right-item hover:after:bg-red-500 group">

7
packages/nc-gui-v2/components/smartsheet/sidebar/toolbar/Reload.vue

@ -1,16 +1,15 @@
<script setup lang="ts"> <script setup lang="ts">
import { ReloadViewDataHookInj, RightSidebarInj } from '~/context' import { ReloadViewDataHookInj, inject } from '#imports'
import { inject, ref } from '#imports'
const reloadHook = inject(ReloadViewDataHookInj)! const reloadHook = inject(ReloadViewDataHookInj)!
const sidebarOpen = inject(RightSidebarInj, ref(true)) const { isOpen } = useSidebar({ storageKey: 'nc-right-sidebar' })
const onClick = () => reloadHook.trigger() const onClick = () => reloadHook.trigger()
</script> </script>
<template> <template>
<a-tooltip :placement="sidebarOpen ? 'bottomRight' : 'left'"> <a-tooltip :placement="isOpen ? 'bottomRight' : 'left'">
<template #title> {{ $t('general.reload') }} </template> <template #title> {{ $t('general.reload') }} </template>
<div class="nc-sidebar-right-item hover:after:bg-green-500 group"> <div class="nc-sidebar-right-item hover:after:bg-green-500 group">

Loading…
Cancel
Save