@k-int/stripes-kint-components 4.4.0 → 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 4.4.1 2023-02-08
2
+ * CustomPropertiesSettings
3
+ * Added displayConditions which act in the same way as below, allowing for programatic turning on/off of access to certain actions
4
+ * Settings (Multiple components)
5
+ * Added allowEdit property, which defaults to `true`, and if false, does not render edit button for any appSetting
6
+ * Added allowGlobalEdit property to `useSettings` hook, which allows the programatic turning on/off of `allowEdit` for ALL settings. More granular control will currently have to be handled manually via `dynamicPageExclusions` and then manual setting up of SettingsPage components with the requisite `allowEdit` booleans controlled by the implementing software.
1
7
  ## 4.4.0 2023-02-08
2
8
  * Removed all cyclic imports, linting
3
9
  * ActionList
@@ -44,12 +44,24 @@ var CustomPropertiesSettings = function CustomPropertiesSettings(_ref) {
44
44
  catchQueryCalls = _ref.catchQueryCalls,
45
45
  contextFilterOptions = _ref.contextFilterOptions,
46
46
  customPropertiesEndpoint = _ref.customPropertiesEndpoint,
47
+ _ref$displayCondition = _ref.displayConditions,
48
+ displayConditions = _ref$displayCondition === void 0 ? {
49
+ create: true,
50
+ delete: true,
51
+ edit: true
52
+ } : _ref$displayCondition,
47
53
  helpPopovers = _ref.helpPopovers,
48
54
  passedIntlKey = _ref.intlKey,
49
55
  passedIntlNS = _ref.intlNS,
50
56
  _ref$labelOverrides = _ref.labelOverrides,
51
57
  labelOverrides = _ref$labelOverrides === void 0 ? {} : _ref$labelOverrides,
52
58
  refdataEndpoint = _ref.refdataEndpoint;
59
+ var _displayConditions$cr = displayConditions.create,
60
+ createCondition = _displayConditions$cr === void 0 ? true : _displayConditions$cr,
61
+ _displayConditions$de = displayConditions.delete,
62
+ deleteCondition = _displayConditions$de === void 0 ? true : _displayConditions$de,
63
+ _displayConditions$ed = displayConditions.edit,
64
+ editCondition = _displayConditions$ed === void 0 ? true : _displayConditions$ed;
53
65
  var callout = (0, _react.useContext)(_core.CalloutContext);
54
66
  var queryClient = (0, _reactQuery.useQueryClient)();
55
67
  var _useState = (0, _react.useState)(),
@@ -175,7 +187,7 @@ var CustomPropertiesSettings = function CustomPropertiesSettings(_ref) {
175
187
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Pane, {
176
188
  defaultWidth: "fill",
177
189
  id: "settings-customProperties.lookupPane",
178
- lastMenu: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
190
+ lastMenu: createCondition && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
179
191
  buttonStyle: "primary",
180
192
  marginBottom0: true,
181
193
  onClick: function onClick() {
@@ -204,34 +216,41 @@ var CustomPropertiesSettings = function CustomPropertiesSettings(_ref) {
204
216
  }), customProperty && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Pane, {
205
217
  actionMenu: function actionMenu(_ref2) {
206
218
  var onToggle = _ref2.onToggle;
207
- return [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
208
- buttonStyle: "dropdownItem",
209
- marginBottom0: true,
210
- onClick: function onClick() {
211
- return setMode(EDITING);
212
- },
213
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
214
- icon: "edit",
215
- children: kintIntl.formatKintMessage({
216
- id: 'edit',
217
- overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.edit
219
+ var actionsArray = [];
220
+ if (editCondition) {
221
+ actionsArray.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
222
+ buttonStyle: "dropdownItem",
223
+ marginBottom0: true,
224
+ onClick: function onClick() {
225
+ return setMode(EDITING);
226
+ },
227
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
228
+ icon: "edit",
229
+ children: kintIntl.formatKintMessage({
230
+ id: 'edit',
231
+ overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.edit
232
+ })
218
233
  })
219
- })
220
- }, "".concat(customProperty.name, "-action-edit")), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
221
- buttonStyle: "dropdownItem",
222
- marginBottom0: true,
223
- onClick: function onClick() {
224
- setDeleteModal(true);
225
- onToggle();
226
- },
227
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
228
- icon: "trash",
229
- children: kintIntl.formatKintMessage({
230
- id: 'delete',
231
- overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.delete
234
+ }, "".concat(customProperty.name, "-action-edit")));
235
+ }
236
+ if (deleteCondition) {
237
+ actionsArray.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
238
+ buttonStyle: "dropdownItem",
239
+ marginBottom0: true,
240
+ onClick: function onClick() {
241
+ setDeleteModal(true);
242
+ onToggle();
243
+ },
244
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
245
+ icon: "trash",
246
+ children: kintIntl.formatKintMessage({
247
+ id: 'delete',
248
+ overrideValue: labelOverrides === null || labelOverrides === void 0 ? void 0 : labelOverrides.delete
249
+ })
232
250
  })
