mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
fixes:
renaming entities sets the references component value to default value current state was not updating to latest state removed/deleted render count hook [dev-testing purpose]
This commit is contained in:
parent
82fd53d30a
commit
8a64175c0a
5 changed files with 5 additions and 46 deletions
|
|
@ -1,11 +1,8 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
import cx from 'classnames';
|
||||
const tinycolor = require('tinycolor2');
|
||||
import useRenderCount from '@/_hooks/useRenderCount';
|
||||
|
||||
export const Button = function Button(props) {
|
||||
useRenderCount(`Button Main component ${props.id}`);
|
||||
|
||||
const { height, properties, styles, fireEvent, id, dataCy, setExposedVariable, setExposedVariables } = props;
|
||||
const { backgroundColor, textColor, borderRadius, loaderColor, disabledState, borderColor, boxShadow } = styles;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import DOMPurify from 'dompurify';
|
|||
import Markdown from 'react-markdown';
|
||||
import './text.scss';
|
||||
import Loader from '@/ToolJetUI/Loader/Loader';
|
||||
import useRenderCount from '@/_hooks/useRenderCount';
|
||||
|
||||
const VERTICAL_ALIGNMENT_VS_CSS_VALUE = {
|
||||
top: 'flex-start',
|
||||
|
|
@ -11,17 +10,7 @@ const VERTICAL_ALIGNMENT_VS_CSS_VALUE = {
|
|||
bottom: 'flex-end',
|
||||
};
|
||||
|
||||
export const Text = function Text({
|
||||
height,
|
||||
properties,
|
||||
fireEvent,
|
||||
styles,
|
||||
darkMode,
|
||||
setExposedVariable,
|
||||
dataCy,
|
||||
...props
|
||||
}) {
|
||||
useRenderCount(`TextComponent Main component ${props.id}`);
|
||||
export const Text = function Text({ height, properties, fireEvent, styles, darkMode, setExposedVariable, dataCy }) {
|
||||
let {
|
||||
textSize,
|
||||
textColor,
|
||||
|
|
|
|||
|
|
@ -213,8 +213,6 @@ const EditorComponent = (props) => {
|
|||
|
||||
const prevAppDefinition = useRef(appDefinition);
|
||||
|
||||
const onAppLoadAndPageLoadEventsAreTriggered = useRef(false);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
resetAllStores();
|
||||
}, []);
|
||||
|
|
@ -282,9 +280,9 @@ const EditorComponent = (props) => {
|
|||
}
|
||||
|
||||
if (mounted && didAppDefinitionChanged && currentPageId) {
|
||||
// const components = appDefinition?.pages[currentPageId]?.components || {};
|
||||
const components = appDefinition?.pages[currentPageId]?.components || {};
|
||||
|
||||
// computeComponentState(components);
|
||||
computeComponentState(components);
|
||||
|
||||
if (appDiffOptions?.skipAutoSave === true || appDiffOptions?.entityReferenceUpdated === true) return;
|
||||
|
||||
|
|
@ -789,7 +787,6 @@ const EditorComponent = (props) => {
|
|||
handleLowPriorityWork(async () => {
|
||||
await runQueries(useDataQueriesStore.getState().dataQueries, editorRef, true);
|
||||
await handleEvent('onPageLoad', currentPageEvents, {}, true);
|
||||
await handleLowPriorityWork(() => (onAppLoadAndPageLoadEventsAreTriggered.current = true));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,17 +3,15 @@ import moment from 'moment';
|
|||
import _, { isEmpty } from 'lodash';
|
||||
import axios from 'axios';
|
||||
import JSON5 from 'json5';
|
||||
import { previewQuery, executeAction } from '@/_helpers/appUtils';
|
||||
import { executeAction } from '@/_helpers/appUtils';
|
||||
import { toast } from 'react-hot-toast';
|
||||
import { authenticationService } from '@/_services/authentication.service';
|
||||
|
||||
import { useDataQueriesStore } from '@/_stores/dataQueriesStore';
|
||||
import { getCurrentState, useCurrentState } from '@/_stores/currentStateStore';
|
||||
import { getCurrentState } from '@/_stores/currentStateStore';
|
||||
import { getWorkspaceIdOrSlugFromURL, getSubpath, returnWorkspaceIdIfNeed } from './routes';
|
||||
import { getCookie, eraseCookie } from '@/_helpers/cookie';
|
||||
import { staticDataSources } from '@/Editor/QueryManager/constants';
|
||||
import { resolveReferences as newResolver } from '@/Editor/CodeEditor/utils';
|
||||
import { useResolveStore } from '@/_stores/resolverStore';
|
||||
|
||||
export function findProp(obj, prop, defval) {
|
||||
if (typeof defval === 'undefined') defval = null;
|
||||
|
|
@ -329,18 +327,7 @@ export const serializeNestedObjectToQueryParams = function (obj, prefix) {
|
|||
export function resolveWidgetFieldValue(prop, _default = [], customResolveObjects = {}) {
|
||||
const widgetFieldValue = prop;
|
||||
|
||||
const isStoreAndEditorReady = useResolveStore.getState().updateStoreState && useCurrentState.getState().isEditorReady;
|
||||
|
||||
try {
|
||||
if (isStoreAndEditorReady) {
|
||||
const [_, _error, resolveValue] = newResolver(widgetFieldValue?.value);
|
||||
|
||||
if (_error) {
|
||||
return _default;
|
||||
}
|
||||
|
||||
return resolveValue;
|
||||
}
|
||||
const state = getCurrentState();
|
||||
return resolveReferences(widgetFieldValue, state, _default, customResolveObjects);
|
||||
} catch (err) {
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
import { useRef, useEffect } from 'react';
|
||||
|
||||
function useRenderCount(componentName) {
|
||||
const renderCountRef = useRef(0);
|
||||
|
||||
renderCountRef.current++;
|
||||
|
||||
return renderCountRef.current;
|
||||
}
|
||||
|
||||
export default useRenderCount;
|
||||
Loading…
Reference in a new issue