import { Registerable } from '@baserow/modules/core/registry' /** * The name plugin might be a bit confusing because you also have Nuxt plugins, but * this is not the same. A plugin can contain hooks for certain events such as when * a user account is created. */ export class BaserowPlugin extends Registerable { constructor(...args) { super(...args) this.type = this.getType() } /** * Hook that is called when a user creates a new account. This can for example be * used for submitting an analytical event. */ userCreated(user, context) {} /** * Hook that is called when the initial workspace is created for a user. This happens * when the user cancels the onboarding, for example. */ initialWorkspaceCreated(workspace) {} /** * Every registered plugin can have a component that's rendered at the top of the * left sidebar. */ getImpersonateComponent() { return null } /** * Every registered plugin can have a component displaying a badge with the highest license type */ getHighestLicenseTypeBadge() { return null } /** * Every registered plugin can display an additional item in the sidebar within * the workspace context. */ getSidebarWorkspaceComponents(workspace) { return null } /** * Return additional items for the Settings or Help menu in the workspace sidebar. */ getSidebarWorkspaceMenuComponents(workspace, menu) { return [] } /** * Every registered plugin can display additional items in the sidebar menu that * is shown on pages without a workspace context, like the all workspaces page. */ getSidebarAllWorkspacesComponents() { return [] } /** * Every registered plugin can display components after the "Add filter" links of * a Local Baserow service's filter form. The form's host provides * `serviceFilterTarget` (a computed `{ kind, id }`) identifying the data source or * node, and `serviceFilters` to check for unsaved filter changes. The filter form * provides `serviceFilterForm` to freeze the filters. */ getServiceFilterFooterComponents() { return [] } /** * Every registered plugin can display an additional item in the right sidebar within * the workspace context. */ getRightSidebarWorkspaceComponents(workspace) { return null } /** * Every registered plugin can display additional items in the user context menu. */ getUserContextComponents() { return null } /* * Every registered plugin can display a component in the links section of the * dashboard sidebar. */ getDashboardResourceLinksComponent() { return null } /* * Every registered plugin can display components at the top of the workspace * homepage, above the resources. They are given the selected workspace. */ getDashboardTopComponents(workspace) { return [] } /* * Every registered plugin can display a plan badge on the workspace homepage, * directly after the "Overview" title. The component receives the `workspace` and * the `componentArguments` fetched by `fetchAsyncDashboardData`. */ getDashboardWorkspacePlanBadge() { return null } getDashboardWorkspaceRowUsageComponent() { return null } /** * Every registered plugin can display multiple components in the header of * each workspace box on the all workspaces page, directly after the workspace * name. The components receive the `workspace` and the `componentArguments` * fetched by `fetchAsyncDashboardData`. * @returns {*[]} */ getAllWorkspacesWorkspaceBadgeComponents(workspace) { return [] } /** * Every registered plugin can display multiple components at the end of the * meta line (member and item count) of each workspace box on the all * workspaces page. The components receive the `workspace` and the * `componentArguments` fetched by `fetchAsyncDashboardData`. * @returns {*[]} */ getAllWorkspacesWorkspaceMetaComponents(workspace) { return [] } /** * Because the dashboard could contain dynamic `getDashboardWorkspaceComponent` and * `getDashboardWorkspaceExtraComponent` components, it could be that additional data * must be fetched from the backend when the page first loads. This method can be * overwritten to do that. * * Optionally, a workspace id can be provided to fetch only data for a particular * workspace. The all workspaces page calls it without a workspace id, so the * data of all workspaces must then be returned. */ fetchAsyncDashboardData(context, workspaceId) { return null } /** * Tells core Baserow how new fetched data for a particular workspace * should be merged with previously fetched dashboard data from * fetchAsyncDashboardData() */ mergeDashboardData(data, newData) { return data } /** * Every registered plugin can display a component in the `AuthRegister` component * directly at the bottom of the form. This component can be used to extend the * register functionality. */ getRegisterComponent() { return null } /** * Every registered plugin can display a component in the `app.vue` layout. This * is the root component that's being used for every authenticated page in the app. */ getAppLayoutComponent() { return null } /** * Every registered plugin can display multiple additional public share link options * which will be visible on the share public view context. */ getAdditionalShareLinkOptions() { return [] } /** * Every registered plugin can display multiple additional options in the share * dashboard context, below the public link of the dashboard. */ getAdditionalDashboardShareLinkOptions() { return [] } /** * Every registered plugin can display multiple components to the head of the table * header. This will be positioned directly next to the name of the view. */ getAdditionalTableHeaderComponents(view, isPublic) { return [] } /** * Every registered plugin can inject additional `context__menu-item` * components into the shared three dots menu that's shown on publicly shared * views. */ getAdditionalPublicViewMenuItems(view) { return [] } /** * Every registered plugin can display multiple additional items in the context * menu of a workspace, and in the Settings menu of the workspace in the sidebar. * Like the components of `getSidebarWorkspaceMenuComponents`, they render their * own `
  • `, receive the workspace as `workspace` * prop, and emit `hide` to close the menu. * @returns {*[]} */ getAdditionalWorkspaceContextComponents(workspace) { return [] } /** * Every registered plugin can display multiple additional context items in the * application context displayed by the sidebar when opening the context menu of * an application. * @returns {*[]} */ getAdditionalApplicationContextComponents(workspace, application) { return [] } /** * Every registered plugin can display multiple additional context items in the * context menu of an application child item. * @returns {*[]} */ getAdditionalApplicationChildContextComponents(workspace, application, item) { return [] } /** * Every registered plugin can display multiple additional context menu items in the * view context menu displayed at the top bar (three dots menu) in the View view. * @returns {*[]} */ getAdditionalViewContextComponents(workspace, table, view) { return [] } /** * Every registered plugin can display multiple additional components in the * automation editor header, positioned directly after the built-in header items. * This can for example be used to warn the user about automation usage limits. * @returns {*[]} */ getAutomationHeaderComponents(workspace) { return [] } /** * Every registered plugin can display multiple additional components in each * workflow history run entry. * @returns {*[]} */ getWorkflowHistoryComponents(workflowHistory) { return [] } /** * Components showing the AI usage (e.g. cost) of an agent reply or a job that * generated AI field values. They receive the item's `plugin_data` as * `pluginData` prop. * @returns {*[]} */ getAIUsageComponents() { return [] } /** * Every registered plugin can display multiple additional components next to * node names in the automation workflow node creation/replacement context. * @returns {*[]} */ getAutomationWorkflowNodeContextComponents({ workflow, automation, node, nodeType, }) { return [] } /** * Every registered plugin can display multiple additional components next to * the action type names in the button field action type dropdown. * @returns {*[]} */ getButtonFieldActionTypeContextComponents({ workspace, actionType }) { return [] } /** * Every registered plugin can display multiple additional components next to * the heading of the button field action list. * @returns {*[]} */ getButtonFieldActionListHeadingComponents({ workspace }) { return [] } /** * Provides additional icons before 'standard' icons in the field header in a * grid view. * * @param workspace * @param view * @param field * @returns {*[]} */ getGridViewFieldTypeIconsBefore(workspace, view, field) { return [] } /** * If set, `getExtraSnapshotModalComponents` will allow plugins to decide what kind of * copy is shown under the snapshots modal's "Take a snapshot now" title. Every * component receives the `application` prop. */ getExtraSnapshotModalComponents(workspace, application) { return null } /** * Components shown in the snapshots modal, above the form to create a snapshot. * Every component receives the `application` prop. */ getSnapshotModalComponents(workspace, application) { return [] } /** * Components shown at the bottom of the Snapshots page of the workspace settings. * Every component receives the `workspace` prop and the `snapshotSettings` prop, * which is `null` when the snapshot settings couldn't be loaded. */ getWorkspaceSnapshotSettingsComponents(workspace) { return [] } /** * If set, `getExtraExportWorkspaceModalComponents` will allow plugins to decide what kind of * copy is shown in the export workspace modal's Alert box. */ getExtraExportWorkspaceModalComponents(workspace) { return null } /** * If set, `getExtraImportWorkspaceModalComponents` will allow plugins to decide what kind of * copy is shown in the import workspace modal's Alert box. */ getExtraImportWorkspaceModalComponents(workspace) { return null } /** * Whether the user can create, in the workspace, an identity that has access to * only some of its applications, and make an application act as it. A template * install or an import then creates the identities that come with it. * @returns {boolean} */ canCreateScopedIdentities(workspace) { return false } /** * Some features are optionally enabled, this function will be called when the * $hasFeature directive is called on each plugin to check if any of the plugins * enable the particular feature. * @returns {boolean} */ hasFeature(feature, forSpecificWorkspace) { return false } /** * Can return components that will be added to the admin instance settings page. */ getSettingsPageComponents() { return [] } /** * Can overwrite the help component shown on the dashboard page. Note that it can * only show one component, so if any plugin sets one, the original one will be * hidden, and those will be shown. */ getDashboardHelpComponents() { return [] } /** * Overwrite the logo component everywhere. If there are multiple plugins * providing a logo, then the one with the highest `getLogoComponentOrder` will be * used because we can only show one. */ getLogoComponent() { return null } /** * If multiple logo components are returned, then the one with the highest order * will be placed. */ getLogoComponentOrder() { return 50 } /* Allow plugins to add scripts in the head section of a builder application */ getBuilderApplicationHeaderAddition({ builder, mode }) { return {} } /** * Whether the plugin adds code written by the application's editors to every * page of a builder application, such as custom JavaScript. Preview tells the * editor when that code is restricted there. */ hasBuilderAuthorCode({ builder }) { return false } }