/*
- *
+ *
* Copyright 2016 RIFT.IO Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
import CatalogDataSource from '../sources/CatalogDataSource'
import ComposerAppStore from '../stores/ComposerAppStore'
import SelectionManager from '../libraries/SelectionManager'
-import ExportSelectorDialog from '../components/ExportSelectorDialog'
const defaults = {
catalogs: [],
}
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);
}
}
}
exportSelectedCatalogItems(draggedItem) {
- const onSelectFormat = (selectedFormat, event) => {
- this.setState({
- selectedFormat: selectedFormat
- });
- };
-
- const onSelectGrammar = (selectedGrammar, event) => {
- this.setState({
- selectedGrammar: selectedGrammar
- });
- }
-
-
- const onCancel = () => {
- this.resetSelectionState();
- ModalOverlayActions.hideModalOverlay();
- };
-
- const onDownload = (event) => {
+ // collect the selected items and delegate to the catalog package manager action creator
+ const selectedItems = this.getAllSelectedCatalogItems();
+ if (selectedItems.length) {
CatalogPackageManagerActions.downloadCatalogPackage.defer({
selectedItems: selectedItems,
- selectedFormat: this.selectedFormat,
- selectedGrammar: this.selectedGrammar
+ selectedFormat: 'mano',
+ selectedGrammar: 'osm'
});
this.resetSelectionState();
- ModalOverlayActions.hideModalOverlay();
- return;
- }
-
- if (draggedItem) {
- // if item is given make sure it is also selected
- //draggedItem.uiState.selected = true;
- SelectionManager.addSelection(draggedItem);
- this.updateCatalogItem(draggedItem);
- }
- // collect the selected items and delegate to the catalog package manager action creator
- const selectedItems = this.getAllSelectedCatalogItems();
- if (selectedItems.length) {
- CatalogDataStore.chooseExportFormat(onSelectFormat, onSelectGrammar, onDownload, onCancel);
}
}
-
- static chooseExportFormat(onSelectFormat, onSelectGrammar, onDownload, onCancel) {
- ModalOverlayActions.showModalOverlay.defer(
- <ExportSelectorDialog
- onSelectFormat={onSelectFormat}
- onSelectGrammar={onSelectGrammar}
- onCancel={onCancel}
- onDownload={onDownload}
- currentlySelectedFormat='mano'
- currentlySelectedGrammar='osm'
- />
- );
+ 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');