RIFT-15318: Hide assets tab when there are none 89/989/1
authorLaurence Maultsby <laurence.maultsby@riftio.com>
Thu, 19 Jan 2017 16:44:34 +0000 (11:44 -0500)
committerLaurence Maultsby <laurence.maultsby@riftio.com>
Thu, 19 Jan 2017 16:44:34 +0000 (11:44 -0500)
Signed-off-by: Laurence Maultsby <laurence.maultsby@riftio.com>
skyquake/plugins/composer/api/composer.js
skyquake/plugins/composer/src/src/components/CanvasPanel.js
skyquake/plugins/composer/src/src/stores/ComposerAppStore.js

index 8df1a91..864f2b0 100644 (file)
@@ -612,6 +612,9 @@ FileManager.get = function(req) {
                                 data: data.body
                             });
                         }
+                    }).catch(function(err) {
+                        console.log('Failed to retrieve FileManager.list')
+                        resolve(err);
                     })
                 }
             })
index 96904ea..cb212cb 100644 (file)
@@ -81,9 +81,13 @@ const CanvasPanel = React.createClass({
                                                <button className={isDescriptorView ? '-selected' : ''} onClick={ComposerAppActions.showDescriptor}>
                                                        Descriptor
                                                </button>
-                                               <button className={!isDescriptorView ? '-selected' : ''}  onClick={ComposerAppActions.showAssets}>
-                                                       Assets
-                                               </button>
+                                               {
+                                                       this.props.files ?
+                                                               <button className={!isDescriptorView ? '-selected' : ''}  onClick={ComposerAppActions.showAssets}>
+                                                                       Assets
+                                                               </button>
+                                                       : null
+                                               }
                                        </div>
                                </div>
                        )
index 854864b..347ba9a 100644 (file)
@@ -457,18 +457,27 @@ class ComposerAppStore {
                let self = this;
                let filesState = null;
         if (self.fileMonitoringSocketID) {
-                       filesState = addInputState( _.cloneDeep(this.filesState),data);
-                       // filesState = _.merge(self.filesState, addInputState({},data));
-                       let normalizedData = normalizeTree(data);
-                       this.setState({
-                               files: {
-                                       data: _.mergeWith(normalizedData.data, self.files.data, function(obj, src) {
-                                               return _.uniqBy(obj? obj.concat(src) : src, 'name');
-                                       }),
-                                       id: self.files.id || normalizedData.id
-                               },
-                               filesState: filesState
-                       });
+               let newState = {};
+               if(data.hasOwnProperty('contents')) {
+                       filesState = addInputState( _.cloneDeep(this.filesState),data);
+                               // filesState = _.merge(self.filesState, addInputState({},data));
+                               let normalizedData = normalizeTree(data);
+                               newState = {
+                                       files: {
+                                               data: _.mergeWith(normalizedData.data, self.files.data, function(obj, src) {
+                                                       return _.uniqBy(obj? obj.concat(src) : src, 'name');
+                                               }),
+                                               id: self.files.id || normalizedData.id
+                                       },
+                                       filesState: filesState
+                               }
+               } else {
+                       newState = {
+                               files: false
+                       }
+               }
+
+                       this.setState(newState);
         }
                function normalizeTree(data) {
                        let f = {