mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-07 00:01:49 +00:00
feat: add license key expiration warning on workers page (#7225)
* feat: add license key expiration warning on workers page - Add license expiration check for superadmins in enterprise mode - Show error toast if license is expired - Show warning toast if license expires within 7 days - Follows existing license parsing pattern from InstanceSetting.svelte Fixes #7224 Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> * nit * nit --------- Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: windmill-internal-app[bot] <windmill-internal-app[bot]@users.noreply.github.com> Co-authored-by: HugoCasa <hugo@casademont.ch>
This commit is contained in:
committed by
GitHub
co-authored by
windmill-internal-app[bot]
claude[bot]
HugoCasa
parent
b39c473892
commit
e2e7a8c292
@@ -112,6 +112,70 @@
|
||||
}
|
||||
}
|
||||
|
||||
function parseLicenseKey(key: string): {
|
||||
valid: boolean
|
||||
expiration?: Date
|
||||
} {
|
||||
let splitted = key.split('.')
|
||||
if (splitted.length >= 3) {
|
||||
try {
|
||||
let i = parseInt(splitted[1])
|
||||
let date = new Date(i * 1000)
|
||||
const stringDate = date.toLocaleDateString()
|
||||
if (stringDate !== 'Invalid Date') {
|
||||
return {
|
||||
valid: date.getTime() > Date.now(),
|
||||
expiration: date
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
return {
|
||||
valid: false
|
||||
}
|
||||
}
|
||||
|
||||
async function checkLicenseExpiration() {
|
||||
if (!$superadmin || !$enterpriseLicense) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const licenseKey = (await SettingService.getGlobal({
|
||||
key: 'license_key'
|
||||
})) as string
|
||||
|
||||
if (!licenseKey) {
|
||||
return
|
||||
}
|
||||
|
||||
const { valid, expiration } = parseLicenseKey(licenseKey)
|
||||
|
||||
if (!valid && expiration) {
|
||||
// License is expired
|
||||
sendUserToast(
|
||||
`Enterprise license key expired on ${expiration.toLocaleDateString()}. Please renew your license key to continue using Windmill.`,
|
||||
true
|
||||
)
|
||||
} else if (expiration) {
|
||||
// Check if expires within 7 days
|
||||
const daysUntilExpiration = Math.floor(
|
||||
(expiration.getTime() - Date.now()) / (1000 * 60 * 60 * 24)
|
||||
)
|
||||
|
||||
if (daysUntilExpiration <= 7 && daysUntilExpiration >= 0) {
|
||||
sendUserToast(
|
||||
`Enterprise license key expires in ${daysUntilExpiration} day${daysUntilExpiration !== 1 ? 's' : ''} on ${expiration.toLocaleDateString()}. Please renew your license key to continue using Windmill.`,
|
||||
true
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
// Silently fail - don't show errors for license check
|
||||
console.error('Failed to check license expiration:', err)
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
intervalId = setInterval(() => {
|
||||
loadWorkers()
|
||||
@@ -126,6 +190,7 @@
|
||||
loadWorkerGroups()
|
||||
loadCustomTags()
|
||||
$: ($superadmin || $devopsRole) && loadDefaultTagsPerWorkspace()
|
||||
$: $superadmin && $enterpriseLicense && checkLicenseExpiration()
|
||||
|
||||
onDestroy(() => {
|
||||
if (intervalId) {
|
||||
|
||||
Reference in New Issue
Block a user