kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
implement review fixes
rodzic
3eba2b9a89
commit
219db25d1c
|
@ -96,7 +96,18 @@ export const PolicyFields: FC<{
|
|||
<div className='mt-2'>{schema.description}</div>
|
||||
{
|
||||
schema.type === 'boolean' ?
|
||||
<input type='checkbox' checked={!!value} /> :
|
||||
<input
|
||||
type='checkbox'
|
||||
checked={!!value}
|
||||
onChange={(e) => {
|
||||
dispatch({
|
||||
type: 'UPDATE_FIELD',
|
||||
policyName,
|
||||
fieldName: name,
|
||||
value: e.target.checked,
|
||||
});
|
||||
}}
|
||||
/> :
|
||||
<Input
|
||||
type={getInputType(schema.type)}
|
||||
value={value as string | number}
|
||||
|
|
|
@ -61,11 +61,17 @@ export const createPolicyReducer = (allPolicies: PolicyItem[]) => (state: Policy
|
|||
case 'ADD_MULTI_VALUE': {
|
||||
const fieldKey = `${action.policyName}.${action.fieldName}`;
|
||||
const current = (state.fields[fieldKey] as (string | number)[]) || [];
|
||||
const policyDef = allPolicies.find(p => p.internalName === action.policyName);
|
||||
const paramSchema = policyDef?.parameters[action.fieldName];
|
||||
const value = paramSchema?.type === 'multi_number' && typeof action.value === 'string'
|
||||
? Number(action.value)
|
||||
: action.value;
|
||||
|
||||
return {
|
||||
...state,
|
||||
fields: {
|
||||
...state.fields,
|
||||
[fieldKey]: [...current, action.value],
|
||||
[fieldKey]: [...current, value],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import { PolicyItem, PolicyParam, PolicyParams, PolicySpec, PolicySpecItem } fro
|
|||
const messages = defineMessages({
|
||||
heading: { id: 'admin.policies.heading', defaultMessage: 'Manage Policies' },
|
||||
searchPlaceholder: { id: 'admin.policies.search_placeholder', defaultMessage: 'What do you want to do?' },
|
||||
policyModeError: { id: 'admin.policies.policy_mode_error', defaultMessage: 'The Ditto custom policy is enabled. Unset the <code>DITTO_CUSTOM_POLICY</code> environment variable to use the Policy UI.' },
|
||||
policyModeError: { id: 'admin.policies.policy_mode_error', defaultMessage: 'The Ditto custom policy is enabled. Unset the DITTO_CUSTOM_POLICY environment variable to use the Policy UI.' },
|
||||
noPolicyConfigured: { id: 'admin.policies.no_policies_configured', defaultMessage: 'No policies configured! Use the search bar above to get started.' },
|
||||
addValue: { id: 'admin.policies.add_value', defaultMessage: 'Add' },
|
||||
removeValue: { id: 'admin.policies.remove_value', defaultMessage: 'Remove value' },
|
||||
|
|
Ładowanie…
Reference in New Issue