Skip to content

Commit

Permalink
feat: Comment on project updates notification (#528)
Browse files Browse the repository at this point in the history
* feat: comment on project updates notifications

* zh i18n

* fix: i18n

---------

Signed-off-by: ncomerci <[email protected]>
  • Loading branch information
ncomerci committed Apr 8, 2024
1 parent 35c5ea8 commit 80fa55a
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React from 'react'

import NotificationItem from '../../NotificationItem'
import {
CommonNotificationProps,
GovernanceNewCommentOnProjectUpdateNotification
} from '../../types'
import NewCommentIcon from '../../../Icons/Notifications/NewCommentIcon'

const i18N = {
en: {
description: (link: string): React.ReactNode => (
<>
Engage in a productive conversation by replying to{' '}
<a href={link} className="dcl notification-link">
this comment
</a>
.
</>
),
title: 'New comment on your update for your project'
},
es: {
description: (link: string): React.ReactNode => (
<>
Participe en una conversación productiva respondiendo a{' '}
<a href={link} className="dcl notification-link">
este comentario
</a>
.
</>
),
title: 'Nuevo comentario en la actualización del proyecto'
},
zh: {
description: (link: string): React.ReactNode => (
<>
<a href={link} className="dcl notification-link">
通过回复此评论
</a>
,参与到富有成效的对话中。
</>
),
title: '您的更新收到了新评论'
}
}

const GovernanceNewCommentOnProjectUpdateNotification = ({
notification,
locale
}: CommonNotificationProps<GovernanceNewCommentOnProjectUpdateNotification>) => (
<NotificationItem
image={{ image: <NewCommentIcon height="48" width="48" /> }}
timestamp={notification.timestamp}
isNew={!notification.read}
locale={locale}
>
<p className="dcl notification-item__content-title">
{i18N[locale].title}{' '}
<span className="dcl notification-text-highlighted">
{notification.metadata.proposalTitle}
</span>
</p>
<p className="dcl notification-item__content-description">
{i18N[locale].description(notification.metadata.link)}
</p>
</NotificationItem>
)

export default GovernanceNewCommentOnProjectUpdateNotification
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const i18N = {
.
</>
),
title: 'Nuevo comentation en tu propuesta'
title: 'Nuevo comentario en tu propuesta'
},
zh: {
description: (link: string): React.ReactNode => (
Expand Down
2 changes: 2 additions & 0 deletions src/components/Notifications/NotificationTypes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import GovernanceAnnouncementNotification from './Governance/GovernanceAnnouncem
import GovernanceAuthoredProposalFinishedNotification from './Governance/GovernanceAuthoredProposalFinishedNotification'
import GovernanceCoauthorRequestedNotification from './Governance/GovernanceCoauthorRequestedNotification'
import GovernanceNewCommentOnProposalNotification from './Governance/GovernanceNewCommentOnProposalNotification'
import GovernanceNewCommentOnProjectUpdateNotification from './Governance/GovernanceNewCommentOnProjectUpdateNotification'
import GovernanceProposalEnactedNotification from './Governance/GovernanceProposalEnactedNotification'
import GovernanceVotingEndedVoterNotification from './Governance/GovernanceVotingEndedVoterNotification'
import LandRentedNotification from './Land/LandRentedNotification'
Expand All @@ -29,6 +30,7 @@ export {
GovernanceAuthoredProposalFinishedNotification,
GovernanceCoauthorRequestedNotification,
GovernanceNewCommentOnProposalNotification,
GovernanceNewCommentOnProjectUpdateNotification,
GovernanceProposalEnactedNotification,
GovernanceVotingEndedVoterNotification,
LandRentalEndedNotification,
Expand Down
20 changes: 20 additions & 0 deletions src/components/Notifications/Notifications.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import GovernanceAnnouncementNotification from './NotificationTypes/Governance/G
import GovernanceAuthoredProposalFinishedNotification from './NotificationTypes/Governance/GovernanceAuthoredProposalFinishedNotification'
import GovernanceCoauthorRequestedNotification from './NotificationTypes/Governance/GovernanceCoauthorRequestedNotification'
import GovernanceNewCommentOnProposalNotification from './NotificationTypes/Governance/GovernanceNewCommentOnProposalNotification'
import GovernanceNewCommentOnProjectUpdateNotification from './NotificationTypes/Governance/GovernanceNewCommentOnProjectUpdateNotification'
import GovernanceVotingEndedVoterNotification from './NotificationTypes/Governance/GovernanceVotingEndedVoterNotification'
import GovernanceProposalEnactedNotification from './NotificationTypes/Governance/GovernanceProposalEnactedNotification'
import {
Expand Down Expand Up @@ -441,6 +442,25 @@ storiesOf('Notifications Toggle', module)
updated_at: '2023-11-29T12:51:00.600Z'
}}
/>
<GovernanceNewCommentOnProjectUpdateNotification
locale="en"
notification={{
id: 'AA',
read: true,
type: DecentralandNotificationType.GOVERNANCE_NEW_COMMENT_ON_PROJECT_UPDATE,
address: '0xA',
timestamp: new Date().getTime(),
metadata: {
link: 'https://decentraland.org/governance',
title: 'Test Governance Announcement',
description: 'Test description',
proposalId: 'AAA_PROPOSAL_111',
proposalTitle: 'Open Source all code using DAO funds'
},
created_at: '2023-11-29T12:51:00.600Z',
updated_at: '2023-11-29T12:51:00.600Z'
}}
/>
<GovernanceProposalEnactedNotification
locale="en"
notification={{
Expand Down
7 changes: 7 additions & 0 deletions src/components/Notifications/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export enum DecentralandNotificationType {
GOVERNANCE_AUTHORED_PROPOSAL_FINISHED = 'governance_authored_proposal_finished',
GOVERNANCE_VOTING_ENDED_VOTER = 'governance_voting_ended_voter',
GOVERNANCE_NEW_COMMENT_ON_PROPOSAL = 'governance_new_comment_on_proposal',
GOVERNANCE_NEW_COMMENT_ON_PROJECT_UPDATE = 'governance_new_comment_on_project_update',
WORLDS_MISSING_RESOURCES = 'worlds_missing_resources',
WORLDS_ACCESS_RESTRICTED = 'worlds_access_restricted',
WORLDS_ACCESS_RESTORED = 'worlds_access_restored',
Expand Down Expand Up @@ -134,6 +135,11 @@ export type GovernanceNewCommentOnProposalNotification =
DecentralandNotificationType.GOVERNANCE_NEW_COMMENT_ON_PROPOSAL,
CommonGovernanceNotificationMetadata
>
export type GovernanceNewCommentOnProjectUpdateNotification =
RawDecentralandNotification<
DecentralandNotificationType.GOVERNANCE_NEW_COMMENT_ON_PROJECT_UPDATE,
CommonGovernanceNotificationMetadata
>

type GovernanceNotifications =
| GovernanceAnnouncementNotification
Expand All @@ -142,6 +148,7 @@ type GovernanceNotifications =
| GovernanceAuthoredProposalFinishedNotification
| GovernanceVotingEndedVoterNotification
| GovernanceNewCommentOnProposalNotification
| GovernanceNewCommentOnProjectUpdateNotification

// Worlds Notifications

Expand Down
3 changes: 3 additions & 0 deletions src/components/Notifications/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
GovernanceAuthoredProposalFinishedNotification,
GovernanceCoauthorRequestedNotification,
GovernanceNewCommentOnProposalNotification,
GovernanceNewCommentOnProjectUpdateNotification,
GovernanceProposalEnactedNotification,
GovernanceVotingEndedVoterNotification,
ItemSoldNotification,
Expand Down Expand Up @@ -62,6 +63,8 @@ export const NotificationComponentByType: DecentralandNotificationComponentByTyp
GovernanceAuthoredProposalFinishedNotification,
[DecentralandNotificationType.GOVERNANCE_NEW_COMMENT_ON_PROPOSAL]:
GovernanceNewCommentOnProposalNotification,
[DecentralandNotificationType.GOVERNANCE_NEW_COMMENT_ON_PROJECT_UPDATE]:
GovernanceNewCommentOnProjectUpdateNotification,
[DecentralandNotificationType.GOVERNANCE_PROPOSAL_ENACTED]:
GovernanceProposalEnactedNotification,
[DecentralandNotificationType.GOVERNANCE_VOTING_ENDED_VOTER]:
Expand Down

0 comments on commit 80fa55a

Please sign in to comment.