X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Fcomposer%2Fsrc%2Fsrc%2Fstores%2FCatalogDataStore.js;h=06d1342768ee7a80958a614843ca55bcd3628f9a;hp=9345bc39fcdf805aef67cfa1ed6fe2f9f02717e6;hb=fc0265f43d6ca5d7d7b0240e0bd0c6f6f313d6f8;hpb=84756036cd195d2eb15c343c74e9c880c503582b diff --git a/skyquake/plugins/composer/src/src/stores/CatalogDataStore.js b/skyquake/plugins/composer/src/src/stores/CatalogDataStore.js index 9345bc39f..06d134276 100644 --- a/skyquake/plugins/composer/src/src/stores/CatalogDataStore.js +++ b/skyquake/plugins/composer/src/src/stores/CatalogDataStore.js @@ -1,6 +1,6 @@ /* - * + * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -460,27 +460,10 @@ class CatalogDataStore { } duplicateSelectedCatalogItem() { - const item = this.getFirstSelectedCatalogItem(); - if (item) { - const newItem = _cloneDeep(item); - newItem.name = newItem.name + ' Copy'; - newItem.id = guid(); - UID.assignUniqueId(newItem.uiState); - const nsd = this.addNewItemToCatalog(newItem); - this.selectCatalogItem(nsd); - nsd.uiState.isNew = true; - nsd.uiState.modified = true; - nsd.uiState['instance-ref-count'] = 0; - // note duplicated items get a new id, map the layout position - // of the old id to the new id in order to preserve the layout - if (nsd.uiState.containerPositionMap) { - nsd.uiState.containerPositionMap[nsd.id] = nsd.uiState.containerPositionMap[item.id]; - delete nsd.uiState.containerPositionMap[item.id]; - } - setTimeout(() => { - this.selectCatalogItem(nsd); - CatalogItemsActions.editCatalogItem.defer(nsd); - }, 200); + // make request to backend to duplicate an item + const srcItem = this.getFirstSelectedCatalogItem(); + if (srcItem) { + CatalogPackageManagerActions.copyCatalogPackage.defer(srcItem); } } @@ -591,6 +574,13 @@ class CatalogDataStore { this.resetSelectionState(); } } + saveCatalogItemError(data){ + let error = JSON.parse(data.error.responseText); + const errorMsg = error && error.body && error.body['rpc-reply'] && JSON.stringify(error.body['rpc-reply']['rpc-error'], null, ' ') + ComposerAppActions.showError.defer({ + errorMessage: 'Unable to save the descriptor.\n' + errorMsg + }); + } } export default alt.createStore(CatalogDataStore, 'CatalogDataStore');