Skip to content

Commit

Permalink
feat: add Password component to flow (#1831)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreammy23 authored Aug 15, 2024
2 parents 145b255 + 2696d9a commit c9a4668
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions web/components/flow/node-param-handler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
RenderTreeSelect,
RenderTimePicker,
RenderTextArea,
RenderPassword,
} from './node-renderer';
import { convertKeysToCamelCase } from '@/utils/flow';

Expand Down Expand Up @@ -138,6 +139,8 @@ const NodeParamHandler: React.FC<NodeParamHandlerProps> = ({ node, data, label,
case 'time_picker':
return <RenderTimePicker {...props} />;
case 'tree_select':
return <RenderPassword {...props} />;
case 'password':
return <RenderTreeSelect {...props} />;
default:
return null;
Expand Down
1 change: 1 addition & 0 deletions web/components/flow/node-renderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './textarea';
export * from './slider';
export * from './time-picker';
export * from './tree-select';
export * from './password';
1 change: 1 addition & 0 deletions web/components/flow/node-renderer/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const RenderInput = (params: Props) => {
className="w-full"
placeholder="please input"
defaultValue={defaultValue}
allowClear
onChange={(e) => {
onChange(e.target.value);
}}
Expand Down
18 changes: 18 additions & 0 deletions web/components/flow/node-renderer/password.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { IFlowNodeParameter } from '@/types/flow';
import { Input } from 'antd';
import { convertKeysToCamelCase } from '@/utils/flow';

const { Password } = Input;

type TextAreaProps = {
data: IFlowNodeParameter;
defaultValue: any;
onChange: (value: any) => void;
};

export const RenderPassword = (params: TextAreaProps) => {
const { data, defaultValue, onChange } = params;
const attr = convertKeysToCamelCase(data.ui?.attr || {});

return <Password {...attr} placeholder="input password" defaultValue={defaultValue} onChange={onChange} />;
};

0 comments on commit c9a4668

Please sign in to comment.