v0.1.0:24 — Keysat licensing service end-to-end
Daemon, StartOS wrapper, admin SPA, public buy/thank-you pages, discount codes, free-license redemption, Apply-discount UX, self-licensing, and v0.1.0 release notes.
This commit is contained in:
@@ -4,28 +4,29 @@
|
||||
// with `not_activated`, freeing up a seat for another install.
|
||||
|
||||
import { sdk } from '../sdk'
|
||||
import { store } from '../fileModels/store'
|
||||
import { adminCall, LICENSING_URL } from '../utils'
|
||||
|
||||
const input = sdk.InputSpec.of({
|
||||
machine_id: {
|
||||
type: 'text',
|
||||
const { InputSpec, Value } = sdk
|
||||
|
||||
const input = InputSpec.of({
|
||||
machine_id: Value.text({
|
||||
name: 'Machine ID',
|
||||
description: 'UUID of the machine to deactivate. Find via list-machines.',
|
||||
required: true,
|
||||
default: null,
|
||||
},
|
||||
reason: {
|
||||
type: 'text',
|
||||
}),
|
||||
reason: Value.text({
|
||||
name: 'Reason',
|
||||
description: 'Stored for audit. E.g., "laptop stolen", "support request".',
|
||||
required: false,
|
||||
default: null,
|
||||
},
|
||||
}),
|
||||
})
|
||||
|
||||
export const deactivateMachine = sdk.Action.withInput(
|
||||
'deactivateMachine',
|
||||
async ({ effects }) => ({
|
||||
'deactivate-machine',
|
||||
async () => ({
|
||||
name: 'Deactivate machine',
|
||||
description:
|
||||
'Force an install off a license. Frees up a seat and causes that ' +
|
||||
@@ -38,11 +39,13 @@ export const deactivateMachine = sdk.Action.withInput(
|
||||
visibility: 'enabled',
|
||||
}),
|
||||
input,
|
||||
async ({ effects, input: formInput }) => {
|
||||
const store = await sdk.store.getOwn(effects, sdk.StorePath).const()
|
||||
async () => null,
|
||||
async ({ effects: _effects, input: formInput }) => {
|
||||
const storeData = await store.read().once()
|
||||
if (!storeData) throw new Error('Store not initialized — restart the service.')
|
||||
const resp = await adminCall(
|
||||
LICENSING_URL,
|
||||
store.admin_api_key,
|
||||
storeData.admin_api_key,
|
||||
`/v1/admin/machines/${encodeURIComponent(formInput.machine_id)}/deactivate`,
|
||||
{
|
||||
method: 'POST',
|
||||
@@ -52,6 +55,11 @@ export const deactivateMachine = sdk.Action.withInput(
|
||||
if (!resp.ok) {
|
||||
throw new Error(`Deactivate failed: HTTP ${resp.status} — ${await resp.text()}`)
|
||||
}
|
||||
return { message: `Deactivated machine ${formInput.machine_id}.` }
|
||||
return {
|
||||
version: '1',
|
||||
title: 'Machine deactivated',
|
||||
message: `Deactivated machine ${formInput.machine_id}.`,
|
||||
result: null,
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user