Skip to content

Commit 3161517

Browse files
Merge pull request KelvinTegelaar#1697 from KelvinTegelaar/dev
Dev to release
2 parents 05610a9 + d055e20 commit 3161517

File tree

3 files changed

+56
-14
lines changed

3 files changed

+56
-14
lines changed

public/version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0.0
1+
4.0.1

src/views/tenant/standards/BestPracticeAnalyser.js

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
CSpinner,
1515
} from '@coreui/react'
1616
import useQuery from 'src/hooks/useQuery'
17+
import PropTypes from 'prop-types'
1718
import { Field, Form, FormSpy } from 'react-final-form'
1819
import { RFFCFormInput, RFFCFormSelect } from 'src/components/forms'
1920
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
@@ -25,6 +26,7 @@ import {
2526
faCheck,
2627
faCross,
2728
faTimes,
29+
faSync,
2830
faExclamation,
2931
} from '@fortawesome/free-solid-svg-icons'
3032
import { CippTable, cellBooleanFormatter } from 'src/components/tables'
@@ -38,10 +40,15 @@ import { CellTip, cellGenericFormatter } from 'src/components/tables/CellGeneric
3840
import { useExecBestPracticeAnalyserMutation } from 'src/store/api/reports'
3941
import { ModalService } from 'src/components/utilities'
4042
import { cellTableFormatter } from 'src/components/tables/CellTable'
41-
const RefreshAction = () => {
42-
const [execBestPracticeAnalyser, { isLoading, isSuccess, error }] =
43-
useExecBestPracticeAnalyserMutation()
4443

44+
const RefreshAction = ({ singleTenant = false, refreshFunction = null }) => {
45+
const tenantDomain = useSelector((state) => state.app.currentTenant.defaultDomainName)
46+
const [execBestPracticeAnalyser, { isLoading, isSuccess, error }] =
47+
useLazyGenericGetRequestQuery()
48+
var params = {}
49+
if (singleTenant) {
50+
params['TenantFilter'] = tenantDomain
51+
}
4552
const showModal = () =>
4653
ModalService.confirm({
4754
body: (
@@ -51,18 +58,39 @@ const RefreshAction = () => {
5158
<i>Please note: this runs at 3:00 AM UTC automatically every day.</i>
5259
</div>
5360
),
54-
onConfirm: () => execBestPracticeAnalyser(),
61+
onConfirm: () =>
62+
execBestPracticeAnalyser({
63+
path: 'api/BestPracticeAnalyser_OrchestrationStarter',
64+
params: params,
65+
}),
5566
})
5667

5768
return (
58-
<CButton onClick={showModal} size="sm" className="m-1">
59-
{isLoading && <CSpinner size="sm" />}
60-
{error && <FontAwesomeIcon icon={faExclamationTriangle} className="pe-1" />}
61-
{isSuccess && <FontAwesomeIcon icon={faCheck} className="pe-1" />}
62-
Force Refresh All Data
63-
</CButton>
69+
<>
70+
<CButton onClick={showModal} size="sm" className="m-1">
71+
{isLoading && <CSpinner size="sm" />}
72+
{error && <FontAwesomeIcon icon={faExclamationTriangle} className="pe-1" />}
73+
{isSuccess && <FontAwesomeIcon icon={faCheck} className="pe-1" />}
74+
{(singleTenant && 'Refresh Tenant Data') || 'Force Refresh All Data'}
75+
</CButton>
76+
{refreshFunction !== null && (
77+
<CButton
78+
onClick={() => {
79+
refreshFunction((Math.random() + 1).toString(36).substring(7))
80+
}}
81+
className="m-1"
82+
size="sm"
83+
>
84+
<FontAwesomeIcon icon={faSync} />
85+
</CButton>
86+
)}
87+
</>
6488
)
6589
}
90+
RefreshAction.propTypes = {
91+
singleTenant: PropTypes.bool,
92+
refreshFunction: PropTypes.func,
93+
}
6694

6795
const getsubcolumns = (data) => {
6896
const flatObj = data && data.length > 0 ? data : [{ data: 'No Data Found' }]
@@ -96,6 +124,7 @@ const getNestedValue = (obj, path) => {
96124
}
97125
const BestPracticeAnalyser = () => {
98126
const [reportTemplate, setReportTemplate] = useState('CIPP Best Practices v1.0 - Table view')
127+
const [refreshValue, setRefreshValue] = useState('')
99128
const { data: templates = [], isLoading: templatesfetch } = useGenericGetRequestQuery({
100129
path: 'api/listBPATemplates',
101130
})
@@ -184,9 +213,10 @@ const BestPracticeAnalyser = () => {
184213
tenantFilter: tenant.customerId,
185214
Report: reportTemplate,
186215
SearchNow: SearchNow,
216+
refresh: refreshValue,
187217
},
188218
})
189-
}, [Report, execGraphRequest, tenant.defaultDomainName, query])
219+
}, [Report, execGraphRequest, tenant.defaultDomainName, query, refreshValue, reportTemplate])
190220

191221
return (
192222
<>
@@ -264,7 +294,12 @@ const BestPracticeAnalyser = () => {
264294
data={graphrequest.data.Data}
265295
isFetching={graphrequest.isFetching}
266296
tableProps={{
267-
actions: [<RefreshAction key="refresh-action-button" />],
297+
actions: [
298+
<RefreshAction
299+
key="refresh-action-button"
300+
refreshFunction={setRefreshValue}
301+
/>,
302+
],
268303
}}
269304
/>
270305
</CCardBody>
@@ -273,6 +308,13 @@ const BestPracticeAnalyser = () => {
273308
{graphrequest.isSuccess && QueryColumns.set && graphrequest.data.Style == 'Tenant' && (
274309
<>
275310
<CRow>
311+
<div width="30px" className="mb-3">
312+
<RefreshAction
313+
key="refresh-action-button"
314+
singleTenant={true}
315+
refreshFunction={setRefreshValue}
316+
/>
317+
</div>
276318
{graphrequest.data.Columns.map((info, idx) => (
277319
<CCol md={12} xl={4} className="mb-3">
278320
<CCard className="h-100">

version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0.0
1+
4.0.1

0 commit comments

Comments
 (0)