mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
process constants which are returned in array
This commit is contained in:
parent
db145cbc78
commit
e33248a8c5
2 changed files with 23 additions and 1 deletions
|
|
@ -16,7 +16,7 @@ import { usePrevious } from '@dnd-kit/utilities';
|
||||||
import { deepCamelCase } from '@/_helpers/appUtils';
|
import { deepCamelCase } from '@/_helpers/appUtils';
|
||||||
import { useEventActions } from '../_stores/slices/eventsSlice';
|
import { useEventActions } from '../_stores/slices/eventsSlice';
|
||||||
import useRouter from '@/_hooks/use-router';
|
import useRouter from '@/_hooks/use-router';
|
||||||
import { navigate } from '../_utils/misc';
|
import { extractEnvironmentConstantsFromConstantsList, navigate } from '../_utils/misc';
|
||||||
import { getWorkspaceId } from '@/_helpers/utils';
|
import { getWorkspaceId } from '@/_helpers/utils';
|
||||||
import { shallow } from 'zustand/shallow';
|
import { shallow } from 'zustand/shallow';
|
||||||
import { fetchAndSetWindowTitle, pageTitles, defaultWhiteLabellingSettings } from '@white-label/whiteLabelling';
|
import { fetchAndSetWindowTitle, pageTitles, defaultWhiteLabellingSettings } from '@white-label/whiteLabelling';
|
||||||
|
|
@ -176,6 +176,8 @@ const useAppData = (appId, moduleId, mode = 'edit', { environmentId, versionId }
|
||||||
? await orgEnvironmentConstantService.getConstantsFromPublicApp(slug)
|
? await orgEnvironmentConstantService.getConstantsFromPublicApp(slug)
|
||||||
: await orgEnvironmentConstantService.getConstantsFromApp();
|
: await orgEnvironmentConstantService.getConstantsFromApp();
|
||||||
|
|
||||||
|
constantsResp.constants = extractEnvironmentConstantsFromConstantsList(constantsResp?.constants, 'production');
|
||||||
|
|
||||||
const pages = appData.pages.map((page) => {
|
const pages = appData.pages.map((page) => {
|
||||||
return page;
|
return page;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,26 @@ export async function copyToClipboard(text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const extractEnvironmentConstantsFromConstantsList = (constantsList = [], environmentName = 'development') => {
|
||||||
|
try {
|
||||||
|
return constantsList.map((constant) => {
|
||||||
|
if (constant.values && Array.isArray(constant.values)) {
|
||||||
|
const { value } = constant.values.find((value) => value.environmentName === environmentName);
|
||||||
|
return {
|
||||||
|
id: constant.id,
|
||||||
|
name: constant.name,
|
||||||
|
value,
|
||||||
|
type: constant.type,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return constant;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export function setTablePageIndex(tableId, index) {
|
export function setTablePageIndex(tableId, index) {
|
||||||
if (_.isEmpty(tableId)) {
|
if (_.isEmpty(tableId)) {
|
||||||
console.log('No table is associated with this event.');
|
console.log('No table is associated with this event.');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue