Skip to content

Commit

Permalink
Merge branch 'feat/implement-tree-max-limit-from-remote-config' into …
Browse files Browse the repository at this point in the history
…alpha
  • Loading branch information
mguellsegarra committed Feb 27, 2025
2 parents d6a9305 + 12d7a5e commit bf9d62b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/context/ConfigContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import {
} from "@gisce/react-formiga-components";
import { strings } from "@/locales";

type ConfigContextProps = ConfigContextValues & {
type ConfigContextProps = Omit<ConfigContextValues, "treeMaxLimit"> & {
locale: Locale;
localizedStrings?: Strings;
treeMaxLimit?: number;
};

type ConfigContextValues = {
Expand All @@ -19,14 +20,18 @@ type ConfigContextValues = {
globalValues?: Record<string, any>;
rootContext?: Record<string, any>;
devMode?: boolean;
treeMaxLimit: number;
};

const MAX_SEARCH_LIMIT = 100;

const defaultConfigContext: ConfigContextValues = {
erpFeatures: {},
title: "Webclient",
globalValues: {},
rootContext: {},
devMode: false,
treeMaxLimit: MAX_SEARCH_LIMIT,
};

export const ConfigContext =
Expand Down Expand Up @@ -58,6 +63,7 @@ export const ConfigContextProvider = memo(
rootContext,
devMode,
title,
treeMaxLimit = MAX_SEARCH_LIMIT,
children,
}: ConfigContextProps & { children?: React.ReactNode }) => {
const providerValue = useMemo(
Expand All @@ -67,10 +73,12 @@ export const ConfigContextProvider = memo(
rootContext,
devMode,
title,
treeMaxLimit,
}),
[erpFeatures, globalValues, rootContext, devMode, title],
[erpFeatures, globalValues, rootContext, devMode, title, treeMaxLimit],
);

console.log("treeMaxLimit", treeMaxLimit);
return (
<ConfigContext.Provider value={providerValue}>
<FormigaConfigProvider
Expand Down
6 changes: 2 additions & 4 deletions src/views/RootView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ type RootViewProps = {
children: ReactNode;
};

const MAX_SEARCH_LIMIT = 100;

function RootView(props: RootViewProps, ref: any) {
const { children } = props;
const [activeKey, setActiveKey] = useState<string>("welcome");
const { t } = useLocale();
const { globalValues, rootContext } = useConfigContext();
const { globalValues, rootContext, treeMaxLimit } = useConfigContext();

const [tabs, setTabs] = useState<Tab[]>([
{
Expand Down Expand Up @@ -150,7 +148,7 @@ function RootView(props: RootViewProps, ref: any) {

openAction({
...action,
limit: limit && limit > MAX_SEARCH_LIMIT ? MAX_SEARCH_LIMIT : limit,
limit: limit && limit > treeMaxLimit ? treeMaxLimit : limit,
context: { ...rootContext, ...parsedContext },
domain: parsedDomain,
actionRawData: {
Expand Down

0 comments on commit bf9d62b

Please sign in to comment.