Skip to content

Commit

Permalink
feat: plugin input type add select and custom var (#2571)
Browse files Browse the repository at this point in the history
* feat: plugin input type add select and custom var

* fix

* fix ui

* fix

* fix
  • Loading branch information
newfish-cmyk authored Aug 30, 2024
1 parent 903f39f commit 9d5fd24
Show file tree
Hide file tree
Showing 29 changed files with 577 additions and 353 deletions.
8 changes: 6 additions & 2 deletions packages/global/core/workflow/node/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export enum FlowNodeInputTypeEnum { // render ui

// special input
selectApp = 'selectApp',
customVariable = 'customVariable',

// ai model select
selectLLMModel = 'selectLLMModel',
Expand Down Expand Up @@ -44,7 +45,7 @@ export const FlowNodeInputMap: Record<
icon: 'core/workflow/inputType/numberInput'
},
[FlowNodeInputTypeEnum.select]: {
icon: 'core/workflow/inputType/input'
icon: 'core/workflow/inputType/option'
},
[FlowNodeInputTypeEnum.switch]: {
icon: 'core/workflow/inputType/switch'
Expand Down Expand Up @@ -79,8 +80,11 @@ export const FlowNodeInputMap: Record<
[FlowNodeInputTypeEnum.hidden]: {
icon: 'core/workflow/inputType/select'
},
[FlowNodeInputTypeEnum.customVariable]: {
icon: 'core/workflow/inputType/customVariable'
},
[FlowNodeInputTypeEnum.custom]: {
icon: 'core/workflow/inputType/select'
icon: 'core/workflow/inputType/custom'
}
};

Expand Down
19 changes: 11 additions & 8 deletions packages/global/core/workflow/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,17 @@ export const pluginData2FlowNodeIO = ({
const pluginOutput = nodes.find((node) => node.flowNodeType === FlowNodeTypeEnum.pluginOutput);

return {
inputs: pluginInput
? pluginInput.inputs.map((item) => ({
...item,
...getModuleInputUiField(item),
value: getOrInitModuleInputValue(item),
canEdit: false
}))
: [],
inputs:
pluginInput?.inputs.map((item) => ({
...item,
...getModuleInputUiField(item),
value: getOrInitModuleInputValue(item),
canEdit: false,
renderTypeList:
item.renderTypeList[0] === FlowNodeInputTypeEnum.customVariable
? [FlowNodeInputTypeEnum.reference, FlowNodeInputTypeEnum.input]
: item.renderTypeList
})) || [],
outputs: pluginOutput
? [
...pluginOutput.inputs.map((item) => ({
Expand Down
16 changes: 10 additions & 6 deletions packages/web/components/common/Icon/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ export const iconPaths = {
collectionLight: () => import('./icons/collectionLight.svg'),
collectionSolid: () => import('./icons/collectionSolid.svg'),
'common/add2': () => import('./icons/common/add2.svg'),
'common/setting': () => import('./icons/common/setting.svg'),
'common/addUser': () => import('./icons/common/addUser.svg'),
'common/monitor': () => import('./icons/common/monitor.svg'),
'common/list': () => import('./icons/common/list.svg'),
'common/addCircleLight': () => import('./icons/common/addCircleLight.svg'),
'common/addLight': () => import('./icons/common/addLight.svg'),
'common/addUser': () => import('./icons/common/addUser.svg'),
'common/arrowLeft': () => import('./icons/common/arrowLeft.svg'),
'common/backFill': () => import('./icons/common/backFill.svg'),
'common/backLight': () => import('./icons/common/backLight.svg'),
'common/check': () => import('./icons/common/check.svg'),
Expand All @@ -29,6 +27,7 @@ export const iconPaths = {
'common/errorFill': () => import('./icons/common/errorFill.svg'),
'common/file/move': () => import('./icons/common/file/move.svg'),
'common/folderFill': () => import('./icons/common/folderFill.svg'),
'common/folderImport': () => import('./icons/common/folderImport.svg'),
'common/fullScreenLight': () => import('./icons/common/fullScreenLight.svg'),
'common/gitFill': () => import('./icons/common/gitFill.svg'),
'common/gitInlight': () => import('./icons/common/gitInlight.svg'),
Expand All @@ -41,12 +40,12 @@ export const iconPaths = {
'common/language/en': () => import('./icons/common/language/en.svg'),
'common/language/zh': () => import('./icons/common/language/zh.svg'),
'common/leftArrowLight': () => import('./icons/common/leftArrowLight.svg'),
'common/arrowLeft': () => import('./icons/common/arrowLeft.svg'),
'common/lineChange': () => import('./icons/common/lineChange.svg'),
'common/linkBlue': () => import('./icons/common/linkBlue.svg'),
'common/folderImport': () => import('./icons/common/folderImport.svg'),
'common/list': () => import('./icons/common/list.svg'),
'common/loading': () => import('./icons/common/loading.svg'),
'common/logLight': () => import('./icons/common/logLight.svg'),
'common/monitor': () => import('./icons/common/monitor.svg'),
'common/navbar/pluginFill': () => import('./icons/common/navbar/pluginFill.svg'),
'common/navbar/pluginLight': () => import('./icons/common/navbar/pluginLight.svg'),
'common/openai': () => import('./icons/common/openai.svg'),
Expand All @@ -67,6 +66,7 @@ export const iconPaths = {
'common/searchLight': () => import('./icons/common/searchLight.svg'),
'common/select': () => import('./icons/common/select.svg'),
'common/selectLight': () => import('./icons/common/selectLight.svg'),
'common/setting': () => import('./icons/common/setting.svg'),
'common/settingLight': () => import('./icons/common/settingLight.svg'),
'common/subtract': () => import('./icons/common/subtract.svg'),
'common/text/t': () => import('./icons/common/text/t.svg'),
Expand Down Expand Up @@ -176,12 +176,16 @@ export const iconPaths = {
'core/workflow/debugResult': () => import('./icons/core/workflow/debugResult.svg'),
'core/workflow/edgeArrow': () => import('./icons/core/workflow/edgeArrow.svg'),
'core/workflow/grout': () => import('./icons/core/workflow/grout.svg'),
'core/workflow/inputType/customVariable': () =>
import('./icons/core/workflow/inputType/customVariable.svg'),
'core/workflow/inputType/dynamic': () => import('./icons/core/workflow/inputType/dynamic.svg'),
'core/workflow/inputType/file': () => import('./icons/core/workflow/inputType/file.svg'),
'core/workflow/inputType/input': () => import('./icons/core/workflow/inputType/input.svg'),
'core/workflow/inputType/jsonEditor': () =>
import('./icons/core/workflow/inputType/jsonEditor.svg'),
'core/workflow/inputType/numberInput': () =>
import('./icons/core/workflow/inputType/numberInput.svg'),
'core/workflow/inputType/option': () => import('./icons/core/workflow/inputType/option.svg'),
'core/workflow/inputType/reference': () =>
import('./icons/core/workflow/inputType/reference.svg'),
'core/workflow/inputType/select': () => import('./icons/core/workflow/inputType/select.svg'),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9d5fd24

Please sign in to comment.