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
[student-libraries] Refactor the library creation dialog in preparation for adding 'unpublish' functionality #32792
Conversation
} | ||
return ( | ||
<div> | ||
<p style={styles.alert}>{errorMessage}</p> |
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 looks like this will be rendered even when there is not error message?
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.
✔️
libraryDescription | ||
); | ||
|
||
// TODO: Display final version of error and success messages to the user. |
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.
Is there anything left to do related to this TODO?
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.
✔️
class LibraryCreationDialog extends React.Component { | ||
static propTypes = { | ||
libraryClientApi: PropTypes.object.isRequired, | ||
|
||
// From Redux |
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.
🎆
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.
✔️
return <div>{errorMessage}</div>; | ||
}; | ||
render() { | ||
const {message} = this.props; |
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.
Nit: do these need to be two different lines?
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.
No, they don't - It seems like it's becoming good practice to do it this way (although certainly not necessary in this case).
Couple examples of this pattern:
https://towardsdatascience.com/react-best-practices-804def6d5215
https://brewhouse.io/blog/2015/03/24/best-practices-for-component-state-in-reactjs.html
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!
unit tests passed: https://drone.cdn-code.org/code-dot-org/code-dot-org/9416/ |
bodyContent = <ErrorDisplay message={i18n.libraryNoFunctionsError()} />; | ||
break; | ||
default: | ||
bodyContent = this.displayContent(); |
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 seems kind of weird to be using the default case as a legitimate/common case. Would it make sense to add a DialogState
to cover this case (so that the options of DialogState actually exhaustively cover the cases, and the default case of this switch statement would catch if we like, add a new DialogState or something like that?)
|
||
displayLoadingState = () => { | ||
export class LoadingDisplay extends React.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.
Could some of these be pure functional components instead of classes? https://towardsdatascience.com/react-best-practices-804def6d5215
This splits the LibraryCreationDialog into three parts
Background
Unpublish will add significant functionality to the library creation dialog. It will allow users to unpublish their library. It will also allow us to detect if a library has already been created, and, if it has, to merge the existing metadata into the library.
Testing story
Updated old tests
Reviewer Checklist: