Support deleting license key from self host install
This commit is contained in:
parent
91e2747122
commit
9dc2eac580
|
@ -0,0 +1,31 @@
|
||||||
|
<script>
|
||||||
|
import { Modal, ModalContent, Body } from "@budibase/bbui"
|
||||||
|
|
||||||
|
let modal
|
||||||
|
|
||||||
|
export let onConfirm
|
||||||
|
|
||||||
|
export function show() {
|
||||||
|
modal.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
export function hide() {
|
||||||
|
modal.hide()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Modal bind:this={modal} on:hide={modal}>
|
||||||
|
<ModalContent
|
||||||
|
title="Confirm deletion"
|
||||||
|
size="S"
|
||||||
|
showCancelButton={true}
|
||||||
|
confirmText={"Confirm"}
|
||||||
|
{onConfirm}
|
||||||
|
>
|
||||||
|
<Body size="S">Are you sure you want to delete this license key?</Body>
|
||||||
|
<Body size="S">This license key cannot be re-activated.</Body>
|
||||||
|
</ModalContent>
|
||||||
|
</Modal>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
</style>
|
|
@ -9,7 +9,7 @@
|
||||||
Tags,
|
Tags,
|
||||||
notifications,
|
notifications,
|
||||||
} from "@budibase/bbui"
|
} from "@budibase/bbui"
|
||||||
import { groups, auth, licensing } from "stores/portal"
|
import { groups, auth, licensing, admin } from "stores/portal"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
import CreateEditGroupModal from "./_components/CreateEditGroupModal.svelte"
|
import CreateEditGroupModal from "./_components/CreateEditGroupModal.svelte"
|
||||||
import UserGroupsRow from "./_components/UserGroupsRow.svelte"
|
import UserGroupsRow from "./_components/UserGroupsRow.svelte"
|
||||||
|
@ -53,6 +53,8 @@
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
try {
|
try {
|
||||||
|
// always load latest
|
||||||
|
await licensing.init()
|
||||||
if ($licensing.groupsEnabled) {
|
if ($licensing.groupsEnabled) {
|
||||||
await groups.actions.init()
|
await groups.actions.init()
|
||||||
}
|
}
|
||||||
|
@ -77,7 +79,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<Body>Easily assign and manage your users access with User Groups</Body>
|
<Body>Easily assign and manage your users access with User Groups</Body>
|
||||||
{#if !$auth.accountPortalAccess}
|
{#if !$auth.accountPortalAccess && $admin.cloud}
|
||||||
<Body>Contact your account holder to upgrade</Body>
|
<Body>Contact your account holder to upgrade</Body>
|
||||||
{/if}
|
{/if}
|
||||||
</Layout>
|
</Layout>
|
||||||
|
@ -90,7 +92,7 @@
|
||||||
{:else}
|
{:else}
|
||||||
<Button
|
<Button
|
||||||
newStyles
|
newStyles
|
||||||
disabled={!$auth.accountPortalAccess}
|
disabled={!$auth.accountPortalAccess && $admin.cloud}
|
||||||
on:click={$licensing.goToUpgradePage()}
|
on:click={$licensing.goToUpgradePage()}
|
||||||
>
|
>
|
||||||
Upgrade
|
Upgrade
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
import { auth, admin } from "stores/portal"
|
import { auth, admin } from "stores/portal"
|
||||||
import { redirect } from "@roxi/routify"
|
import { redirect } from "@roxi/routify"
|
||||||
import { processStringSync } from "@budibase/string-templates"
|
import { processStringSync } from "@budibase/string-templates"
|
||||||
|
import DeleteLicenseKeyModal from "../../../../components/portal/licensing/DeleteLicenseKeyModal.svelte"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
|
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
let licenseKeyDisabled = false
|
let licenseKeyDisabled = false
|
||||||
let licenseKeyType = "text"
|
let licenseKeyType = "text"
|
||||||
let licenseKey = ""
|
let licenseKey = ""
|
||||||
|
let deleteLicenseKeyModal
|
||||||
|
|
||||||
// Make sure page can't be visited directly in cloud
|
// Make sure page can't be visited directly in cloud
|
||||||
$: {
|
$: {
|
||||||
|
@ -45,6 +47,20 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const destroy = async () => {
|
||||||
|
try {
|
||||||
|
await API.deleteLicenseKey({ licenseKey })
|
||||||
|
await auth.getSelf()
|
||||||
|
await setLicenseInfo()
|
||||||
|
// reset the form
|
||||||
|
licenseKey = ""
|
||||||
|
licenseKeyDisabled = false
|
||||||
|
notifications.success("Successfully deleted")
|
||||||
|
} catch (e) {
|
||||||
|
notifications.error(e.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const refresh = async () => {
|
const refresh = async () => {
|
||||||
try {
|
try {
|
||||||
await API.refreshLicense()
|
await API.refreshLicense()
|
||||||
|
@ -76,6 +92,10 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $auth.isAdmin}
|
{#if $auth.isAdmin}
|
||||||
|
<DeleteLicenseKeyModal
|
||||||
|
bind:this={deleteLicenseKeyModal}
|
||||||
|
onConfirm={destroy}
|
||||||
|
/>
|
||||||
<Layout noPadding>
|
<Layout noPadding>
|
||||||
<Layout gap="XS" noPadding>
|
<Layout gap="XS" noPadding>
|
||||||
<Heading size="M">Upgrade</Heading>
|
<Heading size="M">Upgrade</Heading>
|
||||||
|
@ -109,10 +129,19 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="button-container">
|
||||||
<Button cta on:click={activate} disabled={activateDisabled}
|
<div class="action-button">
|
||||||
>Activate</Button
|
<Button cta on:click={activate} disabled={activateDisabled}
|
||||||
>
|
>Activate</Button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="action-button">
|
||||||
|
{#if licenseInfo?.licenseKey}
|
||||||
|
<Button warning on:click={() => deleteLicenseKeyModal.show()}
|
||||||
|
>Delete</Button
|
||||||
|
>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
<Divider size="S" />
|
<Divider size="S" />
|
||||||
|
@ -152,4 +181,10 @@
|
||||||
grid-gap: var(--spacing-l);
|
grid-gap: var(--spacing-l);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
.action-button {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
.button-container {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -9,6 +9,15 @@ export const buildLicensingEndpoints = API => ({
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a self hosted license key
|
||||||
|
*/
|
||||||
|
deleteLicenseKey: async () => {
|
||||||
|
return API.delete({
|
||||||
|
url: `/api/global/license/info`,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the license info - metadata about the license including the
|
* Get the license info - metadata about the license including the
|
||||||
* obfuscated license key.
|
* obfuscated license key.
|
||||||
|
|
|
@ -24,6 +24,11 @@ export const getInfo = async (ctx: any) => {
|
||||||
ctx.status = 200
|
ctx.status = 200
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const deleteInfo = async (ctx: any) => {
|
||||||
|
await licensing.deleteLicenseInfo()
|
||||||
|
ctx.status = 200
|
||||||
|
}
|
||||||
|
|
||||||
export const getQuotaUsage = async (ctx: any) => {
|
export const getQuotaUsage = async (ctx: any) => {
|
||||||
ctx.body = await quotas.getQuotaUsage()
|
ctx.body = await quotas.getQuotaUsage()
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ router
|
||||||
.post("/api/global/license/activate", controller.activate)
|
.post("/api/global/license/activate", controller.activate)
|
||||||
.post("/api/global/license/refresh", controller.refresh)
|
.post("/api/global/license/refresh", controller.refresh)
|
||||||
.get("/api/global/license/info", controller.getInfo)
|
.get("/api/global/license/info", controller.getInfo)
|
||||||
|
.delete("/api/global/license/info", controller.deleteInfo)
|
||||||
.get("/api/global/license/usage", controller.getQuotaUsage)
|
.get("/api/global/license/usage", controller.getQuotaUsage)
|
||||||
|
|
||||||
export = router
|
export = router
|
||||||
|
|
Loading…
Reference in New Issue