From 1dda5b4058d6dbc5997244e1f16d35ad594e0cbb Mon Sep 17 00:00:00 2001 From: Suzanne Aitchison Date: Wed, 10 Nov 2021 13:47:55 +0000 Subject: [PATCH] fix some prop type errors on the home page (#15314) --- app/javascript/articles/components/Meta.jsx | 12 +++++++----- .../common-prop-types/article-prop-types.js | 7 +++++-- app/javascript/common-prop-types/index.js | 1 - .../common-prop-types/organization-prop-type.js | 8 -------- app/javascript/leftSidebar/TagsFollowed.jsx | 17 +++++++---------- .../organization/OrganizationPicker.jsx | 8 ++++++-- 6 files changed, 25 insertions(+), 28 deletions(-) delete mode 100644 app/javascript/common-prop-types/organization-prop-type.js diff --git a/app/javascript/articles/components/Meta.jsx b/app/javascript/articles/components/Meta.jsx index ad675c0f3..225f6e4ec 100644 --- a/app/javascript/articles/components/Meta.jsx +++ b/app/javascript/articles/components/Meta.jsx @@ -1,8 +1,6 @@ import { h } from 'preact'; -import { - articlePropTypes, - organizationPropType, -} from '../../common-prop-types'; +import PropTypes from 'prop-types'; +import { articlePropTypes } from '../../common-prop-types'; import { MinimalProfilePreviewCard } from '../../profilePreviewCards/MinimalProfilePreviewCard'; import { PublishDate } from './PublishDate'; @@ -97,7 +95,11 @@ Meta.defaultProps = { Meta.propTypes = { article: articlePropTypes.isRequired, - organization: organizationPropType, + organization: PropTypes.shape({ + name: PropTypes.string.isRequired, + profile_image_90: PropTypes.string.isRequired, + slug: PropTypes.string.isRequired, + }), }; Meta.displayName = 'Meta'; diff --git a/app/javascript/common-prop-types/article-prop-types.js b/app/javascript/common-prop-types/article-prop-types.js index 528430db1..4642b9bbd 100644 --- a/app/javascript/common-prop-types/article-prop-types.js +++ b/app/javascript/common-prop-types/article-prop-types.js @@ -1,5 +1,4 @@ import PropTypes from 'prop-types'; -import { organizationPropType } from './organization-prop-type'; export const articleSnippetResultPropTypes = PropTypes.shape({ body_text: PropTypes.arrayOf(PropTypes.string), @@ -30,7 +29,11 @@ export const articlePropTypes = PropTypes.shape({ username: PropTypes.string.isRequired, name: PropTypes.string.isRequired, }), - organization: organizationPropType, + organization: PropTypes.shape({ + name: PropTypes.string.isRequired, + profile_image_90: PropTypes.string.isRequired, + slug: PropTypes.string.isRequired, + }), highlight: articleSnippetResultPropTypes, public_reactions_count: PropTypes.number, reactions_count: PropTypes.number, diff --git a/app/javascript/common-prop-types/index.js b/app/javascript/common-prop-types/index.js index 8589579af..811c881bf 100644 --- a/app/javascript/common-prop-types/index.js +++ b/app/javascript/common-prop-types/index.js @@ -1,5 +1,4 @@ export * from './user-prop-types'; export * from './default-children-prop-types'; -export * from './organization-prop-type'; export * from './article-prop-types'; export * from './selected-tags-prop-types'; diff --git a/app/javascript/common-prop-types/organization-prop-type.js b/app/javascript/common-prop-types/organization-prop-type.js deleted file mode 100644 index ca5f2afce..000000000 --- a/app/javascript/common-prop-types/organization-prop-type.js +++ /dev/null @@ -1,8 +0,0 @@ -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, -}); diff --git a/app/javascript/leftSidebar/TagsFollowed.jsx b/app/javascript/leftSidebar/TagsFollowed.jsx index e99602c60..a4ef21986 100644 --- a/app/javascript/leftSidebar/TagsFollowed.jsx +++ b/app/javascript/leftSidebar/TagsFollowed.jsx @@ -10,20 +10,20 @@ export const TagsFollowed = ({ tags = [] }) => { return ( - {tags.map((tag) => - tag.points >= 1 ? ( + {tags.map(({ name, id, points }) => + points >= 1 ? ( ) : null, @@ -38,10 +38,7 @@ TagsFollowed.propTypes = { PropTypes.shape({ id: PropTypes.number.isRequired, name: PropTypes.string.isRequired, - hotness_score: PropTypes.number.isRequired, points: PropTypes.number.isRequired, - bg_color_hex: PropTypes.string.isRequired, - text_color_hex: PropTypes.string.isRequired, }), ), }; diff --git a/app/javascript/organization/OrganizationPicker.jsx b/app/javascript/organization/OrganizationPicker.jsx index 3bfdc1aec..98cee03ec 100644 --- a/app/javascript/organization/OrganizationPicker.jsx +++ b/app/javascript/organization/OrganizationPicker.jsx @@ -1,6 +1,5 @@ import { h } from 'preact'; import PropTypes from 'prop-types'; -import { organizationPropType } from '../common-prop-types'; const orgOptions = (organizations, organizationId, emptyLabel) => { const orgs = organizations.map((organization) => { @@ -60,5 +59,10 @@ OrganizationPicker.propTypes = { emptyLabel: PropTypes.string, onToggle: PropTypes.func.isRequired, organizationId: PropTypes.number.isRequired, - organizations: PropTypes.arrayOf(organizationPropType).isRequired, + organizations: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.isRequired, + name: PropTypes.string.isRequired, + }), + ).isRequired, };