-
Notifications
You must be signed in to change notification settings - Fork 37
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
refactor/interpretations component [DHIS2-5470] #370
Conversation
…leCard, replace Link text with InterpretationIcons, exporting Icons through misc.js, adding styles into styles file
… and Interpretations.js
…nd CommentTextArea.js, adding styles folder for components within interpretations/ folder. adding style file for CommentTextArea
…js wrapped with withStyles, removing unused className rules, adding PropType classes
… file for InterpretationComments.js changin in-line style to className, exporting and wrapping Component in withStyles
…='md' and will recieve rules from d2-ui-theme
…-line to classNames, adding PropTypes
….js in withStyles, adding style file
…sing style has its separate one
… all children in the same div
…ex all throughout the whole row
…ggestion, removing unnecesarry divs, replacing with fragments
…ncrease available space and mirror original interpretation structure
…r than 24 hours old, rendering specific date if evaluation returns true
…inor styling changes
… renders the tooltip above the icon when there's only 1 valid action rendered, minor adjustments after linking package locally and testing in DV
…ck-suggestion (momentarily) add new file NewInterpretation.js with boilerplate to replace the interpretation dialog that covers the whole screen, in order to not block the data you want to interpret
…ion.js instead of dialog
…lacing interpretations dialog, additional re-factoring
//TODO length > 5 && showPreviousComments | ||
// "Show previous comments ( x of < interpretations.length - rendered comments> )" | ||
return ( | ||
interpretations.length ? ( |
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.
Doesn't seem like this check is necessary, since interpretations.length was already checked on line 16
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 file is not complete, the TODO comment might not be that clear as well. Currently i have a early return if there's no interpretation.
If there's more than 5 interpretations (lets say 15 of them), the component will mount with 10 hidden interpretations (with a "show previous comments" button), and render the 5 newest (mirroring the facebook/other social media behavior)
this.props.onClose(); | ||
}); | ||
|
||
_saveInterpretation() { |
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.
What does the leading "_" indicate?
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.
Most of this file is copy pasted from InterpretationsDialog, i assume the underscore indicates that this function performs a network request.
I'll change the name to postInterpretation
instead.
@@ -0,0 +1,38 @@ | |||
export const styles = theme => ({ |
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.
mispelled filename:
CollapsibelCard -> CollapsibleCard
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.
Corrected filename and import name of CollapsibleCard.
expandOpen: { | ||
transform: 'rotate(180deg)', | ||
}, | ||
}); |
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.
Could you fix the missing newline on all the files?
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.
Added newline on all the .style files. Checked the .style files in DV and I cant say that we are normally doing this, but the lines do get more clear. I think eslint/prettier removes it with the message "remove unnecessary newline"
import i18n from '@dhis2/d2-i18n'; | ||
import SharingDialog from '@dhis2/d2-ui-sharing-dialog'; | ||
import { withStyles } from '@material-ui/core/styles'; | ||
import some from 'lodash/fp/some'; | ||
import InterpretationComments from './InterpretationComments'; | ||
import InterpretationDialog from './InterpretationDialog'; |
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.
InterpretationDialog file has been deleted.
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've re-created that file and added it back. I assume the symlink were still present and pointed to the inode which resided in my trash folder, so i didnt get any errors.
this.state = { tooltipIsOpen: false }; | ||
} | ||
|
||
componentWillUnmount() { |
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.
Seems to be some alignment issues in this file?
onCurrentInterpretationChange={onCurrentInterpretationChange} | ||
/> | ||
</div> | ||
<MuiThemeProvider muiTheme={getMuiTheme()}> |
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.
What happens if we don't include this Provider?
@@ -60,7 +60,7 @@ export class Details extends React.Component { | |||
const SubscriptionButton = this.renderSubscriptionButton(); | |||
|
|||
return ( | |||
<CollapsibleCard title={i18n.t('Favorite details')}> | |||
<CollapsibleCard title={i18n.t('Chart details')}> |
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 won't always be a chart. Is it possible to pass in the type (Map, Pivot table, chart...), or maybe it should just say "Details"? (double check with Joe).
…/interpretations-component
…ew interpretation when new model is loaded
…currentUser and pass to access validation checks
This PR includes refactoring of the interpretations component, changes:
Added d2 as context on all components requiring access to the object, instead of passing it down as props. I've also removed imports on helper functions / models and are passing it through th fn parameter.
Added RichText and RichTextParser wrapper to the textareas.
Added Cancel Button permanently instead of only when editing an existing one.
Removed the InterpretationsDialog, instead the textarea is rendered at the bottom of the panel.
Reduced the renderfunctions by creating
renderX
fn.Removed the
misc.js
file andutils/
folder and created folders for each function (So it wont become a dumping ground for all sorts of "generic" fn's / components.I have removed the maxWidth on CollapsibleCard and added
flex: '1 1 100%
to the root container such that the component can use the available space in DV / Maps / Dashboard.The Date, Likes and replies are rendered below the text of the interpretation/comment card.
If the created date is more than 24 hours old, the formatted relative date will be rendered instead of "x days/months/years ago".
Removed some unused code.
Re-structured/ Moved some test cases to new components that i have created.
Added Read/Write checks for interpretations.
Added prop Item and appName for the dashboard, in order to render the redirect button.
Added InputFields instead of Dialogs for original interpretations.
Added Toolbar with markdown functionality.
I did not put in the (edited) label, since the
lastUpdated
value changes when a user replies to the interpretation, or if the sharing properties are changed. Meaning that the (edited) label will eventually appear and might confuse the user (as it was supposed to indicate whether or not the specific text have been changed).Bold / Italic is reset by the UI component in the new DV (I spoke with Viktor and he informed me that this component will be removed in the next release)
Quick Summary of the render structure:
InterpretationsCard:
InterpretationsList:
Interpretation:
ActionButtonContainer:
ActionButton / Likes / Replies:
CommentsList:
Comment:
NewInterpretationField/NewCommentField:
Toolbar: