mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-22 15:54:09 +00:00
Most of the features in this pull request are completed and can be
reviewed and merged.
## TODO
- [x] no selection panel
- [x] group selected panel
- [x] tabs
- [x] favorites tab
- [x] global settings tab
- [x] nodes tab
- [x] widget actions menu
- [x] [Bug]: style bugs
- [x] button zoom to the node on canvas.
- [x] rename widgets on widget actions
- [ ] [Bug]: the canvas has not been updated after renaming.
- [x] global settings
- [ ] setting item: "show advanced parameters"
- blocked by other things. skip for now.
- [x] setting item: show toolbox on selection
- [x] setting item: nodes 2.0
- [ ] setting item: "background color"
- blocked by other things. skip for now.
- [x] setting item: grid spacing
- [x] setting item: snap nodes to grid
- [x] setting item: link shape
- [x] setting item: show connected links
- [x] form style reuses the form style of node widgets
- [x] group node cases
- [x] group node settings
- [x] show all nodes in group
- [x] show frame name on nodes when multiple selections are made
- [x] group multiple selections
- [x] [Bug]: nodes without widgets cannot display the location and their
group
- [x] [Bug]: labels layout
- [x] favorites
- [x] the indicator on widgets
- [x] favorite and unfavorite buttons on widgets
- [x] [Bug]: show node name in favorite widgets + improve labels layout
- [ ] [Bug]: After canceling the like, the like list will not be updated
immediately.
- [x] [Bug]: The favorite function does not work for the project on
Subgraph.
- [x] subgraph
- [x] add the node name from where this parameter comes from when node
is subgraph
- [x] show and hide directly on Inputs
- [x] some bugs need to be fixed.
- [x] advanced widgets
- [x] button: show advanced inputs
- Clicking button expands the "Advanced Inputs" section on the right
side panel, regardless of whether the panel is open or not
- [x] [Bug]: style bugs
- [x] advanced inputs section when node is subgraph
- [x] inputs tab rearranging
- [x] favorited inputs rearranging
- [x] subgraph inputs rearranging
- [ ] review and reconstruction to improve complexity and architecture
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-7812-feat-right-side-panel-favorites-no-selection-state-and-more-2da6d73d36508134b503d676f9b3d248)
by [Unito](https://www.unito.io)
---------
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: bymyself <cbyrne@comfy.org>
143 lines
3.9 KiB
Vue
143 lines
3.9 KiB
Vue
<script setup lang="ts">
|
|
import { useMounted, watchDebounced } from '@vueuse/core'
|
|
import { storeToRefs } from 'pinia'
|
|
import {
|
|
computed,
|
|
nextTick,
|
|
onBeforeUnmount,
|
|
onMounted,
|
|
ref,
|
|
shallowRef
|
|
} from 'vue'
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
import FormSearchInput from '@/renderer/extensions/vueNodes/widgets/components/form/FormSearchInput.vue'
|
|
import { DraggableList } from '@/scripts/ui/draggableList'
|
|
import { useFavoritedWidgetsStore } from '@/stores/workspace/favoritedWidgetsStore'
|
|
import type { ValidFavoritedWidget } from '@/stores/workspace/favoritedWidgetsStore'
|
|
import { useRightSidePanelStore } from '@/stores/workspace/rightSidePanelStore'
|
|
|
|
import { searchWidgets } from '../shared'
|
|
import SectionWidgets from './SectionWidgets.vue'
|
|
|
|
const favoritedWidgetsStore = useFavoritedWidgetsStore()
|
|
const rightSidePanelStore = useRightSidePanelStore()
|
|
const { searchQuery } = storeToRefs(rightSidePanelStore)
|
|
const { t } = useI18n()
|
|
|
|
const draggableList = ref<DraggableList | undefined>(undefined)
|
|
const sectionWidgetsRef = ref<{ widgetsContainer: HTMLElement }>()
|
|
const isSearching = ref(false)
|
|
|
|
const favoritedWidgets = computed(
|
|
() => favoritedWidgetsStore.validFavoritedWidgets
|
|
)
|
|
|
|
const label = computed(() =>
|
|
favoritedWidgets.value.length === 0
|
|
? t('rightSidePanel.favoritesNone')
|
|
: t('rightSidePanel.favorites')
|
|
)
|
|
|
|
const searchedFavoritedWidgets = shallowRef<ValidFavoritedWidget[]>(
|
|
favoritedWidgets.value
|
|
)
|
|
|
|
async function searcher(query: string) {
|
|
isSearching.value = query.trim().length > 0
|
|
searchedFavoritedWidgets.value = searchWidgets(favoritedWidgets.value, query)
|
|
}
|
|
|
|
const isMounted = useMounted()
|
|
|
|
function setDraggableState() {
|
|
if (!isMounted.value) return
|
|
draggableList.value?.dispose()
|
|
const container = sectionWidgetsRef.value?.widgetsContainer
|
|
if (isSearching.value || !container?.children?.length) return
|
|
|
|
draggableList.value = new DraggableList(container, '.draggable-item')
|
|
|
|
draggableList.value.applyNewItemsOrder = function () {
|
|
const reorderedItems: HTMLElement[] = []
|
|
|
|
let oldPosition = -1
|
|
this.getAllItems().forEach((item, index) => {
|
|
if (item === this.draggableItem) {
|
|
oldPosition = index
|
|
return
|
|
}
|
|
if (!this.isItemToggled(item)) {
|
|
reorderedItems[index] = item
|
|
return
|
|
}
|
|
const newIndex = this.isItemAbove(item) ? index + 1 : index - 1
|
|
reorderedItems[newIndex] = item
|
|
})
|
|
|
|
for (let index = 0; index < this.getAllItems().length; index++) {
|
|
const item = reorderedItems[index]
|
|
if (typeof item === 'undefined') {
|
|
reorderedItems[index] = this.draggableItem as HTMLElement
|
|
}
|
|
}
|
|
|
|
const newPosition = reorderedItems.indexOf(
|
|
this.draggableItem as HTMLElement
|
|
)
|
|
const widgets = [...searchedFavoritedWidgets.value]
|
|
const [widget] = widgets.splice(oldPosition, 1)
|
|
widgets.splice(newPosition, 0, widget)
|
|
searchedFavoritedWidgets.value = widgets
|
|
favoritedWidgetsStore.reorderFavorites(widgets)
|
|
}
|
|
}
|
|
|
|
watchDebounced(
|
|
searchedFavoritedWidgets,
|
|
() => {
|
|
setDraggableState()
|
|
},
|
|
{ debounce: 100 }
|
|
)
|
|
|
|
onMounted(() => {
|
|
setDraggableState()
|
|
})
|
|
|
|
onBeforeUnmount(() => {
|
|
draggableList.value?.dispose()
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div class="px-4 pt-1 pb-4 flex gap-2 border-b border-interface-stroke">
|
|
<FormSearchInput
|
|
v-model="searchQuery"
|
|
:searcher
|
|
:update-key="favoritedWidgets"
|
|
/>
|
|
</div>
|
|
<SectionWidgets
|
|
ref="sectionWidgetsRef"
|
|
:label
|
|
:widgets="searchedFavoritedWidgets"
|
|
:is-draggable="!isSearching"
|
|
hidden-favorite-indicator
|
|
show-node-name
|
|
enable-empty-state
|
|
class="border-b border-interface-stroke"
|
|
@update:collapse="nextTick(setDraggableState)"
|
|
>
|
|
<template #empty>
|
|
<div class="text-sm text-muted-foreground px-4 text-center py-10">
|
|
{{
|
|
isSearching
|
|
? t('rightSidePanel.noneSearchDesc')
|
|
: t('rightSidePanel.favoritesNoneDesc')
|
|
}}
|
|
</div>
|
|
</template>
|
|
</SectionWidgets>
|
|
</template>
|