mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
fix : Exposed actions become unavailable on reload (#10379)
* fix : exposed actions gets removed on reload * fix : table losing exposed vars on reload * fix: destrucute isEditorReady from correct object --------- Co-authored-by: Johnson Cherian <johnsonc.dev@gmail.com>
This commit is contained in:
parent
387ac15119
commit
0070c22042
21 changed files with 173 additions and 112 deletions
|
|
@ -6,7 +6,7 @@ import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
|
||||||
import '@/_styles/custom.scss';
|
import '@/_styles/custom.scss';
|
||||||
import { EditorContext } from './Context/EditorContextWrapper';
|
import { EditorContext } from './Context/EditorContextWrapper';
|
||||||
import { validateWidget } from '@/_helpers/utils';
|
import { validateWidget } from '@/_helpers/utils';
|
||||||
import { useCurrentState } from '@/_stores/currentStateStore';
|
import { useCurrentState, useCurrentStateStore } from '@/_stores/currentStateStore';
|
||||||
import { useAppDataStore } from '@/_stores/appDataStore';
|
import { useAppDataStore } from '@/_stores/appDataStore';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
|
|
@ -97,6 +97,8 @@ const BoxUI = (props) => {
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const isEditorReady = useCurrentStateStore((state) => state.isEditorReady);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OverlayTrigger
|
<OverlayTrigger
|
||||||
placement={inCanvas ? 'auto' : 'top'}
|
placement={inCanvas ? 'auto' : 'top'}
|
||||||
|
|
@ -183,6 +185,7 @@ const BoxUI = (props) => {
|
||||||
currentPageId={currentPageId}
|
currentPageId={currentPageId}
|
||||||
getContainerProps={component.component === 'Form' ? getContainerProps : null}
|
getContainerProps={component.component === 'Form' ? getContainerProps : null}
|
||||||
childComponents={childComponents}
|
childComponents={childComponents}
|
||||||
|
isEditorReady={isEditorReady}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</OverlayTrigger>
|
</OverlayTrigger>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@ import * as Icons from '@tabler/icons-react';
|
||||||
import Loader from '@/ToolJetUI/Loader/Loader';
|
import Loader from '@/ToolJetUI/Loader/Loader';
|
||||||
|
|
||||||
export const Button = function Button(props) {
|
export const Button = function Button(props) {
|
||||||
const { height, properties, styles, fireEvent, id, dataCy, setExposedVariable, setExposedVariables } = props;
|
const { height, properties, styles, fireEvent, id, dataCy, setExposedVariable, setExposedVariables, isEditorReady } =
|
||||||
|
props;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
backgroundColor,
|
backgroundColor,
|
||||||
textColor,
|
textColor,
|
||||||
|
|
@ -93,31 +95,33 @@ export const Button = function Button(props) {
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const exposedVariables = {
|
if (isEditorReady) {
|
||||||
click: async function () {
|
const exposedVariables = {
|
||||||
if (!disable) {
|
click: async function () {
|
||||||
fireEvent('onClick');
|
if (!disable) {
|
||||||
}
|
fireEvent('onClick');
|
||||||
},
|
}
|
||||||
setText: async function (text) {
|
},
|
||||||
setLabel(text);
|
setText: async function (text) {
|
||||||
setExposedVariable('buttonText', text);
|
setLabel(text);
|
||||||
},
|
setExposedVariable('buttonText', text);
|
||||||
disable: async function (value) {
|
},
|
||||||
setDisable(value);
|
disable: async function (value) {
|
||||||
},
|
setDisable(value);
|
||||||
visibility: async function (value) {
|
},
|
||||||
setVisibility(value);
|
visibility: async function (value) {
|
||||||
},
|
setVisibility(value);
|
||||||
loading: async function (value) {
|
},
|
||||||
setLoading(value);
|
loading: async function (value) {
|
||||||
},
|
setLoading(value);
|
||||||
};
|
},
|
||||||
|
};
|
||||||
|
|
||||||
setExposedVariables(exposedVariables);
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [disable]);
|
}, [disable, isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setExposedVariable('setLoading', async function (loading) {
|
setExposedVariable('setLoading', async function (loading) {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ export const Chart = function Chart({
|
||||||
setExposedVariable,
|
setExposedVariable,
|
||||||
setExposedVariables,
|
setExposedVariables,
|
||||||
dataCy,
|
dataCy,
|
||||||
|
isEditorReady,
|
||||||
}) {
|
}) {
|
||||||
const [loadingState, setLoadingState] = useState(false);
|
const [loadingState, setLoadingState] = useState(false);
|
||||||
|
|
||||||
|
|
@ -80,8 +81,9 @@ export const Chart = function Chart({
|
||||||
xAxisTitle: xAxisTitle,
|
xAxisTitle: xAxisTitle,
|
||||||
yAxisTitle: yAxisTitle,
|
yAxisTitle: yAxisTitle,
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) setExposedVariables(exposedVariables);
|
||||||
}, [JSON.stringify(chartLayout, chartTitle)]);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [JSON.stringify(chartLayout, chartTitle), isEditorReady]);
|
||||||
|
|
||||||
const layout = {
|
const layout = {
|
||||||
width: width - 4,
|
width: width - 4,
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ export const Checkbox = ({
|
||||||
component,
|
component,
|
||||||
validate,
|
validate,
|
||||||
width,
|
width,
|
||||||
|
isEditorReady,
|
||||||
}) => {
|
}) => {
|
||||||
const defaultValueFromProperties = properties.defaultValue ?? false;
|
const defaultValueFromProperties = properties.defaultValue ?? false;
|
||||||
const [defaultValue, setDefaultValue] = useState(defaultValueFromProperties);
|
const [defaultValue, setDefaultValue] = useState(defaultValueFromProperties);
|
||||||
|
|
@ -68,10 +69,10 @@ export const Checkbox = ({
|
||||||
setDefaultValue(defaultValueFromProperties);
|
setDefaultValue(defaultValueFromProperties);
|
||||||
setChecked(defaultValueFromProperties);
|
setChecked(defaultValueFromProperties);
|
||||||
setValue(defaultValueFromProperties);
|
setValue(defaultValueFromProperties);
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) setExposedVariables(exposedVariables);
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [defaultValueFromProperties]);
|
}, [defaultValueFromProperties, isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (disable !== disabledState) setDisable(properties.disabledState);
|
if (disable !== disabledState) setDisable(properties.disabledState);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ export const ColorPicker = function ({
|
||||||
height,
|
height,
|
||||||
fireEvent,
|
fireEvent,
|
||||||
dataCy,
|
dataCy,
|
||||||
|
isEditorReady,
|
||||||
}) {
|
}) {
|
||||||
const { visibility, boxShadow } = styles;
|
const { visibility, boxShadow } = styles;
|
||||||
const defaultColor = properties.defaultColor;
|
const defaultColor = properties.defaultColor;
|
||||||
|
|
@ -57,8 +58,9 @@ export const ColorPicker = function ({
|
||||||
selectedColorRGB: hexToRgb(colorCode),
|
selectedColorRGB: hexToRgb(colorCode),
|
||||||
selectedColorRGBA: hexToRgba(colorCode),
|
selectedColorRGBA: hexToRgba(colorCode),
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
fireEvent('onChange');
|
fireEvent('onChange');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -67,14 +69,15 @@ export const ColorPicker = function ({
|
||||||
selectedColorRGB: undefined,
|
selectedColorRGB: undefined,
|
||||||
selectedColorRGBA: undefined,
|
selectedColorRGBA: undefined,
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
fireEvent('onChange');
|
fireEvent('onChange');
|
||||||
setColor('Invalid Color');
|
setColor('Invalid Color');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [setColor]);
|
}, [setColor, isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let exposedVariables = {};
|
let exposedVariables = {};
|
||||||
|
|
@ -85,8 +88,9 @@ export const ColorPicker = function ({
|
||||||
selectedColorRGB: hexToRgb(defaultColor),
|
selectedColorRGB: hexToRgb(defaultColor),
|
||||||
selectedColorRGBA: hexToRgba(defaultColor),
|
selectedColorRGBA: hexToRgba(defaultColor),
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
setColor(defaultColor);
|
setColor(defaultColor);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -95,12 +99,13 @@ export const ColorPicker = function ({
|
||||||
selectedColorRGB: undefined,
|
selectedColorRGB: undefined,
|
||||||
selectedColorRGBA: undefined,
|
selectedColorRGBA: undefined,
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
setColor(`Invalid Color`);
|
setColor(`Invalid Color`);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [defaultColor]);
|
}, [defaultColor, isEditorReady]);
|
||||||
|
|
||||||
const handleColorChange = (colorCode) => {
|
const handleColorChange = (colorCode) => {
|
||||||
let exposedVariables = {};
|
let exposedVariables = {};
|
||||||
|
|
@ -113,7 +118,9 @@ export const ColorPicker = function ({
|
||||||
selectedColorRGB: `rgb(${r},${g},${b})`,
|
selectedColorRGB: `rgb(${r},${g},${b})`,
|
||||||
selectedColorRGBA: `rgb(${r},${g},${b},${a})`,
|
selectedColorRGBA: `rgb(${r},${g},${b},${a})`,
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
fireEvent('onChange');
|
fireEvent('onChange');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ export const DropdownV2 = ({
|
||||||
component,
|
component,
|
||||||
exposedVariables,
|
exposedVariables,
|
||||||
dataCy,
|
dataCy,
|
||||||
|
isEditorReady,
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const {
|
||||||
label,
|
label,
|
||||||
|
|
@ -225,8 +226,11 @@ export const DropdownV2 = ({
|
||||||
setIsDropdownDisabled(value);
|
setIsDropdownDisabled(value);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
|
||||||
}, []);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
|
}, [isEditorReady]);
|
||||||
|
|
||||||
const customStyles = {
|
const customStyles = {
|
||||||
container: (base) => ({
|
container: (base) => ({
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ export const Form = function Form(props) {
|
||||||
getContainerProps,
|
getContainerProps,
|
||||||
containerProps,
|
containerProps,
|
||||||
childComponents,
|
childComponents,
|
||||||
|
isEditorReady,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const { events: allAppEvents } = useAppInfo();
|
const { events: allAppEvents } = useAppInfo();
|
||||||
|
|
@ -132,7 +133,9 @@ export const Form = function Form(props) {
|
||||||
...(!advanced && { children: formattedChildData }),
|
...(!advanced && { children: formattedChildData }),
|
||||||
};
|
};
|
||||||
|
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
return setValidation(childValidation);
|
return setValidation(childValidation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,9 +161,10 @@ export const Form = function Form(props) {
|
||||||
isValid: childValidation,
|
isValid: childValidation,
|
||||||
};
|
};
|
||||||
setValidation(childValidation);
|
setValidation(childValidation);
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
setExposedVariables(exposedVariables);
|
||||||
}, [childrenData, childComponents, advanced, JSON.stringify(JSONSchema)]);
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [childrenData, childComponents, advanced, JSON.stringify(JSONSchema), isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const childIds = Object.keys(childrenData);
|
const childIds = Object.keys(childrenData);
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@ export const Icon = ({
|
||||||
fireEvent,
|
fireEvent,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
setExposedVariable,
|
|
||||||
setExposedVariables,
|
setExposedVariables,
|
||||||
darkMode,
|
darkMode,
|
||||||
dataCy,
|
dataCy,
|
||||||
component,
|
component,
|
||||||
|
isEditorReady,
|
||||||
}) => {
|
}) => {
|
||||||
const { icon } = properties;
|
const { icon } = properties;
|
||||||
const { iconColor, visibility, boxShadow } = styles;
|
const { iconColor, visibility, boxShadow } = styles;
|
||||||
|
|
@ -40,9 +40,11 @@ export const Icon = ({
|
||||||
fireEvent('onClick');
|
fireEvent('onClick');
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [setIconVisibility]);
|
}, [setIconVisibility, isEditorReady]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import React, { useRef } from 'react';
|
||||||
import { KanbanBoard } from './KanbanBoard';
|
import { KanbanBoard } from './KanbanBoard';
|
||||||
|
|
||||||
export const Kanban = (props) => {
|
export const Kanban = (props) => {
|
||||||
const { height, width, properties, styles, id, mode } = props;
|
const { height, width, properties, styles, id, mode, isEditorReady } = props;
|
||||||
const { showDeleteButton } = properties;
|
const { showDeleteButton } = properties;
|
||||||
const { visibility, disabledState, boxShadow } = styles;
|
const { visibility, disabledState, boxShadow } = styles;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ const dropAnimation = {
|
||||||
const TRASH_ID = 'void';
|
const TRASH_ID = 'void';
|
||||||
|
|
||||||
export function KanbanBoard({ widgetHeight, kanbanProps, parentRef, mode, id }) {
|
export function KanbanBoard({ widgetHeight, kanbanProps, parentRef, mode, id }) {
|
||||||
const { properties, fireEvent, setExposedVariable, setExposedVariables, styles } = kanbanProps;
|
const { properties, fireEvent, setExposedVariable, setExposedVariables, styles, isEditorReady } = kanbanProps;
|
||||||
const { columnData, cardData, cardWidth, cardHeight, showDeleteButton, enableAddCard } = properties;
|
const { columnData, cardData, cardWidth, cardHeight, showDeleteButton, enableAddCard } = properties;
|
||||||
const { accentColor } = styles;
|
const { accentColor } = styles;
|
||||||
const [lastSelectedCard, setLastSelectedCard] = useState({});
|
const [lastSelectedCard, setLastSelectedCard] = useState({});
|
||||||
|
|
@ -112,17 +112,20 @@ export function KanbanBoard({ widgetHeight, kanbanProps, parentRef, mode, id })
|
||||||
cardDataAsObj[cardId] = value;
|
cardDataAsObj[cardId] = value;
|
||||||
const diffKeys = Object.keys(diff(cardToBeUpdated, value));
|
const diffKeys = Object.keys(diff(cardToBeUpdated, value));
|
||||||
if (lastSelectedCard?.id === cardId) {
|
if (lastSelectedCard?.id === cardId) {
|
||||||
setExposedVariables({
|
if (isEditorReady) {
|
||||||
lastSelectedCard: cardDataAsObj[cardId],
|
setExposedVariables({
|
||||||
|
lastSelectedCard: cardDataAsObj[cardId],
|
||||||
|
|
||||||
|
lastUpdatedCard: cardDataAsObj[cardId],
|
||||||
|
lastCardUpdate: diffKeys.map((key) => {
|
||||||
|
return {
|
||||||
|
[key]: { oldValue: cardToBeUpdated[key], newValue: value[key] },
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
updatedCardData: getData(cardDataAsObj),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
lastUpdatedCard: cardDataAsObj[cardId],
|
|
||||||
lastCardUpdate: diffKeys.map((key) => {
|
|
||||||
return {
|
|
||||||
[key]: { oldValue: cardToBeUpdated[key], newValue: value[key] },
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
updatedCardData: getData(cardDataAsObj),
|
|
||||||
});
|
|
||||||
fireEvent('onUpdate');
|
fireEvent('onUpdate');
|
||||||
} else {
|
} else {
|
||||||
setExposedVariable('updatedCardData', getData(cardDataAsObj));
|
setExposedVariable('updatedCardData', getData(cardDataAsObj));
|
||||||
|
|
@ -130,7 +133,7 @@ export function KanbanBoard({ widgetHeight, kanbanProps, parentRef, mode, id })
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [lastSelectedCard, JSON.stringify(cardDataAsObj)]);
|
}, [lastSelectedCard, JSON.stringify(cardDataAsObj), isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setExposedVariable('moveCard', async function (cardId, columnId) {
|
setExposedVariable('moveCard', async function (cardId, columnId) {
|
||||||
|
|
@ -169,11 +172,13 @@ export function KanbanBoard({ widgetHeight, kanbanProps, parentRef, mode, id })
|
||||||
...items,
|
...items,
|
||||||
[columnId]: [...items[columnId], cardDetails.id],
|
[columnId]: [...items[columnId], cardDetails.id],
|
||||||
}));
|
}));
|
||||||
setExposedVariables({ lastAddedCard: { ...cardDetails }, updatedCardData: getData(cardDataAsObj) });
|
if (isEditorReady) {
|
||||||
|
setExposedVariables({ lastAddedCard: { ...cardDetails }, updatedCardData: getData(cardDataAsObj) });
|
||||||
|
}
|
||||||
fireEvent('onCardAdded');
|
fireEvent('onCardAdded');
|
||||||
});
|
});
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [items, JSON.stringify(cardDataAsObj)]);
|
}, [items, JSON.stringify(cardDataAsObj), isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setExposedVariable('deleteCard', async function (cardId) {
|
setExposedVariable('deleteCard', async function (cardId) {
|
||||||
|
|
@ -186,11 +191,13 @@ export function KanbanBoard({ widgetHeight, kanbanProps, parentRef, mode, id })
|
||||||
...items,
|
...items,
|
||||||
[columnId]: items[columnId].filter((id) => id !== cardId),
|
[columnId]: items[columnId].filter((id) => id !== cardId),
|
||||||
}));
|
}));
|
||||||
setExposedVariables({ lastRemovedCard: { ...deletedCard }, updatedCardData: getData(cardDataAsObj) });
|
if (isEditorReady) {
|
||||||
|
setExposedVariables({ lastRemovedCard: { ...deletedCard }, updatedCardData: getData(cardDataAsObj) });
|
||||||
|
}
|
||||||
fireEvent('onCardRemoved');
|
fireEvent('onCardRemoved');
|
||||||
});
|
});
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [showModal, JSON.stringify(cardDataAsObj)]);
|
}, [showModal, JSON.stringify(cardDataAsObj), isEditorReady]);
|
||||||
|
|
||||||
const [clonedItems, setClonedItems] = useState(null);
|
const [clonedItems, setClonedItems] = useState(null);
|
||||||
const sensors = useSensors(
|
const sensors = useSensors(
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ export const Listview = function Listview({
|
||||||
darkMode,
|
darkMode,
|
||||||
dataCy,
|
dataCy,
|
||||||
childComponents,
|
childComponents,
|
||||||
|
isEditorReady,
|
||||||
}) {
|
}) {
|
||||||
const fallbackProperties = { height: 100, showBorder: false, data: [] };
|
const fallbackProperties = { height: 100, showBorder: false, data: [] };
|
||||||
const fallbackStyles = { visibility: true, disabledState: false };
|
const fallbackStyles = { visibility: true, disabledState: false };
|
||||||
|
|
@ -58,7 +59,9 @@ export const Listview = function Listview({
|
||||||
selectedRecordId: index,
|
selectedRecordId: index,
|
||||||
selectedRecord: childrenData[index],
|
selectedRecord: childrenData[index],
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
fireEvent('onRecordClicked');
|
fireEvent('onRecordClicked');
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +71,9 @@ export const Listview = function Listview({
|
||||||
selectedRowId: index,
|
selectedRowId: index,
|
||||||
selectedRow: childrenData[index],
|
selectedRow: childrenData[index],
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
fireEvent('onRowClicked');
|
fireEvent('onRowClicked');
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}
|
}
|
||||||
|
|
@ -85,16 +90,20 @@ export const Listview = function Listview({
|
||||||
data: removeFunctionObjects(childrenDataClone),
|
data: removeFunctionObjects(childrenDataClone),
|
||||||
children: childrenData,
|
children: childrenData,
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
if (selectedRowIndex != undefined) {
|
if (selectedRowIndex != undefined) {
|
||||||
const exposedVariables = {
|
const exposedVariables = {
|
||||||
selectedRowId: selectedRowIndex,
|
selectedRowId: selectedRowIndex,
|
||||||
selectedRow: childrenData[selectedRowIndex],
|
selectedRow: childrenData[selectedRowIndex],
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [childrenData, childComponents]);
|
}, [childrenData, childComponents, isEditorReady]);
|
||||||
|
|
||||||
function filterComponents() {
|
function filterComponents() {
|
||||||
if (!childrenData || childrenData.length === 0) {
|
if (!childrenData || childrenData.length === 0) {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ export const Modal = function Modal({
|
||||||
dataCy,
|
dataCy,
|
||||||
height,
|
height,
|
||||||
mode,
|
mode,
|
||||||
|
isEditorReady,
|
||||||
}) {
|
}) {
|
||||||
const [showModal, setShowModal] = useState(false);
|
const [showModal, setShowModal] = useState(false);
|
||||||
|
|
||||||
|
|
@ -77,9 +78,10 @@ export const Modal = function Modal({
|
||||||
setExposedVariable('show', false);
|
setExposedVariable('show', false);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
setExposedVariables(exposedVariables);
|
||||||
}, [setShowModal]);
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [setShowModal, isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isInitialRender.current) {
|
if (isInitialRender.current) {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ export const Multiselect = function Multiselect({
|
||||||
darkMode,
|
darkMode,
|
||||||
fireEvent,
|
fireEvent,
|
||||||
dataCy,
|
dataCy,
|
||||||
|
isEditorReady,
|
||||||
}) {
|
}) {
|
||||||
const { label, value, values, display_values, showAllOption } = properties;
|
const { label, value, values, display_values, showAllOption } = properties;
|
||||||
const { borderRadius, visibility, disabledState, boxShadow } = styles;
|
const { borderRadius, visibility, disabledState, boxShadow } = styles;
|
||||||
|
|
@ -124,10 +125,11 @@ export const Multiselect = function Multiselect({
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [selected, setSelected]);
|
}, [selected, setSelected, isEditorReady]);
|
||||||
|
|
||||||
const filterOptions = (options, filter) => {
|
const filterOptions = (options, filter) => {
|
||||||
setSearched(filter);
|
setSearched(filter);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ export const MultiselectV2 = ({
|
||||||
darkMode,
|
darkMode,
|
||||||
fireEvent,
|
fireEvent,
|
||||||
validate,
|
validate,
|
||||||
width,
|
isEditorReady,
|
||||||
}) => {
|
}) => {
|
||||||
let {
|
let {
|
||||||
label,
|
label,
|
||||||
|
|
@ -177,8 +177,10 @@ export const MultiselectV2 = ({
|
||||||
setIsMultiSelectDisabled(value);
|
setIsMultiSelectDisabled(value);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
}, []);
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
|
}, [isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Expose selectOption
|
// Expose selectOption
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ export const RadioButton = function RadioButton({
|
||||||
setExposedVariables,
|
setExposedVariables,
|
||||||
darkMode,
|
darkMode,
|
||||||
dataCy,
|
dataCy,
|
||||||
|
isEditorReady,
|
||||||
}) {
|
}) {
|
||||||
const { label, value, values, display_values } = properties;
|
const { label, value, values, display_values } = properties;
|
||||||
const { visibility, disabledState, activeColor, boxShadow } = styles;
|
const { visibility, disabledState, activeColor, boxShadow } = styles;
|
||||||
|
|
@ -43,9 +44,10 @@ export const RadioButton = function RadioButton({
|
||||||
onSelect(option);
|
onSelect(option);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
setExposedVariables(exposedVariables);
|
||||||
}, [value, setValue]);
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [value, setValue, isEditorReady]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,7 @@ export function Table({
|
||||||
setProperty,
|
setProperty,
|
||||||
mode,
|
mode,
|
||||||
exposedVariables,
|
exposedVariables,
|
||||||
|
isEditorReady,
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
color,
|
color,
|
||||||
|
|
@ -510,11 +511,13 @@ export function Table({
|
||||||
}, [JSON.stringify([tableData, transformations, currentState])]);
|
}, [JSON.stringify([tableData, transformations, currentState])]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setExposedVariables({
|
if (isEditorReady) {
|
||||||
currentData: tableData,
|
setExposedVariables({
|
||||||
updatedData: tableData,
|
currentData: tableData,
|
||||||
});
|
updatedData: tableData,
|
||||||
}, [JSON.stringify(tableData)]);
|
});
|
||||||
|
}
|
||||||
|
}, [JSON.stringify(tableData), isEditorReady]);
|
||||||
|
|
||||||
const columnDataForAddNewRows = generateColumnsData({
|
const columnDataForAddNewRows = generateColumnsData({
|
||||||
columnProperties: useDynamicColumn ? generatedColumn : component.definition.properties.columns.value,
|
columnProperties: useDynamicColumn ? generatedColumn : component.definition.properties.columns.value,
|
||||||
|
|
@ -775,7 +778,7 @@ export function Table({
|
||||||
fireEvent('onRowClicked');
|
fireEvent('onRowClicked');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [JSON.stringify(tableData), JSON.stringify(tableDetails.selectedRow)]);
|
}, [JSON.stringify(tableData), JSON.stringify(tableDetails.selectedRow), isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setExposedVariable('deselectRow', async function () {
|
setExposedVariable('deselectRow', async function () {
|
||||||
|
|
@ -787,7 +790,7 @@ export function Table({
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
}, [JSON.stringify(tableData), JSON.stringify(tableDetails.selectedRow)]);
|
}, [JSON.stringify(tableData), JSON.stringify(tableDetails.selectedRow), isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setExposedVariable('discardChanges', async function () {
|
setExposedVariable('discardChanges', async function () {
|
||||||
|
|
@ -799,7 +802,7 @@ export function Table({
|
||||||
mergeToTableDetails({ dataUpdates: {}, changeSet: {} });
|
mergeToTableDetails({ dataUpdates: {}, changeSet: {} });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [JSON.stringify(tableData), JSON.stringify(tableDetails.changeSet)]);
|
}, [JSON.stringify(tableData), JSON.stringify(tableDetails.changeSet), isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setExposedVariable('discardNewlyAddedRows', async function () {
|
setExposedVariable('discardNewlyAddedRows', async function () {
|
||||||
|
|
@ -818,6 +821,7 @@ export function Table({
|
||||||
JSON.stringify(tableDetails.addNewRowsDetails.newRowsChangeSet),
|
JSON.stringify(tableDetails.addNewRowsDetails.newRowsChangeSet),
|
||||||
tableDetails.addNewRowsDetails.addingNewRows,
|
tableDetails.addNewRowsDetails.addingNewRows,
|
||||||
JSON.stringify(tableDetails.addNewRowsDetails.newRowsDataUpdates),
|
JSON.stringify(tableDetails.addNewRowsDetails.newRowsDataUpdates),
|
||||||
|
isEditorReady,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -841,7 +845,7 @@ export function Table({
|
||||||
setExposedVariables({ selectedRow, selectedRowId });
|
setExposedVariables({ selectedRow, selectedRowId });
|
||||||
mergeToTableDetails({ selectedRow, selectedRowId });
|
mergeToTableDetails({ selectedRow, selectedRowId });
|
||||||
}
|
}
|
||||||
}, [selectedFlatRows.length, selectedFlatRows]);
|
}, [selectedFlatRows.length, selectedFlatRows, isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setExposedVariable('downloadTableData', async function (format) {
|
setExposedVariable('downloadTableData', async function (format) {
|
||||||
|
|
@ -855,7 +859,7 @@ export function Table({
|
||||||
mergeToTableDetails({ selectedRowsDetails: [], selectedRow: {}, selectedRowId: null });
|
mergeToTableDetails({ selectedRowsDetails: [], selectedRow: {}, selectedRowId: null });
|
||||||
toggleAllRowsSelected(false);
|
toggleAllRowsSelected(false);
|
||||||
}
|
}
|
||||||
}, [showBulkSelector, highlightSelectedRow, allowSelection]);
|
}, [showBulkSelector, highlightSelectedRow, allowSelection, isEditorReady]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (enablePagination) {
|
if (enablePagination) {
|
||||||
|
|
@ -971,7 +975,7 @@ export function Table({
|
||||||
}
|
}
|
||||||
|
|
||||||
//hack : in the initial render, data is undefined since, upon feeding data to the table from some query, query inside current state is {}. Hence we added data in the dependency array, now question is should we add data or rows?
|
//hack : in the initial render, data is undefined since, upon feeding data to the table from some query, query inside current state is {}. Hence we added data in the dependency array, now question is should we add data or rows?
|
||||||
}, [JSON.stringify(defaultSelectedRow), JSON.stringify(data)]);
|
}, [JSON.stringify(defaultSelectedRow), JSON.stringify(data), isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// csa for select all rows in table
|
// csa for select all rows in table
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ export const Tabs = function Tabs({
|
||||||
styles,
|
styles,
|
||||||
darkMode,
|
darkMode,
|
||||||
dataCy,
|
dataCy,
|
||||||
|
isEditorReady,
|
||||||
}) {
|
}) {
|
||||||
const { tabWidth, boxShadow } = styles;
|
const { tabWidth, boxShadow } = styles;
|
||||||
|
|
||||||
|
|
@ -103,10 +104,11 @@ export const Tabs = function Tabs({
|
||||||
},
|
},
|
||||||
currentTab: currentTab,
|
currentTab: currentTab,
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [setCurrentTab, currentTab]);
|
}, [setCurrentTab, currentTab, isEditorReady]);
|
||||||
|
|
||||||
const renderTabContent = (id, tab) => (
|
const renderTabContent = (id, tab) => (
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ export const TextArea = function TextArea({
|
||||||
setExposedVariable,
|
setExposedVariable,
|
||||||
setExposedVariables,
|
setExposedVariables,
|
||||||
dataCy,
|
dataCy,
|
||||||
|
isEditorReady,
|
||||||
}) {
|
}) {
|
||||||
const [value, setValue] = useState(properties.value);
|
const [value, setValue] = useState(properties.value);
|
||||||
|
|
||||||
|
|
@ -28,10 +29,10 @@ export const TextArea = function TextArea({
|
||||||
setExposedVariable('value', '');
|
setExposedVariable('value', '');
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [setValue]);
|
}, [properties.value, setValue, isEditorReady]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<textarea
|
<textarea
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import { resolveWidgetFieldValue } from '@/_helpers/utils';
|
import { resolveWidgetFieldValue } from '@/_helpers/utils';
|
||||||
|
|
||||||
import * as Icons from '@tabler/icons-react';
|
import * as Icons from '@tabler/icons-react';
|
||||||
import Loader from '@/ToolJetUI/Loader/Loader';
|
import Loader from '@/ToolJetUI/Loader/Loader';
|
||||||
const tinycolor = require('tinycolor2');
|
const tinycolor = require('tinycolor2');
|
||||||
|
|
@ -18,6 +17,7 @@ export const TextInput = function TextInput({
|
||||||
darkMode,
|
darkMode,
|
||||||
dataCy,
|
dataCy,
|
||||||
isResizing,
|
isResizing,
|
||||||
|
isEditorReady,
|
||||||
}) {
|
}) {
|
||||||
const textInputRef = useRef();
|
const textInputRef = useRef();
|
||||||
const labelRef = useRef();
|
const labelRef = useRef();
|
||||||
|
|
@ -172,9 +172,9 @@ export const TextInput = function TextInput({
|
||||||
setVisibility(value);
|
setVisibility(value);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) setExposedVariables(exposedVariables);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, [isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const exposedVariables = {
|
const exposedVariables = {
|
||||||
|
|
@ -189,9 +189,9 @@ export const TextInput = function TextInput({
|
||||||
fireEvent('onChange');
|
fireEvent('onChange');
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) setExposedVariables(exposedVariables);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [setValue]);
|
}, [setValue, isEditorReady]);
|
||||||
const iconName = styles.icon; // Replace with the name of the icon you want
|
const iconName = styles.icon; // Replace with the name of the icon you want
|
||||||
// eslint-disable-next-line import/namespace
|
// eslint-disable-next-line import/namespace
|
||||||
const IconElement = Icons[iconName] == undefined ? Icons['IconHome2'] : Icons[iconName];
|
const IconElement = Icons[iconName] == undefined ? Icons['IconHome2'] : Icons[iconName];
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ export const TreeSelect = ({
|
||||||
fireEvent,
|
fireEvent,
|
||||||
darkMode,
|
darkMode,
|
||||||
dataCy,
|
dataCy,
|
||||||
|
isEditorReady,
|
||||||
}) => {
|
}) => {
|
||||||
const { label } = properties;
|
const { label } = properties;
|
||||||
const { visibility, disabledState, checkboxColor, boxShadow } = styles;
|
const { visibility, disabledState, checkboxColor, boxShadow } = styles;
|
||||||
|
|
@ -51,10 +52,11 @@ export const TreeSelect = ({
|
||||||
checkedPathStrings: checkedPathString,
|
checkedPathStrings: checkedPathString,
|
||||||
checked: checkedArr,
|
checked: checkedArr,
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [JSON.stringify(checkedData), JSON.stringify(data)]);
|
}, [JSON.stringify(checkedData), JSON.stringify(data), isEditorReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setExposedVariable('expanded', expandedData);
|
setExposedVariable('expanded', expandedData);
|
||||||
|
|
@ -90,8 +92,9 @@ export const TreeSelect = ({
|
||||||
checkedPathStrings: checkedPathString,
|
checkedPathStrings: checkedPathString,
|
||||||
checked: checked,
|
checked: checked,
|
||||||
};
|
};
|
||||||
setExposedVariables(exposedVariables);
|
if (isEditorReady) {
|
||||||
|
setExposedVariables(exposedVariables);
|
||||||
|
}
|
||||||
updatedNode.checked ? fireEvent('onCheck') : fireEvent('onUnCheck');
|
updatedNode.checked ? fireEvent('onCheck') : fireEvent('onUnCheck');
|
||||||
fireEvent('onChange');
|
fireEvent('onChange');
|
||||||
setChecked(checked);
|
setChecked(checked);
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ export const shouldUpdate = (prevProps, nextProps) => {
|
||||||
|
|
||||||
if (componentId) {
|
if (componentId) {
|
||||||
const componentToRender = listToRender.find((item) => item === componentId);
|
const componentToRender = listToRender.find((item) => item === componentId);
|
||||||
|
|
||||||
const parentReRendered = listToRender.find((item) => item === prevProps?.parentId);
|
const parentReRendered = listToRender.find((item) => item === prevProps?.parentId);
|
||||||
|
|
||||||
const grandParentReRendered = listToRender.find((item) => item === prevProps?.grandParentId);
|
const grandParentReRendered = listToRender.find((item) => item === prevProps?.grandParentId);
|
||||||
|
|
@ -26,7 +25,7 @@ export const shouldUpdate = (prevProps, nextProps) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Added to render the defaukt child components
|
// Added to render the default child components
|
||||||
if (prevProps?.childComponents === null && nextProps?.childComponents) return false;
|
if (prevProps?.childComponents === null && nextProps?.childComponents) return false;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -39,6 +38,7 @@ export const shouldUpdate = (prevProps, nextProps) => {
|
||||||
prevProps?.height === nextProps?.height &&
|
prevProps?.height === nextProps?.height &&
|
||||||
prevProps?.darkMode === nextProps?.darkMode &&
|
prevProps?.darkMode === nextProps?.darkMode &&
|
||||||
prevProps?.childComponents === nextProps?.childComponents &&
|
prevProps?.childComponents === nextProps?.childComponents &&
|
||||||
|
prevProps?.isEditorReady === nextProps?.isEditorReady &&
|
||||||
!needToRender
|
!needToRender
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue