MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / InputFileSelect

Function InputFileSelect

web/pgadmin/static/js/components/FormComponents.jsx:469–506  ·  view source on GitHub ↗
({ controlProps, onChange, disabled, readonly, isvalidate = false, hideBrowseButton=false,validate, ...props })

Source from the content-addressed store, hash-verified

467};
468
469export function InputFileSelect({ controlProps, onChange, disabled, readonly, isvalidate = false, hideBrowseButton=false,validate, ...props }) {
470 const inpRef = useRef();
471 let textControlProps = {};
472 if(controlProps?.placeholder) {
473 const {placeholder} = controlProps;
474 textControlProps = {placeholder};
475 }
476 const showFileDialog = ()=>{
477 let params = {
478 supported_types: controlProps.supportedTypes || [],
479 dialog_type: controlProps.dialogType || 'select_file',
480 dialog_title: controlProps.dialogTitle || '',
481 btn_primary: controlProps.btnPrimary || '',
482 };
483 showFileManager(params, (fileName, dir)=>{
484 if (dir && dir != MY_STORAGE){
485 onChange?.(dir + ':' + decodeURI(fileName));
486 }else{
487 onChange?.(decodeURI(fileName));
488 }
489 inpRef.current.focus();
490 });
491 };
492
493 return (
494 <InputText ref={inpRef} disabled={disabled} readonly={readonly} onChange={onChange} controlProps={textControlProps} {...props} endAdornment={
495 <>
496 {!hideBrowseButton &&
497 <IconButton onClick={showFileDialog}
498 disabled={disabled || readonly} aria-label={gettext('Select a file')}><FolderOpenRoundedIcon /></IconButton>
499 }
500 {isvalidate &&
501 <PgIconButton title={gettext('Validate')} style={{ border: 'none' }} disabled={!props.value} onClick={() => { validate(props.value); }} icon={<AssignmentTurnedIn />}></PgIconButton>
502 }
503 </>
504 } />
505 );
506}
507InputFileSelect.propTypes = {
508 controlProps: PropTypes.object,
509 onChange: PropTypes.func,

Callers

nothing calls this directly

Calls 1

gettextFunction · 0.85

Tested by

no test coverage detected