mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-12 00:20:15 +00:00
feat/fix: App mode further updates (#9545)
## Summary Additional updates ## Changes - **What**: - Share widget rename functionality with properties panel implementation - Add hammer icon to builder mode tabs - Change (!) to (i) on app builder info sections ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9545-feat-fix-App-mode-further-updates-31c6d73d36508104aaa9c5f1e6205a0b) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -3,7 +3,9 @@ import { resolvePromotedWidgetSource } from '@/core/graph/subgraph/resolvePromot
|
||||
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
|
||||
import type { SubgraphNode } from '@/lib/litegraph/src/subgraph/SubgraphNode'
|
||||
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
|
||||
import { useCanvasStore } from '@/renderer/core/canvas/canvasStore'
|
||||
import type { InputSpec } from '@/schemas/nodeDef/nodeDefSchemaV2'
|
||||
import { useDialogService } from '@/services/dialogService'
|
||||
|
||||
export type WidgetValue = boolean | number | string | object | undefined
|
||||
|
||||
@@ -75,3 +77,34 @@ export function renameWidget(
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
export async function promptWidgetLabel(
|
||||
widget: IBaseWidget,
|
||||
t: (key: string) => string
|
||||
): Promise<string | null> {
|
||||
return useDialogService().prompt({
|
||||
title: t('g.rename'),
|
||||
message: t('g.enterNewNamePrompt'),
|
||||
defaultValue: widget.label,
|
||||
placeholder: widget.name
|
||||
})
|
||||
}
|
||||
|
||||
export async function promptRenameWidget(
|
||||
widget: IBaseWidget,
|
||||
node: LGraphNode,
|
||||
t: (key: string) => string,
|
||||
parents?: SubgraphNode[]
|
||||
): Promise<string | null> {
|
||||
const rawLabel = await promptWidgetLabel(widget, t)
|
||||
if (rawLabel === null) return null
|
||||
|
||||
const normalizedLabel = rawLabel.trim()
|
||||
if (!normalizedLabel) return null
|
||||
|
||||
if (!renameWidget(widget, node, normalizedLabel, parents)) return null
|
||||
|
||||
widget.callback?.(widget.value)
|
||||
useCanvasStore().canvas?.setDirty(true)
|
||||
return normalizedLabel
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user