Files
Peter EvansandJeremie Pardou d7e2c3f635 chore: remove core and WAB feature flags shipping in v3 (#6903)
* chore: remove core and WAB feature flags shipping in v3

* docs: drop stale feature flag mentions from invitation link comments

* docs: add missing changelogs for released core features

* docs: mark identities ADR as accepted

* chore: remove the identities feature flag

* docs: add changelog for workspace identities

* test: remove obsolete identity feature flag test

* docs: remove stale identities feature flag references

---------

Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
2026-12-01 16:01:14 +00:00

228 lines
7.1 KiB
Vue

<template>
<FormGroup
:label="$t('agent.runAs')"
:error="unavailable"
:error-message="errorMessage"
:helper-text="helperText"
small-label
required
>
<PaginatedDropdown
ref="runAsDropdown"
:value="selected"
:fetch-page="fetchIdentities"
:add-empty-item="false"
:initial-display-name="initialName"
:include-display-name-in-selected-event="true"
:disabled="!editable"
:error="unavailable"
:refresh-key="optionsVersion"
fetch-on-open
refresh-on-open
fixed-items
@input="select"
>
<template #items="{ results }">
<DropdownItem
:name="$t('agent.noWorkspaceAccess')"
:value="NO_WORKSPACE_ACCESS"
icon="iconoir-prohibition"
/>
<DropdownItem
v-for="identity in results"
:key="identity.id"
:name="identity.name"
:value="identity.id"
:icon="identityIconClass"
/>
</template>
<template v-if="canCreateIdentity" #footer="{ hide }">
<div class="select__footer">
<button
type="button"
class="select__footer-button"
@click="addIdentity(hide)"
>
<i class="iconoir-plus" aria-hidden="true"></i>
{{ $t('agent.addIdentity') }}
</button>
</div>
</template>
</PaginatedDropdown>
<ManageIdentityModal
v-if="canCreateIdentity"
ref="identityModal"
:workspace="workspace"
@saved="identityCreated"
/>
</FormGroup>
<AgentWorkspaceTools
class="margin-top-3"
:allowed-tools="configuredTools"
:ask-first-tools="configuredAskFirstTools"
:available-tools="configuration.available_tools"
:agent-name="agent.name"
:editable="editable && identityAvailable"
:viewable="showsPendingTools"
:disabled-reason="
identityAvailable || showsPendingTools
? ''
: $t('agent.toolsRequireIdentity')
"
@update="changeTools"
/>
</template>
<script setup>
import { computed, inject, onBeforeUnmount, ref, watch } from 'vue'
import { useStore } from 'vuex'
import ManageIdentityModal from '@baserow/modules/core/components/settings/identities/ManageIdentityModal'
import debounce from 'lodash/debounce'
import { useI18n } from 'vue-i18n'
import PaginatedDropdown from '@baserow/modules/core/components/PaginatedDropdown'
import AgentApplicationService from '@baserow/modules/agent/services/agentApplication'
import { getRunAsStatus } from '@baserow/modules/agent/utils/runAs'
import { UserSubjectType } from '@baserow/modules/core/subjectTypes'
import { RUN_AS_STATUS } from '@baserow/modules/agent/constants'
import AgentWorkspaceTools from '@baserow/modules/agent/components/configuration/AgentWorkspaceTools'
const NO_WORKSPACE_ACCESS = 'none'
defineOptions({ inheritAttrs: false })
const props = defineProps({
configuration: { type: Object, required: true },
editable: Boolean,
})
const emit = defineEmits(['change', 'flush'])
const { $client, $registry, $hasPermission } = useNuxtApp()
const { t } = useI18n()
const agent = inject('agentApplication')
const templatePreview = inject('agentTemplatePreview', false)
const runAsDropdown = ref(null)
const identityIconClass = computed(
() => $registry.get('subject', UserSubjectType.getType()).identityIconClass
)
const identityModal = ref(null)
const store = useStore()
const workspace = computed(() =>
store.getters['workspace/get'](agent.value.workspace.id)
)
const canCreateIdentity = computed(
() =>
props.editable &&
workspace.value &&
$hasPermission('identity.create', workspace.value, workspace.value.id)
)
function addIdentity(hide) {
hide()
identityModal.value.show()
}
function identityCreated(item) {
optionsVersion.value++
select({ value: item.id, item })
}
const status = computed(() => getRunAsStatus(props.configuration.run_as))
const identityAvailable = computed(() => status.value === RUN_AS_STATUS.ACTIVE)
// Intentionally unset access means tools are off. A broken selected identity
// keeps its settings visible so restoring or replacing it recovers the setup.
// A template preview shows the tools its Agent turns on once installed.
const showsPendingTools = computed(
() =>
templatePreview &&
status.value === RUN_AS_STATUS.UNSET &&
props.configuration.pending_tools?.length > 0
)
const configuredTools = computed(() => {
if (showsPendingTools.value) return props.configuration.pending_tools
return status.value === RUN_AS_STATUS.UNSET
? []
: props.configuration.allowed_tools
})
const configuredAskFirstTools = computed(() => {
if (showsPendingTools.value)
return props.configuration.pending_ask_first_tools ?? []
return status.value === RUN_AS_STATUS.UNSET
? []
: props.configuration.ask_first_tools
})
const unavailable = computed(() =>
[RUN_AS_STATUS.TRASHED, RUN_AS_STATUS.MISSING].includes(status.value)
)
const errorMessage = computed(() => {
if (status.value === RUN_AS_STATUS.TRASHED)
return t('agent.runAsTrashed', { name: props.configuration.run_as.name })
return status.value === RUN_AS_STATUS.MISSING ? t('agent.runAsMissing') : ''
})
const helperText = computed(() => {
if (unavailable.value) return ''
if (props.configuration.run_as) {
return t('agent.runAsHelper', { name: props.configuration.run_as.name })
}
// An imported agent turns on its tools when an identity is first picked.
if (showsPendingTools.value) return t('agent.templatePreviewIdentity')
const pending = props.configuration.pending_tools?.length ?? 0
return pending
? t('agent.pendingToolsHelper', { count: pending }, pending)
: t('agent.noWorkspaceAccessHelper')
})
const selected = computed(() => {
const runAs = props.configuration.run_as
return runAs ? runAs.id : NO_WORKSPACE_ACCESS
})
const initialName = computed(
() =>
props.configuration.run_as?.name ??
t(
status.value === RUN_AS_STATUS.MISSING
? 'agent.runAsMissingLabel'
: 'agent.noWorkspaceAccess'
)
)
const optionsVersion = ref(0)
const refreshOptions = debounce(() => ++optionsVersion.value, 100, {
maxWait: 500,
})
watch(() => agent.value?._?.runAsOptionsVersion, refreshOptions)
onBeforeUnmount(() => refreshOptions.cancel())
// Refresh the cached label after the dropdown receives its updated prop.
watch(initialName, () => runAsDropdown.value?.clear(), { flush: 'post' })
function fetchIdentities(page, search) {
return AgentApplicationService($client).getRunAsIdentities(
agent.value.id,
page,
search
)
}
function changeTools(tools) {
if (!props.editable || !identityAvailable.value) return
emit('change', tools)
emit('flush')
}
function select({ value, item }) {
if (value === selected.value && !unavailable.value) return
emit('change', {
run_as:
value === NO_WORKSPACE_ACCESS
? null
: {
type: UserSubjectType.getType(),
id: item.id,
name: item.name,
trashed: false,
status: RUN_AS_STATUS.ACTIVE,
},
...(value === NO_WORKSPACE_ACCESS || status.value === RUN_AS_STATUS.UNSET
? { allowed_tools: [] }
: {}),
})
emit('flush')
}
</script>