π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
fix: update convert to sandbox modal
Ramesh Manef6e2a6ef11dc
diff --git a/packages/nc-gui/components/dlg/ConvertToSandbox.vue b/packages/nc-gui/components/dlg/ConvertToSandbox.vueindex 394e8ae758..ddcac2b38e 100644--- a/packages/nc-gui/components/dlg/ConvertToSandbox.vue+++ b/packages/nc-gui/components/dlg/ConvertToSandbox.vue@@ -1,4 +1,6 @@<script setup lang="ts">+import { FormBuilderValidatorType } from 'nocodb-sdk'+import { FORM_BUILDER_NON_CATEGORIZED, FormBuilderInputType } from '#imports'const props = defineProps<{baseId: string}>()@@ -8,7 +10,13 @@ const visible = defineModel<boolean>('visible', { required: true })const { $api } = useNuxtApp()const { t } = useI18n()-const isLoading = ref(false)+const initialSanboxFormState = ref<Record<string, any>>({+ title: '',+ description: '',+ category: '',+ visibility: 'private',+})+const sandboxForm = reactive({title: '',description: '',@@ -20,34 +28,19 @@ const { base } = storeToRefs(useBase())const basesStore = useBases()-watch(visible, (isVisible) => {- if (isVisible && base.value) {- sandboxForm.title = base.value.title || ''- sandboxForm.description = ''- sandboxForm.category = ''- sandboxForm.visibility = 'private'- }-})--const convertToSandbox = async () => {- if (!sandboxForm.title?.trim()) {- message.error(t('msg.error.titleRequired'))- return- }-- isLoading.value = true+const convertToSandbox = async (formState: Record<string, any>) => {try {const response = await $api.internal.postOperation(- base.value.fk_workspace_id,+ base.value!.fk_workspace_id as string,props.baseId,{operation: 'sandboxCreate',} as any,{- title: sandboxForm.title,- description: sandboxForm.description,- category: sandboxForm.category,- visibility: sandboxForm.visibility,+ title: formState.title,+ description: formState.description,+ category: formState.category,+ visibility: formState.visibility,},)@@ -66,10 +59,72 @@ const convertToSandbox = async () => {await basesStore.loadProject(props.baseId, true)} catch (e: any) {message.error(await extractSdkResponseErrorMsg(e))- } finally {- isLoading.value = false}}++const { formState, isLoading, submit } = useProvideFormBuilderHelper({+ formSchema: [+ {+ type: FormBuilderInputType.Input,+ label: t('labels.sandboxTitle'),+ span: 24,+ model: 'title',+ placeholder: 'Enter a descriptive title',+ category: FORM_BUILDER_NON_CATEGORIZED,+ validators: [+ {+ type: FormBuilderValidatorType.Required,+ message: t('labels.titleRequired'),+ },+ ],+ required: true,+ },+ {+ type: FormBuilderInputType.Textarea,+ label: t('labels.sandboxDescription'),+ span: 24,+ model: 'description',+ placeholder: "Describe your application's capabilities",+ category: FORM_BUILDER_NON_CATEGORIZED,+ },+ {+ type: FormBuilderInputType.Input,+ label: t('labels.sandboxCategory'),+ span: 12,+ model: 'category',+ placeholder: 'e.g., CRM, HR',+ category: FORM_BUILDER_NON_CATEGORIZED,+ },+ {+ type: FormBuilderInputType.Select,+ label: t('labels.sandboxVisibility'),+ span: 12,+ model: 'visibility',+ category: FORM_BUILDER_NON_CATEGORIZED,+ options: [+ { label: 'Public', value: 'public', icon: 'eye' },+ { label: 'Private', value: 'private', icon: 'lock' },+ { label: 'Unlisted', value: 'unlisted', icon: 'ncEyeOff' },+ ],+ defaultValue: 'private',+ },+ ],+ onSubmit: async () => {+ return await convertToSandbox(formState.value)+ },+ initialState: initialSanboxFormState,+})++watch(visible, (isVisible) => {+ if (isVisible && base.value) {+ formState.value = {+ title: base.value.title || '',+ description: '',+ category: '',+ visibility: 'private',+ }+ }+})</script><template>@@ -96,67 +151,14 @@ const convertToSandbox = async () => {</div></div>- <div>- <label class="text-nc-content-gray text-sm font-medium mb-2 block">- {{ $t('labels.sandboxTitle') }} <span class="text-nc-content-red-dark">*</span>- </label>- <a-input v-model:value="sandboxForm.title" placeholder="Enter a descriptive title" size="large" class="rounded-lg" />- </div>-- <div>- <label class="text-nc-content-gray text-sm font-medium mb-2 block">- {{ $t('labels.sandboxDescription') }}- </label>- <a-textarea- v-model:value="sandboxForm.description"- placeholder="Describe your application's capabilities"- :rows="3"- size="large"- class="rounded-lg"- />- </div>-- <div class="grid grid-cols-2 gap-4">- <div>- <label class="text-nc-content-gray text-sm font-medium mb-2 block">- {{ $t('labels.sandboxCategory') }}- </label>- <a-input v-model:value="sandboxForm.category" placeholder="e.g., CRM, HR" size="large" class="rounded-lg" />- </div>-- <div>- <label class="text-nc-content-gray text-sm font-medium mb-2 block">- {{ $t('labels.sandboxVisibility') }}- </label>- <a-select v-model:value="sandboxForm.visibility" size="large" class="w-full rounded-lg">- <a-select-option disabled value="public">- <div class="flex items-center gap-2">- <GeneralIcon icon="eye" class="w-4 h-4" />- <span>Public</span>- </div>- </a-select-option>- <a-select-option value="private">- <div class="flex items-center gap-2">- <GeneralIcon icon="lock" class="w-4 h-4" />- <span>Private</span>- </div>- </a-select-option>- <a-select-option value="unlisted">- <div class="flex items-center gap-2">- <GeneralIcon icon="ncEyeOff" class="w-4 h-4" />- <span>Unlisted</span>- </div>- </a-select-option>- </a-select>- </div>- </div>+ <NcFormBuilder /></div><div class="flex justify-end gap-2 mt-6 pt-4 border-t border-nc-border-gray-medium">- <NcButton size="medium" type="secondary" :disabled="isLoading" @click="visible = false">+ <NcButton size="small" type="secondary" :disabled="isLoading" @click="visible = false">{{ $t('general.cancel') }}</NcButton>- <NcButton size="medium" type="primary" :loading="isLoading" @click="convertToSandbox">+ <NcButton size="small" type="primary" :loading="isLoading" @click="submit"><template #icon><GeneralIcon icon="ncBox" /></template>diff --git a/packages/nc-gui/components/nc/Alert.vue b/packages/nc-gui/components/nc/Alert.vueindex 1629a4ec58..5eb4f734ed 100644--- a/packages/nc-gui/components/nc/Alert.vue+++ b/packages/nc-gui/components/nc/Alert.vue@@ -447,6 +447,10 @@ onUnmounted(() => {.nc-alert-icon-wrapper {@apply text-nc-content-brand;}++ &.nc-show-background {+ @apply bg-nc-bg-brand dark:bg-nc-brand-20;+ }}.nc-alert-progress-wrapper {diff --git a/packages/nc-gui/components/nc/form-builder/SampleModal.vue b/packages/nc-gui/components/nc/form-builder/SampleModal.vueindex ba271728b1..0df19be525 100644--- a/packages/nc-gui/components/nc/form-builder/SampleModal.vue+++ b/packages/nc-gui/components/nc/form-builder/SampleModal.vue@@ -1,4 +1,5 @@<script lang="ts" setup>+import { FormBuilderInputType, FormBuilderValidatorType } from '@noco-integrations/core'const initState = ref({someDefaultProp: 'value',})@@ -12,7 +13,12 @@ const { formState, isLoading, submit } = useProvideFormBuilderHelper({model: 'title',placeholder: 'Some placeholder',category: 'General',- required: true,+ validators: [+ {+ type: FormBuilderValidatorType.Required,+ message: 'Sample Input is required',+ },+ ],},{type: FormBuilderInputType.Input,@@ -22,7 +28,12 @@ const { formState, isLoading, submit } = useProvideFormBuilderHelper({placeholder: 'This is added to config.sample',category: 'Sample Category',helpText: 'This is a sample help text',- required: true,+ validators: [+ {+ type: FormBuilderValidatorType.Required,+ message: 'Input To Nested Path is required',+ },+ ],},{type: FormBuilderInputType.Input,@@ -31,7 +42,6 @@ const { formState, isLoading, submit } = useProvideFormBuilderHelper({model: 'config.sample2',placeholder: 'This is added to config.sample2',category: 'Sample Category',- required: false,},{type: FormBuilderInputType.Select,@@ -45,7 +55,12 @@ const { formState, isLoading, submit } = useProvideFormBuilderHelper({{ label: 'Option 3', value: 'option3' },],defaultValue: 'option2',- required: true,+ validators: [+ {+ type: FormBuilderValidatorType.Required,+ message: 'Sample Select is required',+ },+ ],},{type: FormBuilderInputType.Switch,@@ -54,7 +69,6 @@ const { formState, isLoading, submit } = useProvideFormBuilderHelper({model: 'config.switch',category: 'Misc',helpText: 'This is a sample switch',- required: false,border: true,},],