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 `