mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
* fix: restrict editor-written code in the builder editor and on the editor hostname * fix: simplify builder author code restrictions by hostname * refactor: remove redundant backend custom code hostname checks * refactor: unify builder HTML element rendering restrictions * refactor: clarify builder web frontend hostname terminology * fix: distinguish untrusted builder content in preview notices * refactor: remove unused backend preview security setting * docs: shorten builder code restriction changelog * fix: restrict iframe cookie access across frontend ports * refactor: share web frontend hostname matching * fix: preserve protected HTML interactions and bound iframe height --------- Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
97 lines
3.0 KiB
JavaScript
97 lines
3.0 KiB
JavaScript
import { resolveColor } from '@baserow/modules/core/utils/colors'
|
|
import applicationContextMixin from '@baserow/modules/builder/mixins/applicationContext'
|
|
import resolveFormulaMixin from '@baserow/modules/builder/mixins/resolveFormula'
|
|
import { ThemeConfigBlockType } from '@baserow/modules/builder/themeConfigBlockTypes'
|
|
|
|
export default {
|
|
inject: ['workspace', 'builder', 'currentPage', 'elementPage', 'mode'],
|
|
mixins: [applicationContextMixin, resolveFormulaMixin],
|
|
props: {
|
|
element: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
},
|
|
computed: {
|
|
workflowActionsInProgress() {
|
|
const workflowActions = this.$store.getters[
|
|
'builderWorkflowAction/getElementWorkflowActions'
|
|
](this.elementPage, this.element.id)
|
|
const dispatchedById = this.elementType.uniqueElementId({
|
|
element: this.element,
|
|
applicationContext: this.applicationContext,
|
|
})
|
|
return workflowActions.some((workflowAction) =>
|
|
this.$store.getters['builderWorkflowAction/getDispatching'](
|
|
workflowAction,
|
|
dispatchedById
|
|
)
|
|
)
|
|
},
|
|
elementType() {
|
|
return this.$registry.get('element', this.element.type)
|
|
},
|
|
isEditMode() {
|
|
return this.mode === 'editing'
|
|
},
|
|
/**
|
|
* Restrict author code according to the hostname serving this page.
|
|
*/
|
|
isAuthorCodeRestricted() {
|
|
return this.$isAuthorCodeRestricted()
|
|
},
|
|
/**
|
|
* The editor's hint for an element that holds author code. Preview only
|
|
* shows such an element in full when it doesn't restrict that code.
|
|
*/
|
|
authorCodeEditorHint() {
|
|
return this.$previewRestrictsAuthorCode()
|
|
? this.$t('iframeElementForm.editorEmbedHintPublished')
|
|
: this.$t('iframeElementForm.editorEmbedHint')
|
|
},
|
|
elementIsInError() {
|
|
return this.elementType.isInError(this.element, this.applicationContext)
|
|
},
|
|
|
|
themeConfigBlocks() {
|
|
return this.$registry.getOrderedList('themeConfigBlock')
|
|
},
|
|
colorVariables() {
|
|
return ThemeConfigBlockType.getAllColorVariables(
|
|
this.themeConfigBlocks,
|
|
this.builder.theme
|
|
)
|
|
},
|
|
},
|
|
methods: {
|
|
async fireEvent(event) {
|
|
if (this.mode !== 'editing') {
|
|
if (this.workflowActionsInProgress) {
|
|
return false
|
|
}
|
|
|
|
const workflowActions = this.$store.getters[
|
|
'builderWorkflowAction/getElementWorkflowActions'
|
|
](this.elementPage, this.element.id).filter(
|
|
({ event: eventName }) => eventName === event.name
|
|
)
|
|
|
|
await event.fire({
|
|
workflowActions,
|
|
resolveFormula: this.resolveFormula,
|
|
applicationContext: this.applicationContext,
|
|
})
|
|
}
|
|
},
|
|
getStyleOverride(key, colorVariables = null) {
|
|
return ThemeConfigBlockType.getAllStyles(
|
|
this.themeConfigBlocks,
|
|
this.element.styles?.[key] || {},
|
|
colorVariables || this.colorVariables,
|
|
this.builder.theme
|
|
)
|
|
},
|
|
resolveColor,
|
|
},
|
|
}
|