From d38e4b0b38cbbaee87a27e8fef710cfb25974593 Mon Sep 17 00:00:00 2001 From: Ashok Kumar M <35134347+marks0351@users.noreply.github.com> Date: Mon, 29 Apr 2024 18:30:15 +0530 Subject: [PATCH] fix: WDS widgets not showing up in Air gapped instances. (#33035) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![workerB](https://img.shields.io/endpoint?url=https%3A%2F%2Fworkerb.linearb.io%2Fv2%2Fbadge%2Fprivate%2FU2FsdGVkX19IVboRD3kaZRJNqi3vW6q9oNbSeq9tQI%2Fcollaboration.svg%3FcacheSeconds%3D60)](https://workerb.linearb.io/v2/badge/collaboration-page?magicLinkId=MfLLKnB) ## Description > [!TIP] > _Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team)._ > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 918fd45704546793524f2c97c05ab01e27063b6c > Cypress dashboard url: Click here! ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **New Features** - Enhanced widget configuration logic to better handle icons based on widget methods. - **Refactor** - Improved the filtering logic for widget cards in the editor, now supports different layout configurations more effectively. - Renamed variables for better clarity in widget card selection based on layout system. --- .../src/WidgetProvider/factory/index.tsx | 4 +-- app/client/src/selectors/editorSelectors.tsx | 25 ++++++++----------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/app/client/src/WidgetProvider/factory/index.tsx b/app/client/src/WidgetProvider/factory/index.tsx index 346a03e0a5..04facdf369 100644 --- a/app/client/src/WidgetProvider/factory/index.tsx +++ b/app/client/src/WidgetProvider/factory/index.tsx @@ -80,7 +80,7 @@ class WidgetFactory { private static configureWidget(widget: typeof BaseWidget) { const config = widget.getConfig(); - + const { IconCmp } = widget.getMethods(); const features = widget.getFeatures(); let enhancedFeatures: Record = {}; @@ -103,7 +103,7 @@ class WidgetFactory { ...enhancedFeatures, searchTags: config.searchTags, tags: config.tags, - hideCard: !!config.hideCard || !config.iconSVG, + hideCard: !!config.hideCard || !(config.iconSVG || IconCmp), isDeprecated: !!config.isDeprecated, replacement: config.replacement, displayName: config.name, diff --git a/app/client/src/selectors/editorSelectors.tsx b/app/client/src/selectors/editorSelectors.tsx index bd894a0a50..ec497749cf 100644 --- a/app/client/src/selectors/editorSelectors.tsx +++ b/app/client/src/selectors/editorSelectors.tsx @@ -309,25 +309,20 @@ export const getWidgetCards = createSelector( getIsAnvilLayout, (isAutoLayout, isAnvilLayout) => { const widgetConfigs = WidgetFactory.getConfigs(); - - const cards = Object.values(widgetConfigs).filter((config) => { - // if anvil is not enabled, hide all wds widgets - if ( - Object.values(WDS_V2_WIDGET_MAP).includes(config.type) && - !isAnvilLayout - ) { - return false; + const widgetConfigsArray = Object.values(widgetConfigs); + const layoutSystemBasesWidgets = widgetConfigsArray.filter((config) => { + const isAnvilWidget = Object.values(WDS_V2_WIDGET_MAP).includes( + config.type, + ); + if (isAnvilLayout) { + return isAnvilWidget; } - + return !isAnvilWidget; + }); + const cards = layoutSystemBasesWidgets.filter((config) => { if (isAirgapped()) { return config.widgetName !== "Map" && !config.hideCard; } - - // if anvil is enabled, only show the wds widgets - if (isAnvilLayout) { - return Object.values(WDS_V2_WIDGET_MAP).includes(config.type); - } - return !config.hideCard; });