HEX
Server: Apache
System: Linux www 5.10.0-10-amd64 #1 SMP Debian 5.10.84-1 (2021-12-08) x86_64
User: root (0)
PHP: 8.2.1
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals
Upload Files
File: /mnt/drbd/www/edenhouse/wp-content/plugins/really-simple-ssl/settings/src/Settings/Host.js
import {
    SelectControl,
} from '@wordpress/components';
import {useRef} from "@wordpress/element";
import useFields from "./FieldsData";

const Host = (props) => {
    const {updateField, setChangedField, saveFields, handleNextButtonDisabled} = useFields();
    const disabled = useRef(false);

    const onChangeHandler = async (fieldValue) => {
        let field = props.field;
        //force update, and get new fields.
        handleNextButtonDisabled(true);
        disabled.current = true;
        updateField(field.id, fieldValue);
        setChangedField(field.id, fieldValue);

        await saveFields(true, false);

        handleNextButtonDisabled(false);
        disabled.current = false;
    }

    let fieldValue = props.field.value;
    let field = props.field;
    let options = [];
    if ( field.options ) {
        for (var key in field.options) {
            if (field.options.hasOwnProperty(key)) {
                let item = {};
                item.label = field.options[key];
                item.value = key;
                options.push(item);
            }
        }
    }

    return (
          <SelectControl
              label={ field.label }
              onChange={ ( fieldValue ) => onChangeHandler(fieldValue) }
              value= { fieldValue }
              options={ options }
              disabled={disabled.current}
          />
    )
}
export default Host;