233
- })
234
- }, "".concat(customProperty.name, "-action-delete"))];
251
+ }, "".concat(customProperty.name, "-action-delete")));
252
+ }
253
+ return actionsArray !== null && actionsArray !== void 0 && actionsArray.length ? actionsArray : null;
235
254
  },
236
255
  defaultWidth: "fill",
237
256
  dismissible: true,
@@ -333,6 +352,11 @@ CustomPropertiesSettings.propTypes = {
333
352
  label: _propTypes.default.oneOfType([_propTypes.default.element, _propTypes.default.string])
334
353
  })),
335
354
  customPropertiesEndpoint: _propTypes.default.string,
355
+ displayConditions: _propTypes.default.shape({
356
+ create: _propTypes.default.bool,
357
+ delete: _propTypes.default.bool,
358
+ view: _propTypes.default.bool
359
+ }),
336
360
  helpPopovers: _propTypes.default.object,
337
361
  intlKey: _propTypes.default.string,
338
362
  intlNS: _propTypes.default.string,
@@ -13,7 +13,9 @@ var _EditableSettingsListFieldArray = _interopRequireDefault(require("./Editable
13
13
  var _jsxRuntime = require("react/jsx-runtime");
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
  var EditableSettingsList = function EditableSettingsList(_ref) {
16
- var data = _ref.data,
16
+ var _ref$allowEdit = _ref.allowEdit,
17
+ allowEdit = _ref$allowEdit === void 0 ? true : _ref$allowEdit,
18
+ data = _ref.data,
17
19
  initialValues = _ref.initialValues,
18
20
  passedIntlKey = _ref.intlKey,
19
21
  passedIntlNS = _ref.intlNS,
@@ -36,6 +38,7 @@ var EditableSettingsList = function EditableSettingsList(_ref) {
36
38
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("form", {
37
39
  onSubmit: handleSubmit,
38
40
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalFormArrays.FieldArray, {
41
+ allowEdit: allowEdit,
39
42
  component: _EditableSettingsListFieldArray.default,
40
43
  data: data,
41
44
  intlKey: passedIntlKey,
@@ -50,7 +53,7 @@ var EditableSettingsList = function EditableSettingsList(_ref) {
50
53
  });
51
54
  };
52
55
  EditableSettingsList.propTypes = {
53
- onSave: _propTypes.default.func,
56
+ allowEdit: _propTypes.default.bool,
54
57
  data: _propTypes.default.shape({
55
58
  refdatavalues: _propTypes.default.arrayOf(_propTypes.default.object)
56
59
  }),
@@ -58,7 +61,8 @@ EditableSettingsList.propTypes = {
58
61
  intlKey: _propTypes.default.string,
59
62
  intlNS: _propTypes.default.string,
60
63
  label: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node, _propTypes.default.object]),
61
- labelOverrides: _propTypes.default.object
64
+ labelOverrides: _propTypes.default.object,
65
+ onSave: _propTypes.default.func
62
66
  };
63
67
  var _default = EditableSettingsList;
64
68
  exports.default = _default;
@@ -17,7 +17,9 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
17
17
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
18
18
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
19
19
  var EditableSettingsListFieldArray = function EditableSettingsListFieldArray(_ref) {
20
- var data = _ref.data,
20
+ var _ref$allowEdit = _ref.allowEdit,
21
+ allowEdit = _ref$allowEdit === void 0 ? true : _ref$allowEdit,
22
+ data = _ref.data,
21
23
  fields = _ref.fields,
22
24
  passedIntlKey = _ref.intlKey,
23
25
  passedIntlNS = _ref.intlNS,
@@ -30,6 +32,7 @@ var EditableSettingsListFieldArray = function EditableSettingsListFieldArray(_re
30
32
  };
31
33
  return fields.map(function (setting, i) {
32
34
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactFinalForm.Field, {
35
+ allowEdit: allowEdit,
33
36
  component: _SettingField.SettingField,
34
37
  "data-testid": "editableSettingsListFieldArray[".concat(i, "]"),
35
38
  intlKey: passedIntlKey,
@@ -46,6 +49,7 @@ var EditableSettingsListFieldArray = function EditableSettingsListFieldArray(_re
46
49
  });
47
50
  };
48
51
  EditableSettingsListFieldArray.propTypes = {
52
+ allowEdit: _propTypes.default.bool,
49
53
  fields: _propTypes.default.object,
50
54
  intlKey: _propTypes.default.string,
51
55
  intlNS: _propTypes.default.string,
@@ -30,7 +30,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
30
30
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
31
31
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
32
32
  var SettingField = function SettingField(settingFieldProps) {
33
- var passedIntlKey = settingFieldProps.intlKey,
33
+ var _settingFieldProps$al = settingFieldProps.allowEdit,
34
+ allowEdit = _settingFieldProps$al === void 0 ? true : _settingFieldProps$al,
35
+ passedIntlKey = settingFieldProps.intlKey,
34
36
  passedIntlNS = settingFieldProps.intlNS,
35
37
  _settingFieldProps$la = settingFieldProps.labelOverrides,
36
38
  labelOverrides = _settingFieldProps$la === void 0 ? {} : _settingFieldProps$la,
@@ -129,16 +131,19 @@ var SettingField = function SettingField(settingFieldProps) {
129
131
  }) : kintIntl.formatKintMessage({
130
132
  id: 'edit'
131
133
  });
132
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
133
- marginBottom0: true,
134
- onClick: function onClick(e) {
135
- e.preventDefault();
136
- return editing ? onSave().then(function () {
137
- return setEditing(false);
138
- }) : setEditing(true);
139
- },
140
- children: EditText
141
- });
134
+ if (allowEdit) {
135
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
136
+ marginBottom0: true,
137
+ onClick: function onClick(e) {
138
+ e.preventDefault();
139
+ return editing ? onSave().then(function () {
140
+ return setEditing(false);
141
+ }) : setEditing(true);
142
+ },
143
+ children: EditText
144
+ });
145
+ }
146
+ return null;
142
147
  };
143
148
  var RenderFunction;
144
149
  if (editing === false) {
@@ -174,6 +179,7 @@ var SettingField = function SettingField(settingFieldProps) {
174
179
  });
175
180
  };
176
181
  SettingField.propTypes = {
182
+ allowEdit: _propTypes.default.bool,
177
183
  settingData: _propTypes.default.shape({
178
184
  refdatavalues: _propTypes.default.arrayOf(_propTypes.default.object),
179
185
  currentSetting: _propTypes.default.object,
@@ -17,7 +17,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
17
17
  // Importing directly here to avoid cyclic dependency
18
18
 
19
19
  var SettingPage = function SettingPage(_ref) {
20
- var passedIntlKey = _ref.intlKey,
20
+ var _ref$allowEdit = _ref.allowEdit,
21
+ allowEdit = _ref$allowEdit === void 0 ? true : _ref$allowEdit,
22
+ passedIntlKey = _ref.intlKey,
21
23
  passedIntlNS = _ref.intlNS,
22
24
  _ref$labelOverrides = _ref.labelOverrides,
23
25
  labelOverrides = _ref$labelOverrides === void 0 ? {} : _ref$labelOverrides,
@@ -31,6 +33,7 @@ var SettingPage = function SettingPage(_ref) {
31
33
  handleSubmit = _useSettingSection.handleSubmit,
32
34
  settings = _useSettingSection.settings;
33
35
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_EditableSettingsList.EditableSettingsList, {
36
+ allowEdit: allowEdit,
34
37
  initialValues: {
35
38
  'settings': settings
36
39
  },
@@ -43,6 +46,7 @@ var SettingPage = function SettingPage(_ref) {
43
46
  });
44
47
  };
45
48
  SettingPage.propTypes = {
49
+ allowEdit: _propTypes.default.bool,
46
50
  intlKey: _propTypes.default.string,
47
51
  intlNS: _propTypes.default.string,
48
52
  labelOverrides: _propTypes.default.object,
@@ -28,7 +28,9 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symb
28
28
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
29
29
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
30
30
  var useSettings = function useSettings(_ref) {
31
- var dynamicPageExclusions = _ref.dynamicPageExclusions,
31
+ var _ref$allowGlobalEdit = _ref.allowGlobalEdit,
32
+ allowGlobalEdit = _ref$allowGlobalEdit === void 0 ? true : _ref$allowGlobalEdit,
33
+ dynamicPageExclusions = _ref.dynamicPageExclusions,
32
34
  passedIntlKey = _ref.intlKey,
33
35
  passedIntlNS = _ref.intlNS,
34
36
  _ref$labelOverrides = _ref.labelOverrides,
@@ -72,6 +74,7 @@ var useSettings = function useSettings(_ref) {
72
74
  intlNS: passedIntlNS,
73
75
  sectionName: section,
74
76
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SettingPage.SettingPage, _objectSpread({
77
+ allowEdit: allowGlobalEdit,
75
78
  intlKey: passedIntlKey,
76
79
  intlNS: passedIntlNS,
77
80
  labelOverrides: labelOverrides,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k-int/stripes-kint-components",
3
- "version": "4.4.0",
3
+ "version": "4.4.1",
4
4
  "description": "Stripes Component library for K-Int specific applications",
5
5
  "sideEffects": [
6
6
  "*.css"
@@ -25,12 +25,23 @@ const CustomPropertiesSettings = ({
25
25
  catchQueryCalls,
26
26
  contextFilterOptions,
27
27
  customPropertiesEndpoint,
28
+ displayConditions = {
29
+ create: true,
30
+ delete: true,
31
+ edit: true
32
+ },
28
33
  helpPopovers,
29
34
  intlKey: passedIntlKey,
30
35
  intlNS: passedIntlNS,
31
36
  labelOverrides = {},
32
37
  refdataEndpoint,
33
38
  }) => {
39
+ const {
40
+ create: createCondition = true,
41
+ delete: deleteCondition = true,
42
+ edit: editCondition = true
43
+ } = displayConditions;
44
+
34
45
  const callout = useContext(CalloutContext);
35
46
  const queryClient = useQueryClient();
36
47
 
@@ -146,7 +157,7 @@ const CustomPropertiesSettings = ({
146
157
  <Pane
147
158
  defaultWidth="fill"
148
159
  id="settings-customProperties.lookupPane"
149
- lastMenu={
160
+ lastMenu={createCondition &&
150
161
  <Button
151
162
  buttonStyle="primary"
152
163
  marginBottom0
@@ -180,47 +191,57 @@ const CustomPropertiesSettings = ({
180
191
  </Pane>
181
192
  {customProperty &&
182
193
  <Pane
183
- actionMenu={({ onToggle }) => (
184
- [
185
- <Button
186
- key={`${customProperty.name}-action-edit`}
187
- buttonStyle="dropdownItem"
188
- marginBottom0
189
- onClick={() => setMode(EDITING)}
190
- >
191
- <Icon icon="edit">
192
- {
193
- kintIntl.formatKintMessage(
194
- {
195
- id: 'edit',
196
- overrideValue: labelOverrides?.edit,
197
- }
198
- )
199
- }
200
- </Icon>
201
- </Button>,
202
- <Button
203
- key={`${customProperty.name}-action-delete`}
204
- buttonStyle="dropdownItem"
205
- marginBottom0
206
- onClick={() => {
207
- setDeleteModal(true);
208
- onToggle();
209
- }}
210
- >
211
- <Icon icon="trash">
212
- {
213
- kintIntl.formatKintMessage(
214
- {
215
- id: 'delete',
216
- overrideValue: labelOverrides?.delete,
217
- }
218
- )
219
- }
220
- </Icon>
221
- </Button>
222
- ]
223
- )}
194
+ actionMenu={({ onToggle }) => {
195
+ const actionsArray = [];
196
+ if (editCondition) {
197
+ actionsArray.push(
198
+ <Button
199
+ key={`${customProperty.name}-action-edit`}
200
+ buttonStyle="dropdownItem"
201
+ marginBottom0
202
+ onClick={() => setMode(EDITING)}
203
+ >
204
+ <Icon icon="edit">
205
+ {
206
+ kintIntl.formatKintMessage(
207
+ {
208
+ id: 'edit',
209
+ overrideValue: labelOverrides?.edit,
210
+ }
211
+ )
212
+ }
213
+ </Icon>
214
+ </Button>
215
+ );
216
+ }
217
+
218
+ if (deleteCondition) {
219
+ actionsArray.push(
220
+ <Button
221
+ key={`${customProperty.name}-action-delete`}
222
+ buttonStyle="dropdownItem"
223
+ marginBottom0
224
+ onClick={() => {
225
+ setDeleteModal(true);
226
+ onToggle();
227
+ }}
228
+ >
229
+ <Icon icon="trash">
230
+ {
231
+ kintIntl.formatKintMessage(
232
+ {
233
+ id: 'delete',
234
+ overrideValue: labelOverrides?.delete,
235
+ }
236
+ )
237
+ }
238
+ </Icon>
239
+ </Button>
240
+ );
241
+ }
242
+
243
+ return (actionsArray?.length ? actionsArray : null);
244
+ }}
224
245
  defaultWidth="fill"
225
246
  dismissible
226
247
  id="settings-customProperties-viewPane"
@@ -349,6 +370,11 @@ CustomPropertiesSettings.propTypes = {
349
370
  ])
350
371
  })),
351
372
  customPropertiesEndpoint: PropTypes.string,
373
+ displayConditions: PropTypes.shape({
374
+ create: PropTypes.bool,
375
+ delete: PropTypes.bool,
376
+ view: PropTypes.bool,
377
+ }),
352
378
  helpPopovers: PropTypes.object,
353
379
  intlKey: PropTypes.string,
354
380
  intlNS: PropTypes.string,
@@ -23,6 +23,7 @@ ctx | `<moduleIntlKey>.customProperties.ctx` | Override for the display of field
23
23
  deleteError | `<moduleIntlKey>customProperties.config.delete.errorMessage` | Override for the default callout message shown when a custom property fails to delete. Accepts a function to which it will provide the error message and the customProperty in question. | error; The error on delete, label: The label of the custom property |
24
24
  defaultVisibility | `<moduleIntlKey>.customProperties.defaultVisibility` | Override for the display of field "defaultVisibility" | | |
25
25
  description | `<moduleIntlKey>.customProperties.description` | Override for the display of field "description" | | |
26
+ displayConditions | object | An object of the form `{delete: false, edit: true, create: true}`, with keys `delete`, `edit` and `create`, and a boolean value. These will each default to true if not specified. These booleans will act as an additional check before rendering the actions for create/delete/edit, as well as whether or not to render the action button in the view pane at all. | `{delete: true, edit: true, create: true}` | ✕ |
26
27
  editModalTitle | `<moduleIntlKey>.customProperties.config.editModal` | Override for the modal header on editing a custom property | name: Label of custom property, falling back to name. |
27
28
  label | `<moduleIntlKey>.customProperties.label` | Override for the display of field "label" | | |
28
29
  name | `<moduleIntlKey>.customProperties.name` | Override for the display of field "name" | | |newModalTitle | `<moduleIntlKey>.customProperties.config.newModal` | Override for the modal header on attempting to create a custom property | "Edit custom property" |
@@ -21,6 +21,6 @@ afterQueryCalls | object | An object of the form `{delete: func1, put: func2}` w
21
21
  allowSpecial | boolean | A boolean to turn off/on the stripping out of special characters and replacing them with `_`. Generally turning this on will cause problems with queries to KIWT endpoints and internally with Stripes filters, where a refdata value includes `&&`, `||`, `\` or `"`. | false | ✕ |
22
22
  catchQueryCalls | object | An object of the form `{delete: func1, put: func2}` where `func1`/`func2` are functions to be called with a HTTPError object when the `delete`/`put` calls fail. | `{delete: <Fires a callout of the format "<strong>Error: {label}</strong> was not deleted. {error}">}` | | ✕ |
23
23
  desc | String | A string corresponding to the refdataValue category, usually of the form `DomainClass.Field`. See `useRefdata` for more information. | | ✕ |
24
- endpoint | String | A string containing the path to the endpoint for refdata | | ✓ |
25
24
  displayConditions | object | An object of the form `{delete: false, edit: true, create: true}`, with keys `delete`, `edit` and `create`, and a boolean value. These will each default to true if not specified. These booleans will act as an additional check before rendering the actions for create/delete/edit, as well as whether or not to render the actions column at all. | `{delete: true, edit: true, create: true}` | ✕ |
25
+ endpoint | String | A string containing the path to the endpoint for refdata | | ✓ |
26
26
  labelOverrides | object | An object containing translation overrides. Currently accepts: `deleteError: (err, object) => { ... output a callout message }`. | | ✕ |
@@ -7,6 +7,7 @@ import arrayMutators from 'final-form-arrays';
7
7
  import EditableSettingsListFieldArray from './EditableSettingsListFieldArray';
8
8
 
9
9
  const EditableSettingsList = ({
10
+ allowEdit = true, // A gloabal boolean permission to turn on/off editing of all appSettings in the frontend
10
11
  data,
11
12
  initialValues,
12
13
  intlKey: passedIntlKey,
@@ -28,6 +29,7 @@ const EditableSettingsList = ({
28
29
  {({ handleSubmit }) => (
29
30
  <form onSubmit={handleSubmit}>
30
31
  <FieldArray
32
+ allowEdit={allowEdit}
31
33
  component={EditableSettingsListFieldArray}
32
34
  data={data}
33
35
  intlKey={passedIntlKey}
@@ -44,7 +46,7 @@ const EditableSettingsList = ({
44
46
  };
45
47
 
46
48
  EditableSettingsList.propTypes = {
47
- onSave: PropTypes.func,
49
+ allowEdit: PropTypes.bool,
48
50
  data: PropTypes.shape({
49
51
  refdatavalues: PropTypes.arrayOf(PropTypes.object)
50
52
  }),
@@ -57,6 +59,7 @@ EditableSettingsList.propTypes = {
57
59
  PropTypes.object
58
60
  ]),
59
61
  labelOverrides: PropTypes.object,
62
+ onSave: PropTypes.func,
60
63
  };
61
64
 
62
65
  export default EditableSettingsList;
@@ -5,6 +5,7 @@ import { Field } from 'react-final-form';
5
5
  import { SettingField } from './SettingField';
6
6
 
7
7
  const EditableSettingsListFieldArray = ({
8
+ allowEdit = true,
8
9
  data,
9
10
  fields,
10
11
  intlKey: passedIntlKey,
@@ -22,6 +23,7 @@ const EditableSettingsListFieldArray = ({
22
23
  return (
23
24
  <Field
24
25
  key={setting}
26
+ allowEdit={allowEdit}
25
27
  component={SettingField}
26
28
  data-testid={`editableSettingsListFieldArray[${i}]`}
27
29
  intlKey={passedIntlKey}
@@ -40,6 +42,7 @@ const EditableSettingsListFieldArray = ({
40
42
  };
41
43
 
42
44
  EditableSettingsListFieldArray.propTypes = {
45
+ allowEdit: PropTypes.bool,
43
46
  fields: PropTypes.object,
44
47
  intlKey: PropTypes.string,
45
48
  intlNS: PropTypes.string,
@@ -17,6 +17,7 @@ import renderHelpTextCSS from '../../../../styles/renderHelpText.css';
17
17
 
18
18
  const SettingField = (settingFieldProps) => {
19
19
  const {
20
+ allowEdit = true,
20
21
  intlKey: passedIntlKey,
21
22
  intlNS: passedIntlNS,
22
23
  labelOverrides = {},
@@ -81,21 +82,24 @@ const SettingField = (settingFieldProps) => {
81
82
  kintIntl.formatKintMessage({
82
83
  id: 'edit'
83
84
  });
84
- return (
85
- <Button
86
- marginBottom0
87
- onClick={(e) => {
88
- e.preventDefault();
89
- return (
90
- editing ?
91
- onSave().then(() => setEditing(false)) :
92
- setEditing(true)
93
- );
94
- }}
95
- >
96
- {EditText}
97
- </Button>
98
- );
85
+ if (allowEdit) {
86
+ return (
87
+ <Button
88
+ marginBottom0
89
+ onClick={(e) => {
90
+ e.preventDefault();
91
+ return (
92
+ editing ?
93
+ onSave().then(() => setEditing(false)) :
94
+ setEditing(true)
95
+ );
96
+ }}
97
+ >
98
+ {EditText}
99
+ </Button>
100
+ );
101
+ }
102
+ return null;
99
103
  };
100
104
 
101
105
  let RenderFunction;
@@ -146,6 +150,7 @@ const SettingField = (settingFieldProps) => {
146
150
  };
147
151
 
148
152
  SettingField.propTypes = {
153
+ allowEdit: PropTypes.bool,
149
154
  settingData: PropTypes.shape({
150
155
  refdatavalues: PropTypes.arrayOf(PropTypes.object),
151
156
  currentSetting: PropTypes.object,
@@ -7,6 +7,7 @@ import { SettingsContext } from '../contexts';
7
7
  import useSettingSection from '../settingsHooks/useSettingSection';
8
8
 
9
9
  const SettingPage = ({
10
+ allowEdit = true,
10
11
  intlKey: passedIntlKey,
11
12
  intlNS: passedIntlNS,
12
13
  labelOverrides = {},
@@ -21,6 +22,7 @@ const SettingPage = ({
21
22
 
22
23
  return (
23
24
  <EditableSettingsList
25
+ allowEdit={allowEdit}
24
26
  initialValues={{ 'settings': settings }}
25
27
  intlKey={passedIntlKey}
26
28
  intlNS={passedIntlNS}
@@ -33,6 +35,7 @@ const SettingPage = ({
33
35
  };
34
36
 
35
37
  SettingPage.propTypes = {
38
+ allowEdit: PropTypes.bool,
36
39
  intlKey: PropTypes.string,
37
40
  intlNS: PropTypes.string,
38
41
  labelOverrides: PropTypes.object,
@@ -13,6 +13,7 @@ import { generateKiwtQueryParams, sortByLabel, toCamelCase } from '../utils';
13
13
  import { useKintIntl, useIntlKey } from '../hooks';
14
14
 
15
15
  const useSettings = ({
16
+ allowGlobalEdit = true,
16
17
  dynamicPageExclusions,
17
18
  intlKey: passedIntlKey,
18
19
  intlNS: passedIntlNS,
@@ -56,6 +57,7 @@ const useSettings = ({
56
57
  sectionName={section}
57
58
  >
58
59
  <SettingPage
60
+ allowEdit={allowGlobalEdit}
59
61
  intlKey={passedIntlKey}
60
62
  intlNS={passedIntlNS}
61
63
  labelOverrides={labelOverrides}