"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = useSetClusterPermissions;
const react_redux_1 = require("react-redux");
const config_1 = require("../config");
const slice_1 = require("../store/slices/current-cluster/slice");
function useSetClusterPermissions() {
    const dispatch = (0, react_redux_1.useDispatch)();
    return (cluster, ocmPermissions) => {
        if (!cluster) {
            // We must not update the permissions, the state is reset when the cluster is cleaned
            return;
        }
        let newPermissions = (0, config_1.getBasePermissions)(cluster);
        if (ocmPermissions) {
            newPermissions = Object.assign(Object.assign({}, newPermissions), (0, config_1.ocmPermissionsToAIPermissions)(ocmPermissions || {}));
        }
        dispatch((0, slice_1.updateClusterPermissions)(newPermissions));
    };
}
//# sourceMappingURL=useSetClusterPermissions.js.map