Skip to content

Commit

Permalink
fix: empty tenant configuration definition from crashing. (#3255)
Browse files Browse the repository at this point in the history
  • Loading branch information
thdlam authored Aug 7, 2024
1 parent c5f7b9d commit 9c90db1
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,18 @@ export const ConfigurationDefinitionsTableComponent: FunctionComponent<serviceTa
const nameSpaces: Record<string, string[]> = useMemo(() => {
return {};
}, [definitions]); // eslint-disable-line react-hooks/exhaustive-deps
const isCore = !Object.keys(definitions)[0].includes(':');

const isCoreDefinition = () => {
let isCore = false;
if (definitions && definitions.length > 0) {
isCore = !Object.keys(definitions)[0].includes(':');
}
return isCore;
};

// to ensure it dosent re-calculate this value if value dosent change
const memoizedReducedConfiguration = useMemo(() => {
return Object.keys(definitions).reduce((obj, key) => {
return Object.keys(definitions ?? []).reduce((obj, key) => {
obj[key] = definitions[key];
const parts = key.split(':');
const nameSpace = parts[0];
Expand Down Expand Up @@ -74,7 +81,7 @@ export const ConfigurationDefinitionsTableComponent: FunctionComponent<serviceTa
<ConfigurationDefinitionItemComponent
key={`${configName}-${nameSpace}`}
tenantName={tenantName}
isCore={isCore}
isCore={isCoreDefinition()}
isTenantSpecificConfig={isTenantSpecificConfig}
configName={configName}
nameSpace={nameSpace}
Expand Down

0 comments on commit 9c90db1

Please sign in to comment.