Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) O3-1422 / O3-2724: Move workspace system into the framework #1796

Merged
merged 14 commits into from May 7, 2024
Merged
1 change: 0 additions & 1 deletion .eslintignore
@@ -1,5 +1,4 @@
src/**/*.test.tsx
src/**/*.spec.tsx
**/*.d.ts
**/node_modules/**/*
__mocks__/*
3 changes: 0 additions & 3 deletions packages/esm-form-engine-app/src/declarations.d.ts

This file was deleted.

Expand Up @@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event';
import { launchPatientWorkspace } from '@openmrs/esm-patient-common-lib';
import FormError from './form-error.component';

const mockLaunchPatientWorkspace = launchPatientWorkspace as jest.Mock;
const mocklaunchPatientWorkspace = launchPatientWorkspace as jest.Mock;

jest.mock('@openmrs/esm-patient-common-lib', () => ({
launchPatientWorkspace: jest.fn(),
Expand Down Expand Up @@ -46,6 +46,6 @@ describe('FormError', () => {
await user.click(link);

expect(closeWorkspace).toHaveBeenCalled();
expect(mockLaunchPatientWorkspace).toHaveBeenCalledWith('clinical-forms-workspace');
expect(mocklaunchPatientWorkspace).toHaveBeenCalledWith('clinical-forms-workspace');
});
});
Expand Up @@ -3,19 +3,17 @@ import { useTranslation } from 'react-i18next';
import { InlineLoading } from '@carbon/react';
import { FormEngine } from '@openmrs/openmrs-form-engine-lib';
import { type Visit } from '@openmrs/esm-framework';
import { launchPatientWorkspace, type DefaultWorkspaceProps } from '@openmrs/esm-patient-common-lib';
import { launchPatientWorkspace } from '@openmrs/esm-patient-common-lib';
import FormError from './form-error.component';
import useFormSchema from '../hooks/useFormSchema';
import styles from './form-renderer.scss';
import { type DefaultPatientWorkspaceProps } from '@openmrs/esm-patient-common-lib';

interface FormRendererProps {
interface FormRendererProps extends DefaultPatientWorkspaceProps {
additionalProps?: Record<string, any>;
closeWorkspace: DefaultWorkspaceProps['closeWorkspace'];
closeWorkspaceWithSavedChanges: DefaultWorkspaceProps['closeWorkspaceWithSavedChanges'];
encounterUuid?: string;
formUuid: string;
patientUuid: string;
promptBeforeClosing: DefaultWorkspaceProps['promptBeforeClosing'];
visit?: Visit;
}

Expand Down
2 changes: 0 additions & 2 deletions packages/esm-form-entry-app/src/declarations.d.ts
@@ -1,7 +1,5 @@
import type { i18n } from 'i18next';

declare module '*.css';
declare module '*.scss';
declare const __webpack_share_scopes__;
declare global {
interface Window {
Expand Down
1 change: 1 addition & 0 deletions packages/esm-form-entry-app/tsconfig.app.json
Expand Up @@ -18,6 +18,7 @@
"src/index.ts",
],
"include": [
"../../node_modules/@openmrs/esm-framework/src/declarations.d.ts",
"src/**/*.d.ts",
],
"exclude": [
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion packages/esm-patient-allergies-app/package.json
Expand Up @@ -17,7 +17,7 @@
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js --color",
"coverage": "yarn test --coverage",
"typescript": "tsc",
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.extension.tsx' 'src/**/*.workspace.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js"
},
"browserslist": [
"extends browserslist-config-openmrs"
Expand Down
Expand Up @@ -11,7 +11,7 @@ import {
useAllergicReactions,
updatePatientAllergy,
} from './allergy-form.resource';
import AllergyForm from './allergy-form.component';
import AllergyForm from './allergy-form.workspace';
import { AllergenType, ReactionSeverity } from '../../types';
import { mockAllergy } from '__mocks__';

Expand Down
Expand Up @@ -28,7 +28,7 @@ import {
useLayoutType,
ResponsiveWrapper,
} from '@openmrs/esm-framework';
import { type DefaultWorkspaceProps } from '@openmrs/esm-patient-common-lib';
import { type DefaultPatientWorkspaceProps } from '@openmrs/esm-patient-common-lib';
import {
type Allergen,
type AllergicReaction,
Expand Down Expand Up @@ -66,7 +66,7 @@ type AllergyFormData = {
comment: string;
};

interface AllergyFormProps extends DefaultWorkspaceProps {
interface AllergyFormProps extends DefaultPatientWorkspaceProps {
allergy?: Allergy;
formContext: 'creating' | 'editing';
}
Expand Down
3 changes: 0 additions & 3 deletions packages/esm-patient-allergies-app/src/declarations.d.ts

This file was deleted.

12 changes: 5 additions & 7 deletions packages/esm-patient-allergies-app/src/index.ts
Expand Up @@ -7,7 +7,7 @@ import {
restBaseUrl,
translateFrom,
} from '@openmrs/esm-framework';
import { createDashboardLink, registerWorkspace } from '@openmrs/esm-patient-common-lib';
import { createDashboardLink } from '@openmrs/esm-patient-common-lib';
import { configSchema } from './config-schema';
import { dashboardMeta } from './dashboard.meta';
import allergiesDetailedSummaryComponent from './allergies/allergies-detailed-summary.component';
Expand Down Expand Up @@ -53,12 +53,10 @@ export const allergiesDashboardLink = getSyncLifecycle(
);

// t('recordNewAllergy', "Record a new allergy")
registerWorkspace({
name: 'patient-allergy-form-workspace',
title: translateFrom(moduleName, 'recordNewAllergy', 'Record a new allergy'),
load: getAsyncLifecycle(() => import('./allergies/allergies-form/allergy-form.component'), options),
type: 'form',
});
export const allergyFormWorkspace = getAsyncLifecycle(
() => import('./allergies/allergies-form/allergy-form.workspace'),
options,
);

export const allergyTile = getSyncLifecycle(allergyTileComponent, options);

Expand Down
8 changes: 8 additions & 0 deletions packages/esm-patient-allergies-app/src/routes.json
Expand Up @@ -40,5 +40,13 @@
"name": "allergy-delete-confirmation-dialog",
"component": "allergyDeleteConfirmationDialog"
}
],
"workspaces": [
{
"name": "patient-allergy-form-workspace",
"title": "recordNewAllergy",
"component": "allergyFormWorkspace",
"type": "form"
}
]
}
3 changes: 0 additions & 3 deletions packages/esm-patient-attachments-app/src/declarations.d.ts

