Utilities: Migrate remaining files to TypeScript
This migrates remaining JavaScript files in Utilities to TypeScript.
This commit is contained in:
parent
6415664620
commit
813c06c5bd
9 changed files with 15 additions and 11 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import isRhel from '../../../Utilities/isRhel.js';
|
||||
import isRhel from '../../../Utilities/isRhel';
|
||||
|
||||
const imageOutputStepMapper = (
|
||||
{ 'target-environment': targetEnv, release, enableOscap } = {},
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import {
|
|||
selectDistribution,
|
||||
selectCustomRepositories,
|
||||
} from '../../../store/wizardSlice';
|
||||
import { releaseToVersion } from '../../../Utilities/releaseToVersion.js';
|
||||
import { releaseToVersion } from '../../../Utilities/releaseToVersion';
|
||||
|
||||
/**
|
||||
* This checks the list of the custom repositories against a list of repos freshly
|
||||
|
|
|
|||
|
|
@ -50,8 +50,10 @@ export const useCheckRepositoriesAvailability = () => {
|
|||
);
|
||||
|
||||
const { data: freshRepos, isSuccess } = useMemo(() => {
|
||||
if (firstRequest?.data?.meta?.count > 100) {
|
||||
return { ...followupRequest };
|
||||
if (firstRequest?.data?.meta?.count) {
|
||||
if (firstRequest?.data?.meta?.count > 100) {
|
||||
return { ...followupRequest };
|
||||
}
|
||||
}
|
||||
return { ...firstRequest };
|
||||
}, [firstRequest, followupRequest]);
|
||||
|
|
@ -62,7 +64,7 @@ export const useCheckRepositoriesAvailability = () => {
|
|||
// Transform the fresh repos array into a Set to access its elements in O(1)
|
||||
// complexity later in the for loop.
|
||||
const freshReposUrls = new Set(
|
||||
freshRepos.data.map((freshRepo) => freshRepo.url)
|
||||
freshRepos.data?.map((freshRepo) => freshRepo.url)
|
||||
);
|
||||
for (const payloadRepo of payloadRepositories) {
|
||||
if (!freshReposUrls.has(payloadRepo.baseurl)) {
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
import { addNotification } from '@redhat-cloud-services/frontend-components-notifications/redux';
|
||||
import { Dispatch } from 'redux';
|
||||
|
||||
const manageEdgeImagesUrlName = 'manage-edge-images';
|
||||
|
||||
const getNotificationProp = (dispatch) => {
|
||||
const getNotificationProp = (dispatch: Dispatch) => {
|
||||
return {
|
||||
hasInfo: (hasInfoMessage) => {
|
||||
hasInfo: (hasInfoMessage: Notification) => {
|
||||
dispatch({
|
||||
...addNotification({
|
||||
variant: 'info',
|
||||
|
|
@ -12,7 +13,7 @@ const getNotificationProp = (dispatch) => {
|
|||
}),
|
||||
});
|
||||
},
|
||||
hasSuccess: (hasSuccessMessage) => {
|
||||
hasSuccess: (hasSuccessMessage: Notification) => {
|
||||
dispatch({
|
||||
...addNotification({
|
||||
variant: 'success',
|
||||
|
|
@ -20,7 +21,8 @@ const getNotificationProp = (dispatch) => {
|
|||
}),
|
||||
});
|
||||
},
|
||||
err: (errMessage, err) => {
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
err: (errMessage: any, err: any) => {
|
||||
dispatch({
|
||||
...addNotification({
|
||||
variant: 'danger',
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { RHEL_8, RHEL_9 } from '../constants';
|
||||
|
||||
function isRhel(distro) {
|
||||
function isRhel(distro: string) {
|
||||
switch (distro) {
|
||||
case RHEL_8:
|
||||
case RHEL_9:
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { CENTOS_8, CENTOS_9, RHEL_8, RHEL_9 } from '../constants';
|
||||
|
||||
export const releaseToVersion = (release) => {
|
||||
export const releaseToVersion = (release: string) => {
|
||||
switch (release) {
|
||||
case RHEL_9:
|
||||
return '9';
|
||||
Loading…
Add table
Add a link
Reference in a new issue