From bd24cf2a05ddae2191cd3ec07b62ee6b8f0bc668 Mon Sep 17 00:00:00 2001 From: Nick Taylor Date: Tue, 18 Feb 2020 09:09:50 -0500 Subject: [PATCH] Updates/adds to prop-types for homepage feed makeover. (#6128) --- .../common-prop-types/article-prop-types.js | 42 +++++++++++++++++++ .../src/components/common-prop-types/index.js | 1 + .../organization-prop-type.js | 2 + 3 files changed, 45 insertions(+) create mode 100644 app/javascript/src/components/common-prop-types/article-prop-types.js diff --git a/app/javascript/src/components/common-prop-types/article-prop-types.js b/app/javascript/src/components/common-prop-types/article-prop-types.js new file mode 100644 index 000000000..45f30e5aa --- /dev/null +++ b/app/javascript/src/components/common-prop-types/article-prop-types.js @@ -0,0 +1,42 @@ +import PropTypes from 'prop-types'; +import { tagPropTypes } from './tag-prop-types'; +import { organizationPropType } from './organization-prop-type'; + +export const articleSnippetResultPropTypes = PropTypes.shape({ + body_text: PropTypes.shape({ + matchLevel: PropTypes.oneOf(['full', 'none']), + value: PropTypes.string.isRequired, + }), + comments_blob: PropTypes.shape({ + matchLevel: PropTypes.oneOf(['full', 'none']), + value: PropTypes.string.isRequired, + }), +}); + +export const articlePropTypes = PropTypes.shape({ + id: PropTypes.number.isRequired, + title: PropTypes.string.isRequired, + path: PropTypes.string.isRequired, + cloudinary_video_url: PropTypes.string, + video_duration_in_minutes: PropTypes.number, + type_of: PropTypes.oneOf(['podcast_episodes']), + class_name: PropTypes.oneOf(['PodcastEpisode', 'User', 'Article']), + flare_tag: tagPropTypes, + tag_list: PropTypes.arrayOf(PropTypes.string), + cached_tag_list_array: PropTypes.arrayOf(PropTypes.string), + podcast: PropTypes.shape({ + slug: PropTypes.string.isRequired, + title: PropTypes.string.isRequired, + image_url: PropTypes.string.isRequired, + }), + user_id: PropTypes.string.isRequired, + user: PropTypes.shape({ + username: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + }), + organization: organizationPropType, + _snippetResult: articleSnippetResultPropTypes, + positive_reactions_count: PropTypes.number, + reactions_count: PropTypes.number, + comments_count: PropTypes.number, +}); diff --git a/app/javascript/src/components/common-prop-types/index.js b/app/javascript/src/components/common-prop-types/index.js index eb60f0fef..985b54ea2 100644 --- a/app/javascript/src/components/common-prop-types/index.js +++ b/app/javascript/src/components/common-prop-types/index.js @@ -2,3 +2,4 @@ export * from './user-prop-types'; export * from './default-children-prop-types'; export * from './organization-prop-type'; export * from './tag-prop-types'; +export * from './article-prop-types'; diff --git a/app/javascript/src/components/common-prop-types/organization-prop-type.js b/app/javascript/src/components/common-prop-types/organization-prop-type.js index 84b7dab86..ca5f2afce 100644 --- a/app/javascript/src/components/common-prop-types/organization-prop-type.js +++ b/app/javascript/src/components/common-prop-types/organization-prop-type.js @@ -3,4 +3,6 @@ import PropTypes from 'prop-types'; export const organizationPropType = PropTypes.shape({ id: PropTypes.number.isRequired, name: PropTypes.string.isRequired, + slug: PropTypes.string.isRequired, + profile_image_90: PropTypes.string.isRequired, });