Files
Tsering PaljorandJeremie Pardou 250748c8dc feat: Workspace level integrations (#6547)
* Add ADR-013 for workspace level integrations

* Add implementation

* Improve context section and remove technical points

* Move bulk replacement point to v2

* Remove workspace-level ownership on import since manual promotion should handle this.

* Add a glossary section

* Do Lazy creation + Celery migration

* Remove demotion

* Tighten the Options considered section

* Add Decision describing where the integrations are managed

* Update implementation plan after changes to ADR

* Sync plan and adr

* Rename adr and implementation

* Add the shared application that owns workspace integrations

* Create the shared application of every workspace

* Let only workspace admins manage workspace integrations

* Let applications use the integrations of their workspace.

* Trash workspace integrations in their workspace.

* Copy workspace integrations into exports and keep them in duplicates.

* Workspace admins can share integrations with every application in the workspace.

* Load the shared application of each workspace in the frontend and keep it out of application lists.

* Manage workspace integrations from an Integrations page in workspace settings.

* Offer workspace integrations in the integration dropdowns of every application.

* Move promoted integrations to the workspace list in other open tabs.

* Let admins make an app's integration available to the whole workspace from its integration settings.

* Preselect a workspace integration for new nodes and data sources when the app has none of its own.

* fix tests

* Delete implementation file

* More fixes after rebase

* Fix tests

* Let builders of an application see and use the workspace integrations from it.

* Show the workspace integrations, read-only, in the integration settings of applications.

* Keep a dashboard's integration out of promotion to the workspace.

* Leave the shared applications out of the admin dashboard's application count.

* Create the shared application of the workspaces made by the fill commands.

* Say in the promotion modal that an integration nobody authorized will run as the promoting admin.

* Say in the promotion modal that undoing it won't make the integration run as the previous person again.

* Ignore integration ids in sample data when publishing copies the workspace integrations an app uses.

* Let only undoing a promotion move an integration out of the workspace.

* Let the shared application backfill stop itself after 5 minutes and skip workspaces another transaction has locked.

* Say in the workspace integrations settings that published applications and workflows keep their own copy until they're published again.

* Leave the shared application out of the assistant evals' application counts.

* Refresh the workspace integrations when the Builder's data, events, users and integrations panels open.

* Say that anything new using a promoted integration blocks undoing the promotion, even from its own application.

* Warn when a database button sends through a workspace integration with no host or token.

* Refuse roles and invitations on the shared application.

* Fix tests

* Show an application only the workspace integrations of types it can use.

* Say in the promotion modal what builders of other applications can do as the integration.

* Leave the shared application type out of the API docs for creating and updating applications.

* Check who receives a workspace integration event in one permission call.

* Say which workspaces have a shared application and who creates it.

* Let a redone promotion record what uses the integration again.

* Update docstrings

* Stop template visitors from listing the integrations of the template's workspace.

* Let database buttons find their own copy of a workspace integration after an import.

* Say what holds the workspace row lock while a shared application is created.

* Fix tests

* Stop the workspace integration form component from being made reactive.

* Make test runs use a new copy of the workflow after an integration it uses changes.

* Hide the Members settings tab from members who can't list the workspace members.

* Add changelog

* Fix migration conflict

* Fix migration conflict

* Fix test

* Update comments and ADR number

* Link to the workspace integrations from the sidebar's Settings menu.

* fix: refresh agent action errors when workspace integrations change

* fix: move workspace integrations into workspace settings

* fix: use share icon for workspace integration promotion

* refactor: use explicit shared application relations

* feat: centralize default integration selection

* refactor: share integration change notifications

* refactor: prepare integration mappings before import

* refactor: collect integration references during export

* refactor: prepare integration ownership changes without a new hook

* test: restore registered service model after mocking

* test: cover shared integration defaults in Builder

* test: include Slack in Agent workspace integration choices

* Fix migrations

* Stop template visitors from listing the workspace integrations through an application of the template.

* Only offer integrations of the user source's integration type when updating a user source.

* Say the workspace integration copy means published Application Builder apps and automation workflows.

* Use the same spacing under both integration settings sections and enlarge their headings.

* Keep the shared application out of automatic snapshot schedules.

* Fix test after rebase

---------

Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
2026-11-27 15:49:32 +04:00

254 lines
7.5 KiB
Vue

<template>
<div>
<div class="event__header">
<div class="event__header-left">
<div class="event__label">
{{ event.label }}
</div>
<div
v-if="workflowActions.length"
class="margin-left-1 event__amount-actions"
>
{{ workflowActions.length }}
</div>
</div>
<ButtonText
ref="addWorkflowActionButton"
type="secondary"
icon="iconoir-plus"
:loading="addingAction"
@click="
$refs.workflowActionAddContext.show(
$refs.addWorkflowActionButton.$el,
'bottom',
'right'
)
"
>
{{ $t('event.addAction') }}
</ButtonText>
<Context
ref="workflowActionAddContext"
class="event__add-action-context"
:hide-on-click-outside="true"
max-height-if-outside-viewport
>
<GroupedMenu
:items="workflowActionMenuGroups"
:search-placeholder="$t('event.searchActions')"
:empty-text="$t('event.noActionsFound')"
@select="onWorkflowActionMenuItemSelected"
@disabled-click="onWorkflowActionMenuItemSelected"
@close="$refs.workflowActionAddContext.hide()"
/>
<template
v-for="workflowActionType in availableWorkflowActionTypes"
:key="workflowActionType.getType()"
>
<component
:is="getDeactivatedClickModal(workflowActionType)[0]"
v-if="getDeactivatedClickModal(workflowActionType) !== null"
:ref="`deactivatedClickModal_${workflowActionType.getType()}`"
v-bind="getDeactivatedClickModal(workflowActionType)[1]"
:name="workflowActionType.label"
:workspace="workspace"
/>
</template>
</Context>
</div>
<div>
<!--
By setting the WorkflowAction 'key' property to '$id_$order_$workflow.length'
we ensure that the component is re-rendered once that value changes.
This value will change after an action is ordered, thus triggering the
rendering engine, which can be useful when we want instant visual
feedback.
One example would be to highlight expressions that become invalid after
action ordering.
-->
<WorkflowAction
v-for="(workflowAction, index) in workflowActions"
:key="`${workflowAction.id}_${workflowAction.order}_${workflowActions.length}`"
v-sortable="{
id: workflowAction.id,
handle: '[data-sortable-handle]',
update: orderWorkflowActions,
enabled: $hasPermission(
'builder.page.element.update',
element,
workspace.id
),
}"
:expanded="expanded[workflowAction.id]"
:class="{ 'event__workflow-action--first': index === 0 }"
:element="element"
:available-workflow-action-types="availableWorkflowActionTypes"
:workflow-action="workflowAction"
:workflow-action-index="index"
:application-context-additions="{ workflowAction }"
@toggle="onToggle(workflowAction)"
@delete="deleteWorkflowAction(workflowAction)"
/>
</div>
</div>
</template>
<script>
import { mapActions } from 'vuex'
import { Event } from '@baserow/modules/builder/eventTypes'
import WorkflowAction from '@baserow/modules/builder/components/event/WorkflowAction'
import GroupedMenu from '@baserow/modules/core/components/GroupedMenu'
import applicationContext from '@baserow/modules/builder/mixins/applicationContext'
import { notifyIf } from '@baserow/modules/core/utils/error'
export default {
name: 'Event',
components: { GroupedMenu, WorkflowAction },
mixins: [applicationContext],
inject: ['workspace', 'builder', 'elementPage'],
props: {
event: {
type: Event,
required: true,
},
element: {
type: Object,
required: true,
},
workflowActions: {
type: Array,
required: false,
default: () => [],
},
availableWorkflowActionTypes: {
type: Array,
required: true,
},
},
data() {
return {
addingAction: false,
expanded: {},
}
},
computed: {
workflowActionMenuGroups() {
const groups = new Map()
this.availableWorkflowActionTypes.forEach((workflowActionType) => {
const group = workflowActionType.group
if (!groups.has(group.id)) {
groups.set(group.id, { ...group, children: [] })
}
groups.get(group.id).children.push({
id: `workflow-action-${workflowActionType.getType()}`,
label: workflowActionType.label,
value: workflowActionType.getType(),
icon: workflowActionType.icon,
iconColor: workflowActionType.iconColor,
image: workflowActionType.image,
description: workflowActionType.description,
disabled: workflowActionType.isDeactivated({
workspace: this.workspace,
}),
disabledReason: workflowActionType.isDeactivatedReason({
workspace: this.workspace,
}),
meta: workflowActionType,
})
})
return Array.from(groups.values())
},
},
async mounted() {
try {
await Promise.all([
this.actionFetchIntegrations({
application: this.builder,
}),
])
} catch (error) {
notifyIf(error)
}
},
methods: {
...mapActions({
actionFetchIntegrations: 'integration/fetchUsable',
actionCreateWorkflowAction: 'builderWorkflowAction/create',
actionDeleteWorkflowAction: 'builderWorkflowAction/delete',
actionOrderWorkflowActions: 'builderWorkflowAction/order',
}),
/*
We keep the expanded state at the event level because of the :key it's not working
as expected
*/
onToggle(workflow) {
this.expanded = {
...this.expanded,
[workflow.id]: !this.expanded[workflow.id],
}
},
onWorkflowActionMenuItemSelected(item) {
this.addWorkflowAction(item.meta)
},
async addWorkflowAction(workflowActionType) {
if (workflowActionType.isDeactivated({ workspace: this.workspace })) {
const deactivatedClickModal =
this.getDeactivatedClickModal(workflowActionType)
if (deactivatedClickModal !== null) {
this.$refs[
`deactivatedClickModal_${workflowActionType.getType()}`
][0].show()
}
return
}
this.addingAction = true
this.$refs.workflowActionAddContext.hide()
try {
await this.actionCreateWorkflowAction({
page: this.elementPage,
workflowActionType: workflowActionType.getType(),
eventType: this.event.name,
configuration: {
element_id: this.element.id,
},
})
} catch (error) {
notifyIf(error)
}
this.addingAction = false
},
async deleteWorkflowAction(workflowAction) {
try {
await this.actionDeleteWorkflowAction({
page: this.elementPage,
workflowAction,
})
} catch (error) {
notifyIf(error)
}
},
async orderWorkflowActions(order) {
try {
await this.actionOrderWorkflowActions({
page: this.elementPage,
element: this.element,
order,
})
} catch (error) {
notifyIf(error)
}
},
getDeactivatedClickModal(workflowActionType) {
return workflowActionType.getDeactivatedClickModal({
workspace: this.workspace,
})
},
},
}
</script>