Skip to content

Commit

Permalink
GUI S3 Objects lifecycle (#2759): remove 'Download' and 'Restore' but…
Browse files Browse the repository at this point in the history
…tons for versions of archived files

GUI S3 Objects lifecycle (#2759): lifecycle rules history: transition status icons
  • Loading branch information
AleksandrGorodetskii authored and rodichenko committed Oct 11, 2022
1 parent f8b6578 commit 2073be7
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 24 deletions.
37 changes: 18 additions & 19 deletions client/src/components/pipelines/browser/DataStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -997,11 +997,16 @@ export default class DataStorage extends React.Component {
}
};

canRestoreItem = (item) => {
canRestoreVersion = (item) => {
if (!this.showVersions) {
return false;
}
if ((item.type && item.type.toLowerCase() === 'folder') || !item.isVersion || item.deleteMarker) {
if (
(item.type && item.type.toLowerCase() === 'folder') ||
!item.isVersion ||
item.deleteMarker ||
(item.isVersion && item.archived)
) {
return false;
}
return !item.latest;
Expand Down Expand Up @@ -1069,7 +1074,7 @@ export default class DataStorage extends React.Component {
</Button>
);
}
if (this.versionControlsEnabled && this.canRestoreItem(item)) {
if (this.versionControlsEnabled && this.canRestoreVersion(item)) {
actions.push(
<Button id={`restore ${item.name}`} key="restore" size="small" onClick={() => this.onRestoreClicked(item, item.isVersion ? item.version : undefined)}>
<Icon type="reload" />
Expand Down Expand Up @@ -1326,30 +1331,28 @@ export default class DataStorage extends React.Component {
return undefined;
}
const childList = [];
const restored = (this.checkRestoredStatus(item) || {}).status === STATUS.SUCCEEDED;
for (let version in versions) {
const restored = (this.checkRestoredStatus(item) || {}).status === STATUS.SUCCEEDED;
if (versions.hasOwnProperty(version)) {
const archived = versions[version].labels &&
versions[version].labels['StorageClass'] !== STORAGE_CLASSES.standard;
const latest = versions[version].version === item.version;
childList.push({
key: `${item.type}_${item.path}_${version}`,
...versions[version],
downloadable: item.type.toLowerCase() === 'file' &&
!versions[version].deleteMarker &&
!sensitive &&
(
!item.labels ||
item.labels['StorageClass'] === STORAGE_CLASSES.standard ||
restored
),
((latest && restored) || !archived),
editable: versions[version].version === item.version &&
roleModel.writeAllowed(this.props.info.value) &&
!versions[version].deleteMarker,
deletable: roleModel.writeAllowed(this.props.info.value),
selectable: false,
shareAvailable: false,
latest: versions[version].version === item.version,
latest,
isVersion: true,
archived: item.labels &&
item.labels['StorageClass'] !== STORAGE_CLASSES.standard,
archived,
restored
});
}
Expand All @@ -1375,17 +1378,14 @@ export default class DataStorage extends React.Component {
}
items.push(...results.map(i => {
const restored = (this.checkRestoredStatus(i) || {}).status === STATUS.SUCCEEDED;
const archived = i.labels && i.labels['StorageClass'] !== STORAGE_CLASSES.standard;
return {
key: `${i.type}_${i.path}`,
...i,
downloadable: i.type.toLowerCase() === 'file' &&
!i.deleteMarker &&
!sensitive &&
(
!i.labels ||
i.labels['StorageClass'] === STORAGE_CLASSES.standard ||
restored
),
(!archived || restored),
editable: roleModel.writeAllowed(this.props.info.value) && !i.deleteMarker,
shareAvailable: !i.deleteMarker && this.sharingEnabled,
deletable: roleModel.writeAllowed(this.props.info.value),
Expand All @@ -1401,8 +1401,7 @@ export default class DataStorage extends React.Component {
hcs: !i.deleteMarker &&
i.type.toLowerCase() === 'file' &&
fastCheckHCSPreviewAvailable({path: i.path, storageId: this.props.storageId}),
archived: i.labels &&
i.labels['StorageClass'] !== STORAGE_CLASSES.standard,
archived,
restored
};
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,40 @@
*/

import React from 'react';
import {
Icon,
Tooltip
} from 'antd';
import {DESTINATIONS} from '../life-cycle-edit-modal';
// eslint-disable-next-line max-len
import {EXECUTION_STATUSES} from '../../../../../../../models/dataStorage/lifeCycleRules/DataStorageLifeCycleRulesExecutionLoad';
import displayDate from '../../../../../../../utils/displayDate';

const FORMAT = 'YYYY-MM-DD';

const STATUS_CONFIG = {
[EXECUTION_STATUSES.NOTIFICATION_SENT]: {
type: 'mail',
className: 'cp-primary',
description: 'Notification sent'
},
[EXECUTION_STATUSES.RUNNING]: {
type: 'clock-circle-o',
className: 'cp-primary',
description: 'Running'
},
[EXECUTION_STATUSES.SUCCESS]: {
type: 'check-circle-o',
className: 'cp-success',
description: 'Success'
},
[EXECUTION_STATUSES.FAILED]: {
type: 'exclamation-circle-o',
className: 'cp-error',
description: 'Failed'
}
};

const columns = [{
title: 'Date',
dataIndex: 'date',
Expand All @@ -28,7 +57,36 @@ const columns = [{
}, {
title: 'Action',
dataIndex: 'action',
key: 'action'
key: 'action',
render: (action, record) => {
if (action === 'Transition') {
return (
<div
style={{
display: 'flex',
alignItems: 'center',
flexWrap: 'nowrap'
}}
>
<span>
{action}
</span>
{STATUS_CONFIG[record.status] ? (
<Tooltip
title={STATUS_CONFIG[record.status].description}
>
<Icon
type={STATUS_CONFIG[record.status].type}
className={STATUS_CONFIG[record.status].className}
style={{marginLeft: 5, fontSize: 'larger'}}
/>
</Tooltip>
) : null}
</div>
);
}
return action;
}
}, {
title: 'User',
dataIndex: 'user',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import {
Spin
} from 'antd';
import moment from 'moment-timezone';
import DataStorageLifeCycleRulesExecutionLoad
from '../../../../../../../models/dataStorage/lifeCycleRules/DataStorageLifeCycleRulesExecutionLoad';
// eslint-disable-next-line max-len
import DataStorageLifeCycleRulesExecutionLoad from '../../../../../../../models/dataStorage/lifeCycleRules/DataStorageLifeCycleRulesExecutionLoad';
import {DESTINATIONS} from '../life-cycle-edit-modal';
import columns from './columns';
import styles from './life-cycle-history-modal.css';
Expand Down Expand Up @@ -109,7 +109,8 @@ class LifeCycleHistoryModal extends React.Component {
file: execution.path,
prolongation: undefined,
transition: undefined,
destination: mapDestination(execution.storageClass)
destination: mapDestination(execution.storageClass),
status: execution.status
}));
const prolongationsData = this.prolongations
.map(prolongation => ({
Expand All @@ -121,7 +122,8 @@ class LifeCycleHistoryModal extends React.Component {
file: prolongation.path,
prolongation: `${prolongation.days} days`,
transition: getTransitionDate(prolongation),
destination: undefined
destination: undefined,
status: undefined
}));
return [...executionsData, ...prolongationsData]
.sort((a, b) => a.date - b.date);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@

import Remote from '../../basic/Remote';

const EXECUTION_STATUSES = {
NOTIFICATION_SENT: 'NOTIFICATION_SENT',
RUNNING: 'RUNNING',
SUCCESS: 'SUCCESS',
FAILED: 'FAILED'
};

export default class DataStorageLifeCycleRulesExecutionLoad extends Remote {
constructor (datastorageId, ruleId) {
super();
this.url = `/datastorage/${datastorageId}/lifecycle/rule/${ruleId}/execution`;
}
}

export {EXECUTION_STATUSES};

0 comments on commit 2073be7

Please sign in to comment.