@@ -13,32 +13,32 @@ interface License extends LicenseInfo {
13
13
formattedInstanceName : ComputedRef < string > ;
14
14
}
15
15
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 ( ) ) ;
42
42
43
43
const licenseStatus = reactive ( {
44
44
isSubscriptionLicense : false ,
@@ -64,6 +64,9 @@ function useLicense() {
64
64
65
65
async function getOrUpdateLicenseStatus ( ) {
66
66
const lic = await getLicense ( ) ;
67
+ if ( lic === null ) {
68
+ return ;
69
+ }
67
70
license . license_type = lic . license_type ;
68
71
license . expiration_date = lic . expiration_date ;
69
72
license . trial_license = lic . trial_license ;
@@ -152,6 +155,6 @@ async function getLicense() {
152
155
return data ;
153
156
} catch ( err ) {
154
157
console . log ( err ) ;
155
- return emptyLicense ;
158
+ return null ;
156
159
}
157
160
}
0 commit comments