From 76e1e48a3bb1f9e020da5a922cb99aa48d6a9b93 Mon Sep 17 00:00:00 2001 From: Pawan Kumar Date: Tue, 15 Apr 2025 15:03:17 +0530 Subject: [PATCH] chore: fix agent creation bug (#40251) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /ok-to-test tags="@tag.Templates" ## Summary by CodeRabbit - **New Features** - Added filtering of templates based on the AI agent flow setting, showing only relevant templates when enabled. - **Refactor** - Improved consistency in template filtering across the app by updating related selectors. > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 7050a8bfff005c645f72b007415bc331140374c0 > Cypress dashboard. > Tags: `@tag.Templates` > Spec: >
Tue, 15 Apr 2025 09:31:34 UTC --- app/client/src/selectors/templatesSelectors.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/client/src/selectors/templatesSelectors.tsx b/app/client/src/selectors/templatesSelectors.tsx index b0d7abfaa5..af7ee7146c 100644 --- a/app/client/src/selectors/templatesSelectors.tsx +++ b/app/client/src/selectors/templatesSelectors.tsx @@ -28,7 +28,10 @@ const fuzzySearchOptions = { const AGENT_TEMPLATES_USE_CASE = "Agent"; const AGENT_TEMPLATES_TITLE = "AI Agent"; -export const getTemplatesSelector = createSelector( +export const getTemplatesSelector = (state: AppState) => + state.ui.templates.templates; + +export const getTemplatesByFlagSelector = createSelector( (state: AppState) => state.ui.templates.templates, getIsAiAgentFlowEnabled, (templates, isAiAgentFlowEnabled) => { @@ -124,7 +127,7 @@ export const getBuildingBlockExplorerCards = createSelector( ); export const getFilteredTemplateList = createSelector( - getTemplatesSelector, + getTemplatesByFlagSelector, getTemplateFilterSelector, getTemplateFiltersLength, (templates, templatesFilters, numberOfFiltersApplied) => { @@ -188,7 +191,7 @@ export const getSearchedTemplateList = createSelector( // Get the list of datasources which are used by templates export const templatesDatasourceFiltersSelector = createSelector( - getTemplatesSelector, + getTemplatesByFlagSelector, getDefaultPlugins, (templates, plugins) => { const datasourceFilters: Filter[] = []; @@ -224,7 +227,7 @@ export const allTemplatesFiltersSelector = (state: AppState) => // Get all filters which is associated with atleast one template // If no template is associated with a filter, then the filter shouldn't be in the filter list export const getFilterListSelector = createSelector( - getTemplatesSelector, + getTemplatesByFlagSelector, allTemplatesFiltersSelector, (templates, allTemplateFilters) => { const FUNCTIONS_FILTER = "functions";