From dbaedc8191fbc529780c157e465bc7a40c91dca2 Mon Sep 17 00:00:00 2001 From: Jacques Ikot Date: Tue, 24 Sep 2024 10:14:00 +0100 Subject: [PATCH 1/4] get widgetConfig for iconSVG --- .../DatasourceDropdown/useSource/useConnectToOptions.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx b/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx index 01460af48a5..8751908cd24 100644 --- a/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx +++ b/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx @@ -234,9 +234,10 @@ function useConnectToOptions(props: ConnectToOptionsProps) { // Get the widget config for the current widget const { getOneClickBindingConnectableWidgetConfig } = WidgetFactory.getWidgetMethods(currWidget.type); + const currentWidgetConfig = WidgetFactory.getConfig(currWidget.type); // If the widget is connectable to the current widget, return the option - if (getOneClickBindingConnectableWidgetConfig) { + if (getOneClickBindingConnectableWidgetConfig && currentWidgetConfig) { // This is the path we bind to the sourceData field Ex: `{{Table1.selectedRow}}` const { widgetBindPath } = getOneClickBindingConnectableWidgetConfig(currWidget); @@ -250,7 +251,7 @@ function useConnectToOptions(props: ConnectToOptionsProps) { ), From 41d69133d822f92c133c3a4cfd19bcd1a6fa097c Mon Sep 17 00:00:00 2001 From: Rahul Barwal Date: Fri, 4 Oct 2024 17:13:34 +0530 Subject: [PATCH 2/4] refactor: Update useConnectToOptions to improve widget icon handling --- .../DatasourceDropdown/useSource/useConnectToOptions.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx b/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx index 8751908cd24..d187214e3af 100644 --- a/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx +++ b/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx @@ -234,13 +234,15 @@ function useConnectToOptions(props: ConnectToOptionsProps) { // Get the widget config for the current widget const { getOneClickBindingConnectableWidgetConfig } = WidgetFactory.getWidgetMethods(currWidget.type); - const currentWidgetConfig = WidgetFactory.getConfig(currWidget.type); // If the widget is connectable to the current widget, return the option - if (getOneClickBindingConnectableWidgetConfig && currentWidgetConfig) { + if (getOneClickBindingConnectableWidgetConfig) { // This is the path we bind to the sourceData field Ex: `{{Table1.selectedRow}}` const { widgetBindPath } = getOneClickBindingConnectableWidgetConfig(currWidget); + const iconSVG = + WidgetFactory.getConfig(currWidget.type)?.iconSVG || + currWidget.iconSVG; return { id: widgetId, @@ -251,7 +253,7 @@ function useConnectToOptions(props: ConnectToOptionsProps) { ), From 1ed4915868c4a852cf00cb138104f3d8d0e23dd4 Mon Sep 17 00:00:00 2001 From: Rahul Barwal Date: Fri, 4 Oct 2024 17:13:57 +0530 Subject: [PATCH 3/4] refactor: Improve widget icon handling in useDropdown --- .../OtherFields/Field/Dropdown/useDropdown.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/WidgetSpecificControls/OtherFields/Field/Dropdown/useDropdown.tsx b/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/WidgetSpecificControls/OtherFields/Field/Dropdown/useDropdown.tsx index efac989bf96..e5143135f27 100644 --- a/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/WidgetSpecificControls/OtherFields/Field/Dropdown/useDropdown.tsx +++ b/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/WidgetSpecificControls/OtherFields/Field/Dropdown/useDropdown.tsx @@ -81,12 +81,15 @@ export function useDropdown(props: OneClickDropdownFieldProps) { if (getOneClickBindingConnectableWidgetConfig) { const { message, widgetBindPath } = getOneClickBindingConnectableWidgetConfig(currWidget); + const iconSVG = + WidgetFactory.getConfig(currWidget.type)?.iconSVG || + currWidget.iconSVG; return { id: currWidgetId, value: widgetBindPath, label: currWidget.widgetName, - icon: , + icon: , data: { widgetType: currWidget.type, widgetName: currWidget.widgetName, From 80a63553ab8f1d77695d3261095a90acdb4b5a4d Mon Sep 17 00:00:00 2001 From: Rahul Barwal Date: Fri, 4 Oct 2024 18:50:54 +0530 Subject: [PATCH 4/4] refactor: Improve widget icon handling in OneClickBinding spec_utility.ts --- .../ClientSide/OneClickBinding/spec_utility.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/client/cypress/e2e/Regression/ClientSide/OneClickBinding/spec_utility.ts b/app/client/cypress/e2e/Regression/ClientSide/OneClickBinding/spec_utility.ts index 91b52c0d116..ba218d46f17 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/OneClickBinding/spec_utility.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/OneClickBinding/spec_utility.ts @@ -12,7 +12,22 @@ export class OneClickBinding { column: Record = {}, ) { agHelper.GetNClick(oneClickBindingLocator.datasourceDropdownSelector); - + agHelper.GetElement("[role='menu']").then(($menu) => { + if ( + $menu.find(oneClickBindingLocator.datasourceQuerySelector()).length > 0 + ) { + cy.wrap($menu) + .find(oneClickBindingLocator.datasourceQuerySelector()) + .should("have.length.greaterThan", 0) + .each(($item) => { + cy.wrap($item) + .find("img") + .should(($img) => { + expect($img).to.have.attr("src").and.not.be.empty; + }); + }); + } + }); expandLoadMoreOptions(); agHelper.AssertElementAbsence(oneClickBindingLocator.connectData);