From cfa7a74742d77307fa1f94d6c9bf16bd681ac189 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 4 Jul 2017 22:22:52 +0700 Subject: [PATCH] Fix isSlotEmpty logic and handle empty plugin_config --- client/coral-framework/helpers/plugins.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/coral-framework/helpers/plugins.js b/client/coral-framework/helpers/plugins.js index bb21bef6c..ab5e3080e 100644 --- a/client/coral-framework/helpers/plugins.js +++ b/client/coral-framework/helpers/plugins.js @@ -12,17 +12,19 @@ import camelize from './camelize'; function getSlotComponents(slot) { const pluginConfig = getStore().getState().config.plugin_config; + + // Filter out components that have been disabled in `plugin_config` return flatten(plugins // Filter out components that have been disabled in `plugin_config` - .filter((o) => !pluginConfig[o.plugin] || !pluginConfig[o.plugin].disable_components) + .filter((o) => !pluginConfig || !pluginConfig[o.plugin] || !pluginConfig[o.plugin].disable_components) .filter((o) => o.module.slots[slot]) .map((o) => o.module.slots[slot])); } export function isSlotEmpty(slot) { - return !!getSlotComponents(slot).length; + return getSlotComponents(slot).length === 0; } /**