UNPKG

@openshift-assisted/ui-lib

Version:

React component library for the Assisted Installer UI

28 lines 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const react_1 = tslib_1.__importDefault(require("react")); const apis_1 = require("../services/apis"); const utils_1 = require("../../common/utils"); const services_1 = require("../services"); function useInfraEnvImageUrl() { const getIsoImageUrl = react_1.default.useCallback((clusterId, cpuArchitecture) => tslib_1.__awaiter(this, void 0, void 0, function* () { try { const infraEnvId = yield services_1.InfraEnvsService.getInfraEnvId(clusterId, cpuArchitecture); if (!infraEnvId || infraEnvId instanceof Error) { return { url: '', error: `Failed to retrieve the infraEnv for ${clusterId}` }; } const { data: { url }, } = yield apis_1.InfraEnvsAPI.getImageUrl(infraEnvId); return { url, error: url ? '' : 'Failed to retrieve the image URL, the API returned an invalid URL', }; } catch (e) { return { url: '', error: (0, utils_1.getErrorMessage)(e) }; } }), []); return { getIsoImageUrl }; } exports.default = useInfraEnvImageUrl; //# sourceMappingURL=useInfraEnvImageUrl.js.map