Adding frontend event publishing for events like upgrade panel opened.
This commit is contained in:
parent
557a9a8eeb
commit
63d882efc6
|
@ -93,7 +93,10 @@
|
||||||
<Button
|
<Button
|
||||||
primary
|
primary
|
||||||
disabled={!$auth.accountPortalAccess && $admin.cloud}
|
disabled={!$auth.accountPortalAccess && $admin.cloud}
|
||||||
on:click={$licensing.goToUpgradePage()}
|
on:click={async () => {
|
||||||
|
await environment.upgradePanelOpened()
|
||||||
|
$licensing.goToUpgradePage()
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Upgrade
|
Upgrade
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { writable } from "svelte/store"
|
import { writable } from "svelte/store"
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
|
import { Constants } from "@budibase/frontend-core"
|
||||||
|
|
||||||
export function createEnvironmentStore() {
|
export function createEnvironmentStore() {
|
||||||
const { subscribe, update } = writable({
|
const { subscribe, update } = writable({
|
||||||
|
@ -47,6 +48,12 @@ export function createEnvironmentStore() {
|
||||||
await API.updateEnvironmentVariable(data)
|
await API.updateEnvironmentVariable(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function upgradePanelOpened() {
|
||||||
|
await API.publishEvent(
|
||||||
|
Constants.EventPublishType.ENV_VAR_UPGRADE_PANEL_OPENED
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
subscribe,
|
subscribe,
|
||||||
checkStatus,
|
checkStatus,
|
||||||
|
@ -54,6 +61,7 @@ export function createEnvironmentStore() {
|
||||||
createVariable,
|
createVariable,
|
||||||
deleteVariable,
|
deleteVariable,
|
||||||
updateVariable,
|
updateVariable,
|
||||||
|
upgradePanelOpened,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
export const buildEventEndpoints = API => ({
|
||||||
|
/**
|
||||||
|
* Publish a specific event to the backend.
|
||||||
|
*/
|
||||||
|
publishEvent: async eventType => {
|
||||||
|
return await API.post({
|
||||||
|
url: `/api/global/event/publish`,
|
||||||
|
body: {
|
||||||
|
type: eventType,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
|
@ -27,6 +27,7 @@ import { buildGroupsEndpoints } from "./groups"
|
||||||
import { buildPluginEndpoints } from "./plugins"
|
import { buildPluginEndpoints } from "./plugins"
|
||||||
import { buildBackupsEndpoints } from "./backups"
|
import { buildBackupsEndpoints } from "./backups"
|
||||||
import { buildEnvironmentVariableEndpoints } from "./environmentVariables"
|
import { buildEnvironmentVariableEndpoints } from "./environmentVariables"
|
||||||
|
import { buildEventEndpoints } from "./events"
|
||||||
const defaultAPIClientConfig = {
|
const defaultAPIClientConfig = {
|
||||||
/**
|
/**
|
||||||
* Certain definitions can't change at runtime for client apps, such as the
|
* Certain definitions can't change at runtime for client apps, such as the
|
||||||
|
@ -248,5 +249,6 @@ export const createAPIClient = config => {
|
||||||
...buildPluginEndpoints(API),
|
...buildPluginEndpoints(API),
|
||||||
...buildBackupsEndpoints(API),
|
...buildBackupsEndpoints(API),
|
||||||
...buildEnvironmentVariableEndpoints(API),
|
...buildEnvironmentVariableEndpoints(API),
|
||||||
|
...buildEventEndpoints(API),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,3 +174,7 @@ export const Themes = [
|
||||||
base: "darkest",
|
base: "darkest",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export const EventPublishType = {
|
||||||
|
ENV_VAR_UPGRADE_PANEL_OPENED: "environment_variable_upgrade_panel_opened",
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import templateRoutes from "./global/templates"
|
||||||
import emailRoutes from "./global/email"
|
import emailRoutes from "./global/email"
|
||||||
import authRoutes from "./global/auth"
|
import authRoutes from "./global/auth"
|
||||||
import roleRoutes from "./global/roles"
|
import roleRoutes from "./global/roles"
|
||||||
|
import eventRoutes from "./global/events"
|
||||||
import environmentRoutes from "./system/environment"
|
import environmentRoutes from "./system/environment"
|
||||||
import tenantsRoutes from "./system/tenants"
|
import tenantsRoutes from "./system/tenants"
|
||||||
import statusRoutes from "./system/status"
|
import statusRoutes from "./system/status"
|
||||||
|
@ -34,4 +35,5 @@ export const routes: Router[] = [
|
||||||
migrationRoutes,
|
migrationRoutes,
|
||||||
accountRoutes,
|
accountRoutes,
|
||||||
restoreRoutes,
|
restoreRoutes,
|
||||||
|
eventRoutes,
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue