Skip to content

Commit

Permalink
clear filter text when Show button clicked, state moved to servicePage
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamNowotny committed Sep 11, 2024
1 parent 2350a74 commit d61697e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
21 changes: 7 additions & 14 deletions src/options/pages/service/components/filterQuery.tsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,35 @@
import React, { useState } from 'react';
import React from 'react';
import { Form } from 'react-bootstrap';
import IconTimes from '~icons/fa/times-circle-o';
import './filterQuery.css';

export default ({ onUpdate }: { onUpdate: (string) => void }) => {
const [query, setQuery] = useState('');

const updateQuery = value => {
setQuery(value);
onUpdate(value);
};

export default ({ text, onUpdate }: { text?: string; onUpdate: (string) => void }) => {
const handleKeyDown = e => {
if (e.key === 'Escape') {
e.preventDefault();
updateQuery('');
onUpdate('');
}
};
const handleChange = e => {
const value = e.target.value;
updateQuery(value);
onUpdate(value);
};

return (
<div className="filter-query mb-2">
<Form.Control
className="search-query"
value={query}
value={text}
type="text"
placeholder="Search..."
onChange={handleChange}
onKeyDown={handleKeyDown}
/>
{query && (
{text && (
<IconTimes
className="reset-icon"
onClick={() => {
updateQuery('');
onUpdate('');
}}
/>
)}
Expand Down
5 changes: 4 additions & 1 deletion src/options/pages/service/servicePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default () => {
const showPipelines = (pipelines: CIPipelineList, settings: CIServiceSettings) => {
setNewService({ ...settings, ...{ pipelines: settings.pipelines } });
setAllPipelines(pipelines);
setFilter('');
};
const handleSave = (settings: CIServiceSettings) => {
setNewService(settings);
Expand Down Expand Up @@ -55,7 +56,9 @@ export default () => {
<SelectedPipelines pipelines={service.pipelines} />
</Col>
<Col xs={6} className="project-selection-container">
{allPipelines && <PipelineFilter onUpdate={updateFilter} />}
{allPipelines && (
<PipelineFilter text={filter} onUpdate={updateFilter} />
)}
<PipelineList
key={service.name}
pipelines={allPipelines}
Expand Down

0 comments on commit d61697e

Please sign in to comment.