diff options
author | svishnev <shlomo-stanisla.vishnevetskiy@amdocs.com> | 2018-03-19 12:15:19 +0200 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2018-03-20 07:51:05 +0000 |
commit | 091edfdac90f66d91caff1b93131f99ba74f9aeb (patch) | |
tree | a6a24fc4a295b7f804aeb2a2211e58b38bbf922a /openecomp-ui/src/sdc-app/onboarding/versionsPage | |
parent | fefa3e408f77289594e47edc878d1bee61fca90b (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/onboarding/versionsPage')
4 files changed, 59 insertions, 18 deletions
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}) => ( + <div className='depricate-btn-wrapper'> + <Button data-test-id='depricate-action-btn' className='depricate-btn' onClick={depricateAction}>{title}</Button> + </div> +); + +const FeatureDepricatedButton = featureToggle('ARCHIVE_ITEM')(DepricateButton); + +const VersionPageTitle = ({itemName, depricatedTitle, isArchived, onRestore, onArchive}) => { + return ( + <div className='version-page-header'> + <div className='versions-page-title'>{`${i18n('Available Versions')} - ${itemName} ${depricatedTitle}`}</div> + <FeatureDepricatedButton depricateAction={isArchived ? () => onRestore() : () => onArchive() } title={i18n(isArchived ? 'RESTORE' : 'ARCHIVE')}/> + </div> + ); +}; 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 ( <div className='versions-page-view'> - <div className='versions-page-title'>{i18n('Available Versions - {itemName}', {itemName: itemName})}</div> + <VersionPageTitle + itemName={itemName} + depricatedTitle={depricatedTitle} + onArchive={onArchive} + isArchived={isArchived} + onRestore={onRestore}/> <PermissionsView owner={owner} contributors={contributors} @@ -65,7 +90,7 @@ class VersionsPage extends React.Component { versions={versions} onSelectVersion={onSelectVersion} onNavigateToVersion={onNavigateToVersion} - onCreateVersion={onCreateVersion} + onCreateVersion={isArchived ? false : onCreateVersion} selectedVersion={selectedVersion} isCollaborator={isCollaborator} /> </div> 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' /> </div> <div className='version-item-field item-create'> - {!isHeader && isCollaborator && additionalInfo.OptionalCreationMethods.length > 0 && + {!isHeader && isCollaborator && additionalInfo.OptionalCreationMethods.length > 0 && onCreateVersion && <SVGIcon name='plus-circle' data-test-id='versions-page-create-version' onClick={e => { e.stopPropagation(); onCreateVersion(); }} label={i18n('Create New Version')} labelPosition='right' - disabled={!isCollaborator} /> + disabled={!isCollaborator || !onCreateVersion} /> } </div> </div> } - - </div> ); @@ -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} /> )} |