Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

chore: sync EE changes

Pranav Ce3b5dc8110c7
diff --git a/packages/nc-gui/components/nc/Select.vue b/packages/nc-gui/components/nc/Select.vue
index 34ddf21d4e..7f6e6c9ae8 100644
--- a/packages/nc-gui/components/nc/Select.vue
+++ b/packages/nc-gui/components/nc/Select.vue
@@ -22,7 +22,7 @@ const props = withDefaults(
},
)
-const emits = defineEmits(['update:value', 'change'])
+const emits = defineEmits(['update:value', 'change', 'search'])
const placeholder = computed(() => props.placeholder)
@@ -41,6 +41,10 @@ const vModel = useVModel(props, 'value', emits)
const onChange = (value: string) => {
emits('change', value)
}
+
+const onSearch = (value: string) => {
+ emits('search', value)
+}
</script>
<template>
@@ -59,6 +63,7 @@ const onChange = (value: string) => {
:max-tag-count="maxTagCount"
class="nc-select nc-select-shadow"
@change="onChange as any"
+ @search="onSearch"
>
<template #suffixIcon>
<GeneralLoader v-if="loading" />
diff --git a/packages/nc-gui/components/nc/form-builder/index.vue b/packages/nc-gui/components/nc/form-builder/index.vue
index 880f7bb09b..d427123da6 100644
--- a/packages/nc-gui/components/nc/form-builder/index.vue
+++ b/packages/nc-gui/components/nc/form-builder/index.vue
@@ -178,6 +178,32 @@ const handleSelectChange = (field: FormBuilderElement, value: any) => {
}
}
+const searchDebounceMap = new Map<string, ReturnType<typeof useDebounceFn>>()
+
+const getSelectSearchHandler = (field: FormBuilderElement) => {
+ if (!field.searchable || !field.model) return undefined
+
+ if (!searchDebounceMap.has(field.model)) {
+ searchDebounceMap.set(
+ field.model,
+ useDebounceFn(async (query: string) => {
+ await loadOptions(field, query)
+ }, 300),
+ )
+ }
+
+ return (query: string) => {
+ searchDebounceMap.get(field.model)?.(query)
+ }
+}
+
+const getSelectFilterOption = (field: FormBuilderElement) => {
+ if (field.searchable) {
+ return false // Disable client-side filtering when using server-side search
+ }
+ return undefined // Use default client-side filtering
+}
+
eventBus.on(integegrationEventHandler)
onBeforeUnmount(() => {
@@ -185,10 +211,10 @@ onBeforeUnmount(() => {
})
watch(
- () => unref(formSchema),
- async () => {
+ haveIntegrationInput,
+ async (hasIntegration) => {
// if integration field is available, load the integration state
- if (haveIntegrationInput.value) {
+ if (hasIntegration) {
await loadIntegrations()
}
},
@@ -364,7 +390,9 @@ watch(
show-search
:placeholder="field.placeholder"
:loading="field.fetchOptionsKey && getIsLoadingFieldOptions(field.model)"
+ :filter-option="getSelectFilterOption(field)"
@update:value="handleSelectChange(field, $event)"
+ @search="getSelectSearchHandler(field)?.($event)"
>
<a-select-option
v-for="option in field.fetchOptionsKey ? getFieldOptions(field.model) : field.options"
@@ -547,9 +575,17 @@ watch(
@update:model-value="setFormStateWithEmit(field.model, $event)"
/>
</template>
- <template v-else-if="field.type === FormBuilderInputType.FieldMapping">
+ <template v-else-if="field.type === FormBuilderInputType.KeyValue">
+ <NcFormBuilderInputKeyValue
+ :model-value="deepReference(field.model)"
+ :element="field"
+ :disabled="disabled"
+ @update:model-value="setFormStateWithEmit(field.model, $event)"
+ />
+ </template>
+ <template v-else-if="field.type === FormBuilderInputType.EntitySelector">
<NcFormBuilderInputMountedWrapper @mounted="loadOptions(field)">
- <NcFormBuilderInputFieldMapping
+ <NcFormBuilderInputEntitySelector
:model-value="deepReference(field.model)"
:element="field"
:disabled="disabled"
@@ -557,6 +593,14 @@ watch(
/>
</NcFormBuilderInputMountedWrapper>
</template>
+ <template v-else-if="field.type === FormBuilderInputType.ConditionBuilder">
+ <NcFormBuilderInputConditionBuilder
+ :model-value="deepReference(field.model)"
+ :element="field"
+ :disabled="disabled"
+ @update:model-value="setFormStateWithEmit(field.model, $event)"
+ />
+ </template>
<div
v-if="field.helpText && field.type !== FormBuilderInputType.Switch && !field.showHintAsTooltip"
class="w-full mt-1"
diff --git a/packages/nc-gui/components/nc/form-builder/input/ConditionBuilder.vue b/packages/nc-gui/components/nc/form-builder/input/ConditionBuilder.vue
new file mode 100644
index 0000000000..db288add5c
--- /dev/null
+++ b/packages/nc-gui/components/nc/form-builder/input/ConditionBuilder.vue
@@ -0,0 +1,683 @@
+<script setup lang="ts">
+import type {
+ ConditionBuilderValue,
+ FilterCombinator,
+ FilterConditionValue,
+ FilterDataType,
+ FilterOperator,
+ FilterOperatorType,
+ FormBuilderConditionBuilderElement,
+} from 'nocodb-sdk'
+
+interface Props {
+ element: FormBuilderConditionBuilderElement
+ modelValue?: ConditionBuilderValue | null
+ disabled?: boolean
+}
+
+const props = withDefaults(defineProps<Props>(), {
+ disabled: false,
+})
+const emit = defineEmits(['update:modelValue'])
+
+const vModel = useVModel(props, 'modelValue', emit)
+
+const workflowContext = inject(WorkflowVariableInj, null)
+
+const { getFieldOptions, getIsLoadingFieldOptions, loadOptions } = useFormBuilderHelperOrThrow()
+
+// Dropdown state
+const isDropdownOpen = ref(false)
+
+// Track property input mode per condition: 'select' or 'manual'
+const propertyInputMode = ref<Record<string, 'select' | 'manual'>>({})
+
+// Define all available operators
+const ALL_OPERATORS: FilterOperator[] = [
+ // String operators
+ { id: 'string:equals', name: 'equals', type: 'string', operation: 'equals' },
+ { id: 'string:notEquals', name: 'not equals', type: 'string', operation: 'notEquals' },
+ { id: 'string:contains', name: 'contains', type: 'string', operation: 'contains' },
+ { id: 'string:notContains', name: 'does not contain', type: 'string', operation: 'notContains' },
+ { id: 'string:startsWith', name: 'starts with', type: 'string', operation: 'startsWith' },
+ { id: 'string:endsWith', name: 'ends with', type: 'string', operation: 'endsWith' },
+ { id: 'string:regex', name: 'matches regex', type: 'string', operation: 'regex' },
+ { id: 'string:exists', name: 'exists', type: 'string', operation: 'exists', singleValue: true },
+ { id: 'string:notExists', name: 'does not exist', type: 'string', operation: 'notExists', singleValue: true },
+ { id: 'string:empty', name: 'is empty', type: 'string', operation: 'empty', singleValue: true },
+ { id: 'string:notEmpty', name: 'is not empty', type: 'string', operation: 'notEmpty', singleValue: true },
+
+ // Number operators
+ { id: 'number:equals', name: 'equals', type: 'number', operation: 'equals' },
+ { id: 'number:notEquals', name: 'not equals', type: 'number', operation: 'notEquals' },
+ { id: 'number:gt', name: 'greater than', type: 'number', operation: 'gt' },
+ { id: 'number:gte', name: 'greater than or equal', type: 'number', operation: 'gte' },
+ { id: 'number:lt', name: 'less than', type: 'number', operation: 'lt' },
+ { id: 'number:lte', name: 'less than or equal', type: 'number', operation: 'lte' },
+ { id: 'number:exists', name: 'exists', type: 'number', operation: 'exists', singleValue: true },
+ { id: 'number:notExists', name: 'does not exist', type: 'number', operation: 'notExists', singleValue: true },
+ { id: 'number:empty', name: 'is empty', type: 'number', operation: 'empty', singleValue: true },
+ { id: 'number:notEmpty', name: 'is not empty', type: 'number', operation: 'notEmpty', singleValue: true },
+
+ // DateTime operators
+ { id: 'dateTime:equals', name: 'equals', type: 'dateTime', operation: 'equals' },
+ { id: 'dateTime:notEquals', name: 'not equals', type: 'dateTime', operation: 'notEquals' },
+ { id: 'dateTime:after', name: 'after', type: 'dateTime', operation: 'after' },
+ { id: 'dateTime:before', name: 'before', type: 'dateTime', operation: 'before' },
+ { id: 'dateTime:exists', name: 'exists', type: 'dateTime', operation: 'exists', singleValue: true },
+ { id: 'dateTime:notExists', name: 'does not exist', type: 'dateTime', operation: 'notExists', singleValue: true },
+ { id: 'dateTime:empty', name: 'is empty', type: 'dateTime', operation: 'empty', singleValue: true },
+ { id: 'dateTime:notEmpty', name: 'is not empty', type: 'dateTime', operation: 'notEmpty', singleValue: true },
+
+ // Boolean operators
+ { id: 'boolean:isTrue', name: 'is true', type: 'boolean', operation: 'isTrue', singleValue: true },
+ { id: 'boolean:isFalse', name: 'is false', type: 'boolean', operation: 'isFalse', singleValue: true },
+ { id: 'boolean:exists', name: 'exists', type: 'boolean', operation: 'exists', singleValue: true },
+ { id: 'boolean:notExists', name: 'does not exist', type: 'boolean', operation: 'notExists', singleValue: true },
+
+ // Any type operators
+ { id: 'any:equals', name: 'equals', type: 'any', operation: 'equals' },
+ { id: 'any:notEquals', name: 'not equals', type: 'any', operation: 'notEquals' },
+ { id: 'any:exists', name: 'exists', type: 'any', operation: 'exists', singleValue: true },
+ { id: 'any:notExists', name: 'does not exist', type: 'any', operation: 'notExists', singleValue: true },
+ { id: 'any:empty', name: 'is empty', type: 'any', operation: 'empty', singleValue: true },
+ { id: 'any:notEmpty', name: 'is not empty', type: 'any', operation: 'notEmpty', singleValue: true },
+]
+
+// Default operator by type
+const DEFAULT_OPERATOR_BY_TYPE: Record<FilterDataType, string> = {
+ string: 'string:equals',
+ number: 'number:equals',
+ boolean: 'boolean:isTrue',
+ dateTime: 'dateTime:equals',
+ array: 'any:exists',
+ object: 'any:exists',
+ any: 'any:equals',
+}
+
+// Get available operators based on element configuration
+const availableOperators = computed(() => {
+ let operators = ALL_OPERATORS
+
+ // Filter by allowed types
+ if (props.element.allowedTypes?.length) {
+ operators = operators.filter((op) => props.element.allowedTypes!.includes(op.type) || op.type === 'any')
+ }
+
+ // Filter by supported operators
+ if (props.element.supportedOperators?.length) {
+ operators = operators.filter((op) => props.element.supportedOperators!.includes(op.operation))
+ }
+
+ return operators
+})
+
+// Group operators by type for dropdown
+const operatorsByType = computed(() => {
+ const grouped: Record<string, FilterOperator[]> = {}
+ availableOperators.value.forEach((op) => {
+ if (!grouped[op.type]) {
+ grouped[op.type] = []
+ }
+ grouped[op.type].push(op)
+ })
+ return grouped
+})
+
+// Get operator by ID
+function getOperator(type: FilterDataType, operation: FilterOperatorType): FilterOperator | undefined {
+ return availableOperators.value.find((op) => op.type === type && op.operation === operation)
+}
+
+// Initialize conditions
+const conditions = ref<FilterConditionValue[]>([])
+const combinator = ref<FilterCombinator>('and')
+
+// Track internal updates
+const isInternalUpdate = ref(false)
+
+// Initialize from modelValue
+function initializeConditions() {
+ if (!vModel.value) {
+ conditions.value = []
+ combinator.value = 'and'
+ return
+ }
+
+ combinator.value = vModel.value.combinator || 'and'
+ conditions.value = (vModel.value.conditions || []).map((c) => ({
+ ...c,
+ id: c.id || generateRandomUUID(),
+ }))
+}
+
+// Watch for external changes
+watch(
+ () => props.modelValue,
+ () => {
+ if (isInternalUpdate.value) return
+ initializeConditions()
+ },
+ { immediate: true, deep: true },
+)
+
+// Sync back to modelValue
+watch(
+ [conditions, combinator],
+ () => {
+ isInternalUpdate.value = true
+ vModel.value = {
+ combinator: combinator.value,
+ conditions: conditions.value,
+ }
+ nextTick(() => {
+ isInternalUpdate.value = false
+ })
+ },
+ { deep: true },
+)
+
+// Get workflow variables
+const workflowVariables = computed(() => {
+ if (!workflowContext?.selectedNodeId?.value || !workflowContext?.getAvailableVariablesFlat) {
+ return []
+ }
+ return workflowContext.getAvailableVariablesFlat(workflowContext.selectedNodeId.value)
+})
+
+const groupedVariables = computed(() => {
+ if (!workflowContext?.selectedNodeId?.value || !workflowContext?.getAvailableVariables) {
+ return []
+ }
+ return workflowContext.getAvailableVariables(workflowContext.selectedNodeId.value)
+})
+
+// Add new condition
+function addCondition() {
+ if (props.element.maxConditions && conditions.value.length >= props.element.maxConditions) {
+ return
+ }
+
+ const defaultType = props.element.allowedTypes?.[0] || 'string'
+ const defaultOperatorId = DEFAULT_OPERATOR_BY_TYPE[defaultType]
+ const defaultOperator = availableOperators.value.find((op) => op.id === defaultOperatorId) || availableOperators.value[0]
+
+ conditions.value.push({
+ id: generateRandomUUID(),
+ leftValue: '',
+ operator: {
+ type: defaultOperator?.type || 'string',
+ operation: defaultOperator?.operation || 'equals',
+ },
+ rightValue: '',
+ })
+}
+
+// Remove condition
+function removeCondition(index: number) {
+ conditions.value.splice(index, 1)
+}
+
+// Update condition
+function updateCondition(index: number, field: keyof FilterConditionValue, value: unknown) {
+ if (field === 'operator' && typeof value === 'string') {
+ // Parse operator ID (e.g., 'string:equals')
+ const [type, operation] = value.split(':') as [FilterDataType, FilterOperatorType]
+ conditions.value[index].operator = { type, operation }
+ } else {
+ ;(conditions.value[index] as Record<string, unknown>)[field] = value
+ }
+}
+
+// Get operator select options
+const operatorOptions = computed(() => {
+ const options: Array<{ label: string; value: string; group?: string }> = []
+
+ Object.entries(operatorsByType.value).forEach(([type, ops]) => {
+ ops.forEach((op) => {
+ options.push({
+ label: op.name,
+ value: op.id,
+ group: type,
+ })
+ })
+ })
+
+ return options
+})
+
+// Check if operator is single-value (no right side needed)
+function isSingleValueOperator(condition: FilterConditionValue): boolean {
+ const operator = getOperator(condition.operator.type, condition.operator.operation)
+ return operator?.singleValue || false
+}
+
+// Can add more conditions
+const canAddCondition = computed(() => {
+ if (props.disabled) return false
+ return !(props.element.maxConditions && conditions.value.length >= props.element.maxConditions)
+})
+
+// Property options support
+const hasPropertyOptions = computed(() => {
+ return !!(props.element.propertyOptions?.length || props.element.fetchPropertyOptionsKey)
+})
+
+// Get property options (static or fetched)
+const propertyOptions = computed(() => {
+ // Static options from element config
+ if (props.element.propertyOptions?.length) {
+ return props.element.propertyOptions
+ }
+ // Fetched options
+ if (props.element.fetchPropertyOptionsKey && props.element.model) {
+ return getFieldOptions(`${props.element.model}_properties`) || []
+ }
+ return []
+})
+
+const isLoadingPropertyOptions = computed(() => {
+ if (!props.element.fetchPropertyOptionsKey || !props.element.model) return false
+ return getIsLoadingFieldOptions(`${props.element.model}_properties`)
+})
+
+// Get input mode for a condition
+function getPropertyInputMode(conditionId: string): 'select' | 'manual' {
+ return propertyInputMode.value[conditionId] || (hasPropertyOptions.value ? 'select' : 'manual')
+}
+
+// Toggle property input mode for a condition
+function togglePropertyInputMode(conditionId: string) {
+ const current = getPropertyInputMode(conditionId)
+ propertyInputMode.value[conditionId] = current === 'select' ? 'manual' : 'select'
+}
+
+// Load property options if fetchPropertyOptionsKey is set
+async function loadPropertyOptions() {
+ if (props.element.fetchPropertyOptionsKey && props.element.model) {
+ const elementForFetch = {
+ ...props.element,
+ model: `${props.element.model}_properties`,
+ fetchOptionsKey: props.element.fetchPropertyOptionsKey,
+ }
+ await loadOptions(elementForFetch as any)
+ }
+}
+
+// Load options on mount
+onMounted(() => {
+ loadPropertyOptions()
+})
+</script>
+
+<template>
+ <div class="nc-condition-builder">
+ <NcListDropdown
+ v-model:visible="isDropdownOpen"
+ :disabled="disabled"
+ placement="bottomLeft"
+ overlay-class-name="nc-condition-builder-dropdown"
+ >
+ <!-- Trigger: Compact condition count display -->
+ <div
+ class="nc-conditions-count flex-1"
+ :class="{
+ 'text-nc-content-brand': conditions.length > 0,
+ 'text-nc-content-gray-muted': conditions.length === 0,
+ }"
+ >
+ {{ conditions.length > 0 ? `${conditions.length} condition${conditions.length !== 1 ? 's' : ''}` : 'No conditions' }}
+ </div>
+ <GeneralIcon
+ icon="ncChevronDown"
+ class="flex-none w-4 h-4"
+ :class="{
+ 'text-nc-content-brand': conditions.length > 0,
+ 'text-nc-content-gray-muted': conditions.length === 0,
+ }"
+ />
+
+ <!-- Dropdown overlay: Full condition builder -->
+ <template #overlay>
+ <div class="nc-condition-builder-dropdown-container">
+ <!-- Empty state -->
+ <div v-if="conditions.length === 0" class="p-4">
+ <NcButton type="text" size="small" :disabled="disabled" @click="addCondition">
+ <template #icon>
+ <GeneralIcon icon="ncPlus" class="w-4 h-4" />
+ </template>
+ Add condition
+ </NcButton>
+ <div class="text-nc-content-gray-muted mt-2 ml-0.5">No conditions added</div>
+ </div>
+
+ <!-- Conditions list -->
+ <div v-else class="p-3">
+ <div class="space-y-1.5 mb-3">
+ <template v-for="(condition, index) in conditions" :key="condition.id">
+ <!-- Single connected row like If node -->
+ <div class="flex flex-nowrap gap-0 nc-filter-wrapper">
+ <!-- Where / AND / OR -->
+ <div v-if="index === 0" class="flex items-center !min-w-18 !max-w-18 nc-filter-where-label">Where</div>
+ <NcSelect
+ v-else
+ :value="combinator"
+ :disabled="index !== 1"
+ class="h-full !max-w-18 !min-w-18 capitalize"
+ dropdown-class-name="nc-dropdown-filter-logical-op"
+ @update:value="combinator = $event"
+ >
+ <a-select-option value="and">
+ <div class="flex items-center justify-between gap-2">
+ <span class="capitalize">And</span>
+ <GeneralIcon
+ v-if="combinator === 'and'"
+ id="nc-selected-item-icon"
+ icon="ncCheck"
+ class="text-primary w-4 h-4"
+ />
+ </div>
+ </a-select-option>
+ <a-select-option value="or">
+ <div class="flex items-center justify-between gap-2">
+ <span class="capitalize">Or</span>
+ <GeneralIcon
+ v-if="combinator === 'or'"
+ id="nc-selected-item-icon"
+ icon="ncCheck"
+ class="text-primary w-4 h-4"
+ />
+ </div>
+ </a-select-option>
+ </NcSelect>
+
+ <!-- Field Input -->
+ <div v-if="!element.fixedLeftValue" class="nc-filter-field-input min-w-36 max-w-36 flex items-center">
+ <template v-if="hasPropertyOptions && getPropertyInputMode(condition.id) === 'select'">
+ <NcButton
+ type="text"
+ size="xs"
+ class="nc-property-mode-toggle flex-shrink-0 ml-1"
+ :disabled="disabled"
+ @click="togglePropertyInputMode(condition.id)"
+ >
+ <GeneralIcon icon="ncList" class="text-nc-content-gray-muted w-3.5 h-3.5" />
+ </NcButton>
+ <NcSelect
+ :value="condition.leftValue || undefined"
+ :disabled="disabled"
+ :loading="isLoadingPropertyOptions"
+ :placeholder="element.propertyPlaceholder || 'Property'"
+ class="nc-property-select flex-1"
+ dropdown-class-name="nc-dropdown-filter-property"
+ show-search
+ allow-clear
+ :filter-option="(input: string, option: any) => option.label?.toLowerCase()?.includes(input.toLowerCase())"
+ @update:value="updateCondition(index, 'leftValue', $event || '')"
+ >
+ <a-select-option v-for="opt in propertyOptions" :key="opt.value" :value="opt.value">
+ <div class="flex items-center justify-between gap-2">
+ <span class="truncate">{{ opt.label }}</span>
+ <GeneralIcon
+ v-if="condition.leftValue === opt.value"
+ id="nc-selected-item-icon"
+ icon="ncCheck"
+ class="text-primary w-4 h-4 flex-shrink-0"
+ />
+ </div>
+ </a-select-option>
+ </NcSelect>
+ </template>
+
+ <!-- Manual mode (WorkflowInput) -->
+ <template v-else>
+ <!-- Mode toggle button (only show if hasPropertyOptions) -->
+ <NcButton
+ v-if="hasPropertyOptions"
+ type="text"
+ size="xs"
+ class="nc-property-mode-toggle flex-shrink-0 ml-1"
+ :disabled="disabled"
+ @click="togglePropertyInputMode(condition.id)"
+ >
+ <GeneralIcon icon="ncCode" class="text-nc-content-gray-muted w-3.5 h-3.5" />
+ </NcButton>
+ <NcFormBuilderInputWorkflowInput
+ :model-value="condition.leftValue || ''"
+ :placeholder="element.propertyPlaceholder || 'Property'"
+ :variables="workflowVariables"
+ :grouped-variables="groupedVariables"
+ :read-only="disabled"
+ class="nc-property-input flex-1 h-8"
+ @update:model-value="updateCondition(index, 'leftValue', $event)"
+ />
+ </template>
+ </div>
+
+ <!-- Operator -->
+ <NcSelect
+ :value="`${condition.operator.type}:${condition.operator.operation}`"
+ :options="operatorOptions"
+ :disabled="disabled"
+ class="nc-filter-comparison-op !min-w-26.75"
+ dropdown-class-name="nc-dropdown-filter-comp-op"
+ @update:value="updateCondition(index, 'operator', $event)"
+ />
+
+ <!-- Value Input (if needed) -->
+ <div
+ v-if="!isSingleValueOperator(condition)"
+ class="nc-filter-value-input flex items-center flex-grow min-w-34"
+ >
+ <NcFormBuilderInputWorkflowInput
+ :model-value="condition.rightValue || ''"
+ placeholder="Enter value"
+ :variables="workflowVariables"
+ :grouped-variables="groupedVariables"
+ :read-only="disabled"
+ class="nc-value-input flex-1 h-8"
+ @update:model-value="updateCondition(index, 'rightValue', $event)"
+ />
+ </div>
+ <div v-else class="flex-grow"></div>
+
+ <!-- Remove Button -->
+ <NcButton
+ v-if="!disabled"
+ type="text"
+ size="small"
+ class="nc-filter-item-remove-btn self-center"
+ @click="removeCondition(index)"
+ >
+ <GeneralIcon icon="deleteListItem" />
+ </NcButton>
+ </div>
+ </template>
+ </div>
+
+ <!-- Add condition button -->
+ <div v-if="canAddCondition" class="nc-condition-builder-add">
+ <NcButton type="text" size="small" :disabled="disabled" @click="addCondition">
+ <template #icon>
+ <GeneralIcon icon="ncPlus" class="w-4 h-4" />
+ </template>
+ Add condition
+ </NcButton>
+ </div>
+ </div>
+ </div>
+ </template>
+ </NcListDropdown>
+ </div>
+</template>
+
+<style lang="scss">
+.nc-condition-builder-dropdown {
+ @apply !min-w-[560px] !max-w-[700px];
+
+ .ant-dropdown-menu {
+ @apply !p-0;
+ }
+}
+
+.nc-dropdown-filter-property {
+ @apply !min-w-[180px];
+}
+</style>
+
+<style scoped lang="scss">
+.nc-condition-builder {
+ @apply w-full;
+
+ .nc-condition-builder-dropdown-container {
+ @apply max-h-[400px] overflow-y-auto;
+ }
+
+ .nc-condition-builder-add {
+ @apply self-start;
+ }
+}
+
+.nc-filter-wrapper {
+ @apply bg-nc-bg-default !rounded-lg border-1px border-nc-border-gray-medium w-full items-center;
+
+ & > *,
+ .nc-filter-field-input {
+ @apply !border-none;
+ }
+
+ & > :not(:last-child):not(:empty) {
+ border-right: 1px solid var(--nc-border-gray-medium) !important;
+ border-bottom-right-radius: 0 !important;
+ border-top-right-radius: 0 !important;
+ }
+
+ & > :not(:first-child) {
+ border-bottom-left-radius: 0 !important;
+ border-top-left-radius: 0 !important;
+ }
+
+ & > :last-child {
+ @apply relative;
+ &::after {
+ content: '';
+ @apply absolute h-full w-1px bg-nc-border-gray-medium -left-1px top-0;
+ }
+ }
+
+ :deep(::placeholder) {
+ @apply text-sm tracking-normal;
+ }
+
+ :deep(::-ms-input-placeholder) {
+ @apply text-sm tracking-normal;
+ }
+
+ :deep(input) {
+ @apply text-sm;
+ }
+
+ :deep(.nc-select:not(.ant-select-disabled):hover) {
+ &,
+ .ant-select-selector {
+ @apply bg-nc-bg-gray-extralight;
+ }
+ }
+
+ :deep(.nc-select),
+ :deep(.nc-select.ant-select) {
+ .ant-select-selector {
+ border: none !important;
+ box-shadow: none !important;
+ border-radius: 0 !important;
+ }
+
+ .ant-select-disabled {
+ border-radius: 0 !important;
+ }
+
+ // Hide search icon when using show-search
+ &.ant-select-show-search .ant-select-selector .ant-select-selection-search-input {
+ @apply !h-full;
+ }
+ }
+
+ :deep(.ant-select-selector) {
+ border: none !important;
+ box-shadow: none !important;
+ border-radius: 0 !important;
+ }
+
+ :deep(.ant-input) {
+ border: none !important;
+ box-shadow: none !important;
+ border-radius: 0 !important;
+ }
+}
+
+.nc-filter-where-label {
+ @apply text-nc-content-gray-disabled pl-3;
+}
+
+.nc-filter-item-remove-btn {
+ @apply text-nc-content-gray-subtle2 hover:text-nc-content-gray;
+}
+
+.nc-filter-field-input {
+ .nc-property-mode-toggle {
+ @apply flex-shrink-0 !border-r-1;
+ }
+
+ :deep(.nc-select),
+ :deep(.nc-select.ant-select) {
+ @apply h-8;
+
+ .ant-select-selector {
+ @apply !h-8 !min-h-8;
+ border: none !important;
+ box-shadow: none !important;
+ border-radius: 0 !important;
+ }
+
+ .ant-select-arrow {
+ @apply text-nc-content-gray-muted;
+ }
+
+ .ant-select-clear {
+ @apply bg-nc-bg-default;
+ }
+ }
+
+ :deep(.nc-workflow-input) {
+ .ProseMirror {
+ @apply !h-8 !min-h-8 border-none !py-1;
+ }
+ }
+}
+
+.nc-filter-value-input {
+ :deep(.nc-workflow-input) {
+ .ProseMirror {
+ @apply !h-8 !min-h-8 border-none !py-1 !pr-8;
+ }
+
+ .nc-workflow-input-insert-btn {
+ @apply !-top-0.5;
+ }
+ }
+}
+
+:deep(.nc-workflow-input) {
+ .ProseMirror {
+ @apply !h-8 !min-h-8 border-none !py-1;
+ }
+
+ .nc-workflow-input-insert-btn {
+ @apply !-top-0.5;
+ }
+}
+
+:deep(.ant-select-selector) {
+ @apply !min-h-8;
+}
+</style>
diff --git a/packages/nc-gui/components/nc/form-builder/input/EntitySelector.vue b/packages/nc-gui/components/nc/form-builder/input/EntitySelector.vue
new file mode 100644
index 0000000000..8b25eeea6a
--- /dev/null
+++ b/packages/nc-gui/components/nc/form-builder/input/EntitySelector.vue
@@ -0,0 +1,227 @@
+<script setup lang="ts">
+import type { EntitySelectorMode, FormBuilderEntitySelectorElement, FormBuilderSelectOption } from 'nocodb-sdk'
+
+interface Props {
+ element: FormBuilderEntitySelectorElement
+ modelValue?: string | null
+ disabled?: boolean
+}
+
+const props = withDefaults(defineProps<Props>(), {
+ disabled: false,
+})
+const emit = defineEmits(['update:modelValue'])
+
+const vModel = useVModel(props, 'modelValue', emit)
+
+const { getFieldOptions, getIsLoadingFieldOptions, loadOptions } = useFormBuilderHelperOrThrow()
+
+const workflowContext = inject(WorkflowVariableInj, null)
+
+// Get modes from element config, default to list mode only
+const modes = computed<EntitySelectorMode[]>(() => {
+ if (props.element.modes && props.element.modes.length > 0) {
+ return props.element.modes
+ }
+ // Default: list mode only
+ return [{ type: 'list', placeholder: props.element.placeholder }]
+})
+
+// Current active mode
+const currentModeIndex = ref(0)
+const currentMode = computed(() => modes.value[currentModeIndex.value] || modes.value[0])
+
+// Check if we have multiple modes
+const hasMultipleModes = computed(() => modes.value.length > 1)
+
+// Get list mode config (for fetching options)
+const listModeConfig = computed(() => modes.value.find((m) => m.type === 'list'))
+
+// Get options for dropdown mode
+const listOptions = computed<FormBuilderSelectOption[]>(() => {
+ if (!props.element.model || currentMode.value?.type !== 'list') return []
+ return getFieldOptions(props.element.model) || []
+})
+
+const isLoadingOptions = computed(() => {
+ if (!props.element.model) return false
+ return getIsLoadingFieldOptions(props.element.model)
+})
+
+// Debounced search for server-side filtering
+const debouncedSearch = useDebounceFn(async (query: string) => {
+ if (currentMode.value?.type === 'list' && props.element.model && currentMode.value.searchable) {
+ // Create element with fetchOptionsKey from current mode for loadOptions
+ const elementWithFetchKey = {
+ ...props.element,
+ fetchOptionsKey: currentMode.value.fetchOptionsKey,
+ }
+ await loadOptions(elementWithFetchKey, query)
+ }
+}, 300)
+
+function handleSearch(query: string) {
+ if (currentMode.value?.searchable) {
+ debouncedSearch(query)
+ }
+}
+
+// Get workflow variables for manual input mode
+const workflowVariables = computed(() => {
+ if (!workflowContext?.selectedNodeId?.value || !workflowContext?.getAvailableVariablesFlat) {
+ return []
+ }
+ return workflowContext.getAvailableVariablesFlat(workflowContext.selectedNodeId.value)
+})
+
+const groupedVariables = computed(() => {
+ if (!workflowContext?.selectedNodeId?.value || !workflowContext?.getAvailableVariables) {
+ return []
+ }
+ return workflowContext.getAvailableVariables(workflowContext.selectedNodeId.value)
+})
+
+// Check if value is a variable expression (contains $( or {{ )
+function isVariableExpression(value: string | null | undefined): boolean {
+ if (!value) return false
+ return value.includes('$(') || value.includes('{{')
+}
+
+// Handle mode toggle
+function toggleMode() {
+ const newModeIndex = (currentModeIndex.value + 1) % modes.value.length
+ const newMode = modes.value[newModeIndex]
+
+ // When switching to list mode, clear value if it's a variable expression
+ // or if it doesn't exist in the options
+ if (newMode?.type === 'list' && vModel.value) {
+ const isExpression = isVariableExpression(vModel.value)
+ const existsInOptions = listOptions.value.some((opt) => opt.value === vModel.value)
+
+ if (isExpression || !existsInOptions) {
+ vModel.value = ''
+ }
+ }
+
+ currentModeIndex.value = newModeIndex
+}
+
+// Handle list selection
+function handleListSelect(selectedValue: string) {
+ vModel.value = selectedValue
+}
+
+// Handle manual input change
+function handleInputChange(newValue: string) {
+ vModel.value = newValue
+}
+
+// Create element with fetchOptionsKey from list mode for loadOptions
+function getElementWithFetchKey() {
+ if (listModeConfig.value?.fetchOptionsKey) {
+ return { ...props.element, fetchOptionsKey: listModeConfig.value.fetchOptionsKey }
+ }
+ return props.element
+}
+
+// Load options when component mounts (for dropdown mode)
+onMounted(() => {
+ if (currentMode.value?.type === 'list' && props.element.model && listModeConfig.value?.fetchOptionsKey) {
+ loadOptions(getElementWithFetchKey())
+ }
+})
+
+// Watch for mode changes to load options
+watch(currentModeIndex, () => {
+ if (currentMode.value?.type === 'list' && props.element.model && listModeConfig.value?.fetchOptionsKey) {
+ loadOptions(getElementWithFetchKey())
+ }
+})
+</script>
+
+<template>
+ <div class="nc-entity-selector">
+ <div class="nc-entity-selector-container">
+ <!-- Mode toggle button (only show if multiple modes) -->
+ <NcTooltip v-if="hasMultipleModes" placement="top">
+ <template #title>
+ {{ currentMode?.type === 'list' ? 'Switch to expression input' : 'Switch to dropdown' }}
+ </template>
+ <NcButton type="text" size="small" class="nc-entity-selector-mode-toggle" :disabled="disabled" @click="toggleMode">
+ <GeneralIcon :icon="currentMode?.type === 'list' ? 'ncList' : 'ncCode'" class="text-nc-content-gray-muted" />
+ </NcButton>
+ </NcTooltip>
+
+ <!-- Input container -->
+ <div class="nc-entity-selector-input-container">
+ <!-- List mode (dropdown) -->
+ <template v-if="currentMode?.type === 'list'">
+ <a-select
+ :value="vModel"
+ :options="listOptions"
+ :disabled="disabled"
+ :loading="isLoadingOptions"
+ :placeholder="currentMode.placeholder || element.placeholder || 'Select...'"
+ class="nc-select flex-1 nc-select-shadow"
+ show-search
+ allow-clear
+ :filter-option="currentMode.searchable ? false : (input: string, option: any) => option.label?.toLowerCase()?.includes(input.toLowerCase())"
+ @change="handleListSelect"
+ @search="handleSearch"
+ >
+ <template #suffixIcon>
+ <GeneralIcon icon="ncChevronDown" class="text-nc-content-gray-muted" />
+ </template>
+ </a-select>
+ </template>
+
+ <!-- Manual mode (WorkflowInput) -->
+ <template v-else>
+ <NcFormBuilderInputWorkflowInput
+ :model-value="vModel || ''"
+ :placeholder="currentMode?.placeholder || element.placeholder || 'Enter value or expression...'"
+ :variables="workflowVariables"
+ :grouped-variables="groupedVariables"
+ :read-only="disabled"
+ class="flex-1"
+ @update:model-value="handleInputChange"
+ />
+ </template>
+ </div>
+ </div>
+ </div>
+</template>
+
+<style scoped lang="scss">
+.nc-entity-selector {
+ @apply w-full;
+
+ .nc-entity-selector-container {
+ @apply flex items-center gap-2;
+ }
+
+ .nc-entity-selector-mode-toggle {
+ @apply flex-shrink-0;
+ }
+
+ .nc-entity-selector-input-container {
+ @apply flex-1 flex items-center gap-1 min-w-0;
+
+ :deep(.nc-workflow-input) {
+ @apply min-w-0;
+
+ .ProseMirror {
+ @apply !h-8 !min-h-8 !py-1 !pr-8;
+ }
+
+ .nc-workflow-insert-btn-tooltip {
+ @apply !top-0.5;
+ }
+ }
+
+ :deep(.nc-select) {
+ @apply min-w-0;
+ }
+ }
+}
+</style>
diff --git a/packages/nc-gui/components/nc/form-builder/input/FieldMapping.vue b/packages/nc-gui/components/nc/form-builder/input/FieldMapping.vue
deleted file mode 100644
index bb53071ff2..0000000000
--- a/packages/nc-gui/components/nc/form-builder/input/FieldMapping.vue
+++ /dev/null
@@ -1,228 +0,0 @@
-<script setup lang="ts">
-import type { FormBuilderFieldMappingElement, FormBuilderSelectOption } from 'nocodb-sdk'
-
-interface Props {
- element: FormBuilderFieldMappingElement
- modelValue?: Record<string, string> | null
-}
-
-const props = defineProps<Props>()
-const emit = defineEmits(['update:modelValue'])
-
-const vModel = useVModel(props, 'modelValue', emit)
-
-interface FieldRow {
- id: string
- fieldId: string
- value: string
-}
-
-const isInternalUpdate = ref(false)
-const { getFieldOptions } = useFormBuilderHelperOrThrow()
-
-const workflowContext = inject(WorkflowVariableInj, null)
-
-const fieldOptions = computed<FormBuilderSelectOption[]>(() => {
- if (!props.element.model) return []
- return getFieldOptions(props.element.model) || []
-})
-
-const flatVariables = computed(() => {
- if (!workflowContext?.selectedNodeId?.value || !workflowContext?.getAvailableVariablesFlat) {
- return []
- }
- return workflowContext.getAvailableVariablesFlat(workflowContext.selectedNodeId.value)
-})
-
-const groupedVariables = computed(() => {
- if (!workflowContext?.selectedNodeId?.value || !workflowContext?.getAvailableVariables) {
- return []
- }
- return workflowContext.getAvailableVariables(workflowContext.selectedNodeId.value)
-})
-
-const fieldRows = ref<FieldRow[]>(
- props.modelValue && typeof props.modelValue === 'object'
- ? Object.entries(props.modelValue).map(([fieldId, value]) => ({
- id: generateRandomUUID(),
- fieldId,
- value: value || '',
- }))
- : [
- {
- id: generateRandomUUID(),
- fieldId: '',
- value: '',
- },
- ],
-)
-
-watch(
- fieldRows,
- (rows) => {
- const newValue: Record<string, string> = {}
- rows.forEach((row) => {
- if (row.fieldId) {
- newValue[row.fieldId] = row.value
- }
- })
- isInternalUpdate.value = true
- vModel.value = Object.keys(newValue).length > 0 ? newValue : null
- nextTick(() => {
- isInternalUpdate.value = false
- })
- },
- { deep: true },
-)
-
-function addFieldRow() {
- fieldRows.value.push({
- id: generateRandomUUID(),
- fieldId: '',
- value: '',
- })
-}
-
-function removeFieldRow(index: number) {
- fieldRows.value.splice(index, 1)
-
- if (fieldRows.value.length === 0) {
- addFieldRow()
- }
-}
-
-const disableAddFieldRow = computed(() => {
- const selectedFieldIds = new Set(fieldRows.value.map((row) => row.fieldId))
- const availableOptions = fieldOptions.value.filter((option) => !selectedFieldIds.has(option.value))
- return availableOptions.length === 0
-})
-
-function getAvailableOptions(currentRowId: string) {
- const selectedFieldIds = new Set(
- fieldRows.value.filter((row) => row.id !== currentRowId && row.fieldId).map((row) => row.fieldId),
- )
-
- return fieldOptions.value.filter((option) => !selectedFieldIds.has(option.value))
-}
-
-// Watch modelValue for external changes (e.g., when form builder resets the field)
-watch(
- () => props.modelValue,
- (newValue) => {
- // Skip if this update originated from within the component
- if (isInternalUpdate.value) return
-
- if (!newValue || (typeof newValue === 'object' && Object.keys(newValue).length === 0)) {
- // Reset to single empty row when cleared externally
- fieldRows.value = [
- {
- id: generateRandomUUID(),
- fieldId: '',
- value: '',
- },
- ]
- } else if (typeof newValue === 'object') {
- // Update fieldRows when modelValue changes externally
- fieldRows.value = Object.entries(newValue).map(([fieldId, value]) => ({
- id: generateRandomUUID(),
- fieldId,
- value: value || '',
- }))
- }
- },
-)
-</script>
-
-<template>
- <div class="flex flex-col gap-2 w-full nc-field-mapping">
- <div v-for="(row, index) in fieldRows" :key="row.id" class="nc-field-mapping-row">
- <div class="nc-field-mapping-content">
- <a-select
- v-model:value="row.fieldId"
- class="nc-select flex-1 w-full nc-select-shadow"
- :placeholder="$t('placeholder.selectField')"
- show-search
- :filter-option="
- (input: string, option: any) => {
- return option.label?.toLowerCase()?.includes(input.toLowerCase())
- }
- "
- >
- <template #suffixIcon>
- <GeneralIcon class="text-nc-content-gray nc-select-expand-btn" icon="ncChevronDown" />
- </template>
-
- <a-select-option
- v-for="option in getAvailableOptions(row.id)"
- :key="option.value"
- :value="option.value"
- :label="option.label"
- :disabled="option.ncItemDisabled"
- >
- <div class="flex items-center">
- <NcTooltip class="flex-1" :disabled="!option.ncItemTooltip">
- <template #title>
- {{ option.ncItemTooltip }}
- </template>
- <div class="flex items-center gap-2">
- <span>{{ option.label }}</span>
- </div>
- </NcTooltip>
-
- <GeneralIcon
- v-if="row.fieldId === option.value"
- id="nc-selected-item-icon"
- class="text-nc-content-brand"
- icon="check"
- />
- </div>
- </a-select-option>
- </a-select>
-
- <NcFormBuilderInputWorkflowInput
- class="flex-1 w-full"
- :grouped-variables="groupedVariables"
- :variables="flatVariables"
- :model-value="row.value"
- @update:model-value="row.value = $event"
- />
- <NcButton type="text" size="small" @click="removeFieldRow(index)">
- <GeneralIcon icon="delete" class="text-nc-content-gray-muted" />
- </NcButton>
- </div>
- </div>
-
- <NcButton :disabled="disableAddFieldRow" class="nc-field-mapping-add-btn" type="text" size="small" @click="addFieldRow">
- <div class="flex items-center gap-1">
- <GeneralIcon icon="plus" />
- <span> Add new field </span>
- </div>
- </NcButton>
- </div>
-</template>
-
-<style scoped lang="scss">
-.nc-field-mapping {
- :deep(.nc-workflow-input) {
- .ProseMirror {
- @apply !h-8 !min-h-8 !py-1;
- }
-
- .nc-workflow-input-insert-btn {
- @apply !-top-0.5;
- }
- }
-
- .nc-field-mapping-row {
- @apply flex items-start gap-2;
-
- .nc-field-mapping-content {
- @apply flex items-start gap-2 flex-1;
- }
- }
-
- .nc-field-mapping-add-btn {
- @apply self-start;
- }
-}
-</style>
diff --git a/packages/nc-gui/components/nc/form-builder/input/KeyValue.vue b/packages/nc-gui/components/nc/form-builder/input/KeyValue.vue
new file mode 100644
index 0000000000..c2f667f64c
--- /dev/null
+++ b/packages/nc-gui/components/nc/form-builder/input/KeyValue.vue
@@ -0,0 +1,167 @@
+<script setup lang="ts">
+import type { FormBuilderKeyValueElement } from 'nocodb-sdk'
+
+interface Props {
+ element: FormBuilderKeyValueElement
+ modelValue?: Record<string, string> | null
+ disabled?: boolean
+}
+
+const props = withDefaults(defineProps<Props>(), {
+ disabled: false,
+})
+const emit = defineEmits(['update:modelValue'])
+
+const vModel = useVModel(props, 'modelValue', emit)
+
+const workflowContext = inject(WorkflowVariableInj, null)
+
+interface KeyValueRow {
+ id: string
+ key: string
+ value: string
+}
+
+const isInternalUpdate = ref(false)
+
+// Get workflow variables for expression input
+const workflowVariables = computed(() => {
+ if (!workflowContext?.selectedNodeId?.value || !workflowContext?.getAvailableVariablesFlat) {
+ return []
+ }
+ return workflowContext.getAvailableVariablesFlat(workflowContext.selectedNodeId.value)
+})
+
+const groupedVariables = computed(() => {
+ if (!workflowContext?.selectedNodeId?.value || !workflowContext?.getAvailableVariables) {
+ return []
+ }
+ return workflowContext.getAvailableVariables(workflowContext.selectedNodeId.value)
+})
+
+const rows = ref<KeyValueRow[]>(
+ props.modelValue && typeof props.modelValue === 'object'
+ ? Object.entries(props.modelValue).map(([key, value]) => ({
+ id: generateRandomUUID(),
+ key,
+ value: value || '',
+ }))
+ : [
+ {
+ id: generateRandomUUID(),
+ key: '',
+ value: '',
+ },
+ ],
+)
+
+watch(
+ rows,
+ (newRows) => {
+ const newValue: Record<string, string> = {}
+ newRows.forEach((row) => {
+ if (row.key) {
+ newValue[row.key] = row.value
+ }
+ })
+ isInternalUpdate.value = true
+ vModel.value = Object.keys(newValue).length > 0 ? newValue : null
+ nextTick(() => {
+ isInternalUpdate.value = false
+ })
+ },
+ { deep: true },
+)
+
+function addRow() {
+ rows.value.push({
+ id: generateRandomUUID(),
+ key: '',
+ value: '',
+ })
+}
+
+function removeRow(index: number) {
+ rows.value.splice(index, 1)
+
+ if (rows.value.length === 0) {
+ addRow()
+ }
+}
+
+// Watch modelValue for external changes
+watch(
+ () => props.modelValue,
+ (newValue) => {
+ if (isInternalUpdate.value) return
+
+ if (!newValue || (typeof newValue === 'object' && Object.keys(newValue).length === 0)) {
+ rows.value = [
+ {
+ id: generateRandomUUID(),
+ key: '',
+ value: '',
+ },
+ ]
+ } else if (typeof newValue === 'object') {
+ rows.value = Object.entries(newValue).map(([key, value]) => ({
+ id: generateRandomUUID(),
+ key,
+ value: value || '',
+ }))
+ }
+ },
+)
+</script>
+
+<template>
+ <div class="nc-key-value flex flex-col gap-2 w-full">
+ <div v-for="(row, index) in rows" :key="row.id" class="nc-key-value-row">
+ <div class="nc-key-value-content">
+ <a-input v-model:value="row.key" class="flex-1 w-full" :placeholder="element.keyLabel || 'Key'" :disabled="disabled" />
+
+ <NcFormBuilderInputWorkflowInput
+ v-model="row.value"
+ class="flex-1 w-full"
+ :placeholder="element.valueLabel || 'Value'"
+ :variables="workflowVariables"
+ :grouped-variables="groupedVariables"
+ :read-only="disabled"
+ />
+
+ <NcButton type="text" size="small" :disabled="disabled" @click="removeRow(index)">
+ <GeneralIcon icon="delete" class="text-nc-content-gray-muted" />
+ </NcButton>
+ </div>
+ </div>
+
+ <NcButton class="nc-key-value-add-btn self-start" type="text" size="small" :disabled="disabled" @click="addRow">
+ <div class="flex items-center gap-1">
+ <GeneralIcon icon="plus" />
+ <span>{{ element.placeholder || 'Add row' }}</span>
+ </div>
+ </NcButton>
+ </div>
+</template>
+
+<style scoped lang="scss">
+.nc-key-value {
+ :deep(.nc-workflow-input) {
+ .ProseMirror {
+ @apply !h-8 !min-h-8 !py-1;
+ }
+
+ .nc-workflow-input-insert-btn {
+ @apply !-top-0.5;
+ }
+ }
+
+ .nc-key-value-row {
+ @apply flex items-start gap-2;
+
+ .nc-key-value-content {
+ @apply flex items-start gap-2 flex-1;
+ }
+ }
+}
+</style>
diff --git a/packages/nc-gui/components/smartsheet/topbar/ManagedAppStatus.vue b/packages/nc-gui/components/smartsheet/topbar/ManagedAppStatus.vue
deleted file mode 100644
index 8ddeeaefb7..0000000000
--- a/packages/nc-gui/components/smartsheet/topbar/ManagedAppStatus.vue
+++ /dev/null
@@ -1,112 +0,0 @@
-<script setup lang="ts">
-const { base, isManagedAppMaster } = storeToRefs(useBase())
-const { $api } = useNuxtApp()
-
-const isModalVisible = ref(false)
-const initialTab = ref<'publish' | 'fork' | 'deployments' | undefined>(undefined)
-
-const managedApp = ref<any>(null)
-const currentVersion = ref<any>(null)
-
-// Load managed app info and current version
-const loadManagedApp = async () => {
- if (!base.value?.managed_app_id || !base.value?.managed_app_master || !base.value?.fk_workspace_id) return
-
- try {
- const response = await $api.internal.getOperation(base.value.fk_workspace_id, base.value.id!, {
- operation: 'managedAppGet',
- baseId: base.value.id,
- } as any)
- if (response) {
- managedApp.value = response
- }
- } catch (e) {
- console.error('Failed to load managed app:', e)
- }
-}
-
-// Load current version info
-const loadCurrentVersion = async () => {
- if (!base.value?.managed_app_version_id || !base.value?.managed_app_master || !base.value?.fk_workspace_id) return
-
- try {
- // Get version details from versions list
- const response = await $api.internal.getOperation(base.value.fk_workspace_id, base.value.id!, {
- operation: 'managedAppVersionsList',
- managedAppId: (base.value as any).managed_app_id,
- } as any)
- if (response?.list) {
- currentVersion.value = response.list.find((v: any) => v.id === base.value.managed_app_version_id)
- }
- } catch (e) {
- console.error('Failed to load current version:', e)
- }
-}
-
-const openModal = (tab?: 'publish' | 'fork' | 'deployments') => {
- initialTab.value = tab
- isModalVisible.value = true
-}
-
-const handlePublished = async () => {
- await loadManagedApp()
- await loadCurrentVersion()
-}
-
-const handleForked = async () => {
- await loadManagedApp()
- await loadCurrentVersion()
-}
-
-watch(
- () => (base.value as any)?.managed_app_id,
- async (managedAppId) => {
- if (managedAppId) {
- await loadManagedApp()
- await loadCurrentVersion()
- }
- },
- { immediate: true },
-)
-</script>
-
-<template>
- <div v-if="isManagedAppMaster" class="flex items-center gap-2">
- <!-- Version Badge (clickable to open modal) -->
- <div
- class="flex items-center gap-1.5 px-2.5 py-1 bg-nc-bg-gray-light rounded-md border-1 border-nc-border-gray-medium cursor-pointer hover:(bg-nc-bg-gray-medium border-nc-border-gray-dark) transition-colors"
- @click="openModal()"
- >
- <GeneralIcon icon="ncInfoSolid" class="w-3.5 h-3.5 text-nc-content-gray nc-managed-app-status-info-icon" />
- <span class="text-xs font-mono font-semibold text-nc-content-gray-emphasis">v{{ currentVersion?.version || '1.0.0' }}</span>
- <div
- v-if="currentVersion?.status === 'draft'"
- class="ml-1 px-1.5 py-0.5 text-xs rounded bg-nc-bg-orange-light text-nc-content-orange-dark font-medium"
- >
- {{ $t('labels.draft') }}
- </div>
- <div
- v-else-if="currentVersion?.status === 'published'"
- class="ml-1 px-1.5 py-0.5 text-xs rounded bg-nc-bg-green-dark text-nc-content-green-dark font-medium"
- >
- {{ $t('labels.published') }}
- </div>
- </div>
- </div>
-
- <!-- Managed App Modal -->
- <SmartsheetTopbarManagedAppModal
- v-model:visible="isModalVisible"
- :managed-app="managedApp"
- :current-version="currentVersion"
- :initial-tab="initialTab"
- @published="handlePublished"
- @forked="handleForked"
- />
-</template>
-
-<style lang="scss" scoped>
-:deep(.nc-managed-app-status-info-icon path.nc-icon-inner) {
- stroke: var(--nc-bg-gray-light) !important;
-}
-</style>
diff --git a/packages/nc-gui/composables/useFormBuilder/index.ts b/packages/nc-gui/composables/useFormBuilder/index.ts
index 34fc7cd890..d98ed6e4da 100644
--- a/packages/nc-gui/composables/useFormBuilder/index.ts
+++ b/packages/nc-gui/composables/useFormBuilder/index.ts
@@ -3,6 +3,7 @@ import { diff } from 'deep-object-diff'
import type {
CustomFormBuilderValidator,
FormBuilderCondition,
+ FormBuilderConditionGroup,
FormBuilderElement,
FormBuilderValidator,
FormDefinition,
@@ -60,6 +61,8 @@ const [useProvideFormBuilderHelper, useFormBuilderHelper] = useInjectionState(
setNestedProp(defaultState, field.model, field.defaultValue ?? false)
} else if (field.type === FormBuilderInputType.Select) {
setNestedProp(defaultState, field.model, field.defaultValue ?? [])
+ } else if (field.type === FormBuilderInputType.ConditionBuilder) {
+ setNestedProp(defaultState, field.model, field.defaultValue ?? { combinator: 'and', conditions: [] })
} else {
setNestedProp(defaultState, field.model, field.defaultValue ?? '')
}
@@ -78,7 +81,7 @@ const [useProvideFormBuilderHelper, useFormBuilderHelper] = useInjectionState(
setFormStateHelper(formState, path, value)
}
- const loadOptions = async (field: FormBuilderElement) => {
+ const loadOptions = async (field: FormBuilderElement, searchQuery?: string) => {
/**
* If the field is not visible, don't load options
*/
@@ -87,7 +90,7 @@ const [useProvideFormBuilderHelper, useFormBuilderHelper] = useInjectionState(
isLoadingFieldOptions.value[field.model] = true
try {
- fieldOptions.value[field.model] = await fetchOptions(field.fetchOptionsKey)
+ fieldOptions.value[field.model] = await fetchOptions(field.fetchOptionsKey, searchQuery)
} finally {
isLoadingFieldOptions.value[field.model] = false
}
@@ -132,47 +135,98 @@ const [useProvideFormBuilderHelper, useFormBuilderHelper] = useInjectionState(
})
}
- function checkCondition(field: FormBuilderElement) {
- if (!field.condition) return true
+ function checkConditionItem(condition: FormBuilderCondition): boolean {
+ const value = deepReference(condition.model)
- const condition = field.condition
+ // Check equality
+ if (condition.value !== undefined || condition.equal !== undefined) {
+ return condition.value !== undefined ? condition.value === value : condition.equal === value
+ }
+
+ // Check not equal
+ if (condition.notEqual !== undefined) {
+ return condition.notEqual !== value
+ }
- function checkConditionItem(condition: FormBuilderCondition) {
- const value = deepReference(condition.model)
- if (condition.value || condition.equal) {
- return condition.value ? condition.value === value : condition.equal === value
+ // Check if value is in array
+ // When value is an array (multi-select), check if ANY condition.in element is in value
+ if (condition.in) {
+ if (Array.isArray(value)) {
+ return condition.in.some((item) => value.includes(item))
}
+ return condition.in.includes(value)
+ }
- if (condition.in) {
- return condition.in.includes(value)
+ // Check if value is NOT in array
+ // When value is an array (multi-select), check if NONE of condition.notIn elements are in value
+ if (condition.notIn) {
+ if (Array.isArray(value)) {
+ return !condition.notIn.some((item) => value.includes(item))
}
+ return !condition.notIn.includes(value)
+ }
- if (condition.empty) {
- if (Array.isArray(value)) {
- return value.length === 0
- }
+ // Check if empty
+ if (condition.empty) {
+ if (Array.isArray(value)) {
+ return value.length === 0
+ }
+ return !value
+ }
- return !value
+ // Check if not empty
+ if (condition.notEmpty) {
+ if (Array.isArray(value)) {
+ return value.length > 0
}
+ return !!value
+ }
- if (condition.notEmpty) {
- if (Array.isArray(value)) {
- return value.length > 0
- }
+ return false
+ }
+
+ function checkConditionGroup(
+ conditionOrGroup: FormBuilderCondition | FormBuilderCondition[] | FormBuilderConditionGroup,
+ ): boolean {
+ // Single condition
+ if ('model' in conditionOrGroup && typeof conditionOrGroup.model === 'string') {
+ return checkConditionItem(conditionOrGroup as FormBuilderCondition)
+ }
+
+ // Array of conditions (AND logic)
+ if (Array.isArray(conditionOrGroup)) {
+ return conditionOrGroup.every((c) => checkConditionItem(c))
+ }
+
+ // Condition group with operator
+ if ('conditions' in conditionOrGroup) {
+ const group = conditionOrGroup as FormBuilderConditionGroup
+ const operator = group.operator || 'and'
- return !!value
+ if (operator === 'or') {
+ return group.conditions.some((c) => checkConditionItem(c))
}
+ // Default: AND
+ return group.conditions.every((c) => checkConditionItem(c))
+ }
- return false
+ return true
+ }
+
+ function checkCondition(field: FormBuilderElement): boolean {
+ // Check show condition
+ if (field.condition) {
+ const showResult = checkConditionGroup(field.condition)
+ if (!showResult) return false
}
- if (Array.isArray(condition)) {
- return condition.every((c) => {
- return checkConditionItem(c)
- })
+ // Check hide condition (opposite logic - hide when condition is met)
+ if (field.hideCondition) {
+ const hideResult = checkConditionGroup(field.hideCondition)
+ if (hideResult) return false
}
- return checkConditionItem(condition)
+ return true
}
const groupCollapseState = ref<Record<string, boolean>>({})
@@ -247,23 +301,67 @@ const [useProvideFormBuilderHelper, useFormBuilderHelper] = useInjectionState(
if (field.validators && checkCondition(field)) {
validatorsObject[field.model] = field.validators
.map((validator: FormBuilderValidator) => {
- if (validator.type === FormBuilderValidatorType.Required) {
- return {
- required: true,
- message: validator.message,
- }
+ switch (validator.type) {
+ case FormBuilderValidatorType.Required:
+ return {
+ required: true,
+ message: validator.message || 'This field is required',
+ }
+
+ case FormBuilderValidatorType.Regex:
+ return {
+ pattern: new RegExp(validator.pattern, validator.flags),
+ message: validator.message || 'Invalid format',
+ }
+
+ case FormBuilderValidatorType.MinValue:
+ return {
+ type: 'number',
+ min: validator.value,
+ message: validator.message || `Value must be at least ${validator.value}`,
+ }
+
+ case FormBuilderValidatorType.MaxValue:
+ return {
+ type: 'number',
+ max: validator.value,
+ message: validator.message || `Value must be at most ${validator.value}`,
+ }
+
+ case FormBuilderValidatorType.MinLength:
+ return {
+ min: validator.value,
+ message: validator.message || `Must be at least ${validator.value} characters`,
+ }
+
+ case FormBuilderValidatorType.MaxLength:
+ return {
+ max: validator.value,
+ message: validator.message || `Must be at most ${validator.value} characters`,
+ }
+
+ case FormBuilderValidatorType.Email:
+ return {
+ type: 'email',
+ message: validator.message || 'Please enter a valid email address',
+ }
+
+ case FormBuilderValidatorType.Url:
+ return {
+ type: 'url',
+ message: validator.message || 'Please enter a valid URL',
+ }
+ case FormBuilderValidatorType.Custom:
+ if (!ncIsFunction((validator as CustomFormBuilderValidator).validator)) {
+ return null
+ }
+ return {
+ validator: (validator as CustomFormBuilderValidator).validator,
+ }
+
+ default:
+ return null
}
-
- if (
- validator.type === FormBuilderValidatorType.Custom &&
- ncIsFunction((validator as CustomFormBuilderValidator).validator)
- ) {
- return {
- validator: (validator as CustomFormBuilderValidator).validator,
- }
- }
-
- return null
})
.filter((v: any) => v !== null)
}
diff --git a/packages/nc-gui/composables/useViewColumns.ts b/packages/nc-gui/composables/useViewColumns.ts
index 507208dfa8..9991478546 100644
--- a/packages/nc-gui/composables/useViewColumns.ts
+++ b/packages/nc-gui/composables/useViewColumns.ts
@@ -363,10 +363,18 @@ const [useProvideViewColumns, useViewColumns] = useInjectionState(
set(v: boolean) {
if (view?.value?.id) {
if (!isLocalMode.value) {
- $api.dbView
- .update(view.value.id, {
- show_system_fields: v,
- })
+ $api.internal
+ .postOperation(
+ view.value.fk_workspace_id!,
+ view.value.base_id!,
+ {
+ operation: 'viewUpdate',
+ viewId: view.value.id,
+ },
+ {
+ show_system_fields: v,
+ },
+ )
.finally(() => {
loadViewColumns()
reloadData?.()
diff --git a/packages/nocodb-sdk/src/lib/formBuilder/index.ts b/packages/nocodb-sdk/src/lib/formBuilder/index.ts
index dd430e0d90..21712840f2 100644
--- a/packages/nocodb-sdk/src/lib/formBuilder/index.ts
+++ b/packages/nocodb-sdk/src/lib/formBuilder/index.ts
@@ -1,4 +1,4 @@
-import { BaseType } from "../Api";
+import { BaseType } from '../Api';
export enum FormBuilderInputType {
Input = 'input',
@@ -16,7 +16,9 @@ export enum FormBuilderInputType {
OAuth = 'oauth',
Checkbox = 'checkbox',
WorkflowInput = 'workflow-input',
- FieldMapping = 'field-mapping',
+ KeyValue = 'key-value',
+ EntitySelector = 'entity-selector',
+ ConditionBuilder = 'condition-builder',
}
/**
@@ -32,10 +34,35 @@ export interface FormBuilderCondition {
equal?: string;
/** Check if the model value is in this array of values */
in?: string[];
+ /** Check if the model value is NOT in this array of values */
+ notIn?: string[];
/** Check if the model value is empty (empty string, empty array, null, undefined) */
empty?: boolean;
/** Check if the model value is not empty */
notEmpty?: boolean;
+ /** Check if the model value does NOT equal this value */
+ notEqual?: string;
+}
+
+/**
+ * Hide condition configuration - field will be hidden when condition is met
+ * Opposite of show condition (condition property)
+ */
+export type FormBuilderHideCondition = FormBuilderCondition;
+
+/**
+ * Logical operator for combining multiple conditions
+ */
+export type FormBuilderConditionOperator = 'and' | 'or';
+
+/**
+ * Multiple conditions with logical operator
+ */
+export interface FormBuilderConditionGroup {
+ /** Logical operator to combine conditions (default: 'and') */
+ operator?: FormBuilderConditionOperator;
+ /** Array of conditions to evaluate */
+ conditions: FormBuilderCondition[];
}
/**
@@ -43,24 +70,113 @@ export interface FormBuilderCondition {
*/
export enum FormBuilderValidatorType {
Required = 'required',
+ Regex = 'regex',
+ MinValue = 'minValue',
+ MaxValue = 'maxValue',
+ MinLength = 'minLength',
+ MaxLength = 'maxLength',
+ Email = 'email',
+ Url = 'url',
Custom = 'custom',
}
/**
- * Validator configuration for form field validation
+ * Base validator configuration
*/
-export interface BaseFormBuilderValidator {
- /** Type of validation to apply */
+interface FormBuilderValidatorBase {
type: FormBuilderValidatorType;
/** Custom error message to display when validation fails */
message?: string;
}
-export interface CustomFormBuilderValidator extends BaseFormBuilderValidator {
- validator: (rule: any, value: any) => Promise<any>
+/**
+ * Required validator
+ */
+export interface FormBuilderRequiredValidator extends FormBuilderValidatorBase {
+ type: FormBuilderValidatorType.Required;
+}
+
+/**
+ * Regex validator - validates against a regular expression pattern
+ */
+export interface FormBuilderRegexValidator extends FormBuilderValidatorBase {
+ type: FormBuilderValidatorType.Regex;
+ /** Regular expression pattern to match */
+ pattern: string;
+ /** Regex flags (e.g., 'i' for case-insensitive) */
+ flags?: string;
+}
+
+/**
+ * MinValue validator - validates minimum numeric value
+ */
+export interface FormBuilderMinValueValidator extends FormBuilderValidatorBase {
+ type: FormBuilderValidatorType.MinValue;
+ /** Minimum allowed value */
+ value: number;
+}
+
+/**
+ * MaxValue validator - validates maximum numeric value
+ */
+export interface FormBuilderMaxValueValidator extends FormBuilderValidatorBase {
+ type: FormBuilderValidatorType.MaxValue;
+ /** Maximum allowed value */
+ value: number;
+}
+
+/**
+ * MinLength validator - validates minimum string length
+ */
+export interface FormBuilderMinLengthValidator
+ extends FormBuilderValidatorBase {
+ type: FormBuilderValidatorType.MinLength;
+ /** Minimum string length */
+ value: number;
+}
+
+/**
+ * MaxLength validator - validates maximum string length
+ */
+export interface FormBuilderMaxLengthValidator
+ extends FormBuilderValidatorBase {
+ type: FormBuilderValidatorType.MaxLength;
+ /** Maximum string length */
+ value: number;
+}
+
+/**
+ * Email validator - validates email format
+ */
+export interface FormBuilderEmailValidator extends FormBuilderValidatorBase {
+ type: FormBuilderValidatorType.Email;
}
-export type FormBuilderValidator = BaseFormBuilderValidator | CustomFormBuilderValidator;
+/**
+ * URL validator - validates URL format
+ */
+export interface FormBuilderUrlValidator extends FormBuilderValidatorBase {
+ type: FormBuilderValidatorType.Url;
+}
+
+export interface CustomFormBuilderValidator extends FormBuilderValidatorBase {
+ type: FormBuilderValidatorType.Custom;
+ validator: (rule: any, value: any) => Promise<any>;
+}
+
+/**
+ * Union type of all validator configurations
+ */
+export type FormBuilderValidator =
+ | FormBuilderRequiredValidator
+ | FormBuilderRegexValidator
+ | FormBuilderMinValueValidator
+ | FormBuilderMaxValueValidator
+ | FormBuilderMinLengthValidator
+ | FormBuilderMaxLengthValidator
+ | FormBuilderEmailValidator
+ | FormBuilderUrlValidator
+ | CustomFormBuilderValidator;
/**
* Option configuration for select elements
@@ -138,8 +254,22 @@ interface FormBuilderElementBase {
description?: string;
/** Category for grouping elements - same category elements are grouped together */
category?: string;
- /** Condition(s) for the element to be visible */
- condition?: FormBuilderCondition | FormBuilderCondition[];
+ /**
+ * Condition(s) for the element to be visible (show condition)
+ * Can be a single condition, array of conditions (AND logic), or a condition group
+ */
+ condition?:
+ | FormBuilderCondition
+ | FormBuilderCondition[]
+ | FormBuilderConditionGroup;
+ /**
+ * Hide condition(s) - element will be hidden when condition is met
+ * Opposite of show condition. Can be a single condition, array (AND), or group
+ */
+ hideCondition?:
+ | FormBuilderHideCondition
+ | FormBuilderHideCondition[]
+ | FormBuilderConditionGroup;
/** Show border around the element */
border?: boolean;
/** Show hint as tooltip instead of inline text */
@@ -224,6 +354,8 @@ export interface FormBuilderSelectElement extends FormBuilderElementBase {
selectMode?: 'single' | 'multiple' | 'multipleWithInput' | 'singleWithInput';
/** Key to fetch options dynamically */
fetchOptionsKey?: string;
+ /** Enable server-side search - when true, typing triggers fetchOptions with search query */
+ searchable?: boolean;
/** Default value - string for single, array for multiple */
defaultValue?: string | string[] | null;
}
@@ -338,16 +470,167 @@ export interface FormBuilderWorkflowInputElement
}
/**
- * FieldMapping element (Dynamic field-value mapping with field selection and workflow input)
+ * KeyValue element (Dynamic key-value pair input for arbitrary data)
*/
-export interface FormBuilderFieldMappingElement extends FormBuilderElementBase {
- type: FormBuilderInputType.FieldMapping;
- /** Key to fetch field options dynamically */
- fetchOptionsKey?: string;
- /** Default field-value mappings as Record<fieldId, value> */
+export interface FormBuilderKeyValueElement extends FormBuilderElementBase {
+ type: FormBuilderInputType.KeyValue;
+ /** Label for the key column */
+ keyLabel?: string;
+ /** Label for the value column */
+ valueLabel?: string;
+ /** Default key-value pairs as Record<key, value> */
defaultValue?: Record<string, string> | null;
}
+/**
+ * EntitySelector mode configuration
+ */
+export interface EntitySelectorMode {
+ /** Mode type: 'list' for dropdown, 'manual' for WorkflowInput */
+ type: 'list' | 'manual';
+ /** Key to fetch options dynamically (for 'list' mode) */
+ fetchOptionsKey?: string;
+ /** Enable server-side search (for 'list' mode) */
+ searchable?: boolean;
+ /** Placeholder text for this mode */
+ placeholder?: string;
+}
+
+/**
+ * EntitySelector element - Select dropdown with optional toggle to WorkflowInput
+ *
+ * Use cases:
+ * - Select an entity from a dropdown (e.g., HubSpot Contact)
+ * - OR enter an ID/expression manually using WorkflowInput
+ *
+ * Value is stored as simple string (the ID/value).
+ */
+export interface FormBuilderEntitySelectorElement
+ extends FormBuilderElementBase {
+ type: FormBuilderInputType.EntitySelector;
+ /** Available modes - defaults to just list mode if not specified */
+ modes?: EntitySelectorMode[];
+ /** Default value - simple string */
+ defaultValue?: string | null;
+}
+
+/**
+ * Filter operator types by data type
+ */
+export type FilterOperatorType =
+ // String operators
+ | 'equals'
+ | 'notEquals'
+ | 'contains'
+ | 'notContains'
+ | 'startsWith'
+ | 'endsWith'
+ | 'regex'
+ // Number operators
+ | 'gt'
+ | 'gte'
+ | 'lt'
+ | 'lte'
+ // DateTime operators
+ | 'after'
+ | 'before'
+ // Boolean operators
+ | 'isTrue'
+ | 'isFalse'
+ // Common operators
+ | 'exists'
+ | 'notExists'
+ | 'empty'
+ | 'notEmpty';
+
+/**
+ * Filter data types
+ */
+export type FilterDataType =
+ | 'string'
+ | 'number'
+ | 'boolean'
+ | 'dateTime'
+ | 'array'
+ | 'object'
+ | 'any';
+
+/**
+ * Filter operator definition
+ */
+export interface FilterOperator {
+ /** Operator identifier */
+ id: string;
+ /** Display name */
+ name: string;
+ /** Data type this operator applies to */
+ type: FilterDataType;
+ /** Operation type */
+ operation: FilterOperatorType;
+ /** Whether this operator doesn't need a right-side value (e.g., exists, empty) */
+ singleValue?: boolean;
+ /** Expected type for right-side value (if different from left) */
+ rightType?: FilterDataType;
+}
+
+/**
+ * Single filter condition value
+ */
+export interface FilterConditionValue {
+ /** Unique ID for this condition */
+ id?: string;
+ /** Left side value (field/variable reference or literal) */
+ leftValue: string;
+ /** Selected operator */
+ operator: {
+ type: FilterDataType;
+ operation: FilterOperatorType;
+ };
+ /** Right side value (comparison value) */
+ rightValue?: string;
+}
+
+/**
+ * Filter combinator type
+ */
+export type FilterCombinator = 'and' | 'or';
+
+/**
+ * Condition builder value (array of conditions with combinator)
+ */
+export interface ConditionBuilderValue {
+ /** Combinator for combining conditions (default: 'and') */
+ combinator: FilterCombinator;
+ /** Array of filter conditions */
+ conditions: FilterConditionValue[];
+}
+
+/**
+ * ConditionBuilder element - Complex filter/condition builder with drag-drop conditions
+ */
+export interface FormBuilderConditionBuilderElement
+ extends FormBuilderElementBase {
+ type: FormBuilderInputType.ConditionBuilder;
+ /** Allowed data types for filtering */
+ allowedTypes?: FilterDataType[];
+ /** Whether the left value is fixed (not editable) */
+ fixedLeftValue?: boolean;
+ /** Supported operators (if not specified, all operators are available) */
+ supportedOperators?: FilterOperatorType[];
+ /** Whether conditions can be reordered */
+ sortable?: boolean;
+ /** Maximum number of conditions */
+ maxConditions?: number;
+ /** Default value */
+ defaultValue?: ConditionBuilderValue | null;
+ /** Static property options for the left value dropdown */
+ propertyOptions?: FormBuilderSelectOption[];
+ /** Key to fetch property options dynamically */
+ fetchPropertyOptionsKey?: string;
+ /** Placeholder for property field */
+ propertyPlaceholder?: string;
+}
+
/**
* Union type of all possible form builder elements
*/
@@ -367,7 +650,9 @@ export type FormBuilderElement =
| FormBuilderOAuthElement
| FormBuilderWorkflowInputElement
| FormBuilderNumberInputElement
- | FormBuilderFieldMappingElement;
+ | FormBuilderKeyValueElement
+ | FormBuilderEntitySelectorElement
+ | FormBuilderConditionBuilderElement;
/**
* Complete form definition - array of form elements
diff --git a/packages/nocodb-sdk/src/lib/workflow/constants.ts b/packages/nocodb-sdk/src/lib/workflow/constants.ts
index ce9e5cc896..8b662e6d24 100644
--- a/packages/nocodb-sdk/src/lib/workflow/constants.ts
+++ b/packages/nocodb-sdk/src/lib/workflow/constants.ts
@@ -14,6 +14,7 @@ export enum TriggerActivationType {
NONE = 'none', // Manual triggers - no activation needed
WEBHOOK = 'webhook', // External webhooks (GitHub, GitLab, etc.)
CRON = 'cron', // Scheduled/cron-based
+ POLLING = 'polling', // Polling-based triggers for services without webhooks
}
/**
diff --git a/packages/nocodb/src/controllers/utils.controller.ts b/packages/nocodb/src/controllers/utils.controller.ts
index e1ca61edd6..b3587e357a 100644
--- a/packages/nocodb/src/controllers/utils.controller.ts
+++ b/packages/nocodb/src/controllers/utils.controller.ts
@@ -29,6 +29,7 @@ import { MetaTable, RootScopes } from '~/utils/globals';
import { NcError } from '~/helpers/catchError';
import { deepMerge, isEE } from '~/utils';
import Noco from '~/Noco';
+import { DataApiLimiterGuard } from '~/guards/data-api-limiter.guard';
@Controller()
export class UtilsController {
@@ -146,8 +147,9 @@ export class UtilsController {
return await this.utilsService.appHealth();
}
- @UseGuards(PublicApiLimiterGuard)
+ @UseGuards(DataApiLimiterGuard, GlobalGuard)
@Post(['/api/v1/db/meta/axiosRequestMake', '/api/v2/meta/axiosRequestMake'])
+ @Acl('fetchViaUrl')
@HttpCode(200)
async axiosRequestMake(@Body() body: any) {
return await this.utilsService.axiosRequestMake({ body });
diff --git a/packages/nocodb/src/interface/Jobs.ts b/packages/nocodb/src/interface/Jobs.ts
index d03ce35af7..97fec1dce9 100644
--- a/packages/nocodb/src/interface/Jobs.ts
+++ b/packages/nocodb/src/interface/Jobs.ts
@@ -62,6 +62,8 @@ export enum JobTypes {
ResumeWorkflow = 'resume-workflow',
TestWorkflowNode = 'test-workflow-node',
HeartbeatWorkflow = 'heartbeat-workflow',
+ PollWorkflow = 'poll-workflow',
+ WorkflowErrorNotification = 'workflow-error-notification',
}
export const SKIP_STORING_JOB_META = [
@@ -81,6 +83,8 @@ export const SKIP_STORING_JOB_META = [
JobTypes.WorkflowResumeSchedule,
JobTypes.ResumeWorkflow,
JobTypes.HeartbeatWorkflow,
+ JobTypes.PollWorkflow,
+ JobTypes.WorkflowErrorNotification,
];
export enum JobStatus {
@@ -300,3 +304,9 @@ export interface TestWorkflowNodeJobData extends JobData {
export interface HeartbeatWorkflowJobData extends JobData {
workflowId: string;
}
+
+export interface PollWorkflowJobData extends JobData {
+ workflowId: string;
+ triggerNodeId: string;
+ activationState: Record<string, any>;
+}
diff --git a/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts b/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts
index a7294f5a8c..3cc8f58644 100644
--- a/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts
+++ b/packages/nocodb/src/meta/migrations/XcMigrationSourcev0.ts
@@ -13,6 +13,7 @@ import * as nc_012_workflow_delay from './v0/nc_012_workflow_delay';
import * as nc_013_composite_pk_missing_tables from './v0/nc_013_composite_pk_missing_tables';
import * as nc_014_sandboxes from './v0/nc_014_sandboxes';
import * as nc_015_managed_apps from './v0/nc_015_managed_apps';
+import * as nc_016_automation_error_notifications from './v0/nc_016_automation_error_notifications';
// Create a custom migration source class
export default class XcMigrationSourcev0 {
@@ -37,6 +38,7 @@ export default class XcMigrationSourcev0 {
'nc_013_composite_pk_missing_tables',
'nc_014_sandboxes',
'nc_015_managed_apps',
+ 'nc_016_automation_error_notifications',
]);
}
@@ -76,6 +78,8 @@ export default class XcMigrationSourcev0 {
return nc_014_sandboxes;
case 'nc_015_managed_apps':
return nc_015_managed_apps;
+ case 'nc_016_automation_error_notifications':
+ return nc_016_automation_error_notifications
}
}
}
diff --git a/packages/nocodb/src/meta/migrations/v0/nc_016_automation_error_notifications.ts b/packages/nocodb/src/meta/migrations/v0/nc_016_automation_error_notifications.ts
new file mode 100644
index 0000000000..d6f894bd61
--- /dev/null
+++ b/packages/nocodb/src/meta/migrations/v0/nc_016_automation_error_notifications.ts
@@ -0,0 +1,63 @@
+import type { Knex } from 'knex';
+import { MetaTable } from '~/utils/globals';
+
+const up = async (knex: Knex) => {
+ await knex.schema.alterTable(MetaTable.AUTOMATION_EXECUTIONS, (table) => {
+ table.timestamp('error_notified_at', { useTz: true }).nullable();
+ });
+ await knex.schema.alterTable(MetaTable.AUTOMATION_EXECUTIONS, (table) => {
+ table.index(
+ ['status', 'error_notified_at'],
+ 'nc_automation_executions_error_notify_idx',
+ );
+ });
+
+ await knex(MetaTable.AUTOMATION_EXECUTIONS)
+ .where('status', 'error')
+ .update({ error_notified_at: knex.fn.now() });
+
+ await knex.schema.createTable(
+ MetaTable.AUTOMATION_SUBSCRIBERS,
+ (table) => {
+ table.string('id', 20)
+ table.string('fk_workspace_id', 20);
+ table.string('base_id', 20)
+ table.string('fk_automation_id', 20)
+ table.string('fk_user_id', 20)
+ table.boolean('notify_on_error').defaultTo(true);
+ table.timestamps({ defaultToNow: true, useTimestamps: true})
+
+ table.primary(['base_id', 'id']);
+ },
+ );
+
+ await knex.schema.alterTable(MetaTable.AUTOMATION_SUBSCRIBERS, (table) => {
+ table.index(
+ ['fk_automation_id'],
+ 'nc_automation_subscribers_automation_idx',
+ );
+ table.index(
+ ['fk_user_id'],
+ 'nc_automation_subscribers_user_idx',
+ );
+ table.unique(['fk_automation_id', 'fk_user_id'], {
+ indexName: 'nc_automation_subscribers_unique_idx',
+ });
+ });
+};
+
+const down = async (knex: Knex) => {
+ await knex.schema.dropTableIfExists(MetaTable.AUTOMATION_SUBSCRIBERS);
+
+ await knex.schema.alterTable(MetaTable.AUTOMATION_EXECUTIONS, (table) => {
+ table.dropIndex(
+ ['status', 'error_notified_at'],
+ 'nc_automation_executions_error_notify_idx',
+ );
+ });
+ await knex.schema.alterTable(MetaTable.AUTOMATION_EXECUTIONS, (table) => {
+ table.dropColumn('error_notified_at');
+ });
+};
+
+export { up, down };
diff --git a/packages/nocodb/src/modules/noco.module.ts b/packages/nocodb/src/modules/noco.module.ts
index 50f24db0cc..990b21ceef 100644
--- a/packages/nocodb/src/modules/noco.module.ts
+++ b/packages/nocodb/src/modules/noco.module.ts
@@ -407,6 +407,7 @@ export const nocoModuleMetadata = {
ViewRowColorService,
ViewRowColorV3Service,
DependencyService,
+ MailService,
/* Datas */
DatasService,
diff --git a/packages/nocodb/src/services/mail/mail.service.ts b/packages/nocodb/src/services/mail/mail.service.ts
index 3c8cc94e35..52fbcd3a4c 100644
--- a/packages/nocodb/src/services/mail/mail.service.ts
+++ b/packages/nocodb/src/services/mail/mail.service.ts
@@ -50,6 +50,8 @@ export class MailService {
columnId?: string;
resetPassword?: string;
verificationToken?: string;
+ automationId?: string;
+ executionId?: string;
} = {},
) {
const dashboardPath = Noco.getConfig()?.dashboardPath;
@@ -58,7 +60,7 @@ export class MailService {
return `${req.ncSiteUrl}${dashboardPath}#/signup/${params.token}`;
}
- let url = req.ncSiteUrl;
+ let url = req?.ncSiteUrl || process.env.NC_PUBLIC_URL;
// Reset password link is served from the backend. So no need to append the dashboard path
if (params.resetPassword) {
@@ -102,6 +104,17 @@ export class MailService {
url += `?${searchParams.toString()}`;
}
}
+
+ if (params.automationId) {
+ url += `/workflows/${params.automationId}`;
+
+ if (params.executionId) {
+ const searchParams = new URLSearchParams();
+ searchParams.set('tab', 'logs');
+ searchParams.set('executionId', params.executionId);
+ url += `?${searchParams.toString()}`;
+ }
+ }
}
return url;
diff --git a/packages/nocodb/src/utils/acl.ts b/packages/nocodb/src/utils/acl.ts
index 783756530c..ecc2623c02 100644
--- a/packages/nocodb/src/utils/acl.ts
+++ b/packages/nocodb/src/utils/acl.ts
@@ -82,6 +82,9 @@ const permissionScopes = {
'mcpRootList',
'getUserProfile',
+
+ // etc
+ 'fetchViaUrl',
],
base: [
'nestedDataListCopyPasteOrDeleteAll',
@@ -291,6 +294,9 @@ const rolePermissions:
mcpCreate: true,
mcpUpdate: true,
mcpDelete: true,
+
+ // etc
+ fetchViaUrl: true,
},
},
[ProjectRoles.COMMENTER]: {
diff --git a/packages/nocodb/src/utils/globals.ts b/packages/nocodb/src/utils/globals.ts
index 2c8b416f79..d58813c5ca 100644
--- a/packages/nocodb/src/utils/globals.ts
+++ b/packages/nocodb/src/utils/globals.ts
@@ -108,6 +108,7 @@ export enum MetaTable {
MANAGED_APPS = 'nc_managed_apps',
MANAGED_APP_VERSIONS = 'nc_managed_app_versions',
MANAGED_APP_DEPLOYMENT_LOGS = 'nc_managed_app_deployment_logs',
+ AUTOMATION_SUBSCRIBERS = 'nc_automation_subscribers',
}
export const BaseRelatedMetaTables = [
@@ -333,6 +334,7 @@ export enum CacheScope {
MANAGED_APP_VERSION = 'managedAppVersion',
MANAGED_APP_DEPLOYMENT_LOG = 'managedAppDeploymentLog',
SUBSCRIPTIONS_ALIAS = 'subscriptionsAlias',
+ AUTOMATION_SUBSCRIBER = 'automationSubscriber',
}
export enum CacheGetType {