Skip to content

Commit

Permalink
feat: assert activation integrity method
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Jun 18, 2024
1 parent 3505c17 commit b477a0e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@kirby-tools/licensing",
"type": "module",
"version": "0.1.10",
"packageManager": "pnpm@9.3.0",
"packageManager": "pnpm@9.4.0",
"description": "Shared tooling for licensing in the Panel",
"author": "Johann Schopplich <hello@johannschopplich.com>",
"license": "AGPL-3.0-or-later",
Expand Down Expand Up @@ -32,7 +32,8 @@
"release": "bumpp"
},
"dependencies": {
"kirbyuse": "^0.4.1"
"kirbyuse": "^0.4.1",
"vue": "^2.7.16"
},
"devDependencies": {
"@antfu/eslint-config": "^2.21.1",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion src/license.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useApi, usePanel } from 'kirbyuse'
import { nextTick, useApi, usePanel } from 'kirbyuse'
import type { Ref } from 'vue'
import { t } from './utils'

const LOCALHOST_HOSTNAMES = ['localhost', '127.0.0.1', '[::1]']
Expand Down Expand Up @@ -98,8 +99,27 @@ export function useLicense({
})
}

const assertActivationIntegrity = async ({ templateRef, license }: {
templateRef: Ref<HTMLElement | null | undefined>
license: boolean | string
}) => {
if (license !== false) {
return true
}

await nextTick()

if (!templateRef.value) {
panel.notification.error('No license key found, but licensing action buttons are missing')
return false
}

return true
}

return {
isLocalhost,
assertActivationIntegrity,
openLicenseModal,
}
}
Expand Down

0 comments on commit b477a0e

Please sign in to comment.