Add Tiers improvements for Bucket Lifecycle management (#3380)

This commit is contained in:
Cesar N
2024-06-13 12:17:49 -07:00
committed by GitHub
parent 56f22a4479
commit fa32d78ff1
15 changed files with 810 additions and 103 deletions

View File

@@ -1195,6 +1195,10 @@ export interface TierListResponse {
items?: Tier[];
}
export interface TiersNameListResponse {
items?: string[];
}
export interface TierCredentialsRequest {
access_key?: string;
secret_key?: string;
@@ -4496,6 +4500,24 @@ export class Api<
...params,
}),
/**
* No description
*
* @tags Tiering
* @name TiersListNames
* @summary Returns a list of tiers' names for ilm
* @request GET:/admin/tiers/names
* @secure
*/
tiersListNames: (params: RequestParams = {}) =>
this.request<TiersNameListResponse, ApiError>({
path: `/admin/tiers/names`,
method: "GET",
secure: true,
format: "json",
...params,
}),
/**
* No description
*

View File

@@ -33,7 +33,7 @@ import {
} from "mds";
import { useSelector } from "react-redux";
import { api } from "api";
import { BucketVersioningResponse, Tier } from "api/consoleApi";
import { BucketVersioningResponse } from "api/consoleApi";
import { errorToHandler } from "api/errors";
import { modalStyleUtils } from "../../Common/FormComponents/common/styleLibrary";
import { selDistSet, setModalErrorSnackMessage } from "../../../../systemSlice";
@@ -88,16 +88,13 @@ const AddLifecycleModal = ({
useEffect(() => {
if (loadingTiers) {
api.admin
.tiersList()
.tiersListNames()
.then((res) => {
const tiersList: Tier[] | null = get(res.data, "items", []);
const tiersList: string[] | null = get(res.data, "items", []);
if (tiersList !== null && tiersList.length >= 1) {
const objList = tiersList.map((tier: Tier) => {
const tierType = tier.type;
const value = get(tier, `${tierType}.name`, "");
return { label: value, value: value };
const objList = tiersList.map((tierName: string) => {
return { label: tierName, value: tierName };
});
setTiersList(objList);
@@ -107,11 +104,12 @@ const AddLifecycleModal = ({
}
setLoadingTiers(false);
})
.catch(() => {
.catch((err) => {
setLoadingTiers(false);
dispatch(setModalErrorSnackMessage(errorToHandler(err.error)));
});
}
}, [loadingTiers]);
}, [dispatch, loadingTiers]);
useEffect(() => {
let valid = true;

View File

@@ -30,10 +30,13 @@ import {
Switch,
} from "mds";
import { api } from "api";
import { ApiError, Tier } from "api/consoleApi";
import { ApiError } from "api/consoleApi";
import { modalStyleUtils } from "../../Common/FormComponents/common/styleLibrary";
import { ITiersDropDown, LifeCycleItem } from "../types";
import { setErrorSnackMessage } from "../../../../systemSlice";
import {
setErrorSnackMessage,
setModalErrorSnackMessage,
} from "../../../../systemSlice";
import { useAppDispatch } from "../../../../store";
import ModalWrapper from "../../Common/ModalWrapper/ModalWrapper";
import QueryMultiSelector from "../../Common/FormComponents/QueryMultiSelector/QueryMultiSelector";
@@ -81,16 +84,13 @@ const EditLifecycleConfiguration = ({
useEffect(() => {
if (loadingTiers) {
api.admin
.tiersList()
.tiersListNames()
.then((res) => {
const tiersList: Tier[] | null = get(res.data, "items", []);
const tiersList: string[] | null = get(res.data, "items", []);
if (tiersList !== null && tiersList.length >= 1) {
const objList = tiersList.map((tier: Tier) => {
const tierType = tier.type;
const value = get(tier, `${tierType}.name`, "");
return { label: value, value: value };
const objList = tiersList.map((tierName: string) => {
return { label: tierName, value: tierName };
});
setTiersList(objList);
if (objList.length > 0) {
@@ -99,11 +99,12 @@ const EditLifecycleConfiguration = ({
}
setLoadingTiers(false);
})
.catch(() => {
.catch((err) => {
setLoadingTiers(false);
dispatch(setModalErrorSnackMessage(errorToHandler(err.error)));
});
}
}, [loadingTiers, lifecycleRule.transition?.storage_class]);
}, [dispatch, loadingTiers, lifecycleRule.transition?.storage_class]);
useEffect(() => {
let valid = true;

View File

@@ -36,7 +36,7 @@ import { ITiersDropDown } from "../types";
import { setModalErrorSnackMessage } from "../../../../systemSlice";
import { useAppDispatch } from "../../../../store";
import { api } from "api";
import { MultiLifecycleResult, Tier } from "api/consoleApi";
import { MultiLifecycleResult } from "api/consoleApi";
import { errorToHandler } from "api/errors";
interface IBulkReplicationModal {
@@ -72,16 +72,13 @@ const AddBulkReplicationModal = ({
useEffect(() => {
if (loadingTiers) {
api.admin
.tiersList()
.tiersListNames()
.then((res) => {
const tiersList: Tier[] | null = get(res.data, "items", []);
const tiersList: string[] | null = get(res.data, "items", []);
if (tiersList !== null && tiersList.length >= 1) {
const objList = tiersList.map((tier: Tier) => {
const tierType = tier.type;
const value = get(tier, `${tierType}.name`, "");
return { label: value, value: value };
const objList = tiersList.map((tierName: string) => {
return { label: tierName, value: tierName };
});
setTiersList(objList);
@@ -96,7 +93,7 @@ const AddBulkReplicationModal = ({
dispatch(setModalErrorSnackMessage(errorToHandler(err.error)));
});
}
}, [loadingTiers, dispatch]);
}, [dispatch, loadingTiers]);
useEffect(() => {
let valid = true;