11<script setup lang="ts">
22import { faTimesCircle } from " @fortawesome/free-regular-svg-icons" ;
3- import { faInfoCircle } from " @fortawesome/free-solid-svg-icons" ;
3+ import { faInfoCircle , faWrench } from " @fortawesome/free-solid-svg-icons" ;
44import { FontAwesomeIcon } from " @fortawesome/vue-fontawesome" ;
5+ import axios from " axios" ;
56import { BAlert } from " bootstrap-vue" ;
67import { computed , onUnmounted , ref , watch } from " vue" ;
78
89import type { WorkflowInvocationElementView } from " @/api/invocations" ;
910import type { WorkflowStepTyped } from " @/api/workflows" ;
11+ import { useDatatypesMapper } from " @/composables/datatypesMapper" ;
1012import type { GraphStep } from " @/composables/useInvocationGraph" ;
13+ import { getAppRoot } from " @/onload/loadConfig" ;
1114import { useInvocationStore } from " @/stores/invocationStore" ;
1215
1316import Heading from " ../Common/Heading.vue" ;
@@ -20,6 +23,8 @@ import GTab from "@/components/BaseComponents/GTab.vue";
2023import GTabs from " @/components/BaseComponents/GTabs.vue" ;
2124import GenericHistoryItem from " @/components/History/Content/GenericItem.vue" ;
2225import LoadingSpan from " @/components/LoadingSpan.vue" ;
26+ import FormDefault from " @/components/Workflow/Editor/Forms/FormDefault.vue" ;
27+ import FormTool from " @/components/Workflow/Editor/Forms/FormTool.vue" ;
2328
2429const TERMINAL_JOB_STATES = [" ok" , " error" , " deleted" , " paused" ];
2530
@@ -41,8 +46,11 @@ const emit = defineEmits<{
4146}>();
4247
4348const invocationStore = useInvocationStore ();
49+ const { datatypes } = useDatatypesMapper ();
4450
4551const localExpanded = ref (Boolean (props .expanded ));
52+ const stepConfigData = ref <Record <string , any > | null >(null );
53+ const loadingStepConfig = ref (false );
4654const stepFetchInterval = ref <any >(undefined );
4755
4856const computedExpanded = computed ({
@@ -143,6 +151,37 @@ const jobsTabTitle = computed(() => {
143151 return " No jobs" ;
144152});
145153
154+ const activeStepWithConfig = computed (() => {
155+ if (! stepConfigData .value ) {
156+ return null ;
157+ }
158+ const step = props .workflowStep as any ;
159+ return {
160+ ... step ,
161+ config_form: stepConfigData .value .config_form ,
162+ inputs: stepConfigData .value .inputs ?? step .inputs ,
163+ outputs: stepConfigData .value .outputs ?? step .outputs ,
164+ } as any ;
165+ });
166+
167+ async function fetchStepConfig() {
168+ if (stepConfigData .value || loadingStepConfig .value ) {
169+ return ;
170+ }
171+ loadingStepConfig .value = true ;
172+ try {
173+ const step = props .workflowStep as any ;
174+ const { data } = await axios .post (` ${getAppRoot ()}api/workflows/build_module ` , {
175+ type: step .type ,
176+ content_id: step .content_id ?? step .tool_id ,
177+ tool_state: step .tool_state ?? " {}" ,
178+ });
179+ stepConfigData .value = data ;
180+ } finally {
181+ loadingStepConfig .value = false ;
182+ }
183+ }
184+
146185function toggleStep() {
147186 computedExpanded .value = ! computedExpanded .value ;
148187}
@@ -278,6 +317,27 @@ onUnmounted(() => {
278317 </div >
279318 </div >
280319 </GTab >
320+
321+ <GTab
322+ :class =" { 'invocation-view-step-config': props.inGraphView }"
323+ lazy
324+ @click =" fetchStepConfig" >
325+ <template v-slot :title >
326+ <FontAwesomeIcon :icon =" faWrench" />
327+ <span v-localize >Step Config</span >
328+ </template >
329+ <BAlert v-if =" loadingStepConfig" show >
330+ <LoadingSpan message =" Loading step configuration" />
331+ </BAlert >
332+ <FormTool
333+ v-else-if =" workflowStepType === 'tool' && activeStepWithConfig"
334+ :step =" activeStepWithConfig"
335+ :datatypes =" datatypes" />
336+ <FormDefault
337+ v-else-if =" workflowStepType !== 'tool' && activeStepWithConfig"
338+ :step =" activeStepWithConfig"
339+ :datatypes =" datatypes" />
340+ </GTab >
281341 </GTabs >
282342 </div >
283343 </div >
@@ -302,4 +362,13 @@ onUnmounted(() => {
302362 opacity : 0.8 ;
303363 }
304364}
365+
366+ .invocation-view-step-config {
367+ :deep (.tool-header ) {
368+ position : unset ;
369+ }
370+ :deep(.ui-form-header-underlay ) {
371+ display : none ;
372+ }
373+ }
305374 </style >
0 commit comments