mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* feat(agent): configure Agent instructions and model Adds the Agent settings fields, readiness and configuration endpoints, an autosaving configuration sidebar and the settings permission. Settings are copied with the Agent and exported only by members who can read them. * test(agent): share Agent page setup and mock helpers Both page specs reuse one setup and one-line route mocks, and API tests share an authenticated client. * fix(agent): lock parent before configuration updates * fix(agent): limit model availability checks to settings readers * refactor(agent): read Agent readiness from the application Readiness travels with the application payload instead of a separate readiness endpoint, so the page load and realtime updates keep it current. The configuration form also stays stable while editing. It no longer reloads on unrelated application updates, saves text fields on blur and selections on change, restores a blank name instead of blocking navigation, keeps the current Agent selected when the save before a switch fails, and ignores re-selecting the current provider. The export permission test now goes through ExportApplicationsActionType. * fix(agent): tighten the Agent configuration API The configuration endpoint now serves only instructions, provider and model behind agent_application.read_configuration, which saving also requires. Renames go through the standard application update, the views return their declared serializers, the length limits come from the model, and the endpoints are documented in the API schema. * fix(agent): rename through the application and fit the assistant panel The configuration sidebar renames the Agent through the regular application update, follows the Agent column width with container queries, offers Retry first without an empty actions row, keeps its focus outline on its own buttons, and names an unavailable provider. The first load starts on mount, and the specs mount with a route record and find fields by label. * fix(agent): keep configuration edits across token refreshes The page reset itself whenever a token refresh reassigned the user, because the watch compared a new array each time; it now watches the Agent and user ids by value. The configuration payload names its readiness `readiness`, like the application payload, and the redundant readiness tests are gone. * fix(agent): explain configuration section errors * fix(agent): address configuration review feedback * refactor(agent): reuse shared menu and button components * fix(agent): align sidebar separators and back control with design * fix(agent): match sidebar close control to design * Remove name input loading spinner and added newline * remove double validation --------- Co-authored-by: Bram Wiepjes <bramw@protonmail.com>
193 lines
4.7 KiB
Vue
193 lines
4.7 KiB
Vue
<template>
|
|
<a
|
|
v-if="tag === 'a' || href"
|
|
class="button-text"
|
|
:class="classes"
|
|
v-bind="customBind"
|
|
>
|
|
<i v-if="icon !== '' && !loading" class="button-text__icon" :class="icon" />
|
|
<img v-else-if="image" alt="" :src="image" class="button-text__image" />
|
|
<i v-if="loading" class="button-text__spinner"></i>
|
|
<span v-if="$slots.default" class="button-text__label"><slot /></span>
|
|
</a>
|
|
<button
|
|
v-else
|
|
class="button-text"
|
|
:class="classes"
|
|
:type="buttonType"
|
|
v-bind="customBind"
|
|
>
|
|
<i v-if="icon && !loading" class="button-text__icon" :class="icon" />
|
|
<img v-else-if="image" alt="" :src="image" class="button-text__image" />
|
|
<i v-if="loading" class="button-text__spinner"></i>
|
|
<span v-if="$slots.default" class="button-text__label"><slot /></span>
|
|
</button>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
name: 'ButtonText',
|
|
props: {
|
|
/**
|
|
* The tag to use for the root element.
|
|
*/
|
|
tag: {
|
|
required: false,
|
|
type: String,
|
|
default: 'button',
|
|
validator(value) {
|
|
return ['a', 'button'].includes(value)
|
|
},
|
|
},
|
|
/**
|
|
* The size of the button. Available sizes are `regular` and `small`.
|
|
*/
|
|
size: {
|
|
required: false,
|
|
type: String,
|
|
default: 'regular',
|
|
validator(value) {
|
|
return ['regular', 'small'].includes(value)
|
|
},
|
|
},
|
|
/**
|
|
* The type of the button. Available types are `primary` and `secondary`.
|
|
*/
|
|
type: {
|
|
required: false,
|
|
type: String,
|
|
default: 'primary',
|
|
validator(value) {
|
|
return ['primary', 'secondary'].includes(value)
|
|
},
|
|
},
|
|
/**
|
|
* The native type attribute when rendering a button element.
|
|
*/
|
|
buttonType: {
|
|
required: false,
|
|
type: String,
|
|
default: null,
|
|
validator(value) {
|
|
return ['button', 'submit', 'reset'].includes(value)
|
|
},
|
|
},
|
|
/**
|
|
* The icon of the button. Must be a valid iconoir or baserow icon class name.
|
|
*/
|
|
icon: {
|
|
required: false,
|
|
type: String,
|
|
default: '',
|
|
},
|
|
/**
|
|
* The image of the button. If no icon is provided, this image will be shown.
|
|
*/
|
|
image: {
|
|
required: false,
|
|
type: String,
|
|
default: null,
|
|
},
|
|
/**
|
|
* If true a loading icon will be shown.
|
|
*/
|
|
loading: {
|
|
required: false,
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
/**
|
|
* If true the button will be disabled.
|
|
*/
|
|
disabled: {
|
|
required: false,
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
/**
|
|
* If the button is a link, this is the href.
|
|
*/
|
|
href: {
|
|
required: false,
|
|
type: String,
|
|
default: null,
|
|
},
|
|
/**
|
|
* If the button is a link, this is the rel. Available values are: nofollow, noopener, noreferrer.
|
|
*/
|
|
rel: {
|
|
required: false,
|
|
type: String,
|
|
default: null,
|
|
validator(value) {
|
|
const validRelValues = ['nofollow', 'noopener', 'noreferrer']
|
|
const relValues = value.split(' ')
|
|
|
|
return relValues.every((relValue) => validRelValues.includes(relValue))
|
|
},
|
|
},
|
|
/**
|
|
* If the button is a link, this is the target. Available values are: _blank, _self, _parent, _top.
|
|
*/
|
|
target: {
|
|
required: false,
|
|
type: String,
|
|
default: null,
|
|
validator(value) {
|
|
return ['_blank', '_self', '_parent', '_top'].includes(value)
|
|
},
|
|
},
|
|
},
|
|
setup(props, { attrs }) {
|
|
const listeners = computed(() =>
|
|
Object.fromEntries(
|
|
Object.entries(attrs).filter(
|
|
([key, value]) =>
|
|
// keep only real listeners: onClick, onUpdate:modelValue, etc.
|
|
key.startsWith('on') && typeof value === 'function'
|
|
)
|
|
)
|
|
)
|
|
|
|
return { listeners, attrs }
|
|
},
|
|
computed: {
|
|
classes() {
|
|
const classObj = {
|
|
[`button-text--${this.size}`]: this.size !== 'regular',
|
|
[`button-text--${this.type}`]: this.type !== 'primary',
|
|
'button-text--loading': this.loading,
|
|
'button-text--disabled': this.disabled && !this.loading,
|
|
}
|
|
return classObj
|
|
},
|
|
customBind() {
|
|
const attr = {}
|
|
|
|
// Only add disabled attribute for button elements, not for links
|
|
// And only add it if it's actually true (not false)
|
|
if (
|
|
(this.tag === 'button' || !this.href) &&
|
|
(this.disabled || this.loading)
|
|
) {
|
|
attr.disabled = true
|
|
}
|
|
|
|
if (this.tag === 'a') {
|
|
attr.href = this.href
|
|
attr.target = this.target
|
|
attr.rel = this.rel
|
|
}
|
|
|
|
Object.keys(attr).forEach((key) => {
|
|
if (attr[key] === null) {
|
|
delete attr[key]
|
|
}
|
|
})
|
|
|
|
return attr
|
|
},
|
|
},
|
|
}
|
|
</script>
|