mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Port Subscriptions node to react. Fixes #6634
This commit is contained in:
committed by
Akshay Joshi
parent
8dac933a66
commit
1f430227aa
42
web/pgadmin/static/js/components/SelectRefresh.jsx
Normal file
42
web/pgadmin/static/js/components/SelectRefresh.jsx
Normal file
@@ -0,0 +1,42 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Box} from '@material-ui/core';
|
||||
import {InputSelect, FormInput} from './FormComponents';
|
||||
import PropTypes from 'prop-types';
|
||||
import CustomPropTypes from '../custom_prop_types';
|
||||
import RefreshIcon from '@material-ui/icons/Refresh';
|
||||
import { PgIconButton } from './Buttons';
|
||||
|
||||
export function SelectRefresh({ required, className, label, helpMessage, testcid, controlProps, ...props }){
|
||||
const [options, setOptions] = useState([]);
|
||||
const [optionsReloadBasis, setOptionsReloadBasis] = useState(false);
|
||||
const {getOptionsOnRefresh, ...selectControlProps} = controlProps;
|
||||
|
||||
const onRefreshClick = ()=>{
|
||||
getOptionsOnRefresh && getOptionsOnRefresh()
|
||||
.then((res)=>{
|
||||
setOptions(res);
|
||||
setOptionsReloadBasis((prevVal)=>!prevVal);
|
||||
});
|
||||
};
|
||||
return (
|
||||
<FormInput required={required} label={label} className={className} helpMessage={helpMessage} testcid={testcid}>
|
||||
<Box display="flex" >
|
||||
<Box flexGrow="1">
|
||||
<InputSelect {...props} options={options} optionsReloadBasis={optionsReloadBasis} controlProps={selectControlProps}/>
|
||||
</Box>
|
||||
<Box>
|
||||
<PgIconButton onClick={onRefreshClick} icon={<RefreshIcon />} title={label||''}/>
|
||||
</Box>
|
||||
</Box>
|
||||
</FormInput>
|
||||
);
|
||||
}
|
||||
|
||||
SelectRefresh.propTypes = {
|
||||
required: PropTypes.bool,
|
||||
label: PropTypes.string,
|
||||
className: CustomPropTypes.className,
|
||||
helpMessage: PropTypes.string,
|
||||
testcid: PropTypes.string,
|
||||
controlProps: PropTypes.object,
|
||||
};
|
||||
Reference in New Issue
Block a user