Skip to content

Commit 49218f0

Browse files
authored
Merge pull request #2518 from JohnDuprey/dev
Custom Roles & Scheduler tweaks
2 parents 4f9fdf1 + 8238f95 commit 49218f0

File tree

4 files changed

+92
-25
lines changed

4 files changed

+92
-25
lines changed

src/components/forms/RFFComponents.jsx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,54 @@ RFFCFormInputArray.propTypes = {
253253
...sharedPropTypes,
254254
}
255255

256+
export const RFFCFormInputList = ({ name, label, className = 'mb-3' }) => {
257+
return (
258+
<>
259+
<FieldArray name={name}>
260+
{({ fields }) => (
261+
<div>
262+
<div className="mb-2">
263+
{label && (
264+
<CFormLabel className="me-2" htmlFor={name}>
265+
{label}
266+
</CFormLabel>
267+
)}
268+
<CButton
269+
onClick={() => fields.push({ Key: '', Value: '' })}
270+
className="circular-button"
271+
title={'+'}
272+
>
273+
<FontAwesomeIcon icon={'plus'} />
274+
</CButton>
275+
</div>
276+
{fields.map((name, index) => (
277+
<div key={name} className={className}>
278+
<div>
279+
<Field name={`${name}`} component="input">
280+
{({ input, meta }) => {
281+
return <CFormInput placeholder="Value" {...input} className="mb-2" />
282+
}}
283+
</Field>
284+
</div>
285+
<CButton
286+
onClick={() => fields.remove(index)}
287+
className={`circular-button`}
288+
title={'-'}
289+
>
290+
<FontAwesomeIcon icon={'minus'} />
291+
</CButton>
292+
</div>
293+
))}
294+
</div>
295+
)}
296+
</FieldArray>
297+
</>
298+
)
299+
}
300+
RFFCFormInputList.propTypes = {
301+
...sharedPropTypes,
302+
}
303+
256304
export const RFFCFormRadio = ({
257305
name,
258306
label,

src/components/forms/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
RFFCFormSelect,
1111
RFFSelectSearch,
1212
RFFCFormInputArray,
13+
RFFCFormInputList,
1314
} from 'src/components/forms/RFFComponents'
1415

1516
export {
@@ -24,4 +25,5 @@ export {
2425
RFFCFormSelect,
2526
RFFSelectSearch,
2627
RFFCFormInputArray,
28+
RFFCFormInputList,
2729
}

src/views/cipp/Scheduler.jsx

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Field, Form, FormSpy } from 'react-final-form'
55
import {
66
RFFCFormInput,
77
RFFCFormInputArray,
8+
RFFCFormInputList,
89
RFFCFormSwitch,
910
RFFSelectSearch,
1011
} from 'src/components/forms'
@@ -157,10 +158,14 @@ const Scheduler = () => {
157158
if (typeof row?.Parameters[key] === 'object') {
158159
var nestedParamList = []
159160
Object.keys(row?.Parameters[key]).forEach((nestedKey) => {
160-
nestedParamList.push({
161-
Key: nestedKey,
162-
Value: row?.Parameters[key][nestedKey],
163-
})
161+
if (nestedKey >= 0) {
162+
nestedParamList.push(row?.Parameters[key][nestedKey])
163+
} else {
164+
nestedParamList.push({
165+
Key: nestedKey,
166+
Value: row?.Parameters[key][nestedKey],
167+
})
168+
}
164169
})
165170
parameters[key] = nestedParamList
166171
} else {
@@ -179,6 +184,10 @@ const Scheduler = () => {
179184
})
180185
})
181186

187+
if (!recurrence) {
188+
recurrence = { name: 'Only once', value: '0' }
189+
}
190+
182191
// Set initial values
183192
var formValues = {
184193
taskName: row.Name,
@@ -413,12 +422,22 @@ const Scheduler = () => {
413422
key={idx}
414423
/>
415424
) : (
416-
<RFFCFormInput
417-
type="text"
418-
key={idx}
419-
name={`parameters.${param.Name}`}
420-
label={`${param.Name}`}
421-
/>
425+
<>
426+
{param.Type === 'System.String[]' ? (
427+
<RFFCFormInputList
428+
name={`parameters.${param.Name}[]`}
429+
label={`${param.Name}`}
430+
key={idx}
431+
/>
432+
) : (
433+
<RFFCFormInput
434+
type="text"
435+
key={idx}
436+
name={`parameters.${param.Name}`}
437+
label={`${param.Name}`}
438+
/>
439+
)}
440+
</>
422441
)}
423442
</>
424443
)}

src/views/cipp/app-settings/components/SettingsCustomRoles.jsx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,8 @@ const SettingsCustomRoles = () => {
150150
})
151151
}
152152
})
153-
if (blockedTenantSelectorRef?.current) {
154-
blockedTenantSelectorRef.current.setValue(blockedTenantList)
155-
}
153+
154+
blockedTenantSelectorRef.current.setValue(blockedTenantList)
156155
} else {
157156
onChange(customRole[0][set])
158157
}
@@ -323,18 +322,17 @@ const SettingsCustomRoles = () => {
323322
</CCallout>
324323
)}
325324
</div>
326-
{selectedTenant.find((tenant) => tenant.value === 'AllTenants') && (
327-
<div className="mb-3">
328-
<h5>Blocked Tenants</h5>
329-
<TenantSelectorMultiple
330-
ref={blockedTenantSelectorRef}
331-
values={blockedTenants}
332-
AllTenants={false}
333-
valueIsDomain={true}
334-
onChange={(e) => handleBlockedTenantChange(e)}
335-
/>
336-
</div>
337-
)}
325+
<div className="mb-3">
326+
<h5>Blocked Tenants</h5>
327+
<TenantSelectorMultiple
328+
ref={blockedTenantSelectorRef}
329+
values={blockedTenants}
330+
AllTenants={false}
331+
valueIsDomain={true}
332+
onChange={(e) => handleBlockedTenantChange(e)}
333+
/>
334+
</div>
335+
338336
<h5>API Permissions</h5>
339337
<CRow className="mt-4 px-2">
340338
<CCol md={4}>

0 commit comments

Comments
 (0)