Skip to content

Commit

Permalink
Merge pull request #247 from thematters/feature/collection-notice
Browse files Browse the repository at this point in the history
Add Collection notice supports
  • Loading branch information
robertu7 authored Apr 30, 2019
2 parents a63cdb8 + 4dbdff2 commit 49c9754
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 100 deletions.
133 changes: 34 additions & 99 deletions common/gql/fragmentTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,117 +5,52 @@
"kind": "INTERFACE",
"name": "Node",
"possibleTypes": [
{
"name": "Article"
},
{
"name": "User"
},
{
"name": "Tag"
},
{
"name": "Draft"
},
{
"name": "Comment"
}
{ "name": "Article" },
{ "name": "User" },
{ "name": "Tag" },
{ "name": "Draft" },
{ "name": "Comment" }
]
},
{
"kind": "INTERFACE",
"name": "Connection",
"possibleTypes": [
{
"name": "ArticleConnection"
},
{
"name": "TagConnection"
},
{
"name": "UserConnection"
},
{
"name": "DraftConnection"
},
{
"name": "AudiodraftConnection"
},
{
"name": "ReadHistoryConnection"
},
{
"name": "RecentSearchConnection"
},
{
"name": "TransactionConnection"
},
{
"name": "InvitationConnection"
},
{
"name": "NoticeConnection"
},
{
"name": "CommentConnection"
},
{
"name": "SearchResultConnection"
},
{
"name": "ReportConnection"
}
{ "name": "ArticleConnection" },
{ "name": "TagConnection" },
{ "name": "UserConnection" },
{ "name": "DraftConnection" },
{ "name": "AudiodraftConnection" },
{ "name": "ReadHistoryConnection" },
{ "name": "RecentSearchConnection" },
{ "name": "TransactionConnection" },
{ "name": "InvitationConnection" },
{ "name": "NoticeConnection" },
{ "name": "CommentConnection" },
{ "name": "SearchResultConnection" },
{ "name": "ReportConnection" }
]
},
{
"kind": "INTERFACE",
"name": "Notice",
"possibleTypes": [
{
"name": "UserNewFollowerNotice"
},
{
"name": "ArticlePublishedNotice"
},
{
"name": "ArticleNewDownstreamNotice"
},
{
"name": "ArticleNewAppreciationNotice"
},
{
"name": "ArticleNewSubscriberNotice"
},
{
"name": "ArticleNewCommentNotice"
},
{
"name": "ArticleMentionedYouNotice"
},
{
"name": "SubscribedArticleNewCommentNotice"
},
{
"name": "UpstreamArticleArchivedNotice"
},
{
"name": "DownstreamArticleArchivedNotice"
},
{
"name": "CommentPinnedNotice"
},
{
"name": "CommentNewReplyNotice"
},
{
"name": "CommentNewUpvoteNotice"
},
{
"name": "CommentMentionedYouNotice"
},
{
"name": "OfficialAnnouncementNotice"
}
{ "name": "UserNewFollowerNotice" },
{ "name": "ArticlePublishedNotice" },
{ "name": "ArticleNewDownstreamNotice" },
{ "name": "ArticleNewCollectedNotice" },
{ "name": "ArticleNewAppreciationNotice" },
{ "name": "ArticleNewSubscriberNotice" },
{ "name": "ArticleNewCommentNotice" },
{ "name": "ArticleMentionedYouNotice" },
{ "name": "SubscribedArticleNewCommentNotice" },
{ "name": "UpstreamArticleArchivedNotice" },
{ "name": "DownstreamArticleArchivedNotice" },
{ "name": "CommentPinnedNotice" },
{ "name": "CommentNewReplyNotice" },
{ "name": "CommentNewUpvoteNotice" },
{ "name": "CommentMentionedYouNotice" },
{ "name": "OfficialAnnouncementNotice" }
]
}
]
Expand Down
72 changes: 72 additions & 0 deletions components/NoticeDigest/ArticleNewCollectedNotice.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import classNames from 'classnames'
import gql from 'graphql-tag'

import { Translate } from '~/components'

import { ArticleNewCollectedNotice as NoticeType } from './__generated__/ArticleNewCollectedNotice'
import NoticeActorAvatar from './NoticeActorAvatar'
import NoticeActorName from './NoticeActorName'
import NoticeArticle from './NoticeArticle'
import NoticeDate from './NoticeDate'
import styles from './styles.css'