This file was deleted.

3 changes: 0 additions & 3 deletions packages/esm-patient-banner-app/src/declarations.d.ts

This file was deleted.

Expand Up @@ -12,14 +12,14 @@ import {
DataTableSkeleton,
} from '@carbon/react';
import { WarningFilled } from '@carbon/react/icons';
import { type DefaultWorkspaceProps } from '@openmrs/esm-patient-common-lib';
import { type DefaultPatientWorkspaceProps } from '@openmrs/esm-patient-common-lib';
import { ExtensionSlot, useLayoutType, showSnackbar, showModal, ResponsiveWrapper } from '@openmrs/esm-framework';
import { markPatientDeceased, usePatientDeathConcepts, usePatientDeceased } from './deceased.resource';
import BaseConceptAnswer from './base-concept-answer.component';

import styles from './deceased-form.scss';

const MarkPatientDeceasedForm: React.FC<DefaultWorkspaceProps> = ({ patientUuid, closeWorkspace }) => {
const MarkPatientDeceasedForm: React.FC<DefaultPatientWorkspaceProps> = ({ patientUuid, closeWorkspace }) => {
const { t } = useTranslation();
const isTablet = useLayoutType() === 'tablet';
const state = useMemo(() => ({ patientUuid }), [patientUuid]);
Expand Down
3 changes: 0 additions & 3 deletions packages/esm-patient-chart-app/src/declarations.d.ts

This file was deleted.

This file was deleted.

This file was deleted.