Skip to content

Commit

Permalink
filter value recalc
Browse files Browse the repository at this point in the history
  • Loading branch information
MVarshini committed Jul 16, 2024
1 parent 2b6972b commit 54473f6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
6 changes: 4 additions & 2 deletions frontend/src/actions/homeActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const fetchOCPJobsData = () => async (dispatch, getState) => {
dispatch(getCPTSummary());
dispatch(setPageOptions(START_PAGE, DEFAULT_PER_PAGE));
dispatch(sliceTableRows(0, DEFAULT_PER_PAGE));
dispatch(buildFilterData());
// dispatch(buildFilterData());
}
} catch (error) {
dispatch(showFailureToast());
Expand Down Expand Up @@ -75,7 +75,7 @@ export const sliceTableRows = (startIdx, endIdx) => (dispatch, getState) => {
};

export const buildFilterData = () => (dispatch, getState) => {
const results = [...getState().cpt.results];
const results = [...getState().cpt.filteredResults];

const tableFilters = [...getState().cpt.tableFilters];

Expand All @@ -89,6 +89,7 @@ export const buildFilterData = () => (dispatch, getState) => {
};
filterData.push(obj);
}

dispatch({
type: TYPES.SET_CPT_FILTER_DATA,
payload: filterData,
Expand Down Expand Up @@ -216,6 +217,7 @@ export const applyFilters = () => (dispatch, getState) => {
dispatch(getCPTSummary());
dispatch(setPageOptions(START_PAGE, DEFAULT_PER_PAGE));
dispatch(sliceTableRows(0, DEFAULT_PER_PAGE));
dispatch(buildFilterData());
};

export const setFilterFromURL = (searchParams) => ({
Expand Down
37 changes: 21 additions & 16 deletions frontend/src/components/molecules/MultiSelectBox/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,30 @@ const MultiSelectBox = (props) => {
innerRef={toggleRef}
isExpanded={isOpen}
style={{
width: "300px",
width: props.width,
height: "36px",
}}
>
{Array.isArray(props.selected.value) &&
props.selected.value.length > 0 ? (
<ChipGroup numChips={2}>
{props.selected.value.map((selection, index) => (
<Chip
key={index}
readOnly
// onClick={(ev) => {
// ev.stopPropagation();
// onSelect(selection);
// }}
>
{selection}
</Chip>
))}
</ChipGroup>
<TextInputGroup>
<TextInputGroupMain>
<ChipGroup numChips={2}>
{props.selected.value.map((selection, index) => (
<Chip
key={index}
isReadOnly={true}
// onClick={(ev) => {
// ev.stopPropagation();
// onSelect(selection);
// }}
>
{selection}
</Chip>
))}
</ChipGroup>
</TextInputGroupMain>
</TextInputGroup>
) : (
<TextInputGroup>
<TextInputGroupMain value={"Select a value"} />
Expand Down Expand Up @@ -94,7 +98,7 @@ const MultiSelectBox = (props) => {
{...option}
ref={null}
>
{option.name}
{option.value}
</SelectOption>
))}
</SelectList>
Expand All @@ -109,5 +113,6 @@ MultiSelectBox.propTypes = {
selected: PropTypes.array,
applyMethod: PropTypes.func,
currCategory: PropTypes.string,
width: PropTypes.string,
};
export default MultiSelectBox;
23 changes: 23 additions & 0 deletions frontend/src/reducers/ocpReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ const initialState = {
{ name: "Infra", value: "infraNodesCount" },
{ name: "Total", value: "totalNodesCount" },
],
selectedFilters: [
{ name: "ciSystem", value: [] },
{ name: "platform", value: [] },
{ name: "benchmark", value: [] },
{ name: "releaseStream", value: [] },
{ name: "build", value: [] },
{ name: "workerNodesCount", value: [] },
{ name: "networkType", value: [] },
{ name: "shortVersion", value: [] },
{ name: "jobType", value: [] },
{ name: "isRehearse", value: [] },
{ name: "ipsec", value: [] },
{ name: "fips", value: [] },
{ name: "encrypted", value: [] },
{ name: "publish", value: [] },
{ name: "computeArch", value: [] },
{ name: "controlPlaneArch", value: [] },
{ name: "jobStatus", value: [] },
{ name: "startDate", value: [] },
{ name: "endDate", value: [] },
],
};

const OCPReducer = (state = initialState, action = {}) => {
Expand Down Expand Up @@ -122,6 +143,8 @@ const OCPReducer = (state = initialState, action = {}) => {
return { ...state, graphData: [...state.graphData, payload] };
case TYPES.SET_OCP_COLUMNS:
return { ...state, tableColumns: payload };
case TYPES.SET_SELECTED_FILTERS:
return { ...state, selectedFilters: payload };
default:
return state;
}
Expand Down

0 comments on commit 54473f6

Please sign in to comment.