"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const constants_1 = require("../../config/constants");
const ui_1 = require("../ui");
const hooks_1 = require("../../hooks");
const use_translation_wrapper_1 = require("../../hooks/use-translation-wrapper");
const RoleDropdown = ({ host, onEditRole, current }) => {
    const [isDisabled, setDisabled] = (0, hooks_1.useStateSafely)(false);
    const setRole = (role) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
        setDisabled(true);
        try {
            yield onEditRole(role);
        }
        finally {
            setDisabled(false);
        }
    });
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    return (react_1.default.createElement(ui_1.SimpleDropdown, { defaultValue: (0, constants_1.hostRoles)(t)[0].value, current: current, items: (0, constants_1.hostRoles)(t), 
        // eslint-disable-next-line @typescript-eslint/no-misused-promises
        setValue: setRole, isDisabled: isDisabled, idPrefix: `role-${host.requestedHostname || ''}`, menuAppendTo: () => document.body }));
};
exports.default = RoleDropdown;
//# sourceMappingURL=RoleDropdown.js.map