Skip to content

Commit

Permalink
GUI Issue #3221: Postpone lifecycle rule action
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrGorodetskii committed May 18, 2023
1 parent 0440ce0 commit d2f8a87
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import StopPipeline from '../../../../models/pipelines/StopPipeline';
import ResumePipeline from '../../../../models/pipelines/ResumePipeline';
import PausePipeline from '../../../../models/pipelines/PausePipeline';
import TerminatePipeline from '../../../../models/pipelines/TerminatePipeline';
import DataStorageLifeCycleRulesPostpone
from '../../../../models/dataStorage/lifeCycleRules/DataStorageLifeCycleRulesPostpone';
import {canPauseRun, canStopRun} from '../../../runs/actions';
import RunStatuses from '../../../special/run-status-icon/run-statuses';

Expand Down Expand Up @@ -101,8 +103,20 @@ const ACTIONS = {
},
postponeLifecycleRule: {
key: 'Postpone',
actionFn: ({notification, router}) => {
router && router.push(`/${notification.storagePath}`);
actionFn: async ({notification = {}, callback}) => {
const details = (notification.resources || [])[0] || {};
const hide = message.loading('Postpone...', -1);
const request = new DataStorageLifeCycleRulesPostpone({
datastorageId: details.entityId,
ruleId: details.storageRuleId,
path: details.storagePath
});
await request.fetch();
if (request.error) {
message.error(request.error);
}
hide();
callback && callback();
},
available: () => true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class NotificationActions extends React.Component {
],
[NOTIFICATION_TYPES.DATASTORAGE_LIFECYCLE_ACTION]: [
ACTIONS.openDatastorage,
ACTIONS.postponeLifecycleAction
ACTIONS.postponeLifecycleRule
],
[NOTIFICATION_TYPES.FULL_NODE_POOL]: [
ACTIONS.openPoolsUsage
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2017-2022 EPAM Systems, Inc. (https://www.epam.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

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

const DEFAULT_DAYS = 14;

export default class DataStorageLifeCycleRulesPostpone extends Remote {
url;

constructor ({
datastorageId,
ruleId,
path,
days = DEFAULT_DAYS,
force = false
}) {
super();
const parts = [
path !== undefined && `path=${encodeURIComponent(path)}`,
days !== undefined && `days=${days}`,
force !== undefined && `force=${force}`
].filter(Boolean);
const query = `?${parts.join('&')}`;
this.url = `/datastorage/${datastorageId}/lifecycle/rule/${ruleId}/prolong${query}`;
}
}

0 comments on commit d2f8a87

Please sign in to comment.