@@ -18,9 +18,7 @@ require('./cluster-edit.css');
1818
1919import * as React from 'react' ;
2020import * as Q from 'q' ;
21- import { AttributeInfo , Attributes } from 'plywood' ;
2221
23- import { Ajax } from '../../../utils/ajax/ajax' ;
2422import { Fn , pluralIfNeeded , makeTitle } from '../../../../common/utils/general/general' ;
2523import { classNames } from '../../../utils/dom/dom' ;
2624import { NUM_REGEX } from '../../../../common/utils/string/string' ;
@@ -41,8 +39,7 @@ import { CLUSTER as LABELS } from '../../../../common/models/labels';
4139export interface ClusterEditProps extends React . Props < any > {
4240 cluster ?: Cluster ;
4341 sources ?: string [ ] ;
44- onSave : ( newCluster : Cluster ) => Q . Promise < void > ;
45- onAddDataCubes ?: ( dataCubes : DataCube [ ] ) => Q . Promise < void > ;
42+ onSave : ( newCluster : Cluster , newDataCubes : DataCube [ ] ) => Q . Promise < void > ;
4643 isNewCluster ?: boolean ;
4744 onCancel ?: ( ) => void ;
4845 getSuggestedCubes ?: ( ) => DataCube [ ] ;
@@ -91,33 +88,11 @@ export class ClusterEdit extends React.Component<ClusterEditProps, ClusterEditSt
9188 }
9289
9390 save ( ) {
94- if ( this . props . onSave ) this . props . onSave ( this . state . newInstance ) ;
91+ if ( this . props . onSave ) this . props . onSave ( this . state . newInstance , null ) ;
9592 }
9693
9794 saveAndAddCubes ( dataCubes : DataCube [ ] ) {
98- if ( this . props . onSave ) {
99- this . props . onSave ( this . state . newInstance )
100- . then ( ( ) => {
101- Q . all ( dataCubes . map ( this . fetchSuggestions ) ) . then ( ( attributes : Attributes [ ] ) => {
102- let newDataCubes = dataCubes . map ( ( dc , i ) => dc . fillAllFromAttributes ( attributes [ i ] ) ) ;
103- this . props . onAddDataCubes ( newDataCubes ) ;
104- } ) ;
105- } ) ;
106- }
107- }
108-
109- fetchSuggestions ( dataCube : DataCube ) : Q . Promise < Attributes > {
110- return Ajax . query ( {
111- method : "POST" ,
112- url : 'settings/attributes' ,
113- data : {
114- clusterName : dataCube . clusterName ,
115- source : dataCube . source
116- }
117- } ) . then (
118- ( resp ) => AttributeInfo . fromJSs ( resp . attributes )
119- ) ;
120- ;
95+ if ( this . props . onSave ) this . props . onSave ( this . state . newInstance , dataCubes ) ;
12196 }
12297
12398 goBack ( ) {
0 commit comments