mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 08:58:26 +00:00
Merge branch 'main' into release/v2.22.0
This commit is contained in:
commit
31c4fefc72
5 changed files with 27 additions and 18 deletions
|
|
@ -2,7 +2,8 @@ import React, { useState, useEffect, useContext } from 'react';
|
|||
import { CodeHinter } from '@/Editor/CodeBuilder/CodeHinter';
|
||||
import { TooljetDatabaseContext } from '@/TooljetDatabase/index';
|
||||
import Select from '@/_ui/Select';
|
||||
import { isEmpty, uniqueId } from 'lodash';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { useMounted } from '@/_hooks/use-mount';
|
||||
import { ButtonSolid } from '@/_ui/AppButton/AppButton';
|
||||
|
||||
|
|
@ -40,7 +41,7 @@ export const CreateRow = React.memo(({ optionchanged, options, darkMode }) => {
|
|||
}
|
||||
const existingColumnOption = Object.values ? Object.values(columnOptions) : [];
|
||||
const emptyColumnOption = { column: '', value: '' };
|
||||
handleColumnOptionChange({ ...existingColumnOption, ...{ [uniqueId()]: emptyColumnOption } });
|
||||
handleColumnOptionChange({ ...existingColumnOption, ...{ [uuidv4()]: emptyColumnOption } });
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import React, { useContext } from 'react';
|
||||
import { TooljetDatabaseContext } from '@/TooljetDatabase/index';
|
||||
import { isEmpty, uniqueId } from 'lodash';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { CodeHinter } from '@/Editor/CodeBuilder/CodeHinter';
|
||||
import Select from '@/_ui/Select';
|
||||
import { operators } from '@/TooljetDatabase/constants';
|
||||
|
|
@ -18,7 +19,7 @@ export const DeleteRows = React.memo(({ darkMode }) => {
|
|||
function addNewFilterConditionPair() {
|
||||
const existingFilters = deleteRowsOptions?.where_filters ? Object.values(deleteRowsOptions?.where_filters) : [];
|
||||
const emptyFilter = { column: '', operator: '', value: '' };
|
||||
const newFilter = { ...emptyFilter, ...{ id: uniqueId() } };
|
||||
const newFilter = { ...emptyFilter, ...{ id: uuidv4() } };
|
||||
handleWhereFiltersChange({ ...existingFilters, ...{ [newFilter.id]: newFilter } });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React, { useContext } from 'react';
|
||||
import { CodeHinter } from '@/Editor/CodeBuilder/CodeHinter';
|
||||
import { TooljetDatabaseContext } from '@/TooljetDatabase/index';
|
||||
import { isEmpty, uniqueId } from 'lodash';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { isEmpty } from 'lodash';
|
||||
import Select from '@/_ui/Select';
|
||||
import { operators } from '@/TooljetDatabase/constants';
|
||||
import { isOperatorOptions } from './util';
|
||||
|
|
@ -21,14 +22,14 @@ export const ListRows = React.memo(({ darkMode }) => {
|
|||
function addNewFilterConditionPair() {
|
||||
const existingFilters = listRowsOptions?.where_filters ? Object.values(listRowsOptions?.where_filters) : [];
|
||||
const emptyFilter = { column: '', operator: '', value: '' };
|
||||
const newFilter = { ...emptyFilter, ...{ id: uniqueId() } };
|
||||
const newFilter = { ...emptyFilter, ...{ id: uuidv4() } };
|
||||
handleWhereFiltersChange({ ...existingFilters, ...{ [newFilter.id]: newFilter } });
|
||||
}
|
||||
|
||||
function addNewSortConditionPair() {
|
||||
const existingFilters = listRowsOptions?.order_filters ? Object.values(listRowsOptions?.order_filters) : [];
|
||||
const emptyFilter = { column: '', order: '' };
|
||||
const newFilter = { ...emptyFilter, ...{ id: uniqueId() } };
|
||||
const newFilter = { ...emptyFilter, ...{ id: uuidv4() } };
|
||||
handleOrderFiltersChange({ ...existingFilters, ...{ [newFilter.id]: newFilter } });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ const ToolJetDbOperations = ({ optionchanged, options, darkMode, isHorizontalLay
|
|||
}, [options['join_table']?.['joins'], tables]);
|
||||
|
||||
useEffect(() => {
|
||||
selectedTableId && fetchTableInformation(selectedTableId);
|
||||
selectedTableId && fetchTableInformation(selectedTableId, false, tables);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [selectedTableId]);
|
||||
|
||||
|
|
@ -266,6 +266,10 @@ const ToolJetDbOperations = ({ optionchanged, options, darkMode, isHorizontalLay
|
|||
});
|
||||
};
|
||||
|
||||
const findTableDetailsWithTableList = (tableId, tableList) => {
|
||||
return tableList.find((table) => table.table_id == tableId);
|
||||
};
|
||||
|
||||
const findTableDetails = (tableId) => {
|
||||
return tables.find((table) => table.table_id == tableId);
|
||||
};
|
||||
|
|
@ -329,15 +333,16 @@ const ToolJetDbOperations = ({ optionchanged, options, darkMode, isHorizontalLay
|
|||
}
|
||||
|
||||
if (Array.isArray(data?.result)) {
|
||||
setTables(
|
||||
const tableList =
|
||||
data.result.map((table) => {
|
||||
return { table_name: table.table_name, table_id: table.id };
|
||||
}) || []
|
||||
);
|
||||
}) || [];
|
||||
|
||||
setTables(tableList);
|
||||
const selectedTableInfo = data.result.find((table) => table.id === options['table_id']);
|
||||
if (selectedTableInfo) {
|
||||
setSelectedTableId(selectedTableInfo.id);
|
||||
fetchTableInformation(selectedTableInfo.id);
|
||||
fetchTableInformation(selectedTableInfo.id, false, tableList);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -345,8 +350,8 @@ const ToolJetDbOperations = ({ optionchanged, options, darkMode, isHorizontalLay
|
|||
/**
|
||||
* TODO: This function to be removed and replaced with loadTableInformation function everywhere
|
||||
*/
|
||||
const fetchTableInformation = async (tableId, isNewTableAdded) => {
|
||||
const tableDetails = findTableDetails(tableId);
|
||||
const fetchTableInformation = async (tableId, isNewTableAdded, tableList) => {
|
||||
const tableDetails = findTableDetailsWithTableList(tableId, tableList);
|
||||
if (tableDetails?.table_name) {
|
||||
const { table_name } = tableDetails;
|
||||
const { error, data } = await tooljetDatabaseService.viewTable(organizationId, table_name);
|
||||
|
|
@ -402,7 +407,7 @@ const ToolJetDbOperations = ({ optionchanged, options, darkMode, isHorizontalLay
|
|||
|
||||
const handleTableNameSelect = (tableId) => {
|
||||
setSelectedTableId(tableId);
|
||||
fetchTableInformation(tableId, true);
|
||||
fetchTableInformation(tableId, true, tables);
|
||||
optionchanged('organization_id', organizationId);
|
||||
optionchanged('table_id', tableId);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ import { CodeHinter } from '@/Editor/CodeBuilder/CodeHinter';
|
|||
import { TooljetDatabaseContext } from '@/TooljetDatabase/index';
|
||||
import Select from '@/_ui/Select';
|
||||
import { operators } from '@/TooljetDatabase/constants';
|
||||
import { isEmpty, uniqueId } from 'lodash';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { isOperatorOptions } from './util';
|
||||
import { ButtonSolid } from '@/_ui/AppButton/AppButton';
|
||||
|
||||
|
|
@ -34,7 +35,7 @@ export const UpdateRows = React.memo(({ darkMode }) => {
|
|||
|
||||
const existingColumnOption = Object.values ? Object.values(updateRowsOptions?.columns) : [];
|
||||
const emptyColumnOption = { column: '', value: '' };
|
||||
handleColumnOptionChange({ ...existingColumnOption, ...{ [uniqueId()]: emptyColumnOption } });
|
||||
handleColumnOptionChange({ ...existingColumnOption, ...{ [uuidv4()]: emptyColumnOption } });
|
||||
}
|
||||
|
||||
function handleWhereFiltersChange(filters) {
|
||||
|
|
@ -44,7 +45,7 @@ export const UpdateRows = React.memo(({ darkMode }) => {
|
|||
function addNewFilterConditionPair() {
|
||||
const existingFilters = updateRowsOptions?.where_filters ? Object.values(updateRowsOptions?.where_filters) : [];
|
||||
const emptyFilter = { column: '', operator: '', value: '' };
|
||||
const newFilter = { ...emptyFilter, ...{ id: uniqueId() } };
|
||||
const newFilter = { ...emptyFilter, ...{ id: uuidv4() } };
|
||||
handleWhereFiltersChange({ ...existingFilters, ...{ [newFilter.id]: newFilter } });
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue