-
Notifications
You must be signed in to change notification settings - Fork 59
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
Conversation
78d2a32
to
82ec502
Compare
{ | ||
name: 'OHRIText', | ||
component: OHRIText, | ||
name: 'TextField', |
There was a problem hiding this comment.
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
a5cf8bd
to
3384a6a
Compare
Size Change: -238 kB (-16%) 👏 Total Size: 1.22 MB
ℹ️ View Unchanged
|
rebase cleanups reference refactors
71fa689
to
c053147
Compare
There was a problem hiding this 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'; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const UISelectExtended: React.FC<FormFieldProps> = ({ question, handler, onChange, previousValue }) => { | |
const UiSelectExtended: React.FC<FormFieldProps> = ({ question, handler, onChange, previousValue }) => { |
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 |
There was a problem hiding this 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> { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@@ -249,7 +249,7 @@ export function getRegisteredExpressionHelpers() { | |||
} | |||
|
|||
function getFormsStore(): FormsRegistryStoreState { | |||
return getGlobalStore<FormsRegistryStoreState>(OHRIFormsStore, { | |||
return getGlobalStore<FormsRegistryStoreState>(FormsStore, { |
There was a problem hiding this comment.
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));
}
uuid: encounter.location.uuid, | ||
}; | ||
}, | ||
getDisplayValue: (field: FormField, value) => { |
There was a problem hiding this comment.
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 })
Requirements
Summary
This PR introduces BREAKING changes with multiple refactors to file names and components
ohri
scoped namingScreenshots
Related Issue
https://openmrs.atlassian.net/browse/O3-3037
Other