mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 06:20:11 +00:00
## Summary Users were finding the final step of the builder flow confusing/misleading, with the "choose default mode" not actually saving the workflow and people losing changes. This updates it to remove "save"/"set default" as a step in the builder, and changes it to a distinct action. ## Changes - **What**: - add mode selection tab on footer toolbar - extract reusable radio group component - remove setting default mode dialog - add save/save as/saved dialogs ## Screenshots (if applicable) https://github.com/user-attachments/assets/c7439c2e-a917-4f2b-b176-f8bb8c10026d ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-10439-feat-App-mode-Rework-save-flow-32d6d73d3650814781b6c7bbea685a97) by [Unito](https://www.unito.io)
66 lines
1.5 KiB
TypeScript
66 lines
1.5 KiB
TypeScript
import type { Ref } from 'vue'
|
|
|
|
import { computed } from 'vue'
|
|
|
|
import { useAppMode } from '@/composables/useAppMode'
|
|
|
|
const BUILDER_STEPS = [
|
|
'builder:inputs',
|
|
'builder:outputs',
|
|
'builder:arrange'
|
|
] as const
|
|
|
|
export type BuilderStepId = (typeof BUILDER_STEPS)[number]
|
|
|
|
const ARRANGE_INDEX = BUILDER_STEPS.indexOf('builder:arrange')
|
|
|
|
export function useBuilderSteps(options?: { hasOutputs?: Ref<boolean> }) {
|
|
const { mode, isBuilderMode, setMode } = useAppMode()
|
|
|
|
const activeStep = computed<BuilderStepId>(() => {
|
|
if (isBuilderMode.value) {
|
|
return mode.value as BuilderStepId
|
|
}
|
|
return 'builder:inputs'
|
|
})
|
|
|
|
const activeStepIndex = computed(() =>
|
|
BUILDER_STEPS.indexOf(activeStep.value)
|
|
)
|
|
|
|
const isFirstStep = computed(() => activeStepIndex.value === 0)
|
|
|
|
const isLastStep = computed(() => {
|
|
if (!options?.hasOutputs?.value)
|
|
return activeStepIndex.value >= ARRANGE_INDEX
|
|
return activeStepIndex.value >= BUILDER_STEPS.length - 1
|
|
})
|
|
|
|
const isSelectStep = computed(
|
|
() =>
|
|
activeStep.value === 'builder:inputs' ||
|
|
activeStep.value === 'builder:outputs'
|
|
)
|
|
|
|
function goBack() {
|
|
if (isFirstStep.value) return
|
|
setMode(BUILDER_STEPS[activeStepIndex.value - 1])
|
|
}
|
|
|
|
function goNext() {
|
|
if (isLastStep.value) return
|
|
setMode(BUILDER_STEPS[activeStepIndex.value + 1])
|
|
}
|
|
|
|
return {
|
|
activeStep,
|
|
activeStepIndex,
|
|
isFirstStep,
|
|
isLastStep,
|
|
isSelectStep,
|
|
navigateToStep: setMode,
|
|
goBack,
|
|
goNext
|
|
}
|
|
}
|