@openmrs/esm-implementer-tools-app 8.0.1-pre.3457 → 8.0.1-pre.3465

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.
@@ -10,20 +10,21 @@ export interface ConfigSubtreeProps {
10
10
  }
11
11
 
12
12
  export function ConfigSubtree({ config, path = [] }: ConfigSubtreeProps) {
13
- function setActiveItemDescriptionOnMouseEnter(thisPath, key, value) {
13
+ function setActiveItemDescriptionOnMouseEnter(thisPath: Array<string>, value: any) {
14
14
  if (!implementerToolsStore.getState().configPathBeingEdited) {
15
+ const isLeaf = value && typeof value === 'object' && Object.hasOwn(value, '_value');
15
16
  implementerToolsStore.setState({
16
17
  activeItemDescription: {
17
18
  path: thisPath,
18
- source: value._source,
19
- description: value._description,
20
- value: JSON.stringify(value._value),
19
+ source: isLeaf ? value._source : undefined,
20
+ description: isLeaf ? value._description : undefined,
21
+ value: isLeaf ? JSON.stringify(value._value) : undefined,
21
22
  },
22
23
  });
23
24
  }
24
25
  }
25
26
 
26
- function removeActiveItemDescriptionOnMouseLeave(thisPath) {
27
+ function removeActiveItemDescriptionOnMouseLeave(thisPath: Array<string>) {
27
28
  const state = implementerToolsStore.getState();
28
29
  if (isEqual(state.activeItemDescription?.path, thisPath) && !isEqual(state.configPathBeingEdited, thisPath)) {
29
30
  implementerToolsStore.setState({ activeItemDescription: undefined });
@@ -32,25 +33,27 @@ export function ConfigSubtree({ config, path = [] }: ConfigSubtreeProps) {
32
33
 
33
34
  return (
34
35
  <>
35
- {Object.entries(config).map(([key, value], i) => {
36
- const thisPath = path.concat([key]);
37
- const isLeaf = value.hasOwnProperty('_value') || value.hasOwnProperty('_type');
38
- return (
39
- <Subtree
40
- label={key}
41
- leaf={isLeaf}
42
- onMouseEnter={() => setActiveItemDescriptionOnMouseEnter(thisPath, key, value)}
43
- onMouseLeave={() => removeActiveItemDescriptionOnMouseLeave(thisPath)}
44
- key={`subtree-${thisPath.join('.')}`}
45
- >
46
- {isLeaf ? (
47
- <EditableValue path={thisPath} element={value} />
48
- ) : (
49
- <ConfigSubtree config={value} path={thisPath} />
50
- )}
51
- </Subtree>
52
- );
53
- })}
36
+ {Object.entries(config)
37
+ .filter(([key]) => !key.startsWith('_'))
38
+ .map(([key, value]) => {
39
+ const thisPath = path.concat([key]);
40
+ const isLeaf = value && typeof value === 'object' && Object.hasOwn(value, '_value');
41
+ return (
42
+ <Subtree
43
+ label={key}
44
+ leaf={isLeaf}
45
+ onMouseEnter={() => setActiveItemDescriptionOnMouseEnter(thisPath, value)}
46
+ onMouseLeave={() => removeActiveItemDescriptionOnMouseLeave(thisPath)}
47
+ key={`subtree-${thisPath.join('.')}`}
48
+ >
49
+ {isLeaf ? (
50
+ <EditableValue path={thisPath} element={value} />
51
+ ) : (
52
+ <ConfigSubtree config={value} path={thisPath} />
53
+ )}
54
+ </Subtree>
55
+ );
56
+ })}
54
57
  </>
55
58
  );
56
59
  }
@@ -125,7 +125,9 @@ export default function EditableValue({ path, element, customType }: EditableVal
125
125
  hasIconOnly
126
126
  onClick={() => {
127
127
  clearConfigErrors(path.join('.'));
128
- temporaryConfigStore.setState(unset(temporaryConfigStore.getState(), ['config', ...path]) as any);
128
+ const state = cloneDeep(temporaryConfigStore.getState());
129
+ unset(state, ['config', ...path]);
130
+ temporaryConfigStore.setState(state);
129
131
  }}
130
132
  />
131
133
  ) : null}