mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-05 22:38:48 +00:00
Merge pull request #8222 from ToolJet/main
Merge main back to develop (v2.24.3)
This commit is contained in:
commit
9549f76abe
13 changed files with 83 additions and 69 deletions
2
.version
2
.version
|
|
@ -1 +1 @@
|
|||
2.24.0
|
||||
2.24.3
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
2.24.0
|
||||
2.24.3
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ export const Pagination = function Pagination({
|
|||
setPageCount(lastActivePageIndex);
|
||||
} else if (serverSide || lastActivePageIndex === 0) {
|
||||
setPageIndex(1);
|
||||
} else {
|
||||
gotoPage(lastActivePageIndex + 1);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [serverSide, lastActivePageIndex]);
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ export function Table({
|
|||
|
||||
function onPageIndexChanged(page) {
|
||||
onComponentOptionChanged(component, 'pageIndex', page).then(() => {
|
||||
onEvent('onPageChanged', { component, data: {} });
|
||||
onEvent('onPageChanged', tableEvents, { component });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -653,8 +653,10 @@ export function Table({
|
|||
if (!sortOptions) {
|
||||
setExposedVariable('sortApplied', []);
|
||||
}
|
||||
if (mounted) setExposedVariable('sortApplied', sortOptions);
|
||||
fireEvent('onSort');
|
||||
if (mounted) {
|
||||
setExposedVariable('sortApplied', sortOptions);
|
||||
fireEvent('onSort');
|
||||
}
|
||||
}, [JSON.stringify(sortOptions)]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -277,7 +277,9 @@ export const Container = ({
|
|||
}
|
||||
|
||||
const canvasBoundingRect = document.getElementsByClassName('real-canvas')[0].getBoundingClientRect();
|
||||
const componentMeta = componentTypes.find((component) => component.component === item.component.component);
|
||||
const componentMeta = _.cloneDeep(
|
||||
componentTypes.find((component) => component.component === item.component.component)
|
||||
);
|
||||
console.log('adding new component');
|
||||
const newComponent = addNewWidgetToTheEditor(
|
||||
componentMeta,
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ export const Inspector = ({
|
|||
});
|
||||
useHotkeys('escape', () => switchSidebarTab(2));
|
||||
|
||||
const componentMeta = componentTypes.find((comp) => component.component.component === comp.component);
|
||||
const componentMeta = _.cloneDeep(componentTypes.find((comp) => component.component.component === comp.component));
|
||||
|
||||
const isMounted = useMounted();
|
||||
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ export const SubContainer = ({
|
|||
defaultChildren.forEach((child) => {
|
||||
const { componentName, layout, incrementWidth, properties, accessorKey, tab, defaultValue, styles } = child;
|
||||
|
||||
const componentMeta = componentTypes.find((component) => component.component === componentName);
|
||||
const componentMeta = _.cloneDeep(componentTypes.find((component) => component.component === componentName));
|
||||
const componentData = JSON.parse(JSON.stringify(componentMeta));
|
||||
|
||||
const width = layout.width ? layout.width : (componentMeta.defaultSize.width * 100) / NO_OF_GRIDS;
|
||||
|
|
@ -308,7 +308,9 @@ export const SubContainer = ({
|
|||
() => ({
|
||||
accept: ItemTypes.BOX,
|
||||
drop(item, monitor) {
|
||||
const componentMeta = componentTypes.find((component) => component.component === item.component.component);
|
||||
const componentMeta = _.cloneDeep(
|
||||
componentTypes.find((component) => component.component === item.component.component)
|
||||
);
|
||||
const canvasBoundingRect = parentRef.current.getElementsByClassName('real-canvas')[0].getBoundingClientRect();
|
||||
const parentComp =
|
||||
parentComponent?.component === 'Kanban'
|
||||
|
|
|
|||
|
|
@ -1199,7 +1199,7 @@ export function computeComponentState(components = {}) {
|
|||
if (!components[key]) return;
|
||||
|
||||
const { component } = components[key];
|
||||
const componentMeta = componentTypes.find((comp) => component.component === comp.component);
|
||||
const componentMeta = _.cloneDeep(componentTypes.find((comp) => component.component === comp.component));
|
||||
|
||||
const existingComponentName = Object.keys(currentComponents).find((comp) => currentComponents[comp].id === key);
|
||||
const existingValues = currentComponents[existingComponentName];
|
||||
|
|
@ -1816,36 +1816,22 @@ export const buildComponentMetaDefinition = (components = {}) => {
|
|||
for (const componentId in components) {
|
||||
const currentComponentData = components[componentId];
|
||||
|
||||
const componentMeta = componentTypes.find((comp) => currentComponentData.component.component === comp.component);
|
||||
const componentMeta = _.cloneDeep(
|
||||
componentTypes.find((comp) => currentComponentData.component.component === comp.component)
|
||||
);
|
||||
|
||||
const mergedDefinition = {
|
||||
...componentMeta.definition,
|
||||
|
||||
properties: {
|
||||
...componentMeta.definition.properties,
|
||||
...currentComponentData?.component.definition.properties,
|
||||
},
|
||||
|
||||
styles: {
|
||||
...componentMeta.definition.styles,
|
||||
...currentComponentData?.component.definition.styles,
|
||||
},
|
||||
generalStyles: {
|
||||
...componentMeta.definition.generalStyles,
|
||||
...currentComponentData?.component.definition.generalStyles,
|
||||
},
|
||||
validation: {
|
||||
...componentMeta.definition.validation,
|
||||
...currentComponentData?.component.definition.validation,
|
||||
},
|
||||
others: {
|
||||
...componentMeta.definition.others,
|
||||
...currentComponentData?.component.definition.others,
|
||||
},
|
||||
general: {
|
||||
...componentMeta.definition.general,
|
||||
...currentComponentData?.component.definition.general,
|
||||
},
|
||||
properties: _.merge(componentMeta.definition.properties, currentComponentData?.component.definition.properties),
|
||||
styles: _.merge(componentMeta.definition.styles, currentComponentData?.component.definition.styles),
|
||||
generalStyles: _.merge(
|
||||
componentMeta.definition.generalStyles,
|
||||
currentComponentData?.component.definition.generalStyles
|
||||
),
|
||||
validation: _.merge(componentMeta.definition.validation, currentComponentData?.component.definition.validation),
|
||||
others: _.merge(componentMeta.definition.others, currentComponentData?.component.definition.others),
|
||||
general: _.merge(componentMeta.definition.general, currentComponentData?.component.definition.general),
|
||||
};
|
||||
|
||||
const mergedComponent = {
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@ import { useAppVersionStore } from '@/_stores/appVersionStore';
|
|||
import { runQueries } from '@/_helpers/appUtils';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { toast } from 'react-hot-toast';
|
||||
import { isEmpty, throttle } from 'lodash';
|
||||
import _, { isEmpty, throttle } from 'lodash';
|
||||
import { useEditorStore } from './editorStore';
|
||||
import { useCurrentStateStore } from './currentStateStore';
|
||||
|
||||
const initialState = {
|
||||
dataQueries: [],
|
||||
|
|
@ -41,7 +42,11 @@ export const useDataQueriesStore = create(
|
|||
|
||||
if (data.data_queries.length !== 0) {
|
||||
const queryConfirmationList = [];
|
||||
const updatedQueries = {};
|
||||
const currentQueries = useCurrentStateStore.getState().queries;
|
||||
|
||||
data.data_queries.forEach(({ id, name, options }) => {
|
||||
updatedQueries[name] = _.merge(currentQueries[name], { id: id });
|
||||
if (options && options?.requestConfirmation && options?.runOnPageLoad) {
|
||||
queryConfirmationList.push({ queryId: id, queryName: name });
|
||||
}
|
||||
|
|
@ -50,6 +55,11 @@ export const useDataQueriesStore = create(
|
|||
if (queryConfirmationList.length !== 0) {
|
||||
useEditorStore.getState().actions.updateQueryConfirmationList(queryConfirmationList);
|
||||
}
|
||||
|
||||
useCurrentStateStore.getState().actions.setCurrentState({
|
||||
...useCurrentStateStore.getState(),
|
||||
queries: updatedQueries,
|
||||
});
|
||||
}
|
||||
|
||||
// Compute query state to be added in the current state
|
||||
|
|
|
|||
|
|
@ -237,7 +237,9 @@ const computeComponentDiff = (appDiff, currentPageId, opts, currentLayout) => {
|
|||
return result;
|
||||
}
|
||||
|
||||
const componentMeta = componentTypes.find((comp) => comp.component === component.component.component);
|
||||
const componentMeta = _.cloneDeep(
|
||||
componentTypes.find((comp) => comp.component === component.component.component)
|
||||
);
|
||||
|
||||
if (!componentMeta) {
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
2.24.0
|
||||
2.24.3
|
||||
|
|
|
|||
|
|
@ -398,7 +398,8 @@ export class AppImportExportService {
|
|||
const mappedComponents = transformComponentData(
|
||||
pageComponents,
|
||||
componentEvents,
|
||||
appResourceMappings.componentsMapping
|
||||
appResourceMappings.componentsMapping,
|
||||
isNormalizedAppDefinitionSchema
|
||||
);
|
||||
|
||||
const componentLayouts = [];
|
||||
|
|
@ -544,21 +545,6 @@ export class AppImportExportService {
|
|||
}
|
||||
}
|
||||
|
||||
if (isNormalizedAppDefinitionSchema) {
|
||||
const appVersionIds = Object.values(appResourceMappings.appVersionMapping);
|
||||
|
||||
for (const appVersionId of appVersionIds) {
|
||||
await this.updateEventActionsForNewVersionWithNewMappingIds(
|
||||
manager,
|
||||
appVersionId,
|
||||
appResourceMappings.dataQueryMapping,
|
||||
appResourceMappings.componentsMapping,
|
||||
appResourceMappings.pagesMapping,
|
||||
isNormalizedAppDefinitionSchema
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await this.setEditingVersionAsLatestVersion(manager, appResourceMappings.appVersionMapping, importingAppVersions);
|
||||
|
||||
return appResourceMappings;
|
||||
|
|
@ -707,7 +693,7 @@ export class AppImportExportService {
|
|||
|
||||
let parentId = component.parent ? component.parent : null;
|
||||
|
||||
const isParentTabOrCalendar = isChildOfTabsOrCalendar(component, pageComponents, parentId);
|
||||
const isParentTabOrCalendar = isChildOfTabsOrCalendar(component, pageComponents, parentId, true);
|
||||
|
||||
if (isParentTabOrCalendar) {
|
||||
const childTabId = component.parent.split('-')[component.parent.split('-').length - 1];
|
||||
|
|
@ -852,6 +838,19 @@ export class AppImportExportService {
|
|||
);
|
||||
}
|
||||
|
||||
const appVersionIds = Object.values(appResourceMappings.appVersionMapping);
|
||||
|
||||
for (const appVersionId of appVersionIds) {
|
||||
await this.updateEventActionsForNewVersionWithNewMappingIds(
|
||||
manager,
|
||||
appVersionId,
|
||||
appResourceMappings.dataQueryMapping,
|
||||
appResourceMappings.componentsMapping,
|
||||
appResourceMappings.pagesMapping,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
return appResourceMappings;
|
||||
}
|
||||
|
||||
|
|
@ -1561,7 +1560,8 @@ function convertSinglePageSchemaToMultiPageSchema(appParams: any) {
|
|||
function transformComponentData(
|
||||
data: object,
|
||||
componentEvents: any[],
|
||||
componentsMapping: Record<string, string>
|
||||
componentsMapping: Record<string, string>,
|
||||
isNormalizedAppDefinitionSchema = true
|
||||
): Component[] {
|
||||
const transformedComponents: Component[] = [];
|
||||
|
||||
|
|
@ -1581,7 +1581,12 @@ function transformComponentData(
|
|||
|
||||
let parentId = component.parent ? component.parent : null;
|
||||
|
||||
const isParentTabOrCalendar = isChildOfTabsOrCalendar(component, allComponents, parentId);
|
||||
const isParentTabOrCalendar = isChildOfTabsOrCalendar(
|
||||
component,
|
||||
allComponents,
|
||||
parentId,
|
||||
isNormalizedAppDefinitionSchema
|
||||
);
|
||||
|
||||
if (isParentTabOrCalendar) {
|
||||
const childTabId = component.parent.split('-')[component.parent.split('-').length - 1];
|
||||
|
|
@ -1618,20 +1623,25 @@ function transformComponentData(
|
|||
}
|
||||
}
|
||||
|
||||
// if (skippedComponents.length) {
|
||||
|
||||
// }
|
||||
|
||||
return transformedComponents;
|
||||
}
|
||||
|
||||
const isChildOfTabsOrCalendar = (component, allComponents = [], componentParentId = undefined) => {
|
||||
const isChildOfTabsOrCalendar = (
|
||||
component,
|
||||
allComponents = [],
|
||||
componentParentId = undefined,
|
||||
isNormalizedAppDefinitionSchema: boolean
|
||||
) => {
|
||||
if (componentParentId) {
|
||||
const parentId = component?.parent?.split('-').slice(0, -1).join('-');
|
||||
|
||||
const parentComponent = allComponents.find((comp) => comp.id === parentId);
|
||||
|
||||
if (parentComponent) {
|
||||
if (!isNormalizedAppDefinitionSchema) {
|
||||
return parentComponent.component.component === 'Tabs' || parentComponent.component.component === 'Calendar';
|
||||
}
|
||||
|
||||
return parentComponent.type === 'Tabs' || parentComponent.type === 'Calendar';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import { dbTransactionForAppVersionAssociationsUpdate, dbTransactionWrap } from
|
|||
import { EventsService } from './events_handler.service';
|
||||
import { LayoutData } from '@dto/component.dto';
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
@Injectable()
|
||||
export class ComponentsService {
|
||||
constructor(
|
||||
|
|
@ -85,10 +87,10 @@ export class ComponentsService {
|
|||
const columnsUpdated = Object.keys(updatedDefinition);
|
||||
|
||||
const newComponentsData = columnsUpdated.reduce((acc, column) => {
|
||||
const newColumnData = {
|
||||
...componentData[column],
|
||||
...updatedDefinition[column],
|
||||
};
|
||||
const newColumnData = _.merge(
|
||||
componentData[column === 'others' ? 'displayPreferences' : column],
|
||||
updatedDefinition[column]
|
||||
);
|
||||
|
||||
if (column === 'others') {
|
||||
acc['displayPreferences'] = newColumnData;
|
||||
|
|
|
|||
Loading…
Reference in a new issue