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/temp image upload #24
Feature/temp image upload #24
Conversation
This reverts commit d6cfed6.
export const MediumDialog: React.FC<IProps> = ({ open, onClose, initialData, isFeatured }) => { | ||
const styles = useStyles(); | ||
|
||
const [title, setTitle] = React.useState(initialData?.title ?? ""); |
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.
Okay...so this is where I'd use a useReducer
as your state is pretty complicated.
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 don't think that would be a benefit though. If TS had Rust/Haskell style sum types I'd go for it, but this is simpler than a reducer imo
isFeatured: boolean | ||
} | ||
|
||
export const MediumDialog: React.FC<IProps> = ({ open, onClose, initialData, isFeatured }) => { |
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 component feels a little complicated. Plus is it a MediumDialog
if it also includes a form?
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 is complicated, but not sure how I'd make it better. It's all one problem. I'd say it is a dialog as although the meat is a form, it's displayed as a dialog, and that's consistent with my naming scheme in the project
This rather bloated PR adds support for media upload to the stuyspec website. This is done via an extension of the article-extension model: now, each article extension can have an optional media field in addition to props, which stores a json-encoded array of medium ids the component will render. Within the CMS, a Medium upload dialog can create a medium, which will then be attached to the article on upload or edit.
TODO: media that are subsequently removed from the article are still attached to the article type on uploading. Currently not an important issue but needs fixing.