@@ -125,10 +125,19 @@ class AccountManager extends window.StorageManager {
125125 //TODO show error
126126 return ;
127127 }
128+ let type = typeForm . value ,
129+ details ;
130+ if ( type === 'enterprise-preconfig' ) {
131+ type = 'enterprise' ;
132+ details = this . enterpriseInstance ;
133+ }
134+ else {
135+ details = this . getDetails ( type ) ;
136+ }
128137 browser . runtime . sendMessage ( {
129138 topic : "login" ,
130- type : typeForm . value ,
131- details : this . getDetails ( typeForm . value )
139+ type,
140+ details
132141 } ) . catch ( ( error ) => {
133142 this . showError ( error . message ) ;
134143 } ) ;
@@ -206,6 +215,19 @@ class AccountManager extends window.StorageManager {
206215 hideError ( ) {
207216 this . form . querySelector ( "#error" ) . hidden = true ;
208217 }
218+
219+ addEnterpriseInstance ( instanceConfig ) {
220+ if ( this . enterpriseInstance ) {
221+ document . getElementById ( 'enterprise-preconfigured' ) . remove ( ) ;
222+ }
223+ this . enterpriseInstance = instanceConfig ;
224+ const optgroup = document . createElement ( "optgroup" ) ;
225+ optgroup . label = instanceConfig . instanceURL ;
226+ optgroup . id = 'enterprise-preconfigured' ;
227+ const option = new Option ( browser . i18n . getMessage ( 'account_enterprise-preconfig' , instanceConfig . instanceURL ) , 'enterprise-preconfig' , true , true ) ;
228+ optgroup . appned ( option ) ;
229+ this . form . querySelector ( "select" ) . append ( optgroup ) ;
230+ }
209231}
210232
211233window . addEventListener ( "DOMContentLoaded" , ( ) => {
@@ -241,4 +263,12 @@ window.addEventListener("DOMContentLoaded", () => {
241263 }
242264 } )
243265 . catch ( console . error ) ;
266+
267+ browser . storage . managed . get ( 'enterprise' )
268+ . then ( ( result ) => {
269+ if ( result . enterprise ) {
270+ manager . addEnterpriseInstance ( result . enterprise ) ;
271+ }
272+ } )
273+ . catch ( console . error ) ;
244274} , PASSIVE_EVENT ) ;
0 commit comments