Added refresh layout button to graph settings
This commit is contained in:
@@ -9,7 +9,7 @@ import { controlButtonVariant } from '@/lib/constants'
|
|||||||
import { useSettingsStore } from '@/stores/settings'
|
import { useSettingsStore } from '@/stores/settings'
|
||||||
import { useBackendState } from '@/stores/state'
|
import { useBackendState } from '@/stores/state'
|
||||||
|
|
||||||
import { SettingsIcon } from 'lucide-react'
|
import { SettingsIcon, RefreshCwIcon } from 'lucide-react'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component that displays a checkbox with a label.
|
* Component that displays a checkbox with a label.
|
||||||
@@ -113,6 +113,7 @@ const LabeledNumberInput = ({
|
|||||||
export default function Settings() {
|
export default function Settings() {
|
||||||
const [opened, setOpened] = useState<boolean>(false)
|
const [opened, setOpened] = useState<boolean>(false)
|
||||||
const [tempApiKey, setTempApiKey] = useState<string>('')
|
const [tempApiKey, setTempApiKey] = useState<string>('')
|
||||||
|
const refreshLayout = useSettingsStore.use.refreshLayout()
|
||||||
|
|
||||||
const showPropertyPanel = useSettingsStore.use.showPropertyPanel()
|
const showPropertyPanel = useSettingsStore.use.showPropertyPanel()
|
||||||
const showNodeSearchBar = useSettingsStore.use.showNodeSearchBar()
|
const showNodeSearchBar = useSettingsStore.use.showNodeSearchBar()
|
||||||
@@ -205,6 +206,15 @@ export default function Settings() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
variant={controlButtonVariant}
|
||||||
|
tooltip="Refresh Layout"
|
||||||
|
size="icon"
|
||||||
|
onClick={refreshLayout}
|
||||||
|
>
|
||||||
|
<RefreshCwIcon />
|
||||||
|
</Button>
|
||||||
<Popover open={opened} onOpenChange={setOpened}>
|
<Popover open={opened} onOpenChange={setOpened}>
|
||||||
<PopoverTrigger asChild>
|
<PopoverTrigger asChild>
|
||||||
<Button variant={controlButtonVariant} tooltip="Settings" size="icon">
|
<Button variant={controlButtonVariant} tooltip="Settings" size="icon">
|
||||||
@@ -317,5 +327,6 @@ export default function Settings() {
|
|||||||
</div>
|
</div>
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -3,12 +3,14 @@ import { persist, createJSONStorage } from 'zustand/middleware'
|
|||||||
import { createSelectors } from '@/lib/utils'
|
import { createSelectors } from '@/lib/utils'
|
||||||
import { defaultQueryLabel } from '@/lib/constants'
|
import { defaultQueryLabel } from '@/lib/constants'
|
||||||
import { Message, QueryRequest } from '@/api/lightrag'
|
import { Message, QueryRequest } from '@/api/lightrag'
|
||||||
|
import { useGraphStore } from '@/stores/graph'
|
||||||
|
|
||||||
type Theme = 'dark' | 'light' | 'system'
|
type Theme = 'dark' | 'light' | 'system'
|
||||||
type Tab = 'documents' | 'knowledge-graph' | 'retrieval' | 'api'
|
type Tab = 'documents' | 'knowledge-graph' | 'retrieval' | 'api'
|
||||||
|
|
||||||
interface SettingsState {
|
interface SettingsState {
|
||||||
// Graph viewer settings
|
// Graph viewer settings
|
||||||
|
refreshLayout: () => void
|
||||||
showPropertyPanel: boolean
|
showPropertyPanel: boolean
|
||||||
showNodeSearchBar: boolean
|
showNodeSearchBar: boolean
|
||||||
|
|
||||||
@@ -57,6 +59,15 @@ const useSettingsStoreBase = create<SettingsState>()(
|
|||||||
persist(
|
persist(
|
||||||
(set) => ({
|
(set) => ({
|
||||||
theme: 'system',
|
theme: 'system',
|
||||||
|
refreshLayout: () => {
|
||||||
|
const graphState = useGraphStore.getState();
|
||||||
|
const currentGraph = graphState.sigmaGraph;
|
||||||
|
graphState.clearSelection();
|
||||||
|
graphState.setSigmaGraph(null);
|
||||||
|
setTimeout(() => {
|
||||||
|
graphState.setSigmaGraph(currentGraph);
|
||||||
|
}, 10);
|
||||||
|
},
|
||||||
|
|
||||||
showPropertyPanel: true,
|
showPropertyPanel: true,
|
||||||
showNodeSearchBar: true,
|
showNodeSearchBar: true,
|
||||||
|
Reference in New Issue
Block a user