finished process instance list filter w/ burnettk

This commit is contained in:
jasquat 2022-11-02 14:54:02 -04:00
parent 2ee06fc53a
commit 5fc23bdb07
4 changed files with 55 additions and 19 deletions

View File

@ -11,6 +11,7 @@
"@babel/core": "^7.18.10", "@babel/core": "^7.18.10",
"@babel/plugin-transform-react-jsx": "^7.18.6", "@babel/plugin-transform-react-jsx": "^7.18.6",
"@babel/preset-react": "^7.18.6", "@babel/preset-react": "^7.18.6",
"@carbon/icons-react": "^11.10.0",
"@carbon/react": "^1.16.0", "@carbon/react": "^1.16.0",
"@carbon/styles": "^1.16.0", "@carbon/styles": "^1.16.0",
"@ginkgo-bioworks/react-json-schema-form-builder": "^2.9.0", "@ginkgo-bioworks/react-json-schema-form-builder": "^2.9.0",

View File

@ -6,6 +6,7 @@
"@babel/core": "^7.18.10", "@babel/core": "^7.18.10",
"@babel/plugin-transform-react-jsx": "^7.18.6", "@babel/plugin-transform-react-jsx": "^7.18.6",
"@babel/preset-react": "^7.18.6", "@babel/preset-react": "^7.18.6",
"@carbon/icons-react": "^11.10.0",
"@carbon/react": "^1.16.0", "@carbon/react": "^1.16.0",
"@carbon/styles": "^1.16.0", "@carbon/styles": "^1.16.0",
"@ginkgo-bioworks/react-json-schema-form-builder": "^2.9.0", "@ginkgo-bioworks/react-json-schema-form-builder": "^2.9.0",

View File

@ -5,14 +5,14 @@ import { Link, useSearchParams } from 'react-router-dom';
import PaginationForTable from '../components/PaginationForTable'; import PaginationForTable from '../components/PaginationForTable';
import { getPageInfoFromSearchParams } from '../helpers'; import { getPageInfoFromSearchParams } from '../helpers';
import HttpService from '../services/HttpService'; import HttpService from '../services/HttpService';
import { RecentProcessModel } from '../interfaces'; import { PaginationObject, RecentProcessModel } from '../interfaces';
const PER_PAGE_FOR_TASKS_ON_HOME_PAGE = 5; const PER_PAGE_FOR_TASKS_ON_HOME_PAGE = 5;
export default function HomePage() { export default function HomePage() {
const [searchParams] = useSearchParams(); const [searchParams] = useSearchParams();
const [tasks, setTasks] = useState([]); const [tasks, setTasks] = useState([]);
const [pagination, setPagination] = useState(null); const [pagination, setPagination] = useState<PaginationObject | null>(null);
useEffect(() => { useEffect(() => {
const { page, perPage } = getPageInfoFromSearchParams( const { page, perPage } = getPageInfoFromSearchParams(
@ -126,10 +126,10 @@ export default function HomePage() {
); );
}; };
const relevantProcessModelSection = const tasksWaitingForMeComponent = () => {
recentProcessModels.length > 0 && buildRecentProcessModelSection(); if (pagination && pagination.total < 1) {
return null;
if (pagination) { }
const { page, perPage } = getPageInfoFromSearchParams( const { page, perPage } = getPageInfoFromSearchParams(
searchParams, searchParams,
PER_PAGE_FOR_TASKS_ON_HOME_PAGE PER_PAGE_FOR_TASKS_ON_HOME_PAGE
@ -145,6 +145,17 @@ export default function HomePage() {
tableToDisplay={buildTable()} tableToDisplay={buildTable()}
path="/tasks" path="/tasks"
/> />
</>
);
};
const relevantProcessModelSection =
recentProcessModels.length > 0 && buildRecentProcessModelSection();
if (pagination) {
return (
<>
{tasksWaitingForMeComponent()}
{relevantProcessModelSection} {relevantProcessModelSection}
</> </>
); );

View File

@ -6,6 +6,8 @@ import {
useSearchParams, useSearchParams,
} from 'react-router-dom'; } from 'react-router-dom';
// @ts-ignore
import { Filter } from '@carbon/icons-react';
import { import {
Button, Button,
ButtonSet, ButtonSet,
@ -57,6 +59,7 @@ export default function ProcessInstanceList() {
const [startTo, setStartTo] = useState<string>(''); const [startTo, setStartTo] = useState<string>('');
const [endFrom, setEndFrom] = useState<string>(''); const [endFrom, setEndFrom] = useState<string>('');
const [endTo, setEndTo] = useState<string>(''); const [endTo, setEndTo] = useState<string>('');
const [showFilterOptions, setShowFilterOptions] = useState<boolean>(false);
const setErrorMessage = (useContext as any)(ErrorContext)[1]; const setErrorMessage = (useContext as any)(ErrorContext)[1];
@ -352,7 +355,9 @@ export default function ProcessInstanceList() {
}; };
const filterOptions = () => { const filterOptions = () => {
const { page, perPage } = getPageInfoFromSearchParams(searchParams); if (!showFilterOptions) {
return null;
}
return ( return (
<> <>
<Grid fullWidth className="with-bottom-margin"> <Grid fullWidth className="with-bottom-margin">
@ -394,18 +399,6 @@ export default function ProcessInstanceList() {
</ButtonSet> </ButtonSet>
</Column> </Column>
</Grid> </Grid>
<Grid fullWidth>
<Column lg={16}>
<PaginationForTable
page={page}
perPage={perPage}
pagination={pagination}
tableToDisplay={buildTable()}
queryParamString={getSearchParamsAsQueryString()}
path="/admin/process-instances"
/>
</Column>
</Grid>
</> </>
); );
}; };
@ -480,12 +473,42 @@ export default function ProcessInstanceList() {
); );
}; };
const toggleShowFilterOptions = () => {
setShowFilterOptions(!showFilterOptions);
};
if (pagination) { if (pagination) {
const { page, perPage } = getPageInfoFromSearchParams(searchParams); const { page, perPage } = getPageInfoFromSearchParams(searchParams);
return ( return (
<> <>
{processInstanceTitleElement()} {processInstanceTitleElement()}
<Grid fullWidth>
<Column lg={15} />
<Column lg={1}>
<Button
kind="ghost"
renderIcon={Filter}
iconDescription="Filter Options"
hasIconOnly
size="lg"
onClick={toggleShowFilterOptions}
/>
</Column>
</Grid>
{filterOptions()} {filterOptions()}
<br />
<Grid fullWidth>
<Column lg={16}>
<PaginationForTable
page={page}
perPage={perPage}
pagination={pagination}
tableToDisplay={buildTable()}
queryParamString={getSearchParamsAsQueryString()}
path="/admin/process-instances"
/>
</Column>
</Grid>
</> </>
); );
} }