@@ -4,7 +4,6 @@ import * as linter from "replicated-lint";
4
4
import Linter from "../shared/Linter" ;
5
5
import AceEditor from "react-ace" ;
6
6
import ErrorBoundary from "../../ErrorBoundary" ;
7
- import Toast from "../shared/Toast" ;
8
7
import get from "lodash/get" ;
9
8
import find from "lodash/find" ;
10
9
@@ -24,10 +23,8 @@ export default class HelmValuesEditor extends React.Component {
24
23
initialSpecValue : "" ,
25
24
helmLintErrors : [ ] ,
26
25
saving : false ,
26
+ saveFinal : false ,
27
27
unsavedChanges : false ,
28
- toastDetails : {
29
- opts : { }
30
- }
31
28
}
32
29
autoBind ( this ) ;
33
30
}
@@ -76,44 +73,13 @@ export default class HelmValuesEditor extends React.Component {
76
73
} ) ;
77
74
}
78
75
79
- cancelToast ( ) {
80
- let nextState = { } ;
81
- nextState . toastDetails = {
82
- showToast : false ,
83
- title : "" ,
84
- subText : "" ,
85
- type : "default" ,
86
- opts : { }
87
- } ;
88
- this . setState ( nextState )
89
- }
90
-
91
76
handleContinue ( ) {
92
- const { actions, isNewRouter } = this . props ;
77
+ const { actions } = this . props ;
93
78
let submitAction ;
94
- if ( isNewRouter ) {
95
- submitAction = find ( actions , [ "buttonType" , "popover" ] ) ;
96
- } else {
97
- submitAction = find ( actions , [ "sort" , 1 ] ) ;
98
- }
79
+ submitAction = find ( actions , [ "buttonType" , "popover" ] ) ;
99
80
this . props . handleAction ( submitAction , true ) ;
100
81
}
101
82
102
- onValuesSaved ( ) {
103
- let nextState = { } ;
104
- nextState . toastDetails = {
105
- showToast : true ,
106
- title : "All changes have been saved." ,
107
- type : "default" ,
108
- opts : {
109
- showCancelButton : true ,
110
- confirmButtonText : "Continue to next step" ,
111
- confirmAction : ( ) => { this . handleContinue ( ) ; }
112
- }
113
- }
114
- this . setState ( nextState ) ;
115
- }
116
-
117
83
handleSkip ( ) {
118
84
const { initialSpecValue } = this . state ;
119
85
const payload = {
@@ -135,13 +101,13 @@ export default class HelmValuesEditor extends React.Component {
135
101
} )
136
102
}
137
103
138
- handleSaveValues ( ) {
104
+ handleSaveValues ( finalize ) {
139
105
const { specValue } = this . state ;
140
106
const payload = {
141
107
values : specValue
142
108
}
143
- if ( payload . values !== "" ) {
144
- this . setState ( { saving : true , helmLintErrors : [ ] } ) ;
109
+ if ( payload . values !== "" ) {
110
+ this . setState ( { saving : true , saveFinal : finalize , helmLintErrors : [ ] } ) ;
145
111
this . props . saveValues ( payload )
146
112
. then ( ( { errors } ) => {
147
113
if ( errors ) {
@@ -151,7 +117,13 @@ export default class HelmValuesEditor extends React.Component {
151
117
} ) ;
152
118
}
153
119
this . setState ( { saving : false , savedYaml : true } ) ;
154
- this . onValuesSaved ( ) ;
120
+ if ( finalize ) {
121
+ this . handleContinue ( ) ;
122
+ return ;
123
+ }
124
+ setTimeout ( ( ) => {
125
+ this . setState ( { savedYaml : false } ) ;
126
+ } , 3000 )
155
127
} )
156
128
. catch ( ( err ) => {
157
129
// TODO: better handling
@@ -164,8 +136,10 @@ export default class HelmValuesEditor extends React.Component {
164
136
const {
165
137
readOnly,
166
138
specValue,
139
+ initialSpecValue,
167
140
saving,
168
- toastDetails,
141
+ saveFinal,
142
+ savedYaml,
169
143
helmLintErrors,
170
144
} = this . state ;
171
145
const {
@@ -177,7 +151,6 @@ export default class HelmValuesEditor extends React.Component {
177
151
return (
178
152
< ErrorBoundary >
179
153
< div className = "flex-column flex1 HelmValues--wrapper u-paddingTop--30" >
180
- < Toast toast = { toastDetails } onCancel = { this . cancelToast } />
181
154
< div className = "flex-column flex-1-auto u-overflow--auto container" >
182
155
< p className = "u-color--dutyGray u-fontStize--large u-fontWeight--medium u-marginBottom--small" >
183
156
/{ name } /
@@ -212,19 +185,23 @@ export default class HelmValuesEditor extends React.Component {
212
185
</ div >
213
186
</ div >
214
187
< div className = "actions-wrapper container u-width--full flex flex-auto justifyContent--flexEnd" >
215
- < p className = "u-color--chestnut u-fontSize--small u-fontWeight--medium u-marginRight--30 u-lineHeight--normal" > { helmLintErrors . join ( "\n" ) } </ p >
188
+ < div className = "flex-column flex-verticalCenter" >
189
+ { helmLintErrors . length ?
190
+ < p className = "u-color--chestnut u-fontSize--small u-fontWeight--medium u-marginRight--normal u-lineHeight--normal" > { helmLintErrors . join ( "\n" ) } </ p >
191
+ : null }
192
+ { savedYaml ?
193
+ < p className = "u-color--vidaLoca u-fontSize--small u-fontWeight--medium u-marginRight--normal u-lineHeight--normal" > Values saved</ p >
194
+ : null }
195
+ </ div >
216
196
< div className = "flex flex-auto alignItems--center" >
217
- < p
218
- className = "u-color--astral u-fontSize--small u-fontWeight--medium u-marginRight--20 u-textDecoration--underlineOnHover"
219
- onClick = { ( ) => { this . handleSkip ( ) } } >
220
- Skip this step
221
- </ p >
222
- < button
223
- className = "btn primary"
224
- onClick = { ( ) => this . handleSaveValues ( ) }
225
- disabled = { saving } >
226
- { saving ? "Saving" : "Save values" }
227
- </ button >
197
+ { initialSpecValue === specValue ?
198
+ < button className = "btn primary" onClick = { ( ) => { this . handleSkip ( ) } } > Continue</ button >
199
+ :
200
+ < div className = "flex" >
201
+ < button className = "btn primary u-marginRight--normal" onClick = { ( ) => this . handleSaveValues ( false ) } disabled = { saving || saveFinal } > { saving ? "Saving" : "Save values" } </ button >
202
+ < button className = "btn secondary" onClick = { ( ) => this . handleSaveValues ( true ) } disabled = { saving || saveFinal } > { saveFinal ? "Saving values" : "Save & continue" } </ button >
203
+ </ div >
204
+ }
228
205
</ div >
229
206
</ div >
230
207
0 commit comments