@@ -13,32 +13,32 @@ interface License extends LicenseInfo {
1313 formattedInstanceName : ComputedRef < string > ;
1414}
1515
16- const emptyLicense : License = {
17- edition : "" ,
18- expiration_date : "" ,
19- upgrade_protection_expiration : "" ,
20- license_type : "" ,
21- instance_name : "" ,
22- trial_license : true ,
23- registered_to : "" ,
24- status : "" ,
25- license_status : LicenseStatus . Unavailable ,
26- license_extension_url : "" ,
27- licenseEdition : computed ( ( ) => {
28- return `${ license . license_type } ${ license . edition ? `, ${ license . edition } ` : "" } ` ;
29- } ) ,
30- formattedInstanceName : computed ( ( ) => {
31- return license . instance_name || "Upgrade ServiceControl to v3.4.0+ to see more information about this license" ;
32- } ) ,
33- formattedExpirationDate : computed ( ( ) => {
34- return license . expiration_date ? new Date ( license . expiration_date . replace ( "Z" , "" ) ) . toLocaleDateString ( ) : "" ;
35- } ) ,
36- formattedUpgradeProtectionExpiration : computed ( ( ) => {
37- return license . upgrade_protection_expiration ? new Date ( license . upgrade_protection_expiration . replace ( "Z" , "" ) ) . toLocaleDateString ( ) : "" ;
38- } ) ,
39- } ;
40-
41- const license = reactive < License > ( emptyLicense ) ;
16+ class emptyLicense implements License {
17+ edition = "" ;
18+ expiration_date = "" ;
19+ upgrade_protection_expiration = "" ;
20+ license_type = "" ;
21+ instance_name = "" ;
22+ trial_license = true ;
23+ registered_to = "" ;
24+ status = "" ;
25+ license_status = LicenseStatus . Unavailable ;
26+ license_extension_url = "" ;
27+ licenseEdition = computed ( ( ) => {
28+ return `${ this . license_type } ${ this . edition ? `, ${ this . edition } ` : "" } ` ;
29+ } ) ;
30+ formattedInstanceName = computed ( ( ) => {
31+ return this . instance_name || "Upgrade ServiceControl to v3.4.0+ to see more information about this license" ;
32+ } ) ;
33+ formattedExpirationDate = computed ( ( ) => {
34+ return this . expiration_date ? new Date ( this . expiration_date . replace ( "Z" , "" ) ) . toLocaleDateString ( ) : "" ;
35+ } ) ;
36+ formattedUpgradeProtectionExpiration = computed ( ( ) => {
37+ return this . upgrade_protection_expiration ? new Date ( this . upgrade_protection_expiration . replace ( "Z" , "" ) ) . toLocaleDateString ( ) : "" ;
38+ } ) ;
39+ }
40+
41+ const license = reactive < License > ( new emptyLicense ( ) ) ;
4242
4343const licenseStatus = reactive ( {
4444 isSubscriptionLicense : false ,
@@ -64,6 +64,9 @@ function useLicense() {
6464
6565async function getOrUpdateLicenseStatus ( ) {
6666 const lic = await getLicense ( ) ;
67+ if ( lic === null ) {
68+ return ;
69+ }
6770 license . license_type = lic . license_type ;
6871 license . expiration_date = lic . expiration_date ;
6972 license . trial_license = lic . trial_license ;
@@ -152,6 +155,6 @@ async function getLicense() {
152155 return data ;
153156 } catch ( err ) {
154157 console . log ( err ) ;
155- return emptyLicense ;
158+ return null ;
156159 }
157160}
0 commit comments