Skip to content

Commit c070884

Browse files
committed
fixes to dropdown filters
1 parent a7b7fe4 commit c070884

File tree

3 files changed

+31
-22
lines changed

3 files changed

+31
-22
lines changed

packages/components/src/internal/icon-library.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import {
3333
faExclamationTriangle,
3434
faExpandArrowsAlt,
3535
faFileInvoiceDollar,
36-
faFilter,
3736
faFolder as faFolderSolid,
3837
faGlobe,
3938
faGripHorizontal,
@@ -157,7 +156,6 @@ const iconLibrary = {
157156
eye: fa(faEye),
158157
fileAlt: fa(faFileAlt),
159158
fileSearchSolid: custom(fileSearchSolid),
160-
filter: fa(faFilter),
161159
folder: fa(faFolder),
162160
folderSolid: fa(faFolderSolid),
163161
'folder-open': fa(faFolderOpen),

src/pages/scientificServices/pipelines/views/JobHistory.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,14 @@ export const JobHistory = () => {
3636
const [pipelineRunsResponse, setPipelineRunsResponse] = useState<GetPipelineRunsResponse>();
3737
const [isLoading, setIsLoading] = useState(false);
3838
const [filters, setFilters] = useState<FilterValues>({});
39-
const [showFilters, setShowFilters] = useState(false);
39+
const [showFilters, setShowFilters] = useState(true); // todo flip back
4040
const [sort, setSort] = useState<SortProperties>({
4141
field: 'created',
4242
direction: 'desc',
4343
});
4444

45-
const availablePipelineNames = ['array_imputation', 'bge_imputation'];
45+
// todo populate this from a hook
46+
const AVAILABLE_PIPELINE_NAMES = ['array_imputation'];
4647

4748
// Fetch pipeline runs when the component mounts or when pagination/sorting/filtering controls change
4849
useEffect(() => {
@@ -123,7 +124,7 @@ export const JobHistory = () => {
123124
<TableFilters
124125
filters={filters}
125126
onFilterChange={handleFilterChange}
126-
availablePipelineNames={availablePipelineNames}
127+
availablePipelineNames={AVAILABLE_PIPELINE_NAMES}
127128
/>
128129
)}
129130
<div style={{ flex: 1 }}>

src/pages/scientificServices/pipelines/views/TableFilters.tsx

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ButtonPrimary, Select } from '@terra-ui-packages/components';
22
import React from 'react';
33
import { DelayedSearchInput } from 'src/components/input';
4-
import { PipelineRunStatus } from 'src/libs/ajax/teaspoons/teaspoons-models';
4+
import { Pipeline, PipelineRunStatus } from 'src/libs/ajax/teaspoons/teaspoons-models';
55

66
export interface FilterValues {
77
description?: string;
@@ -16,7 +16,12 @@ interface TableFiltersProps {
1616
availablePipelineNames: string[];
1717
}
1818

19-
const STATUS_OPTIONS: string[] = ['Succeeded', 'Running', 'Failed', 'Preparing'];
19+
const STATUS_OPTIONS: { value: PipelineRunStatus; label: string }[] = [
20+
{ value: 'PREPARING', label: 'Preparing' },
21+
{ value: 'RUNNING', label: 'In Progress' },
22+
{ value: 'SUCCEEDED', label: 'Done' },
23+
{ value: 'FAILED', label: 'Failed' },
24+
];
2025

2126
export const TableFilters: React.FC<TableFiltersProps> = ({ filters, onFilterChange, availablePipelineNames }) => {
2227
const handleInputChange = (field: keyof FilterValues, value: string) => {
@@ -32,6 +37,8 @@ export const TableFilters: React.FC<TableFiltersProps> = ({ filters, onFilterCha
3237

3338
const hasActiveFilters = Object.values(filters).some((value) => value !== undefined && value !== '');
3439

40+
const PIPELINE_OPTIONS = availablePipelineNames.map((name) => ({ value: name, label: name }));
41+
3542
return (
3643
<div
3744
style={{
@@ -90,15 +97,16 @@ export const TableFilters: React.FC<TableFiltersProps> = ({ filters, onFilterCha
9097
<div style={{ fontWeight: 600, fontSize: '14px' }}>Status</div>
9198
<Select
9299
id='filter-status'
93-
options={STATUS_OPTIONS.map((status) => ({ value: status, label: status }))}
94-
value={filters.status ? { value: filters.status, label: filters.status } : 'bla'}
100+
options={STATUS_OPTIONS}
101+
value={filters.status}
95102
placeholder='All Statuses'
96-
onChange={(selected) => {
97-
if (selected === null) {
103+
onChange={(selectedStatus) => {
104+
if (selectedStatus === null) {
105+
// Clear the status filter
106+
handleInputChange('status', '');
98107
return;
99108
}
100-
// @ts-ignore
101-
handleInputChange('status', selected.value);
109+
handleInputChange('status', selectedStatus.value);
102110
}}
103111
isClearable
104112
styles={{ container: (base) => ({ ...base, minWidth: '150px' }) }}
@@ -110,15 +118,16 @@ export const TableFilters: React.FC<TableFiltersProps> = ({ filters, onFilterCha
110118
<div style={{ fontWeight: 600, fontSize: '14px' }}>Pipeline</div>
111119
<Select
112120
id='filter-pipelineName'
113-
options={availablePipelineNames.map((name) => ({ value: name, label: name }))}
114-
value={filters.pipelineName ? { value: filters.pipelineName, label: filters.pipelineName } : null}
121+
options={PIPELINE_OPTIONS}
122+
value={filters.pipelineName}
115123
placeholder='All Pipelines'
116-
onChange={(selected) => {
117-
if (selected === null) {
124+
onChange={(selectedPipeline) => {
125+
if (selectedPipeline === null) {
126+
// Clear the pipeline name filter
127+
handleInputChange('pipelineName', '');
118128
return;
119129
}
120-
// @ts-ignore
121-
handleInputChange('pipelineName', selected.value);
130+
handleInputChange('pipelineName', selectedPipeline.value);
122131
}}
123132
isClearable
124133
styles={{ container: (base) => ({ ...base, minWidth: '150px' }) }}
@@ -129,14 +138,15 @@ export const TableFilters: React.FC<TableFiltersProps> = ({ filters, onFilterCha
129138
style={{
130139
display: 'flex',
131140
flex: '0 0 auto',
141+
justifyContent: 'center',
132142
}}
133143
>
134144
<ButtonPrimary
135145
disabled={!hasActiveFilters}
136146
onClick={handleClearFilters}
137-
style={{
138-
height: '2.33rem',
139-
}}
147+
// style={{
148+
// height: '2.33rem',
149+
// }}
140150
>
141151
Clear
142152
</ButtonPrimary>

0 commit comments

Comments
 (0)