Skip to content

Custom Roles & Scheduler tweaks #2518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions src/components/forms/RFFComponents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,54 @@ RFFCFormInputArray.propTypes = {
...sharedPropTypes,
}

export const RFFCFormInputList = ({ name, label, className = 'mb-3' }) => {
return (
<>
<FieldArray name={name}>
{({ fields }) => (
<div>
<div className="mb-2">
{label && (
<CFormLabel className="me-2" htmlFor={name}>
{label}
</CFormLabel>
)}
<CButton
onClick={() => fields.push({ Key: '', Value: '' })}
className="circular-button"
title={'+'}
>
<FontAwesomeIcon icon={'plus'} />
</CButton>
</div>
{fields.map((name, index) => (
<div key={name} className={className}>
<div>
<Field name={`${name}`} component="input">
{({ input, meta }) => {
return <CFormInput placeholder="Value" {...input} className="mb-2" />
}}
</Field>
</div>
<CButton
onClick={() => fields.remove(index)}
className={`circular-button`}
title={'-'}
>
<FontAwesomeIcon icon={'minus'} />
</CButton>
</div>
))}
</div>
)}
</FieldArray>
</>
)
}
RFFCFormInputList.propTypes = {
...sharedPropTypes,
}

export const RFFCFormRadio = ({
name,
label,
Expand Down
2 changes: 2 additions & 0 deletions src/components/forms/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
RFFCFormSelect,
RFFSelectSearch,
RFFCFormInputArray,
RFFCFormInputList,
} from 'src/components/forms/RFFComponents'

export {
Expand All @@ -24,4 +25,5 @@ export {
RFFCFormSelect,
RFFSelectSearch,
RFFCFormInputArray,
RFFCFormInputList,
}
39 changes: 29 additions & 10 deletions src/views/cipp/Scheduler.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Field, Form, FormSpy } from 'react-final-form'
import {
RFFCFormInput,
RFFCFormInputArray,
RFFCFormInputList,
RFFCFormSwitch,
RFFSelectSearch,
} from 'src/components/forms'
Expand Down Expand Up @@ -157,10 +158,14 @@ const Scheduler = () => {
if (typeof row?.Parameters[key] === 'object') {
var nestedParamList = []
Object.keys(row?.Parameters[key]).forEach((nestedKey) => {
nestedParamList.push({
Key: nestedKey,
Value: row?.Parameters[key][nestedKey],
})
if (nestedKey >= 0) {
nestedParamList.push(row?.Parameters[key][nestedKey])
} else {
nestedParamList.push({
Key: nestedKey,
Value: row?.Parameters[key][nestedKey],
})
}
})
parameters[key] = nestedParamList
} else {
Expand All @@ -179,6 +184,10 @@ const Scheduler = () => {
})
})

if (!recurrence) {
recurrence = { name: 'Only once', value: '0' }
}

// Set initial values
var formValues = {
taskName: row.Name,
Expand Down Expand Up @@ -413,12 +422,22 @@ const Scheduler = () => {
key={idx}
/>
) : (
<RFFCFormInput
type="text"
key={idx}
name={`parameters.${param.Name}`}
label={`${param.Name}`}
/>
<>
{param.Type === 'System.String[]' ? (
<RFFCFormInputList
name={`parameters.${param.Name}[]`}
label={`${param.Name}`}
key={idx}
/>
) : (
<RFFCFormInput
type="text"
key={idx}
name={`parameters.${param.Name}`}
label={`${param.Name}`}
/>
)}
</>
)}
</>
)}
Expand Down
28 changes: 13 additions & 15 deletions src/views/cipp/app-settings/components/SettingsCustomRoles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,8 @@ const SettingsCustomRoles = () => {
})
}
})
if (blockedTenantSelectorRef?.current) {
blockedTenantSelectorRef.current.setValue(blockedTenantList)
}

blockedTenantSelectorRef.current.setValue(blockedTenantList)
} else {
onChange(customRole[0][set])
}
Expand Down Expand Up @@ -323,18 +322,17 @@ const SettingsCustomRoles = () => {
</CCallout>
)}
</div>
{selectedTenant.find((tenant) => tenant.value === 'AllTenants') && (
<div className="mb-3">
<h5>Blocked Tenants</h5>
<TenantSelectorMultiple
ref={blockedTenantSelectorRef}
values={blockedTenants}
AllTenants={false}
valueIsDomain={true}
onChange={(e) => handleBlockedTenantChange(e)}
/>
</div>
)}
<div className="mb-3">
<h5>Blocked Tenants</h5>
<TenantSelectorMultiple
ref={blockedTenantSelectorRef}
values={blockedTenants}
AllTenants={false}
valueIsDomain={true}
onChange={(e) => handleBlockedTenantChange(e)}
/>
</div>

<h5>API Permissions</h5>
<CRow className="mt-4 px-2">
<CCol md={4}>
Expand Down