From 24b5cb2104afd39ad5df2ef7b0dd181aab0381e1 Mon Sep 17 00:00:00 2001 From: John Duprey Date: Wed, 16 Aug 2023 12:16:36 -0400 Subject: [PATCH 1/2] BPA - Single Tenant/Table Refresh --- .../tenant/standards/BestPracticeAnalyser.js | 66 +++++++++++++++---- 1 file changed, 54 insertions(+), 12 deletions(-) diff --git a/src/views/tenant/standards/BestPracticeAnalyser.js b/src/views/tenant/standards/BestPracticeAnalyser.js index f12b3b9d1e90..68356121e425 100644 --- a/src/views/tenant/standards/BestPracticeAnalyser.js +++ b/src/views/tenant/standards/BestPracticeAnalyser.js @@ -14,6 +14,7 @@ import { CSpinner, } from '@coreui/react' import useQuery from 'src/hooks/useQuery' +import PropTypes from 'prop-types' import { Field, Form, FormSpy } from 'react-final-form' import { RFFCFormInput, RFFCFormSelect } from 'src/components/forms' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' @@ -25,6 +26,7 @@ import { faCheck, faCross, faTimes, + faSync, faExclamation, } from '@fortawesome/free-solid-svg-icons' import { CippTable, cellBooleanFormatter } from 'src/components/tables' @@ -38,10 +40,15 @@ import { CellTip, cellGenericFormatter } from 'src/components/tables/CellGeneric import { useExecBestPracticeAnalyserMutation } from 'src/store/api/reports' import { ModalService } from 'src/components/utilities' import { cellTableFormatter } from 'src/components/tables/CellTable' -const RefreshAction = () => { - const [execBestPracticeAnalyser, { isLoading, isSuccess, error }] = - useExecBestPracticeAnalyserMutation() +const RefreshAction = ({ singleTenant = false, refreshFunction = null }) => { + const tenantDomain = useSelector((state) => state.app.currentTenant.defaultDomainName) + const [execBestPracticeAnalyser, { isLoading, isSuccess, error }] = + useLazyGenericGetRequestQuery() + var params = {} + if (singleTenant) { + params['TenantFilter'] = tenantDomain + } const showModal = () => ModalService.confirm({ body: ( @@ -51,18 +58,39 @@ const RefreshAction = () => { Please note: this runs at 3:00 AM UTC automatically every day. ), - onConfirm: () => execBestPracticeAnalyser(), + onConfirm: () => + execBestPracticeAnalyser({ + path: 'api/BestPracticeAnalyser_OrchestrationStarter', + params: params, + }), }) return ( - - {isLoading && } - {error && } - {isSuccess && } - Force Refresh All Data - + <> + + {isLoading && } + {error && } + {isSuccess && } + {(singleTenant && 'Refresh Tenant Data') || 'Force Refresh All Data'} + + {refreshFunction !== null && ( + { + refreshFunction((Math.random() + 1).toString(36).substring(7)) + }} + className="m-1" + size="sm" + > + + + )} + ) } +RefreshAction.propTypes = { + singleTenant: PropTypes.bool, + refreshFunction: PropTypes.func, +} const getsubcolumns = (data) => { const flatObj = data && data.length > 0 ? data : [{ data: 'No Data Found' }] @@ -96,6 +124,7 @@ const getNestedValue = (obj, path) => { } const BestPracticeAnalyser = () => { const [reportTemplate, setReportTemplate] = useState('CIPP Best Practices v1.0 - Table view') + const [refreshValue, setRefreshValue] = useState('') const { data: templates = [], isLoading: templatesfetch } = useGenericGetRequestQuery({ path: 'api/listBPATemplates', }) @@ -184,9 +213,10 @@ const BestPracticeAnalyser = () => { tenantFilter: tenant.customerId, Report: reportTemplate, SearchNow: SearchNow, + refresh: refreshValue, }, }) - }, [Report, execGraphRequest, tenant.defaultDomainName, query]) + }, [Report, execGraphRequest, tenant.defaultDomainName, query, refreshValue, reportTemplate]) return ( <> @@ -264,7 +294,12 @@ const BestPracticeAnalyser = () => { data={graphrequest.data.Data} isFetching={graphrequest.isFetching} tableProps={{ - actions: [], + actions: [ + , + ], }} /> @@ -273,6 +308,13 @@ const BestPracticeAnalyser = () => { {graphrequest.isSuccess && QueryColumns.set && graphrequest.data.Style == 'Tenant' && ( <> +
+ +
{graphrequest.data.Columns.map((info, idx) => ( From d055e2066fc9ac8e287509c811b3475582f811ea Mon Sep 17 00:00:00 2001 From: KelvinTegelaar <49186168+KelvinTegelaar@users.noreply.github.com> Date: Thu, 17 Aug 2023 01:13:41 +0200 Subject: [PATCH 2/2] version upped for hotfix --- public/version_latest.txt | 2 +- version_latest.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/version_latest.txt b/public/version_latest.txt index 0c89fc927e32..cc868b62c301 100644 --- a/public/version_latest.txt +++ b/public/version_latest.txt @@ -1 +1 @@ -4.0.0 \ No newline at end of file +4.0.1 \ No newline at end of file diff --git a/version_latest.txt b/version_latest.txt index 0c89fc927e32..cc868b62c301 100644 --- a/version_latest.txt +++ b/version_latest.txt @@ -1 +1 @@ -4.0.0 \ No newline at end of file +4.0.1 \ No newline at end of file