mirror of
https://github.com/baserow/baserow.git
synced 2026-12-05 08:48:35 +00:00
* feat: review user templates from the admin page, with an approval setting * Review feedback * Review feedback 2 * Review feedback 3
90 lines
2.4 KiB
Vue
90 lines
2.4 KiB
Vue
<template>
|
|
<UserTemplateConfirmModal
|
|
ref="confirmModal"
|
|
:template="template"
|
|
:title="
|
|
resubmits
|
|
? $t('makeTemplatePublicModal.resubmitTitle', { name: template.name })
|
|
: $t('makeTemplatePublicModal.title', { name: template.name })
|
|
"
|
|
:confirm-label="
|
|
resubmits
|
|
? $t('makeTemplatePublicModal.submitForReviewAgain')
|
|
: $t('makeTemplatePublicModal.makePublic')
|
|
"
|
|
:request="makePublic"
|
|
@done="(id, data) => emit('made-public', data)"
|
|
@hidden="emit('hidden')"
|
|
>
|
|
<i18n-t
|
|
:keypath="description"
|
|
tag="p"
|
|
class="user-template-modal__description margin-bottom-0"
|
|
>
|
|
<template #name>{{ template.name }}</template>
|
|
<template #author>
|
|
<strong>{{ authorName }}</strong>
|
|
</template>
|
|
</i18n-t>
|
|
</UserTemplateConfirmModal>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { computed, ref } from 'vue'
|
|
import { useNuxtApp } from '#app'
|
|
|
|
import TemplateService from '@baserow/modules/core/services/template'
|
|
import UserTemplateConfirmModal from '@baserow/modules/core/components/template/UserTemplateConfirmModal'
|
|
import { makePublicResubmits } from '@baserow/modules/core/utils/userTemplate'
|
|
|
|
const props = defineProps({
|
|
// The user's template as listed in their templates.
|
|
template: {
|
|
type: Object,
|
|
required: true,
|
|
},
|
|
})
|
|
|
|
// `made-public` is emitted with the template as listed in the user's templates,
|
|
// also when the modal was closed or opened for another template while the request
|
|
// ran.
|
|
const emit = defineEmits(['made-public', 'hidden'])
|
|
|
|
const { $client, $store } = useNuxtApp()
|
|
|
|
const confirmModal = ref(null)
|
|
|
|
const resubmits = computed(() => makePublicResubmits(props.template))
|
|
|
|
const description = computed(() => {
|
|
if (!props.template.make_public_needs_review) {
|
|
return 'makeTemplatePublicModal.description'
|
|
}
|
|
return props.template.listed
|
|
? 'makeTemplatePublicModal.resubmitListedDescription'
|
|
: 'makeTemplatePublicModal.reviewDescription'
|
|
})
|
|
|
|
// The author of the user's own templates is the user.
|
|
const authorName = computed(() => $store.getters['auth/getName'])
|
|
|
|
async function makePublic({ slug }) {
|
|
const { data } = await TemplateService($client).setVisibility(
|
|
slug,
|
|
'public',
|
|
{ publicListingConsent: true }
|
|
)
|
|
return data
|
|
}
|
|
|
|
function show(...args) {
|
|
confirmModal.value.show(...args)
|
|
}
|
|
|
|
function hide(...args) {
|
|
confirmModal.value.hide(...args)
|
|
}
|
|
|
|
defineExpose({ show, hide })
|
|
</script>
|