Line data Source code
1 : <template>
2 11 : <div v-if="isOnlyHasNodes" class="p-4">
3 : <NodeSettings :nodes="theNodes" />
4 : </div>
5 : <div v-else class="border-t">
6 : <PropertiesAccordionItem
7 : v-if="hasNodes"
8 : class="border-b"
9 : :label="$t('rightSidePanel.nodes')"
10 : >
11 : <NodeSettings :nodes="theNodes" class="p-4" />
12 : </PropertiesAccordionItem>
13 : <PropertiesAccordionItem
14 : v-if="hasGroups"
15 : class="border-b"
16 : :label="$t('rightSidePanel.groups')"
17 : >
18 : <NodeSettings :nodes="theGroups" class="p-4" />
19 : </PropertiesAccordionItem>
20 : </div>
21 : </template>
22 :
23 : <script setup lang="ts">
24 : /**
25 : * If we only need to show settings for Nodes,
26 : * there's no need to wrap them in PropertiesAccordionItem,
27 : * making the UI cleaner.
28 : * But if there are multiple types of settings,
29 : * it's better to wrap them; otherwise,
30 : * the UI would look messy.
31 : */
32 : import { computed } from 'vue'
33 : import type { Raw } from 'vue'
34 :
35 : import type { LGraphGroup } from '@/lib/litegraph/src/LGraphGroup'
36 : import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
37 : import type { Positionable } from '@comfyorg/graph-model/interfaces'
38 : import { isLGraphGroup, isLGraphNode } from '@/utils/litegraphUtil'
39 :
40 : import PropertiesAccordionItem from '@comfyorg/design-system/accordion/PropertiesAccordionItem'
41 : import NodeSettings from './NodeSettings.vue'
42 :
43 11 : const props = defineProps<{
44 : nodes: Raw<Positionable>[]
45 : }>()
46 :
47 11 : const theNodes = computed<LGraphNode[]>(() =>
48 : props.nodes.filter((node) => isLGraphNode(node))
49 : )
50 :
51 11 : const theGroups = computed<LGraphGroup[]>(() =>
52 : props.nodes.filter((node) => isLGraphGroup(node))
53 : )
54 :
55 11 : const hasGroups = computed(() => theGroups.value.length > 0)
56 11 : const hasNodes = computed(() => theNodes.value.length > 0)
57 11 : const isOnlyHasNodes = computed(() => hasNodes.value && !hasGroups.value)
58 : </script>
|