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

(BREAKING) O3-3037 : Refactor components and rename files #211

Merged
merged 7 commits into from
Apr 24, 2024

Conversation

pirupius
Copy link
Member

@pirupius pirupius commented Apr 24, 2024

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

This PR introduces BREAKING changes with multiple refactors to file names and components

  • Removes ohri scoped naming
  • Renames typings

Screenshots

Related Issue

https://openmrs.atlassian.net/browse/O3-3037

Other

@pirupius pirupius force-pushed the refactor/rename-files branch 3 times, most recently from 78d2a32 to 82ec502 Compare April 24, 2024 10:02
{
name: 'OHRIText',
component: OHRIText,
name: 'TextField',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll be deprecating this value as documented in O3-3109

@pirupius pirupius marked this pull request as ready for review April 24, 2024 14:12
Copy link

github-actions bot commented Apr 24, 2024

Size Change: -238 kB (-16%) 👏

Total Size: 1.22 MB

Filename Size Change
dist/784.js 0 B -237 kB (removed) 🏆
ℹ️ View Unchanged
Filename Size Change
dist/100.js 2.41 kB 0 B
dist/154.js 80.8 kB +1 B (0%)
dist/17.js 16.4 kB 0 B
dist/225.js 2.57 kB +1 B (0%)
dist/248.js 108 kB 0 B
dist/29.js 220 kB 0 B
dist/311.js 237 kB 0 B
dist/327.js 1.58 kB 0 B
dist/353.js 3.02 kB 0 B
dist/459.js 6.07 kB -2 B (0%)
dist/505.js 7.46 kB -1 B (0%)
dist/540.js 2.63 kB 0 B
dist/561.js 487 B 0 B
dist/599.js 2.51 kB +1 B (0%)
dist/606.js 2.23 kB +1 B (0%)
dist/633.js 95 kB +1 B (0%)
dist/791.js 9.8 kB 0 B
dist/828.js 94 kB 0 B
dist/859.js 0 B -879 B (removed) 🏆
dist/886.js 6.94 kB 0 B
dist/942.js 487 B 0 B
dist/993.js 3.08 kB 0 B
dist/main.js 312 kB +121 B (0%)
dist/openmrs-form-engine-lib.js 3.77 kB +2 B (0%)

compressed-size-action

Copy link
Member

@denniskigen denniskigen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks, @pirupius.

@@ -1,18 +1,18 @@
import React, { useEffect, useMemo, useState } from 'react';
import classNames from 'classnames';
import { FormGroup, ContentSwitcher, Switch } from '@carbon/react';
import { FormGroup, ContentSwitcher as Switcher, Switch } from '@carbon/react';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should alias this to something like RfeContentSwitcher to avoid any potential namespace conflicts with the Carbon Switcher component

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or CdsContentSwitcher

import styles from './ui-select-extended.scss';

const UISelectExtended: React.FC<OHRIFormFieldProps> = ({ question, handler, onChange, previousValue }) => {
const UISelectExtended: React.FC<FormFieldProps> = ({ question, handler, onChange, previousValue }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const UISelectExtended: React.FC<FormFieldProps> = ({ question, handler, onChange, previousValue }) => {
const UiSelectExtended: React.FC<FormFieldProps> = ({ question, handler, onChange, previousValue }) => {

@pirupius pirupius merged commit 8acbb35 into main Apr 24, 2024
4 checks passed
@pirupius pirupius deleted the refactor/rename-files branch April 24, 2024 17:20
@pirupius
Copy link
Member Author

Hi @ibacher would love if you have some comments or suggestions on what naming we can improve and will submit those in follow up PR's so as to unblock other PR's

Copy link
Member

@ibacher ibacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming seems fine, so here's a smattering of random suggestions 😄. Keep up the good work!

@@ -121,7 +121,7 @@ export async function fetchOpenMRSForm(nameOrUUID: string): Promise<OpenmrsForm
* @param {OpenmrsForm} form - The OpenMRS form object.
* @returns {Promise<any | null>} - A Promise that resolves to the fetched ClobData or null if not found.
*/
export async function fetchClobData(form: OpenmrsForm): Promise<any | null> {
export async function fetchClobdata(form: OpenmrsForm): Promise<any | null> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have a better type here or to mark the return type as Promise<unknown | null>. It's more annoying, but hey. Even Record<string, unknown> is substantially better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the o3 module in place, we can as well consider getting rid of this function.

@@ -1,18 +1,18 @@
import React, { useEffect, useMemo, useState } from 'react';
import classNames from 'classnames';
import { FormGroup, ContentSwitcher, Switch } from '@carbon/react';
import { FormGroup, ContentSwitcher as Switcher, Switch } from '@carbon/react';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or CdsContentSwitcher

@@ -51,7 +51,7 @@ export const OHRIMultiSelect: React.FC<OHRIFormFieldProps> = ({ question, onChan
}));

const initiallySelectedQuestionItems = [];
questionItems.forEach((item) => {
questionItems.forEach(item => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually, I'm all in favour of fore-going React hooks, but from the name here, it seems like both questionItems and this could benefit from useMemo(), since we only really need to recalculate them if the question changes.

@@ -3,10 +3,10 @@ import { useTranslation } from 'react-i18next';
import { showSnackbar } from '@openmrs/esm-framework';
import { useLaunchWorkspaceRequiringVisit } from '@openmrs/esm-patient-common-lib';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the workspace stuff has been integrated into the framework, we can hopefully drop the need for depending on the patient-common-lib here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the heads up. I've created this ticket to handle this change as we wait for any other new developments that might come as part of this patient chart PR

src/hooks/useClobData.tsx Show resolved Hide resolved
@@ -249,7 +249,7 @@ export function getRegisteredExpressionHelpers() {
}

function getFormsStore(): FormsRegistryStoreState {
return getGlobalStore<FormsRegistryStoreState>(OHRIFormsStore, {
return getGlobalStore<FormsRegistryStoreState>(FormsStore, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a weird way of using a global store. Normally, we'd create a store in a variable like:

const formsStore = createGlobalStore<FormsRegistryStoreState>(FormsStore, /* ... */);

Then, you could create synchronous handlers, e.g.,

export function getRegisteredExpressionHelpers() {
  return formsStore.getState().expressionHelpers;
}

But, even better, since this is React, you can just turn everything into hooks:

export const useRegisteredExpressionHelpers = useStore(formsStore, (state) => state.expressionHelpers);

Setters can then be implemented more sanely like this:

export function registerFieldValidator(registration: ComponentRegistration<FormFieldValidator>) {
  formsStore.set((state) => state.fieldValidators.push(registration));
}

src/submission-handlers/base-handlers.ts Show resolved Hide resolved
uuid: encounter.location.uuid,
};
},
getDisplayValue: (field: FormField, value) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto:

getDisplayValue: (field: FormField, value: { display: string })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants