Render depends on menu items conditionally in chart settings + fix min max values (#15391)
closes https://discord.com/channels/1130383047699738754/1430894689317294152 --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com> Co-authored-by: Raphaël Bosi <71827178+bosiraphael@users.noreply.github.com>
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
import { CHART_CONFIGURATION_SETTING_IDS } from '@/command-menu/pages/page-layout/types/ChartConfigurationSettingIds';
|
||||
import { type ChartSettingsItem } from '@/command-menu/pages/page-layout/types/ChartSettingsGroup';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
|
||||
export const shouldHideChartSetting = (
|
||||
item: ChartSettingsItem,
|
||||
objectMetadataId: string,
|
||||
isGroupByEnabled: boolean,
|
||||
): boolean => {
|
||||
const hasNoObjectMetadata = !isNonEmptyString(objectMetadataId);
|
||||
const dependsOnSource = item?.dependsOn?.includes(
|
||||
CHART_CONFIGURATION_SETTING_IDS.SOURCE,
|
||||
);
|
||||
const dependsOnGroupBy = item?.dependsOn?.includes(
|
||||
CHART_CONFIGURATION_SETTING_IDS.GROUP_BY,
|
||||
);
|
||||
|
||||
return (
|
||||
(hasNoObjectMetadata && (dependsOnSource ?? false)) ||
|
||||
(!isGroupByEnabled && (dependsOnGroupBy ?? false))
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user