@@ -20,7 +20,6 @@ import { Theme } from "@mui/material/styles";
20
20
import createStyles from "@mui/styles/createStyles" ;
21
21
import withStyles from "@mui/styles/withStyles" ;
22
22
import get from "lodash/get" ;
23
- import * as reactMoment from "react-moment" ;
24
23
import Grid from "@mui/material/Grid" ;
25
24
import { BucketInfo , LifeCycleItem } from "../types" ;
26
25
import { AddIcon , TiersIcon } from "../../../../icons" ;
@@ -38,8 +37,8 @@ import TableWrapper from "../../Common/TableWrapper/TableWrapper";
38
37
import HelpBox from "../../../../common/HelpBox" ;
39
38
import PanelTitle from "../../Common/PanelTitle/PanelTitle" ;
40
39
import {
41
- SecureComponent ,
42
40
hasPermission ,
41
+ SecureComponent ,
43
42
} from "../../../../common/SecureComponent" ;
44
43
import { IAM_SCOPES } from "../../../../common/SecureComponent/permissions" ;
45
44
import RBIconButton from "./SummaryItems/RBIconButton" ;
@@ -142,61 +141,95 @@ const BucketLifecyclePanel = ({
142
141
}
143
142
} ;
144
143
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
-
169
144
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 ) ;
171
147
172
148
return stClass ;
173
149
} ;
174
150
175
151
const lifecycleColumns = [
176
- { label : "ID" , elementKey : "id" } ,
177
152
{
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
+ } ,
180
173
} ,
181
174
{
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
+ } ,
184
196
} ,
185
197
{
186
- label : "Expiration" ,
187
- elementKey : "expiration" ,
188
- renderFunction : expirationRender ,
198
+ label : "Tier" ,
199
+ elementKey : "storage_class" ,
200
+ renderFunction : renderStorageClass ,
201
+ renderFullObject : true ,
189
202
} ,
190
203
{
191
- label : "Transition" ,
192
- elementKey : "transition" ,
193
- renderFunction : transitionRender ,
204
+ label : "Prefix" ,
205
+ elementKey : "prefix" ,
194
206
} ,
195
207
{
196
- label : "Storage Class" ,
197
- elementKey : "storage_class" ,
198
- renderFunction : renderStorageClass ,
208
+ label : "After" ,
199
209
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" ,
200
233
} ,
201
234
] ;
202
235
@@ -226,7 +259,7 @@ const BucketLifecyclePanel = ({
226
259
open = { editLifecycleOpen }
227
260
closeModalAndRefresh = { closeEditLCAndRefresh }
228
261
selectedBucket = { bucketName }
229
- lifecycle = { selectedLifecycleRule }
262
+ lifecycleRule = { selectedLifecycleRule }
230
263
/>
231
264
) }
232
265
{ addLifecycleOpen && (
0 commit comments