@openshift-assisted/ui-lib
Version:
React component library for the Assisted Installer UI
41 lines • 2.58 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getImageUrl = exports.updateInfraEnv = exports.removeAllInfraEnvs = exports.createInfraEnv = exports.listInfraEnvsByClusterId = void 0;
const tslib_1 = require("tslib");
const toolkit_1 = require("@reduxjs/toolkit");
const apis_1 = require("../../../services/apis");
const selectors_1 = require("./selectors");
exports.listInfraEnvsByClusterId = (0, toolkit_1.createAsyncThunk)('infraEnvs/listByClusterId', (clusterId) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const { data: infraEnvs } = yield apis_1.InfraEnvsAPI.list(clusterId);
return infraEnvs;
}));
exports.createInfraEnv = (0, toolkit_1.createAsyncThunk)('infraEnvs/createInfraEnv', (params) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const { data: infraEnv } = yield apis_1.InfraEnvsAPI.register(params);
// dispatch({ type: 'currentCluster/updateStaticNetworkConfig' payload: infraEnv.staticNetworkConfig });
return infraEnv;
}));
exports.removeAllInfraEnvs = (0, toolkit_1.createAsyncThunk)('infraEnvs/removeAll', (_, thunkAPI) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const state = thunkAPI.getState();
const infraEnvIds = state.infraEnvs.map((infraEnv) => infraEnv.id);
const promises = [];
for (const infraEnvId of infraEnvIds) {
promises.push(apis_1.InfraEnvsAPI.deregister(infraEnvId));
}
return yield Promise.all(promises);
}));
exports.updateInfraEnv = (0, toolkit_1.createAsyncThunk)('infraEnvs/update', (_a) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
var { infraEnvId } = _a, params = tslib_1.__rest(_a, ["infraEnvId"]);
const { data: infraEnv } = yield apis_1.InfraEnvsAPI.update(infraEnvId, params);
// dispatch({ type: 'currentCluster/updateStaticNetworkConfig' payload: infraEnv.staticNetworkConfig });
return infraEnv;
}));
exports.getImageUrl = (0, toolkit_1.createAsyncThunk)('infraEnvs/getImageUrl', (cpuArchitecture, thunkAPI) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
const state = thunkAPI.getState();
// In OCM there is no late-binding, therefore every cluster created through the UI
// will have at least one infra-env bound to it and its cpuArchitecture initialized
// by default (to x86_64).
const infraEnv = (0, selectors_1.selectInfraEnvByCpuArchitecture)(state, cpuArchitecture);
const { data: preSignedUrl } = yield apis_1.InfraEnvsAPI.getImageUrl(infraEnv.id);
return preSignedUrl;
}));
//# sourceMappingURL=thunks.js.map