Files
baserow/web-frontend/modules/core/components/application/CreateApplicationModal.vue
Peter EvansandJeremie Pardou 2b8e6ba569 feat: add per-workspace snapshot allowances and protected snapshots (#6783)
* feat: add per-workspace snapshot allowances and protected snapshots

* fix: guard snapshot replacement and separate quota management

* refactor: delegate snapshot permission descriptions to application types

* fix: highlight inherited workspace snapshot maximums

---------

Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
2026-11-23 11:23:05 +00:00

88 lines
2.4 KiB
Vue

<template>
<Modal ref="modal" @show="loading = false">
<h2 class="box__title">
{{ $t('action.createNew') }}
{{ $filters.lowercase(applicationType.getName()) }}
</h2>
<Error :error="error"></Error>
<SnapshotAllowanceWarning :workspace="workspace"></SnapshotAllowanceWarning>
<component
:is="applicationType.getApplicationFormComponent()"
ref="applicationForm"
:default-name="getDefaultName()"
:loading="loading"
:workspace="workspace"
@submitted="submitted"
@hidden="hide()"
>
</component>
</Modal>
</template>
<script>
import modal from '@baserow/modules/core/mixins/modal'
import error from '@baserow/modules/core/mixins/error'
import { getNextAvailableNameInSequence } from '@baserow/modules/core/utils/string'
import { DEVELOPMENT_STAGES } from '@baserow/modules/core/constants'
import SnapshotAllowanceWarning from '@baserow/modules/core/components/snapshots/SnapshotAllowanceWarning'
export default {
name: 'CreateApplicationModal',
components: { SnapshotAllowanceWarning },
mixins: [modal, error],
props: {
applicationType: {
type: Object,
required: true,
},
workspace: {
type: Object,
required: true,
},
},
emits: ['created'],
data() {
return {
loading: false,
}
},
computed: {
DEVELOPMENT_STAGES() {
return DEVELOPMENT_STAGES
},
},
methods: {
getDefaultName() {
const excludeNames = this.$store.getters['application/getAllOfWorkspace'](
this.workspace
).map((application) => application.name)
const baseName = this.applicationType.getDefaultName()
return getNextAvailableNameInSequence(baseName, excludeNames)
},
async submitted(values) {
this.loading = true
this.hideError()
try {
const application = await this.$store.dispatch('application/create', {
type: this.applicationType.type,
workspace: this.workspace,
values,
})
this.$emit('created', application)
// select the application just created in the sidebar and open it
await this.$store.dispatch('application/selectById', application.id)
await this.$registry
.get('application', application.type)
.select(application, this)
this.hide()
} catch (error) {
this.handleError(error, 'application')
} finally {
this.loading = false
}
},
},
}
</script>