@@ -117,8 +117,10 @@ class DaStart extends LitElement {
117117 showDone : { state : true } ,
118118 _goText : { state : true } ,
119119 _statusText : { state : true } ,
120+ _errorText : { state : true } ,
120121 _templates : { state : true } ,
121122 _loading : { state : true } ,
123+ _disableCreate : { state : true } ,
122124 } ;
123125
124126 constructor ( ) {
@@ -156,6 +158,8 @@ class DaStart extends LitElement {
156158 goToNextStep ( e ) {
157159 this . showOpen = false ;
158160 this . showDone = false ;
161+ this . _errorText = undefined ;
162+ this . _disableCreate = undefined ;
159163 e . preventDefault ( ) ;
160164 this . activeStep = this . activeStep === 3 ? 1 : this . activeStep += 1 ;
161165 }
@@ -164,7 +168,15 @@ class DaStart extends LitElement {
164168 const { code, content } = this . _templates . find ( ( tpl ) => tpl . selected ) || this . _templates [ 0 ] ;
165169 const hasDemo = ! code . includes ( 'aem-boilerplate' ) ;
166170 if ( hasDemo ) {
167- e . target . disabled = true ;
171+ this . _disableCreate = true ;
172+
173+ const resp = await daFetch ( `${ DA_ORIGIN } /list/${ this . org } /${ this . site } ` ) ;
174+ const json = await resp . json ( ) ;
175+ if ( json . length > 0 ) {
176+ this . _errorText = 'The target site is not empty. Choose no demo content or a different site.' ;
177+ this . _disableCreate = undefined ;
178+ return ;
179+ }
168180
169181 const setStatus = ( text ) => { this . _statusText = text ; } ;
170182
@@ -288,8 +300,8 @@ class DaStart extends LitElement {
288300 ${ this . _loading ? html `< span class ="spinner "> </ span > ` : 'Go' }
289301 </ button >
290302 </ form >
303+ ${ this . _errorText ? html `< p class ="error-text "> ${ this . _errorText } </ p > ` : nothing }
291304 < div class ="text-container ">
292- < p class ="error-text "> ${ this . _errorText ? this . _errorText : nothing } </ p >
293305 < p > Paste your AEM codebase URL above.</ p >
294306 < p > Don't have one, yet? Pick a template below.</ p >
295307 </ div >
@@ -335,8 +347,9 @@ class DaStart extends LitElement {
335347 ` ) }
336348 </ ul >
337349 </ div >
350+ ${ this . _errorText ? html `< p class ="error-text "> ${ this . _errorText } </ p > ` : nothing }
338351 < div class ="step-3-actions ">
339- < button class ="da-login-button con-button blue button-xl " @click =${ this . goToSite } > ${ this . _goText } </ button >
352+ < button class ="da-login-button con-button blue button-xl " @click =${ this . goToSite } ?disabled = ${ this . _disableCreate } > ${ this . _goText } </ button >
340353 < p > ${ this . _statusText ? this . _statusText : nothing } </ p >
341354 </ div >
342355 </ div >
0 commit comments