The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Add cancel button.
Anders Borch4885e3598ae9
diff --git a/front/src/components/table/table-header/SortAndFilterBar.tsx b/front/src/components/table/table-header/SortAndFilterBar.tsxindex 682b1626095..df2e09ab41b 100644--- a/front/src/components/table/table-header/SortAndFilterBar.tsx+++ b/front/src/components/table/table-header/SortAndFilterBar.tsx@@ -24,6 +24,26 @@ const StyledBar = styled.div`height: 40px;`;+const StyledCancelButton = styled.button`+ margin-left: auto;+ border: none;+ background-color: inherit;+ padding: ${(props) => {+ const horiz = props.theme.spacing(2);+ const vert = props.theme.spacing(1);+ return `${vert} ${horiz} ${vert} ${horiz}`;+ }};+ color: ${(props) => props.theme.text40};+ font-weight: 500;+ margin-right: ${(props) => props.theme.spacing(2)};+ cursor: pointer;++ &:hover {+ border-radius: ${(props) => props.theme.spacing(1)};+ background-color: ${(props) => props.theme.tertiaryBackground};+ }+`;+function SortAndFilterBar({ sorts, onRemoveSort }: OwnProps) {return (<StyledBar>@@ -38,6 +58,14 @@ function SortAndFilterBar({ sorts, onRemoveSort }: OwnProps) {/>);})}+ {sorts.length > 0 && (+ <StyledCancelButton+ data-testid={'cancel-button'}+ onClick={() => sorts.forEach((i) => onRemoveSort(i.id))}+ >+ Cancel+ </StyledCancelButton>+ )}</StyledBar>);}diff --git a/front/src/components/table/table-header/__tests__/SortAndFilterBar.test.tsx b/front/src/components/table/table-header/__tests__/SortAndFilterBar.test.tsxindex 89b34679f43..5dcfd17a49d 100644--- a/front/src/components/table/table-header/__tests__/SortAndFilterBar.test.tsx+++ b/front/src/components/table/table-header/__tests__/SortAndFilterBar.test.tsx@@ -2,9 +2,8 @@ import { fireEvent, render } from '@testing-library/react';import { RegularSortAndFilterBar } from '../__stories__/SortAndFilterBar.stories';-const removeFunction = jest.fn();-it('Checks the SortAndFilterBar renders', async () => {+ const removeFunction = jest.fn();const { getByText, getByTestId } = render(<RegularSortAndFilterBar removeFunction={removeFunction} />,);@@ -15,3 +14,14 @@ it('Checks the SortAndFilterBar renders', async () => {expect(removeFunction).toHaveBeenCalled();});++it('Removes sorts when cancel is pressed', async () => {+ const removeFunction = jest.fn();+ const { getByTestId } = render(+ <RegularSortAndFilterBar removeFunction={removeFunction} />,+ );+ const cancel = getByTestId('cancel-button');+ fireEvent.click(cancel);++ expect(removeFunction).toHaveBeenCalled();+});