Files
baserow/web-frontend/modules/core/components/Button.vue
Jérémie Pardou ad80341c03 feat: add Agent subject type (#5851)
* Add workspace Agents and permission management

* fix: remove all duplicate team subject memberships

* fix: align agent team role inheritance with users

* fix: delegate workspace role storage to subject types

* fix: preserve agent team memberships through trash

* Fix migration conflict

* fix: save agent settings pages independently

* fix: preserve agent roles across license changes

* fix: stabilize agent list pagination

* fix: filter agent websocket events by list permission

* fix: authorize agent team membership changes

* fix: serialize concurrent agent team updates

* fix: refresh agent teams through realtime events

* fix: restrict personal views to user subjects

* fix: deny agents with unavailable roles

* fix: exclude agents in trashed workspaces

* test: cover permanent agent access cleanup

* fix: gate agents in team selectors

* fix: accept trash option for preview actors

* fix: set native agent form button types

* fix: ignore stale agent modal saves

* fix: show permitted agent management actions

* fix: validate subject lookup fields

* perf: optimize batched user membership checks

* perf: cache agent team feature per list

* fix: map agent nonmember API errors

* fix: document paginated agent API schema

* fix: stabilize agent API schema operations

* fix: show agent name validation errors

* fix: show total agent count

* test: cover agent creation submissions

* test: cover agent and subject UI behavior

* docs: define direct subject role contracts

* fix: clarify team access management

* fix: use standard empty agents table

* fix: align agent name column styling

* refactor: move agent trash import

* refactor: align agent extension registry naming

* fix: recover agent team selector loading

* fix: validate every subject in role batches

* fix: ignore stale agent list responses

* perf: index recent team subjects

* fix: restore role handler imports

* Fix lint

* fix: reuse prefetched user memberships

* fix: preserve low priority role fallback

* fix: preserve trashed field permission subjects

* fix: open team picker when agent loading fails

* Fix tests
2026-09-21 16:32:32 +02:00

239 lines
5.7 KiB
Vue

<template>
<NuxtLink v-if="to" :to="to" class="button" :class="classes">
<i v-if="icon" class="button__icon" :class="icon" />
<span v-if="hasSlot" class="button__label"><slot></slot></span>
<i v-if="appendIcon" class="button__icon" :class="appendIcon" />
</NuxtLink>
<a
v-else-if="tag === 'a'"
class="button"
:class="classes"
v-bind="customBind"
>
<i v-if="icon" class="button__icon" :class="icon" />
<span v-if="hasSlot" class="button__label"><slot></slot></span>
<i v-if="appendIcon" class="button__icon" :class="appendIcon" />
</a>
<button
v-else
:type="buttonType"
class="button"
:class="classes"
:disabled="disabled || loading"
>
<i v-if="icon" class="button__icon" :class="icon" />
<span v-if="hasSlot" class="button__label"><slot></slot></span>
<i v-if="appendIcon" class="button__icon" :class="appendIcon" />
</button>
</template>
<script>
import { hasRealNodes } from '@baserow/modules/core/utils/dom.js'
import { getUrlScheme } from '@baserow/modules/core/utils/url'
export default {
name: 'Button',
props: {
/**
* The HTML tag to use for the button. Available tags are: a, button.
*/
tag: {
required: false,
type: String,
default: 'button',
validator(value) {
return ['a', 'button', 'nuxt-link'].includes(value)
},
},
/**
* The size of the button.
*/
size: {
required: false,
type: String,
default: 'regular',
validator(value) {
return ['small', 'regular', 'large', 'tiny', 'xlarge'].includes(value)
},
},
/**
* The type of the button. Available types are: primary, secondary, danger.
*/
type: {
required: false,
type: String,
default: 'primary',
validator(value) {
return ['primary', 'secondary', 'danger', 'upload', 'ghost'].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. It will be displayed before the button label.
*/
icon: {
required: false,
type: String,
default: '',
},
/**
* The icon of the button. It will be displayed after the button label.
*/
appendIcon: {
required: false,
type: String,
default: '',
},
/**
* Wether the button is loading or not.
*/
loading: {
required: false,
type: Boolean,
default: false,
},
/**
* Wether the button is active or not.
*/
active: {
required: false,
type: Boolean,
default: false,
},
/**
* Wether the button is disabled or not.
*/
disabled: {
required: false,
type: Boolean,
default: false,
},
/**
* Make the button full width.
*/
fullWidth: {
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)
},
},
/**
* If the button is a nuxt-link, this is the to attribute.
*/
to: {
type: Object,
required: false,
default: null,
},
/**
* If the button is a link, this is the download attribute.
*/
download: {
required: false,
type: String,
default: null,
},
prependIcon: {
required: false,
type: String,
default: '',
},
overflow: {
required: false,
type: Boolean,
default: false,
},
},
computed: {
hasSlot() {
const slot = this.$slots.default
return slot ? hasRealNodes(slot()) : false
},
classes() {
const hasIcon = this.prependIcon || this.appendIcon || this.icon
const classObj = {
[`button--${this.size}`]: this.size,
[`button--${this.type}`]: this.type,
'button--primary': !this.type,
'button--full-width': this.fullWidth,
'button--icon-only': hasIcon && !this.$slots.default,
'button--loading': this.loading,
'button--overflow': this.overflow,
'button--active': this.active,
}
return classObj
},
customBind() {
const attr = {}
if (this.tag === 'a') {
// Escape the href to prevent potential XSS attacks.
const scheme = getUrlScheme(this.href)
const isExecutable =
scheme && ['javascript:', 'vbscript:'].includes(scheme)
attr.href = isExecutable ? null : this.href
attr.target = this.target
attr.rel = this.rel
attr.download = this.download
}
Object.keys(attr).forEach((key) => {
if (attr[key] === null) {
delete attr[key]
}
})
return attr
},
},
methods: {
focus() {
this.$el.focus()
},
},
}
</script>