From acfa51aced030f03941b644d07b3a78f3121fd6d Mon Sep 17 00:00:00 2001 From: Rahul Barwal Date: Mon, 5 Jun 2023 11:46:00 +0530 Subject: [PATCH] feat: Updates templates filters section in appsmith platform (#23361) ## Description Updates templates filters 1. Removes data sources from filters 2. Renames `functions` to `teams` #### PR fixes following issue(s) Fixes # (issue number) #22959 #### Media Screenshot 2023-05-15 at 10 14 30 PM #### Type of change - Breaking change (fix or feature that would cause existing functionality to not work as expected) ## Testing - [x] Cypress #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Test-plan-implementation#speedbreaker-features-to-consider-for-every-change) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans/_edit#areas-of-interest) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --- app/client/src/pages/Templates/Filters.tsx | 10 ++++++++-- app/client/src/selectors/templatesSelectors.tsx | 15 +++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/client/src/pages/Templates/Filters.tsx b/app/client/src/pages/Templates/Filters.tsx index 34f2c76474..219e04d6cc 100644 --- a/app/client/src/pages/Templates/Filters.tsx +++ b/app/client/src/pages/Templates/Filters.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useMemo } from "react"; import styled from "styled-components"; import { useDispatch, useSelector } from "react-redux"; import { Checkbox, Text } from "design-system"; @@ -110,6 +110,12 @@ function FilterCategory({ label, selectedFilters, }: FilterCategoryProps) { + const filterLabelsToDisplay: Record = useMemo( + () => ({ + functions: "teams", + }), + [], + ); // const [expand, setExpand] = useState(!!selectedFilters.length); const dispatch = useDispatch(); // This indicates how many filter items do we want to show, the rest are hidden @@ -139,7 +145,7 @@ function FilterCategory({ return ( - {`${label} `} + {`${filterLabelsToDisplay[label] ?? label} `} {!!selectedFilters.length && `(${selectedFilters.length})`} diff --git a/app/client/src/selectors/templatesSelectors.tsx b/app/client/src/selectors/templatesSelectors.tsx index 3b8c12f881..3ad518c020 100644 --- a/app/client/src/selectors/templatesSelectors.tsx +++ b/app/client/src/selectors/templatesSelectors.tsx @@ -3,7 +3,6 @@ import Fuse from "fuse.js"; import type { AppState } from "@appsmith/reducers"; import { createSelector } from "reselect"; import { getWorkspaceCreateApplication } from "@appsmith/selectors/applicationSelectors"; -import { getWidgetCards } from "./editorSelectors"; import { getDefaultPlugins } from "./entitiesSelector"; import type { Filter } from "pages/Templates/Filters"; @@ -149,14 +148,12 @@ export const templatesFiltersSelector = (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( - getWidgetCards, - templatesDatasourceFiltersSelector, getTemplatesSelector, templatesFiltersSelector, - (widgetConfigs, allDatasources, templates, allTemplateFilters) => { + (templates, allTemplateFilters) => { + const FUNCTIONS_FILTER = "functions"; const filters: Record = { - datasources: [], - functions: [], + [FUNCTIONS_FILTER]: [], }; const allFunctions = allTemplateFilters.functions.map((item) => { @@ -191,11 +188,9 @@ export const getFilterListSelector = createSelector( }); }; - templates.map((template) => { - filterFilters("datasources", allDatasources, template); - filterFilters("functions", allFunctions, template); + templates.forEach((template) => { + filterFilters(FUNCTIONS_FILTER, allFunctions, template); }); - return filters; }, );