From 4e40313ea5bde19e194507a56fd643c51305a86b Mon Sep 17 00:00:00 2001 From: JEFFREY-Bonson Date: Thu, 29 Feb 2024 20:06:02 +0530 Subject: [PATCH] add clear search button --- .../AeInlineMethod/FilterNamespace.jsx | 42 +++++++++++++++---- .../AeInlineMethod/NamespaceSelector.jsx | 1 + .../components/AeInlineMethod/index.jsx | 19 +++++---- .../components/AeInlineMethod/style.scss | 37 ++++++++-------- 4 files changed, 64 insertions(+), 35 deletions(-) diff --git a/app/javascript/components/AeInlineMethod/FilterNamespace.jsx b/app/javascript/components/AeInlineMethod/FilterNamespace.jsx index c66aa1137c6..0c1a41b70f1 100644 --- a/app/javascript/components/AeInlineMethod/FilterNamespace.jsx +++ b/app/javascript/components/AeInlineMethod/FilterNamespace.jsx @@ -1,17 +1,43 @@ -import React from 'react'; +import React, { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; -import { TextInput, Select, SelectItem } from 'carbon-components-react'; +import { + TextInput, Select, SelectItem, Button, +} from 'carbon-components-react'; +import { Close16 } from '@carbon/icons-react'; import { noSelect } from './helper'; const FilterNamespace = ({ domains, filterOnChange }) => { + const [searchText, setSearchText] = useState(''); + + useEffect(() => { + filterOnChange({ text: searchText || noSelect }); + }, [searchText]); + /** Function to render the search text. */ const renderSearchText = () => ( - filterOnChange({ text: event.target.value || noSelect })} - /> +
+ setSearchText(event.target.value)} + /> + { + searchText && ( +
); /** Function to render the domain items in a drop-down list. */ diff --git a/app/javascript/components/AeInlineMethod/NamespaceSelector.jsx b/app/javascript/components/AeInlineMethod/NamespaceSelector.jsx index bb1ed61d8b7..b0fe22d0e6a 100644 --- a/app/javascript/components/AeInlineMethod/NamespaceSelector.jsx +++ b/app/javascript/components/AeInlineMethod/NamespaceSelector.jsx @@ -64,6 +64,7 @@ const NamespaceSelector = ({ onSelectMethod, selectedIds }) => { ? ( { id="add-method" kind="primary" title={__('Add Method')} + renderIcon={AddAlt16} onClick={() => showModal(true)} size="sm" > @@ -131,18 +135,15 @@ const AeInlineMethod = ({ type }) => { ); - /** Function to render the Add method button. */ const renderCustomContents = () => ( - <> -
-
{__('Methods')}
-
-
+ + {renderAddButton()} {renderList()} -
- + + ); + return (
{renderCustomContents()} diff --git a/app/javascript/components/AeInlineMethod/style.scss b/app/javascript/components/AeInlineMethod/style.scss index b51253fa62b..8cddf86a4c6 100644 --- a/app/javascript/components/AeInlineMethod/style.scss +++ b/app/javascript/components/AeInlineMethod/style.scss @@ -5,7 +5,15 @@ .inline-filters { display: flex; flex-direction: row; + align-items: end; gap: 10px; + + .search-wrapper { + display: flex; + flex-grow: 1; + flex-direction: row; + align-items: end; + } } .inline-contents-wrapper { @@ -24,27 +32,20 @@ } } -.custom-form-wrapper { - border: 1px solid lightgray; - margin-bottom: 20px; - display: flex; - flex-direction: column; +.miq-custom-form-accordion +{ + border: 1px solid #e0e0e0; - .custom-form-title-wrapper { - background: lightgray; - display: flex; - flex-direction: row; - - .custom-form-title { - display: flex; - flex-grow: 1; - font-size: 16px; - padding: 8px 10px; - } + li button.bx--accordion__heading { + background: #e0e0e0; + } + .bx--accordion__item:last-child{ + border: 0; } - .custom-form-component-wrapper { - padding: 10px; + .bx--accordion__content { + padding: 20px; + margin: 0; .custom-form-buttons { display: flex;