-
Notifications
You must be signed in to change notification settings - Fork 1
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
Feature/download template redesign #342
base: development
Are you sure you want to change the base?
Conversation
- add sections in download template page - collapsible orgunit section instead of a checkbox - rearrange advanced options
Task linked: CU-8694wfy5f Redesign download template page |
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.
[code-only review] Looking good! just some minor details:
iconPos = "right", | ||
classProps = {}, | ||
arrowStyle = "upDown", | ||
}: SectionProps) => { |
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.
That's not wrong at all, but typically we prefer to write props: SectionProps
here and unpack in the first line of the component, so the signature stays single-line and more readable (subjective!).
arrowStyle?: arrowStyle; | ||
} | ||
|
||
export const Section = ({ |
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.
I see you preferred to define children explicitly in the props instead of using React.FC. We typically use FC, BUT since it adds always children (that's why some people don't like FC), we lose some control, so let's go with this. Eventually, we can decide on creating our own "FCWithProps" or whatever, but no need to to it here.
return ( | ||
<Paper elevation={elevation} className={`${classes.paper} ${classProps.section}`}> | ||
<div | ||
className={`${classes.header} ${leftIcon} ${classProps.header} ${isOpen ? "" : classes.noBorder}`} |
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.
If I am not mistaken, when leftIcon
is null, it will appear "null" in the class list. There are packages for that (classnames), but you can also do this: _.compact([name1, name2, name3]).join(" ")
{title} | ||
{collapsible && !leftIcon && <CollapsibleToggle isOpen={isOpen} arrowStyle={arrowStyle} />} | ||
</div> | ||
<div className={`${classProps.content}`} style={{ display: isOpen ? "" : "none" }}> |
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.
Whenever possible, we strive for immutable props (memoized components will benefit from that).
arrowStyle: "upDown" | "rightLeft"; | ||
} | ||
|
||
export const CollapsibleToggle = ({ isOpen, arrowStyle }: CollapsibleToggleProps) => { |
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's not used externally, right? we can remove the export.
@@ -81,6 +83,7 @@ export const TemplateSelector = ({ | |||
showLanguage: false, | |||
} | |||
); | |||
const [showAdvancedOptions, setShowAdvancedOptions] = useState<boolean>(true); |
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.
Not wrong, but we don't typically pass a type if TS can infer it.
// const isCustomProgram = state.templateType === "custom" && state.type !== "dataSets"; | ||
// const populate = isCustomProgram && filterOrgUnits; | ||
// setState(state => ({ ...state, populate })); | ||
// clearPopulateDates(); |
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.
Typically, commented code should be simply removed, we can use git to go back (We may do this for some temporal/testing code, but not in general)
{models.length > 1 && ( | ||
<Section | ||
title={<h3 className={classes.title}>{i18n.t("Template")}</h3>} | ||
classProps={{ section: classes.section }} |
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.
[immutable props] I think we can simply pass "classes" here (unless we really don't want to pass the other keys that Section uses (header?). If that's the case, we can use useMemo to build the object. We would be using useMemo not because it's a costly operation, but to keep the value/prop immutable.
label={i18n.t("Split data entry tabs by section")} | ||
/> | ||
)} | ||
|
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.
[not to change] The return JSX expression of this component is huuuge (608-294 lines). That's not your fault, you are just moving already existing parts. So this is a note for the future: whenever a component grows too much, let's abstract conceptual units and create new components. But again, it does not make sense to do it now (it's more fitting for a general refactoring/polishing task)
elevation = 1, | ||
iconPos = "right", | ||
classProps = {}, | ||
arrowStyle = "upDown", |
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.
About the expand/collapse styles, I checked what DHIS2 does, and... it depends:
orgUnits tree (icon: left the name): right/down
maps (icon: top-right): up/down
https://play.im.dhis2.org/stable-2-40-6/dhis-web-maps/#/GlCLRPPLsWF
I have no strong opinion on this, so PM to decide.
- update section classProps to more specific classNames - update arrowStyle. Add down_right
…om/EyeSeeTea/Bulk-Load into feature/download-template-redesign
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.
Just some minor details and we're good to go.
Run yarn localize
before a push, to check if there are changes on the i18n files (and the commit then, ofc). There are some changes, I think.
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.
All good! Just added a commit for some useMemo and a comment about i18.
msgstr "<Sin valor>" | ||
#, fuzzy | ||
msgid "Populate" | ||
msgstr "Plantilla" |
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 typically check fuzzy tags in PO files (gettext adds them, meaning: "I think this is the translation for a new literal I found, which is very similar to another existing, but I am not sure"). We review if correct and the remove the line "#, fuzzy".
BUT, as all the po files already contain fuzzy tags (a lot), you may leave this task to another "cleaning" PR, not in this feature. Confirm with your PM.
@@ -286,14 +285,11 @@ export const TemplateSelector = ({ | |||
const showPopulate = !(state.templateType === "custom" && !settings.showPopulateInCustomForms); | |||
const selected = state.id && state.templateId ? getOptionValue({ id: state.id, templateId: state.templateId }) : ""; | |||
|
|||
const subSectionClasses = useMemo(() => ({ sectionHeader: classes.subSectionHeader, sectionPaper: classes.subSection }), [classes]); | |||
const subSectionClasses = { sectionHeader: classes.subSectionHeader, sectionPaper: classes.subSection }; |
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.
[ALREADY COMMITED] But here we do need useMemo to keep it immutable, as it's an object directly passed as a prop (string, numbers, booleans, null, undefined are directly comparable, array/objects/pretty much everything else, not)
📌 References
📝 Implementation
filterOrgUnits
logic. Remove clearing of populate, populate dates, and selectedOrgUnits (more notes in reviewers section)🔥 Notes for the reviewer
📹 Screenshots/Screen capture
📑 Others