Skip to content

Commit

Permalink
Merge pull request #338 from bcgov/fixing-application-page-error
Browse files Browse the repository at this point in the history
Merging with latest formsflow web changes
  • Loading branch information
RyanBirtch-aot authored Mar 13, 2023
2 parents c10c325 + fbbbf59 commit a6c71a7
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 31 deletions.
2 changes: 1 addition & 1 deletion forms-flow-ai/forms-flow-web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKDIR /forms-flow-web/app
# expect a build-time variable
ARG FORMFLOW_SOURCE_REPO_BRANCH
# use the value to set the ENV var default
ENV FORMFLOW_SOURCE_REPO_BRANCH master
ENV FORMFLOW_SOURCE_REPO_BRANCH patch/v5.1.1
# expect a build-time variable
ARG FORMFLOW_SOURCE_REPO_URL
# use the value to set the ENV var default
Expand Down
80 changes: 50 additions & 30 deletions forms-flow-ai/forms-flow-web/src/components/Application/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import overlayFactory from "react-bootstrap-table2-overlay";
import { SpinnerSVG } from "../../containers/SpinnerSVG";
import Head from "../../containers/Head";
import { push } from "connected-react-router";
import isValiResourceId from "../../helper/regExp/validResourceId";
import { Button } from "react-bootstrap";
export const ApplicationList = React.memo(() => {
const { t } = useTranslation();
Expand Down Expand Up @@ -61,6 +62,8 @@ export const ApplicationList = React.memo(() => {
const redirectUrl = MULTITENANCY_ENABLED ? `/tenant/${tenantKey}/` : "/";
const [lastModified, setLastModified] = React.useState(null);
const [isLoading, setIsLoading] = React.useState(false);
const [invalidFilters, setInvalidFilters] = React.useState({});

useEffect(() => {
setIsLoading(false);
}, [applications]);
Expand Down Expand Up @@ -116,6 +119,16 @@ export const ApplicationList = React.memo(() => {
</div>
);
};
const validateFilters = (newState) => {
if (
newState.filters?.id?.filterVal &&
!isValiResourceId(newState.filters?.id?.filterVal)
) {
return setInvalidFilters({ ...invalidFilters, APPLICATION_ID: true });
} else {
return setInvalidFilters({ ...invalidFilters, APPLICATION_ID: false });
}
};

const getReactDashboardURL = () =>{
if(window.location.href.includes("localhost")){
Expand All @@ -128,6 +141,7 @@ export const ApplicationList = React.memo(() => {
};

const handlePageChange = (type, newState) => {
validateFilters(newState);
if (type === "filter") {
setfiltermode(true);
} else if (type === "pagination") {
Expand Down Expand Up @@ -172,6 +186,7 @@ export const ApplicationList = React.memo(() => {
if (!DRAFT_ENABLED) {
headOptions.pop();
}

return (
<ToolkitProvider
bootstrap4
Expand All @@ -182,7 +197,8 @@ export const ApplicationList = React.memo(() => {
lastModified,
setLastModified,
t,
redirectUrl
redirectUrl,
invalidFilters
)}
search
>
Expand All @@ -193,34 +209,38 @@ export const ApplicationList = React.memo(() => {
<Button className="" onClick={() =>{ window.location = getReactDashboardURL();}}>
Return To Dashboard</Button>
<div>
{applicationCount > 0 || filtermode ? <BootstrapTable
remote={{ pagination: true, filter: true, sort: true }}
loading={isLoading}
filter={filterFactory()}
pagination={paginationFactory(
getoptions(applicationCount, page, countPerPage)
)}
onTableChange={handlePageChange}
filterPosition={"top"}
{...props.baseProps}
noDataIndication={() =>
!isLoading && getNoDataIndicationContent()
}
defaultSorted={defaultSortedBy}
overlay={overlayFactory({
spinner: <SpinnerSVG />,
styles: {
overlay: (base) => ({
...base,
background: "rgba(255, 255, 255)",
height: `${
countPerPage > 5 ? "100% !important" : "350px !important"
}`,
top: "65px",
}),
},
})}
/> : iserror ? (
{applicationCount > 0 || filtermode ? (
<BootstrapTable
remote={{ pagination: true, filter: true, sort: true }}
loading={isLoading}
filter={filterFactory()}
pagination={paginationFactory(
getoptions(applicationCount, page, countPerPage)
)}
onTableChange={handlePageChange}
filterPosition={"top"}
{...props.baseProps}
noDataIndication={() =>
!isLoading && getNoDataIndicationContent()
}
defaultSorted={defaultSortedBy}
overlay={overlayFactory({
spinner: <SpinnerSVG />,
styles: {
overlay: (base) => ({
...base,
background: "rgba(255, 255, 255)",
height: `${
countPerPage > 5
? "100% !important"
: "350px !important"
}`,
top: "65px",
}),
},
})}
/>
) : iserror ? (
<Alert variant={"danger"}>{error}</Alert>
) : (
<Nodata text={t("No Applications Found")} />
Expand All @@ -232,4 +252,4 @@ export const ApplicationList = React.memo(() => {
);
});

export default ApplicationList;
export default ApplicationList;

0 comments on commit a6c71a7

Please sign in to comment.