Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualization Page Pagination #3591

Merged
merged 3 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dashboard/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ const App = () => {
path={APP_ROUTES.OVERVIEW}
element={<OverviewComponent />}
/>
<Route
path={APP_ROUTES.VISUALIZATION}
element={<ComparisonComponent />}
/>
</Route>
<Route
path={APP_ROUTES.VISUALIZATION}
element={<ComparisonComponent />}
/>
<Route
path={APP_ROUTES.TABLE_OF_CONTENT}
element={<TableOfContent />}
Expand Down
21 changes: 10 additions & 11 deletions dashboard/src/actions/comparisonActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { DANGER, ERROR_MSG, WARNING } from "assets/constants/toastConstants";
import API from "../utils/axiosInstance";
import { START_PAGE_NUMBER } from "assets/constants/browsingPageConstants";
import { fetchDatasets } from "actions/datasetListActions";
import { getDatasets } from "actions/overviewActions";
import { showToast } from "./toastActions";
import { uriTemplate } from "../utils/helper";

Expand Down Expand Up @@ -279,18 +278,18 @@ export const setSearchValue = (value) => ({
payload: value,
});

export const onDatasetTypeChange = (value, currPage, dispatch) => {
export const onDatasetTypeChange = (value, dispatch) => {
dispatch({
type: TYPES.SET_DATASET_TYPE,
payload: value,
});
if (currPage === CONSTANTS.VISUALIZATION) {
dispatch(getDatasets());
} else {
dispatch({
type: TYPES.SET_RESULT_OFFSET,
payload: 0,
});
dispatch(fetchDatasets(START_PAGE_NUMBER));
}
resetList(dispatch);
};

export const resetList = (dispatch) => {
dispatch({
type: TYPES.SET_RESULT_OFFSET,
payload: 0,
});
dispatch(fetchDatasets(START_PAGE_NUMBER));
};
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import "./index.less";

import * as CONSTANTS from "assets/constants/browsingPageConstants";

import { Checkbox, List, ListItem } from "@patternfly/react-core";
import React, { useCallback, useMemo } from "react";
import React, { useCallback, useMemo, useState } from "react";
import { getQuisbyData, setSelectedId } from "actions/comparisonActions";
import { useDispatch, useSelector } from "react-redux";

import TablePagination from "../PaginationComponent";

const PanelConent = () => {
const dispatch = useDispatch();
const { datasets } = useSelector((state) => state.overview);

const { publicData } = useSelector((state) => state.datasetlist);
const {
activeResourceId,
isCompareSwitchChecked,
Expand All @@ -24,10 +29,10 @@ const PanelConent = () => {
[searchValue]
);
const filteredDatasets = useMemo(
() => datasets.filter(onFilter),
[datasets, onFilter]
() => publicData.filter(onFilter),
[publicData, onFilter]
);

const [page, setPage] = useState(CONSTANTS.START_PAGE_NUMBER);
return (
<>
{filteredDatasets.length > 0 && (
Expand Down Expand Up @@ -67,6 +72,7 @@ const PanelConent = () => {
)}
</div>
)}
<TablePagination page={page} setPage={setPage} />
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const MainContent = () => {
? "Benchmarks are of non-compatabile types!"
: "Benchmark type is currently unsupported!";
const data = isCompareSwitchChecked ? compareChartData : chartData;

return (
<>
{isCompareSwitchChecked ? (
Expand Down Expand Up @@ -81,7 +82,7 @@ export const ViewOptions = (props) => {
const [isOpen, setIsOpen] = React.useState(false);
const selected = useSelector((state) => state.comparison.datasetType);
const onSelect = (_event, value) => {
onDatasetTypeChange(value, props.currPage, dispatch);
onDatasetTypeChange(value, dispatch);
setIsOpen(false);
};
const onToggle = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ import React, { useEffect } from "react";
import {
compareMultipleDatasets,
getQuisbyData,
resetList,
toggleCompareSwitch,
} from "actions/comparisonActions";
import { useDispatch, useSelector } from "react-redux";

import Cookies from "js-cookie";
import PanelConent from "./PanelContent";
import { VISUALIZATION } from "assets/constants/compareConstants";
import { getDatasets } from "actions/overviewActions";

const ComparisonComponent = () => {
const dispatch = useDispatch();
Expand All @@ -36,7 +35,7 @@ const ComparisonComponent = () => {
if (datasets && datasets.length > 0) {
dispatch(getQuisbyData(datasets[0]));
} else {
dispatch(getDatasets());
resetList(dispatch);
}
}, [datasets, dispatch]);
return (
Expand Down Expand Up @@ -68,7 +67,7 @@ const ComparisonComponent = () => {
Compare Datasets
</Button>
)}
{loggedIn && <ViewOptions currPage={VISUALIZATION} />}
{loggedIn && <ViewOptions />}

<SearchByName />
<PanelConent />
Expand Down
3 changes: 1 addition & 2 deletions dashboard/src/modules/components/TableComponent/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { useDispatch, useSelector } from "react-redux";

import Cookies from "js-cookie";
import DatePickerWidget from "../DatePickerComponent";
import { RESULTS } from "assets/constants/compareConstants";
import { RenderPagination } from "../OverviewComponent/common-component";
import TablePagination from "../PaginationComponent";
import { ViewOptions } from "../ComparisonComponent/common-components";
Expand Down Expand Up @@ -165,7 +164,7 @@ const TableWithFavorite = () => {
{loggedIn && (
<>
<span className="runs-text">Datasets</span>
<ViewOptions currPage={RESULTS} />
<ViewOptions />
</>
)}
</div>
Expand Down