All files / Settings/EditableSettingsList/SettingField/EditSettingValue EditSettingValue.js

100% Statements 6/6
100% Branches 1/1
100% Functions 2/2
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54              25x               16x   16x         16x                       25x                                      
import { useMemo } from 'react';
 
import PropTypes from 'prop-types';
 
import { useKintIntl } from '../../../../hooks';
import { StaticSettingsFieldComponent } from '../../../StaticSettingsField';
 
const EditSettingValue = ({
  currentSetting: setting,
  intlKey: passedIntlKey,
  intlNS: passedIntlNS,
  labelOverrides = {},
  name,
  ...props
}) => {
  const kintIntl = useKintIntl(passedIntlKey, passedIntlNS);
 
  const fieldLabel = useMemo(() => kintIntl.formatKintMessage({
    id: 'settings.valueFor',
    overrideValue: labelOverrides?.valueFor
  }, { name: setting.key }), [kintIntl, labelOverrides?.valueFor, setting.key]);
 
  return (
    <StaticSettingsFieldComponent
      key={`static-render-function-${name}`}
      aria-label={fieldLabel}
      autofocus
      name={name}
      setting={setting}
      {...props}
    />
  );
};
 
EditSettingValue.propTypes = {
  currentSetting: PropTypes.shape({
    settingType: PropTypes.string,
    key: PropTypes.string,
  }),
  input: PropTypes.shape({
    name: PropTypes.string
  }),
  intlKey: PropTypes.string,
  intlNS: PropTypes.string,
  labelOverrides: PropTypes.object,
  refdata: PropTypes.arrayOf(PropTypes.object),
  templates: PropTypes.arrayOf(PropTypes.shape({
    name: PropTypes.string,
    id: PropTypes.string
  }))
};
 
export default EditSettingValue;