ui support for archive items

Issue-ID: SDC-1088
Change-Id: I836e4896a8ec6bb065f9d2571f514916ccf6759f
Signed-off-by: svishnev <shlomo-stanisla.vishnevetskiy@amdocs.com>
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/ArchivedLicenseModelListReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/ArchivedLicenseModelListReducer.js
new file mode 100644
index 0000000..8e4750e
--- /dev/null
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/ArchivedLicenseModelListReducer.js
@@ -0,0 +1,25 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * 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 {actionTypes} from './LicenseModelConstants.js';
+
+export default (state = [], action) => {
+	switch (action.type) {
+		case actionTypes.ARCHIVED_LICENSE_MODELS_LIST_LOADED:
+			return [...action.response.results];
+		default:
+			return state;
+	}
+};
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js
index 73027c7..c390ecc 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js
@@ -1,17 +1,17 @@
-/*!
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+/*
+ * Copyright © 2016-2018 European Support Limited
  *
  * 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
- *
+ * 
+ *      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.
+ * 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 {connect} from 'react-redux';
 
@@ -28,7 +28,6 @@
 import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js';
 import {CommitModalType} from 'nfvo-components/panel/versionController/components/CommitCommentModal.jsx';
 
-
 const buildNavigationBarProps = (licenseModel, screen) => {
 	const {id, vendorName, version} = licenseModel;
 	const meta = {version};
@@ -83,6 +82,7 @@
 	userInfo,
 	usersList,
 	permissions,
+	isArchived,
 	itemPermission,
 	isReadOnlyMode
 }) => {
@@ -94,6 +94,7 @@
 		permissions,
 		userInfo,
 		usersList,
+		isArchived,
 		itemName: licenseModelEditor.data.vendorName,
 		itemPermission,
 		isReadOnlyMode
@@ -116,6 +117,7 @@
 			userInfo,
 			permissions,
 			usersList,
+			isArchived: itemPermission.isArchived,
 			itemPermission,
 			isReadOnlyMode
 		}),
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js
index ff264b3..d1d3a77 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js
@@ -1,17 +1,17 @@
-/*!
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+/*
+ * Copyright © 2016-2018 European Support Limited
  *
  * 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
- *
+ * 
+ *      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.
+ * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js';
 import Configuration from 'sdc-app/config/Configuration.js';
@@ -23,7 +23,7 @@
 import FeatureGroupsActionHelper from './featureGroups/FeatureGroupsActionHelper.js';
 import EntitlementPoolsActionHelper from './entitlementPools/EntitlementPoolsActionHelper.js';
 import LicenseKeyGroupsActionHelper from './licenseKeyGroups/LicenseKeyGroupsActionHelper.js';
-import ItemsHelper from '../../common/helpers/ItemsHelper.js';
+import {default as ItemsHelper} from 'sdc-app/common/helpers/ItemsHelper.js';
 import MergeEditorActionHelper from 'sdc-app/common/merge/MergeEditorActionHelper.js';
 import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js';
 import {CommitModalType} from 'nfvo-components/panel/versionController/components/CommitCommentModal.jsx';
@@ -38,13 +38,15 @@
 }
 
 function fetchLicenseModels() {
-	return RestAPIUtil.fetch(`${baseUrl()}?versionFilter=Draft`);
+	return RestAPIUtil.fetch(`${baseUrl()}?versionFilter=${catalogItemStatuses.DRAFT}`);
 }
 
 function fetchFinalizedLicenseModels() {
-	return RestAPIUtil.fetch(`${baseUrl()}?versionFilter=Certified`);
+	return RestAPIUtil.fetch(`${baseUrl()}?versionFilter=${catalogItemStatuses.CERTIFIED}`);
 }
-
+function fetchArchivedLicenseModels() {
+	return RestAPIUtil.fetch(`${baseUrl()}?Status=${catalogItemStatuses.ARCHIVED}`);
+}
 function fetchLicenseModelById(licenseModelId, version) {
 	const {id: versionId} = version;
 	return RestAPIUtil.fetch(`${baseUrl()}${licenseModelId}/versions/${versionId}`);
@@ -83,6 +85,14 @@
 
 	},
 
+	fetchArchivedLicenseModels(dispatch) {
+		return fetchArchivedLicenseModels().then(response => dispatch({
+			type: actionTypes.ARCHIVED_LICENSE_MODELS_LIST_LOADED,
+			response
+		}));
+
+	},
+
 	fetchLicenseModelById(dispatch, {licenseModelId, version}) {
 
 		return fetchLicenseModelById(licenseModelId, version).then(response => {
@@ -145,14 +155,15 @@
 
 	performVCAction(dispatch, {licenseModelId, action, version, comment}) {
 		return MergeEditorActionHelper.analyzeSyncResult(dispatch, {itemId: licenseModelId, version}).then(({inMerge, isDirty, updatedVersion}) => {
-			if (updatedVersion.status === catalogItemStatuses.CERTIFIED &&
+			if ( (updatedVersion.status === catalogItemStatuses.CERTIFIED || updatedVersion.archivedStatus === catalogItemStatuses.ARCHIVED) && 
 				(action === VersionControllerActionsEnum.COMMIT || action === VersionControllerActionsEnum.SYNC)) {
 				versionPageActionHelper.fetchVersions(dispatch, {itemType: itemTypes.LICENSE_MODEL, itemId: licenseModelId});
+				const msg = updatedVersion.archivedStatus === catalogItemStatuses.ARCHIVED ? i18n('Item was Archived') : i18n('Item version already Certified');
 				dispatch({
 					type: modalActionTypes.GLOBAL_MODAL_WARNING,
 					data: {
 						title: i18n('Commit error'),
-						msg: i18n('Item version already Certified'),
+						msg,
 						cancelButtonText: i18n('Cancel')
 					}
 				});
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js
index 283cb23..08009ee 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js
@@ -1,17 +1,17 @@
-/*!
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+/*
+ * Copyright © 2016-2018 European Support Limited
  *
  * 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
- *
+ * 
+ *      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.
+ * 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 keyMirror from 'nfvo-utils/KeyMirror.js';
 import i18n from 'nfvo-utils/i18n/i18n.js';
@@ -20,6 +20,7 @@
 	LICENSE_MODEL_LOADED: null,
 	LICENSE_MODELS_LIST_LOADED: null,
 	FINALIZED_LICENSE_MODELS_LIST_LOADED: null,
+	ARCHIVED_LICENSE_MODELS_LIST_LOADED: null,
 	EDIT_LICENSE_MODEL: null
 });
 
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js
index 71f4171..bcd6e7f 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js
@@ -1,17 +1,17 @@
-/*!
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+/*
+ * Copyright © 2016-2018 European Support Limited
  *
  * 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
- *
+ * 
+ *      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.
+ * 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 {connect} from 'react-redux';
 import LicenseModelCreationActionHelper from './LicenseModelCreationActionHelper.js';
@@ -24,14 +24,15 @@
 import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js';
 import PermissionsActionHelper from 'sdc-app/onboarding/permissions/PermissionsActionHelper.js';
 
-export const mapStateToProps = ({users: {usersList}, licenseModelList, licenseModel: {licenseModelCreation}}) => {
+export const mapStateToProps = ({users: {usersList}, licenseModelList, finalizedLicenseModelList, archivedLicenseModelList, licenseModel: {licenseModelCreation}}) => {
 	let {genericFieldInfo} = licenseModelCreation;
 	let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo);
-
 	let VLMNames = {};
-	for (let i = 0; i < licenseModelList.length; i++) {
-		VLMNames[licenseModelList[i].name.toLowerCase()] = licenseModelList[i].id;
-	}
+
+	const allVlmList = [...licenseModelList, ...finalizedLicenseModelList,...archivedLicenseModelList];
+	allVlmList.map((item) => {
+		VLMNames[item.name.toLowerCase()] = item.id;
+	});
 
 	return {...licenseModelCreation, isFormValid: isFormValid, VLMNames, usersList};
 };
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js
index 09a6e82..84bdac8 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js
@@ -124,7 +124,7 @@
 				type: entitlementPoolsActionTypes.DELETE_ENTITLEMENT_POOL,
 				entitlementPoolId
 			});
-			ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+			return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 		});
 	},
 
@@ -148,7 +148,7 @@
 					type: entitlementPoolsActionTypes.EDIT_ENTITLEMENT_POOL,
 					entitlementPool
 				});
-				ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+				return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 			});
 		}
 		else {
@@ -161,7 +161,7 @@
 						id: response.value
 					}
 				});
-				ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+				return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 			});
 		}
 	},
@@ -198,14 +198,14 @@
 				type: limitEditorActions.CLOSE
 			});
 			this.fetchLimits(dispatch, {licenseModelId, version, entitlementPool});
-			ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+			return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 		});
 	},
 
 	deleteLimit(dispatch, {licenseModelId, version, entitlementPool, limit}) {
 		return  deleteLimit(licenseModelId,entitlementPool.id, version, limit.id).then(() => {
 			this.fetchLimits(dispatch, {licenseModelId, version, entitlementPool});
-			ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+			return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 		});
 	}
 };
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js
index aadf8e0..9e7fe8e 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js
@@ -86,7 +86,7 @@
 				type: featureGroupsActionConstants.DELETE_FEATURE_GROUPS,
 				featureGroupId
 			});
-			ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+			return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 		});
 	},
 
@@ -99,7 +99,7 @@
 				});
 				EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version});
 				LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version});
-				ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+				return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 			});
 		}
 		else {
@@ -114,7 +114,7 @@
 				});
 				EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version});
 				LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version});
-				ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+				return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 			});
 		}
 	},
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js
index b4f03a6..b1b4ee8 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js
@@ -92,14 +92,14 @@
 		if (previousLicenseAgreement) {
 			return putLicenseAgreement(licenseModelId, previousLicenseAgreement, licenseAgreement, version).then(() => {
 				this.fetchLicenseAgreementList(dispatch, {licenseModelId, version});
-				ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+				return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 			});
 		}
 		else {
 			return postLicenseAgreement(licenseModelId, licenseAgreement, version).then(() => {
 				this.fetchLicenseAgreementList(dispatch, {licenseModelId, version});
 				FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version});
-				ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+				return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 			});
 		}
 	},
@@ -110,7 +110,7 @@
 				type: licenseAgreementActionTypes.DELETE_LICENSE_AGREEMENT,
 				licenseAgreementId
 			});
-			ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+			return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 		});
 	},
 
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js
index 4d86815..674c329 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js
@@ -128,7 +128,7 @@
 					type: licenseKeyGroupsConstants.EDIT_LICENSE_KEY_GROUP,
 					licenseKeyGroup
 				});
-				ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+				return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 			});
 		}
 		else {
@@ -141,7 +141,7 @@
 						id: response.value
 					}
 				});
-				ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+				return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 			});
 		}
 
@@ -154,7 +154,7 @@
 				type: licenseKeyGroupsConstants.DELETE_LICENSE_KEY_GROUP,
 				licenseKeyGroupId
 			});
-			ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+			return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 		});
 	},
 
@@ -190,14 +190,14 @@
 				type: limitEditorActions.CLOSE
 			});
 			this.fetchLimits(dispatch, {licenseModelId, version, licenseKeyGroup});
-			ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+			return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 		});
 	},
 
 	deleteLimit(dispatch, {licenseModelId, version, licenseKeyGroup, limit}) {
 		return deleteLimit(licenseModelId,licenseKeyGroup.id, version, limit.id).then(() => {
 			this.fetchLimits(dispatch, {licenseModelId, version, licenseKeyGroup});
-			ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
+			return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id});
 		});
 	}