From 091edfdac90f66d91caff1b93131f99ba74f9aeb Mon Sep 17 00:00:00 2001 From: svishnev Date: Mon, 19 Mar 2018 12:15:19 +0200 Subject: ui support for archive items Issue-ID: SDC-1088 Change-Id: I836e4896a8ec6bb065f9d2571f514916ccf6759f Signed-off-by: svishnev --- .../onboarding/versionsPage/VersionsPage.js | 16 ++++++----- .../onboarding/versionsPage/VersionsPage.jsx | 33 +++++++++++++++++++--- .../versionsPage/VersionsPageActionHelper.js | 18 +++++++++++- .../versionsPage/components/VersionList.jsx | 10 +++---- 4 files changed, 59 insertions(+), 18 deletions(-) (limited to 'openecomp-ui/src/sdc-app/onboarding/versionsPage') diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.js index 7b6f27307d..0fd0eabd86 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.js @@ -1,5 +1,5 @@ /*! - * 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. @@ -24,11 +24,11 @@ import VersionsPageView from './VersionsPage.jsx'; export const mapStateToProps = ({ users: {userInfo}, versionsPage: {permissions, versionsList}, - currentScreen: {itemPermission: {isCollaborator}, props: {itemId}}, + currentScreen: {itemPermission: {isCollaborator, isArchived}, props: {itemId}}, softwareProductList = [] }) => { - let {versions, selectedVersion} = versionsList; + let {versions = [], selectedVersion} = versionsList; let {owner, contributors, viewers} = permissions; // sorting the version list @@ -40,8 +40,7 @@ export const mapStateToProps = ({ return statusCompare; } - }); - + }); const curentSoftwareProduct = softwareProductList.find(item => item.id === itemId); return { versions, @@ -51,7 +50,8 @@ export const mapStateToProps = ({ currentUser: userInfo, selectedVersion, isCollaborator, - isManual: curentSoftwareProduct && curentSoftwareProduct.onboardingMethod === onboardingMethodType.MANUAL + isManual: curentSoftwareProduct && curentSoftwareProduct.onboardingMethod === onboardingMethodType.MANUAL, + isArchived }; }; @@ -80,7 +80,9 @@ export const mapActionsToProps = (dispatch, {itemType, itemId, additionalProps}) onModalNodeClick({version}) { VersionsPageActionHelper.selectVersionFromModal(dispatch, {version}); - } + }, + onArchive: () => VersionsPageActionHelper.archiveItem(dispatch, itemId), + onRestore: () => VersionsPageActionHelper.restoreItemFromArchive(dispatch, itemId) }; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.jsx b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.jsx index 69a34e0a1c..f8417fafbf 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.jsx @@ -1,5 +1,5 @@ /*! - * 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. @@ -18,7 +18,26 @@ import VersionList from './components/VersionList.jsx'; import PermissionsView from './components/PermissionsView.jsx'; import Tree from 'nfvo-components/tree/Tree.jsx'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; +import Button from 'sdc-ui/lib/react/Button.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; +import featureToggle from 'sdc-app/features/featureToggle.js'; + +const DepricateButton = ({depricateAction, title}) => ( +
+ +
+); + +const FeatureDepricatedButton = featureToggle('ARCHIVE_ITEM')(DepricateButton); + +const VersionPageTitle = ({itemName, depricatedTitle, isArchived, onRestore, onArchive}) => { + return ( +
+
{`${i18n('Available Versions')} - ${itemName} ${depricatedTitle}`}
+ onRestore() : () => onArchive() } title={i18n(isArchived ? 'RESTORE' : 'ARCHIVE')}/> +
+ ); +}; class VersionsPage extends React.Component { state = { @@ -26,10 +45,16 @@ class VersionsPage extends React.Component { } render() { let { versions, owner, contributors, currentUser, isCollaborator, itemName = '', viewers, onSelectVersion, onNavigateToVersion, - onTreeFullScreen, onManagePermissions, onCreateVersion, selectedVersion, onModalNodeClick, isManual} = this.props; + onTreeFullScreen, onManagePermissions, onCreateVersion, selectedVersion, onModalNodeClick, isManual, isArchived, onArchive, onRestore} = this.props; + const depricatedTitle = isArchived ? i18n('(Archived)') : ''; return (
-
{i18n('Available Versions - {itemName}', {itemName: itemName})}
+
diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js index edf30fe4ef..d475c03c31 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js @@ -1,5 +1,5 @@ /*! - * 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. @@ -85,6 +85,22 @@ const VersionsPageActionHelper = { type: modalActionTypes.GLOBAL_MODAL_CLOSE }); this.selectVersion(dispatch, {version}); + }, + + archiveItem(dispatch, itemId) { + ItemsHelper.archiveItem(itemId).then(() => { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.ONBOARDING_CATALOG + }); + }); + }, + + restoreItemFromArchive(dispatch, itemId) { + ItemsHelper.restoreItem(itemId).then(() => { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.ONBOARDING_CATALOG + }); + }); } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/components/VersionList.jsx b/openecomp-ui/src/sdc-app/onboarding/versionsPage/components/VersionList.jsx index f209d80125..47255eb9dc 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/components/VersionList.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/components/VersionList.jsx @@ -1,5 +1,5 @@ /*! - * 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. @@ -87,20 +87,18 @@ const VersionListItem = ({ data, onSelectVersion, onNavigateToVersion, onCreateV labelPosition='right' />
- {!isHeader && isCollaborator && additionalInfo.OptionalCreationMethods.length > 0 && + {!isHeader && isCollaborator && additionalInfo.OptionalCreationMethods.length > 0 && onCreateVersion && { e.stopPropagation(); onCreateVersion(); }} label={i18n('Create New Version')} labelPosition='right' - disabled={!isCollaborator} /> + disabled={!isCollaborator || !onCreateVersion} /> }
} - - ); @@ -118,7 +116,7 @@ const VersionList = ({ versions, onSelectVersion, onNavigateToVersion, onCreateV data={version} onSelectVersion={() => onSelectVersion({version})} onNavigateToVersion={() => onNavigateToVersion({version})} - onCreateVersion={() => onCreateVersion({version})} + onCreateVersion={onCreateVersion ? () => onCreateVersion({version}) : false} isSelected={selectedVersion === version.id} isCollaborator={isCollaborator} /> )} -- cgit 1.2.3-korg