Skip to content

Commit 822724a

Browse files
authored
Fix Add Bucket Lifecycle Rule (#1797)
Fix Add Bucket Lifecycle Rule Fix Edit ILM Rule Update Bucket ILM Rules Listing Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
1 parent c18c843 commit 822724a

File tree

8 files changed

+588
-466
lines changed

8 files changed

+588
-466
lines changed

portal-ui/src/screens/Console/Buckets/BucketDetails/AddLifecycleModal.tsx

Lines changed: 179 additions & 163 deletions
Large diffs are not rendered by default.

portal-ui/src/screens/Console/Buckets/BucketDetails/BucketLifecyclePanel.tsx

Lines changed: 75 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { Theme } from "@mui/material/styles";
2020
import createStyles from "@mui/styles/createStyles";
2121
import withStyles from "@mui/styles/withStyles";
2222
import get from "lodash/get";
23-
import * as reactMoment from "react-moment";
2423
import Grid from "@mui/material/Grid";
2524
import { BucketInfo, LifeCycleItem } from "../types";
2625
import { AddIcon, TiersIcon } from "../../../../icons";
@@ -38,8 +37,8 @@ import TableWrapper from "../../Common/TableWrapper/TableWrapper";
3837
import HelpBox from "../../../../common/HelpBox";
3938
import PanelTitle from "../../Common/PanelTitle/PanelTitle";
4039
import {
41-
SecureComponent,
4240
hasPermission,
41+
SecureComponent,
4342
} from "../../../../common/SecureComponent";
4443
import { IAM_SCOPES } from "../../../../common/SecureComponent/permissions";
4544
import RBIconButton from "./SummaryItems/RBIconButton";
@@ -142,61 +141,95 @@ const BucketLifecyclePanel = ({
142141
}
143142
};
144143

145-
const expirationRender = (expiration: any) => {
146-
if (expiration.days) {
147-
return `${expiration.days} day${expiration.days > 1 ? "s" : ""}`;
148-
}
149-
150-
if (expiration.date === "0001-01-01T00:00:00Z") {
151-
return "";
152-
}
153-
154-
return <reactMoment.default>{expiration.date}</reactMoment.default>;
155-
};
156-
157-
const transitionRender = (transition: any) => {
158-
if (transition.days) {
159-
return `${transition.days} day${transition.days > 1 ? "s" : ""}`;
160-
}
161-
162-
if (transition.date === "0001-01-01T00:00:00Z") {
163-
return "";
164-
}
165-
166-
return <reactMoment.default>{transition.date}</reactMoment.default>;
167-
};
168-
169144
const renderStorageClass = (objectST: any) => {
170-
const stClass = get(objectST, "transition.storage_class", "");
145+
let stClass = get(objectST, "transition.storage_class", "");
146+
stClass = get(objectST, "transition.noncurrent_storage_class", stClass);
171147

172148
return stClass;
173149
};
174150

175151
const lifecycleColumns = [
176-
{ label: "ID", elementKey: "id" },
177152
{
178-
label: "Prefix",
179-
elementKey: "prefix",
153+
label: "Type",
154+
renderFullObject: true,
155+
renderFunction: (el: LifeCycleItem) => {
156+
if (!el) {
157+
return <Fragment />;
158+
}
159+
if (
160+
el.expiration &&
161+
(el.expiration.days > 0 || el.expiration.noncurrent_expiration_days)
162+
) {
163+
return <span>Expiry</span>;
164+
}
165+
if (
166+
el.transition &&
167+
(el.transition.days > 0 || el.transition.noncurrent_transition_days)
168+
) {
169+
return <span>Transition</span>;
170+
}
171+
return <Fragment />;
172+
},
180173
},
181174
{
182-
label: "Status",
183-
elementKey: "status",
175+
label: "Version",
176+
renderFullObject: true,
177+
renderFunction: (el: LifeCycleItem) => {
178+
if (!el) {
179+
return <Fragment />;
180+
}
181+
if (el.expiration) {
182+
if (el.expiration.days > 0) {
183+
return <span>Current</span>;
184+
} else if (el.expiration.noncurrent_expiration_days) {
185+
return <span>Non-Current</span>;
186+
}
187+
}
188+
if (el.transition) {
189+
if (el.transition.days > 0) {
190+
return <span>Current</span>;
191+
} else if (el.transition.noncurrent_transition_days) {
192+
return <span>Non-Current</span>;
193+
}
194+
}
195+
},
184196
},
185197
{
186-
label: "Expiration",
187-
elementKey: "expiration",
188-
renderFunction: expirationRender,
198+
label: "Tier",
199+
elementKey: "storage_class",
200+
renderFunction: renderStorageClass,
201+
renderFullObject: true,
189202
},
190203
{
191-
label: "Transition",
192-
elementKey: "transition",
193-
renderFunction: transitionRender,
204+
label: "Prefix",
205+
elementKey: "prefix",
194206
},
195207
{
196-
label: "Storage Class",
197-
elementKey: "storage_class",
198-
renderFunction: renderStorageClass,
208+
label: "After",
199209
renderFullObject: true,
210+
renderFunction: (el: LifeCycleItem) => {
211+
if (!el) {
212+
return <Fragment />;
213+
}
214+
if (el.expiration) {
215+
if (el.expiration.days > 0) {
216+
return <span>{el.expiration.days} days</span>;
217+
} else if (el.expiration.noncurrent_expiration_days) {
218+
return <span>{el.expiration.noncurrent_expiration_days} days</span>;
219+
}
220+
}
221+
if (el.transition) {
222+
if (el.transition.days > 0) {
223+
return <span>{el.transition.days} days</span>;
224+
} else if (el.transition.noncurrent_transition_days) {
225+
return <span>{el.transition.noncurrent_transition_days} days</span>;
226+
}
227+
}
228+
},
229+
},
230+
{
231+
label: "Status",
232+
elementKey: "status",
200233
},
201234
];
202235

@@ -226,7 +259,7 @@ const BucketLifecyclePanel = ({
226259
open={editLifecycleOpen}
227260
closeModalAndRefresh={closeEditLCAndRefresh}
228261
selectedBucket={bucketName}
229-
lifecycle={selectedLifecycleRule}
262+
lifecycleRule={selectedLifecycleRule}
230263
/>
231264
)}
232265
{addLifecycleOpen && (

0 commit comments

Comments
 (0)