diff --git a/packages/builder/src/pages/builder/portal/settings/environment/index.svelte b/packages/builder/src/pages/builder/portal/settings/environment/index.svelte index e6876408fe..fbe5a675c9 100644 --- a/packages/builder/src/pages/builder/portal/settings/environment/index.svelte +++ b/packages/builder/src/pages/builder/portal/settings/environment/index.svelte @@ -93,7 +93,10 @@ diff --git a/packages/builder/src/stores/portal/environment.js b/packages/builder/src/stores/portal/environment.js index 03e73371b1..458eea27be 100644 --- a/packages/builder/src/stores/portal/environment.js +++ b/packages/builder/src/stores/portal/environment.js @@ -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, } } diff --git a/packages/frontend-core/src/api/events.js b/packages/frontend-core/src/api/events.js index e69de29bb2..3f17722d3e 100644 --- a/packages/frontend-core/src/api/events.js +++ b/packages/frontend-core/src/api/events.js @@ -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, + }, + }) + }, +}) diff --git a/packages/frontend-core/src/api/index.js b/packages/frontend-core/src/api/index.js index ca065776b2..e2935b416b 100644 --- a/packages/frontend-core/src/api/index.js +++ b/packages/frontend-core/src/api/index.js @@ -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), } } diff --git a/packages/frontend-core/src/constants.js b/packages/frontend-core/src/constants.js index ff9f4628d0..f2e48b6fef 100644 --- a/packages/frontend-core/src/constants.js +++ b/packages/frontend-core/src/constants.js @@ -174,3 +174,7 @@ export const Themes = [ base: "darkest", }, ] + +export const EventPublishType = { + ENV_VAR_UPGRADE_PANEL_OPENED: "environment_variable_upgrade_panel_opened", +} diff --git a/packages/worker/src/api/routes/index.ts b/packages/worker/src/api/routes/index.ts index f0d4911771..3aa9422238 100644 --- a/packages/worker/src/api/routes/index.ts +++ b/packages/worker/src/api/routes/index.ts @@ -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, ]