mirror of
https://github.com/baserow/baserow.git
synced 2026-12-05 00:38:35 +00:00
* feat(agent): preview template Agents like the real page, with example conversations A template preview showed an Agent as a plain list. Official templates can now carry shared conversations as examples, which visitors read but an install never copies. * test: list the conversations a template preview may read * fix(agent): address template preview review findings Mark pending ask-first tools in the preview, keep user-template conversations private in the core template manager, drop tool steps from example conversations, and show load errors with a retry. * feat(agent): carry pinned shared conversations as examples in exports and templates Davide and Bram chose to export user-started, pinned and shared conversations in every export and template, import them as examples, and show them in user template previews too. * fix(agent): drop the official Agent template and show preview tools read-only The template would list an Agent to every instance while the Agent builder is behind its flag. Visitors can now open the tool groups without changing them. * fix(agent): keep example conversations read-only and skip broken ones on import A message sent to an installed example would leave with the next export, so examples take none. Pinning a shared conversation now says it becomes an example.
136 lines
4.3 KiB
Vue
136 lines
4.3 KiB
Vue
<template>
|
|
<section class="agent-actions" :aria-busy="loading">
|
|
<div class="agent-actions__header">
|
|
<h3>{{ $t('agent.actions') }}</h3>
|
|
<ButtonText
|
|
v-if="editable && availableTypes.length"
|
|
type="primary"
|
|
size="small"
|
|
button-type="button"
|
|
icon="iconoir-plus"
|
|
:disabled="loading || creating || atLimit"
|
|
:loading="creating"
|
|
aria-haspopup="menu"
|
|
@click="picker.toggle($event.currentTarget)"
|
|
>{{ $t('agent.addAction') }}</ButtonText
|
|
>
|
|
</div>
|
|
<p v-if="atLimit" class="agent-actions__limit">
|
|
{{ $t('agent.actionLimitReached', { limit: configuration.max_actions }) }}
|
|
</p>
|
|
<AgentCardListHeader
|
|
v-if="actions.length"
|
|
:all-expanded="allExpanded"
|
|
@toggle-all="toggleAll"
|
|
/>
|
|
<div v-if="loading && !actions.length" class="skeleton" aria-hidden="true">
|
|
<SkeletonBlock width="100%" height="120px" />
|
|
</div>
|
|
<Alert v-else-if="loadError" type="error">
|
|
{{ $t('agent.actionsLoadError') }}
|
|
<template #actions
|
|
><Button
|
|
type="secondary"
|
|
size="small"
|
|
button-type="button"
|
|
@click="fetchActions({ integrations: true })"
|
|
>{{ $t('action.retry') }}</Button
|
|
></template
|
|
>
|
|
</Alert>
|
|
<p v-else-if="!actions.length" class="agent-actions__empty">
|
|
{{ $t('agent.noActions') }}
|
|
</p>
|
|
<div v-else ref="list" class="agent-actions__list">
|
|
<AgentActionCard
|
|
v-for="action in actions"
|
|
:key="action.id"
|
|
:data-card-id="action.id"
|
|
:expanded="expandedIds.has(action.id)"
|
|
:action="action"
|
|
:type-options="actionTypes && (actionTypes[action.type] || {})"
|
|
:run-as-active="runAsActive"
|
|
:workspace="workspace"
|
|
:editable="editable"
|
|
:saving="savingIds.has(action.id)"
|
|
:save-error="saveErrors[action.id] || ''"
|
|
@toggle="toggle(action.id)"
|
|
@update="updateAction(action, $event)"
|
|
@delete="deleteAction(action)"
|
|
@retry="flush(action)"
|
|
/>
|
|
</div>
|
|
<AgentServicePicker
|
|
ref="picker"
|
|
:available-types="availableTypes"
|
|
:workspace="workspace"
|
|
:search-placeholder="$t('agent.searchActionTypes')"
|
|
:empty-text="$t('agent.noActionTypes')"
|
|
@select="addItem"
|
|
/>
|
|
</section>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { computed, inject, ref, watch } from 'vue'
|
|
import { useAgentCardList } from '@baserow/modules/agent/composables/useExpandedItems'
|
|
import { useStore } from 'vuex'
|
|
import ButtonText from '@baserow/modules/core/components/ButtonText'
|
|
import AgentCardListHeader from '@baserow/modules/agent/components/configuration/AgentCardListHeader'
|
|
import AgentActionCard from '@baserow/modules/agent/components/configuration/AgentActionCard'
|
|
import AgentServicePicker from '@baserow/modules/agent/components/configuration/AgentServicePicker'
|
|
import { useAgentActions } from '@baserow/modules/agent/composables/useAgentActions'
|
|
import { RUN_AS_STATUS } from '@baserow/modules/agent/constants'
|
|
import { getRunAsStatus } from '@baserow/modules/agent/utils/runAs'
|
|
|
|
defineOptions({ inheritAttrs: false })
|
|
const props = defineProps({
|
|
configuration: { type: Object, required: true },
|
|
editable: Boolean,
|
|
})
|
|
const emit = defineEmits(['reload'])
|
|
const store = useStore()
|
|
const agent = inject('agentApplication')
|
|
const templatePreview = inject('agentTemplatePreview', false)
|
|
const picker = ref(null)
|
|
const workspace = computed(() =>
|
|
agent.value ? store.getters['workspace/get'](agent.value.workspace.id) : null
|
|
)
|
|
const availableTypes = computed(
|
|
() => props.configuration.available_action_types || []
|
|
)
|
|
const runAsActive = computed(
|
|
() => getRunAsStatus(props.configuration.run_as) === RUN_AS_STATUS.ACTIVE
|
|
)
|
|
const {
|
|
actions,
|
|
actionTypes,
|
|
loading,
|
|
loadError,
|
|
allActions,
|
|
savingIds,
|
|
saveErrors,
|
|
fetchActions,
|
|
createAction,
|
|
updateAction,
|
|
deleteAction,
|
|
flush,
|
|
} = useAgentActions(
|
|
agent,
|
|
() => emit('reload'),
|
|
() => props.configuration.run_as,
|
|
{ loadTypes: !templatePreview }
|
|
)
|
|
const { expandedIds, allExpanded, toggle, toggleAll, list, creating, addItem } =
|
|
useAgentCardList(actions, createAction, allActions)
|
|
const atLimit = computed(
|
|
() =>
|
|
Boolean(props.configuration.max_actions) &&
|
|
allActions.value.length >= props.configuration.max_actions
|
|
)
|
|
watch(
|
|
() => agent.value?.id,
|
|
() => expandedIds.clear()
|
|
)
|
|
</script>
|