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