Skip to content
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

Merged
merged 23 commits into from Dec 12, 2019

Conversation

DJankauskas
Copy link
Member

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.

export const MediumDialog: React.FC<IProps> = ({ open, onClose, initialData, isFeatured }) => {
const styles = useStyles();

const [title, setTitle] = React.useState(initialData?.title ?? "");

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.

Copy link
Member Author

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 }) => {

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?

Copy link
Member Author

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

@DJankauskas DJankauskas merged commit 586f569 into stuyspec:master Dec 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants