@openmrs/esm-form-engine-lib 3.1.5-pre.2012 → 3.1.5-pre.2014

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-form-engine-lib",
3
- "version": "3.1.5-pre.2012",
3
+ "version": "3.1.5-pre.2014",
4
4
  "description": "React Form Engine for O3",
5
5
  "browser": "dist/openmrs-esm-form-engine-lib.js",
6
6
  "main": "src/index.ts",
@@ -3,13 +3,17 @@ import { useTranslation } from 'react-i18next';
3
3
  import { showSnackbar } from '@openmrs/esm-framework';
4
4
  import { useLaunchWorkspaceRequiringVisit } from '@openmrs/esm-patient-common-lib';
5
5
  import { Button } from '@carbon/react';
6
+
7
+ import { useFormProviderContext } from '../../../provider/form-provider';
6
8
  import { type FormFieldInputProps } from '../../../types';
7
9
  import { isTrue } from '../../../utils/boolean-utils';
10
+ import { isViewMode } from '../../../utils/common-utils';
8
11
  import styles from './workspace-launcher.scss';
9
12
 
10
13
  const WorkspaceLauncher: React.FC<FormFieldInputProps> = ({ field }) => {
11
14
  const { t } = useTranslation();
12
15
  const launchWorkspace = useLaunchWorkspaceRequiringVisit(field.questionOptions?.workspaceName);
16
+ const { sessionMode } = useFormProviderContext();
13
17
 
14
18
  const handleLaunchWorkspace = () => {
15
19
  if (!launchWorkspace) {
@@ -23,17 +27,19 @@ const WorkspaceLauncher: React.FC<FormFieldInputProps> = ({ field }) => {
23
27
  launchWorkspace();
24
28
  };
25
29
 
30
+ if (field.isHidden || isViewMode(sessionMode)) {
31
+ return null;
32
+ }
33
+
26
34
  return (
27
- !field.isHidden && (
28
- <div>
29
- <div className={styles.label}>{t(field.label)}</div>
30
- <div className={styles.workspaceButton}>
31
- <Button disabled={isTrue(field.readonly)} onClick={handleLaunchWorkspace}>
32
- {t(field.questionOptions?.buttonLabel) ?? t('launchWorkspace', 'Launch Workspace')}
33
- </Button>
34
- </div>
35
+ <div>
36
+ <div className={styles.label}>{t(field.label)}</div>
37
+ <div className={styles.workspaceButton}>
38
+ <Button disabled={isTrue(field.readonly)} onClick={handleLaunchWorkspace}>
39
+ {t(field.questionOptions?.buttonLabel) ?? t('launchWorkspace', 'Launch Workspace')}
40
+ </Button>
35
41
  </div>
36
- )
42
+ </div>
37
43
  );
38
44
  };
39
45