summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js
diff options
context:
space:
mode:
authorsvishnev <shlomo-stanisla.vishnevetskiy@amdocs.com>2018-03-19 12:15:19 +0200
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2018-03-20 07:51:05 +0000
commit091edfdac90f66d91caff1b93131f99ba74f9aeb (patch)
treea6a24fc4a295b7f804aeb2a2211e58b38bbf922a /openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js
parentfefa3e408f77289594e47edc878d1bee61fca90b (diff)
ui support for archive items
Issue-ID: SDC-1088 Change-Id: I836e4896a8ec6bb065f9d2571f514916ccf6759f Signed-off-by: svishnev <shlomo-stanisla.vishnevetskiy@amdocs.com>
Diffstat (limited to 'openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js')
-rw-r--r--openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js52
1 files changed, 40 insertions, 12 deletions
diff --git a/openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js b/openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js
index b82bc92017..05affe981f 100644
--- a/openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js
+++ b/openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js
@@ -18,6 +18,19 @@ import Configuration from 'sdc-app/config/Configuration.js';
import {permissionTypes} from 'sdc-app/onboarding/permissions/PermissionsConstants.js';
import {actionsEnum as VersionControllerActionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
import {actionTypes as onboardingActionTypes} from 'sdc-app/onboarding/OnboardingConstants.js';
+import restToggle from 'sdc-app/features/restToggle.js';
+import {featureToggleNames} from 'sdc-app/features/FeaturesConstants.js';
+export const archiveActions = {
+ ARCHIVE: 'ARCHIVE',
+ RESTORE: 'RESTORE'
+};
+
+export const itemStatus = {
+ ARCHIVED: 'ARCHIVED',
+ DRAFT: 'Draft',
+ CERTIFIED: 'Certified'
+};
+
function baseUrl() {
const restPrefix = Configuration.get('restPrefix');
@@ -58,21 +71,36 @@ const ItemsHelper = {
return RestAPIUtil.put(`${baseUrl()}/${itemId}/permissions/${permissionTypes.OWNER}`, {removedUsersIds: [], addedUsersIds: [ownerId]});
},
- checkItemStatus(dispatch, {itemId, versionId}) {
- return ItemsHelper.fetchVersion({itemId, versionId}).then(response => {
- let state = response && response.state || {};
- const {baseId, description, id, name, status} = response;
-
- dispatch({
- type: onboardingActionTypes.UPDATE_ITEM_STATUS,
- itemState: state,
- itemStatus: response.status,
- updatedVersion: {baseId, description, id, name, status}
- });
- return Promise.resolve(response);
+ async checkItemStatus(dispatch, {itemId, versionId}) {
+ const response = await ItemsHelper.fetchVersion({itemId, versionId});
+ let state = response && response.state || {};
+ const {baseId, description, id, name, status} = response;
+ const item = await ItemsHelper.fetchItem(itemId);
+ dispatch({
+ type: onboardingActionTypes.UPDATE_ITEM_STATUS,
+ itemState: state,
+ itemStatus: response.status,
+ archivedStatus: item.status,
+ updatedVersion: {baseId, description, id, name, status}
});
+ return Promise.resolve({...response, archivedStatus: item.status});
},
+
+ fetchItem(itemId) {
+ return restToggle({restFunction: () => RestAPIUtil.fetch(`${baseUrl()}/${itemId}`), featureName: featureToggleNames.ARCHIVE_ITEM, mockResult: {}});
+ },
+
+ archiveItem(itemId) {
+ return RestAPIUtil.put(`${baseUrl()}/${itemId}/actions`, {
+ action: archiveActions.ARCHIVE
+ });
+ },
+ restoreItem(itemId) {
+ return RestAPIUtil.put(`${baseUrl()}/${itemId}/actions`, {
+ action: archiveActions.RESTORE
+ });
+ }
};
export default ItemsHelper;