const ArticleNewCollectedNotice = ({ notice }: { notice: NoticeType }) => {
if (!notice || !notice.actor) {
return null
}

const avatarWrapClasses = classNames({
'avatar-wrap': true
})
console.log(notice)

return (
<section className="container">
<section className={avatarWrapClasses}>
<NoticeActorAvatar user={notice.actor} size={'default'} />
</section>

<section className="content-wrap">
<h4>
<Translate zh_hant="恭喜!你的大作" zh_hans="恭喜!你的大作" />{' '}
<NoticeArticle article={notice.target} />{' '}
<Translate zh_hant="已被" zh_hans="已被" />{' '}
<NoticeActorName user={notice.actor} />{' '}
<Translate zh_hant="在其作品" zh_hans="在其作品" />{' '}
<NoticeArticle article={notice.collection} />{' '}
<Translate zh_hant="中關聯推薦。" zh_hans="中关联推荐。" />
</h4>

<NoticeDate notice={notice} />
</section>
<style jsx>{styles}</style>
</section>
)
}

ArticleNewCollectedNotice.fragments = {
notice: gql`
fragment ArticleNewCollectedNotice on ArticleNewCollectedNotice {
id
unread
__typename
...NoticeDate
actor {
...NoticeActorAvatarUser
...NoticeActorNameUser
}
collection {
...NoticeArticle
}
target {
...NoticeArticle
}
}
${NoticeActorAvatar.fragments.user}
${NoticeActorName.fragments.user}
${NoticeArticle.fragments.article}
${NoticeDate.fragments.notice}
`
}

export default ArticleNewCollectedNotice
7 changes: 7 additions & 0 deletions components/NoticeDigest/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import gql from 'graphql-tag'
import { DigestNotice } from './__generated__/DigestNotice'
import ArticleMentionedYouNotice from './ArticleMentionedYouNotice'
import ArticleNewAppreciationNotice from './ArticleNewAppreciationNotice'
import ArticleNewCollectedNotice from './ArticleNewCollectedNotice'
import ArticleNewCommentNotice from './ArticleNewCommentNotice'
import ArticleNewDownstreamNotice from './ArticleNewDownstreamNotice'
import ArticleNewSubscriberNotice from './ArticleNewSubscriberNotice'
Expand All @@ -29,6 +30,9 @@ const fragments = {
... on ArticleNewDownstreamNotice {
...ArticleNewDownstreamNotice
}
... on ArticleNewCollectedNotice {
...ArticleNewCollectedNotice
}
... on ArticleNewAppreciationNotice {
...ArticleNewAppreciationNotice
}
Expand Down Expand Up @@ -69,6 +73,7 @@ const fragments = {
${ArticleNewAppreciationNotice.fragments.notice}
${ArticleNewCommentNotice.fragments.notice}
${ArticleNewDownstreamNotice.fragments.notice}
${ArticleNewCollectedNotice.fragments.notice}
${ArticleNewSubscriberNotice.fragments.notice}
${ArticlePublishedNotice.fragments.notice}
${ArticleMentionedYouNotice.fragments.notice}
Expand All @@ -92,6 +97,8 @@ const FeedDigest = ({ notice }: { notice: DigestNotice }) => {
return <ArticleNewCommentNotice notice={notice} />
case 'ArticleNewDownstreamNotice':
return <ArticleNewDownstreamNotice notice={notice} />
case 'ArticleNewCollectedNotice':
return <ArticleNewCollectedNotice notice={notice} />
case 'ArticleNewSubscriberNotice':
return <ArticleNewSubscriberNotice notice={notice} />
case 'ArticlePublishedNotice':
Expand Down
110 changes: 110 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5105,6 +5105,11 @@
"name": "ArticleNewDownstreamNotice",
"ofType": null
},
{
"kind": "OBJECT",
"name": "ArticleNewCollectedNotice",
"ofType": null
},
{
"kind": "OBJECT",
"name": "ArticleNewAppreciationNotice",
Expand Down Expand Up @@ -12683,6 +12688,111 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "ArticleNewCollectedNotice",
"description": "",
"fields": [
{
"name": "id",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "ID",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "unread",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "createdAt",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "DateTime",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "actor",
"description": "",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "User",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "collection",
"description": "",
"args": [],
"type": {
"kind": "OBJECT",
"name": "Article",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "target",
"description": "",
"args": [],
"type": {
"kind": "OBJECT",
"name": "Article",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
"interfaces": [
{
"kind": "INTERFACE",
"name": "Notice",
"ofType": null
}
],
"enumValues": null,
"possibleTypes": null
},
{
"kind": "OBJECT",
"name": "ArticleNewAppreciationNotice",
Expand Down
2 changes: 1 addition & 1 deletion views/ArticleDetail/Collection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ const CollectionEditingList = ({
window.dispatchEvent(
new CustomEvent('addToast', {
detail: {
color: 'white',
color: 'green',
content: translate({
zh_hant: '關聯已更新',
zh_hans: '关联已更新',
Expand Down

0 comments on commit 49c9754

Please sign in to comment.