@@ -17,11 +17,12 @@ import ButtonGroup from 'antd/lib/button/button-group';
1717import { ItemType } from 'antd/lib/menu/hooks/useItems' ;
1818import { AxiosError } from 'axios' ;
1919import classNames from 'classnames' ;
20- import { cloneDeep , toString } from 'lodash' ;
20+ import { cloneDeep , isEmpty , toString } from 'lodash' ;
2121import { useSnackbar } from 'notistack' ;
2222import { useCallback , useEffect , useMemo , useRef , useState } from 'react' ;
2323import { useTranslation } from 'react-i18next' ;
2424import { useNavigate } from 'react-router-dom' ;
25+ import { ReactComponent as IconAnnouncementsBlack } from '../../../assets/svg/announcements-black.svg' ;
2526import { ReactComponent as EditIcon } from '../../../assets/svg/edit-new.svg' ;
2627import { ReactComponent as DeleteIcon } from '../../../assets/svg/ic-delete.svg' ;
2728import { ReactComponent as VersionIcon } from '../../../assets/svg/ic-version.svg' ;
@@ -42,13 +43,15 @@ import {
4243 ChangeDescription ,
4344 DataProduct ,
4445} from '../../../generated/entity/domains/dataProduct' ;
46+ import { Thread } from '../../../generated/entity/feed/thread' ;
4547import { Operation } from '../../../generated/entity/policies/policy' ;
4648import { PageType } from '../../../generated/system/ui/page' ;
4749import { Style } from '../../../generated/type/tagLabel' ;
4850import { useCustomPages } from '../../../hooks/useCustomPages' ;
4951import { useFqn } from '../../../hooks/useFqn' ;
5052import { FeedCounts } from '../../../interface/feed.interface' ;
5153import { QueryFilterInterface } from '../../../pages/ExplorePage/ExplorePage.interface' ;
54+ import { getActiveAnnouncement } from '../../../rest/feedsAPI' ;
5255import { searchQuery } from '../../../rest/searchAPI' ;
5356import {
5457 getEntityDeleteMessage ,
@@ -63,7 +66,7 @@ import dataProductClassBase from '../../../utils/DataProduct/DataProductClassBas
6366import { getDomainContainerStyles } from '../../../utils/DomainPageStyles' ;
6467import { getQueryFilterToIncludeDomain } from '../../../utils/DomainUtils' ;
6568import entityUtilClassBase from '../../../utils/EntityUtilClassBase' ;
66- import { getEntityName } from '../../../utils/EntityUtils' ;
69+ import { getEntityFeedLink , getEntityName } from '../../../utils/EntityUtils' ;
6770import { getEntityVersionByField } from '../../../utils/EntityVersionUtils' ;
6871import { showNotistackError } from '../../../utils/NotistackUtils' ;
6972import {
@@ -81,6 +84,8 @@ import type { BreadcrumbItem } from '../../common/atoms/navigation/useBreadcrumb
8184import { useBreadcrumbs } from '../../common/atoms/navigation/useBreadcrumbs' ;
8285import { CoverImage } from '../../common/CoverImage/CoverImage.component' ;
8386import { EntityAvatar } from '../../common/EntityAvatar/EntityAvatar' ;
87+ import AnnouncementCard from '../../common/EntityPageInfos/AnnouncementCard/AnnouncementCard' ;
88+ import AnnouncementDrawer from '../../common/EntityPageInfos/AnnouncementDrawer/AnnouncementDrawer' ;
8489import { AlignRightIconButton } from '../../common/IconButtons/EditIconButton' ;
8590import Loader from '../../common/Loader/Loader' ;
8691import { ManageButtonItemLabel } from '../../common/ManageButtonContentItem/ManageButtonContentItem.component' ;
@@ -136,6 +141,9 @@ const DataProductsDetailsPage = ({
136141 const [ feedCount , setFeedCount ] = useState < FeedCounts > (
137142 FEED_COUNT_INITIAL_DATA
138143 ) ;
144+ const [ isAnnouncementDrawerOpen , setIsAnnouncementDrawerOpen ] =
145+ useState < boolean > ( false ) ;
146+ const [ activeAnnouncement , setActiveAnnouncement ] = useState < Thread > ( ) ;
139147
140148 const handleFeedCount = useCallback ( ( data : FeedCounts ) => {
141149 setFeedCount ( data ) ;
@@ -157,6 +165,36 @@ const DataProductsDetailsPage = ({
157165 setIsAssetDrawerOpen ( false ) ;
158166 } , [ ] ) ;
159167
168+ const fetchActiveAnnouncement = async ( ) => {
169+ try {
170+ const announcements = await getActiveAnnouncement (
171+ getEntityFeedLink (
172+ EntityType . DATA_PRODUCT ,
173+ dataProduct . fullyQualifiedName ?? ''
174+ )
175+ ) ;
176+ if ( ! isEmpty ( announcements . data ) ) {
177+ setActiveAnnouncement ( announcements . data [ 0 ] ) ;
178+ } else {
179+ setActiveAnnouncement ( undefined ) ;
180+ }
181+ } catch ( error ) {
182+ showNotistackError ( enqueueSnackbar , error as AxiosError , undefined , {
183+ vertical : 'top' ,
184+ horizontal : 'center' ,
185+ } ) ;
186+ }
187+ } ;
188+
189+ const handleOpenAnnouncementDrawer = ( ) => {
190+ setIsAnnouncementDrawerOpen ( true ) ;
191+ } ;
192+
193+ const handleCloseAnnouncementDrawer = ( ) => {
194+ setIsAnnouncementDrawerOpen ( false ) ;
195+ fetchActiveAnnouncement ( ) ;
196+ } ;
197+
160198 const breadcrumbItems = useMemo < BreadcrumbItem [ ] > ( ( ) => {
161199 const items : BreadcrumbItem [ ] = [ ] ;
162200
@@ -278,6 +316,26 @@ const DataProductsDetailsPage = ({
278316 } , [ dataProduct , enqueueSnackbar ] ) ;
279317
280318 const manageButtonContent : ItemType [ ] = [
319+ ...( editAllPermission
320+ ? ( [
321+ {
322+ label : (
323+ < ManageButtonItemLabel
324+ description = { t ( 'message.announcement-action-description' ) }
325+ icon = { IconAnnouncementsBlack }
326+ id = "announcement-button"
327+ name = { t ( 'label.announcement-plural' ) }
328+ />
329+ ) ,
330+ key : 'announcement-button' ,
331+ onClick : ( e ) => {
332+ e . domEvent . stopPropagation ( ) ;
333+ handleOpenAnnouncementDrawer ( ) ;
334+ setShowActions ( false ) ;
335+ } ,
336+ } ,
337+ ] as ItemType [ ] )
338+ : [ ] ) ,
281339 ...( editDisplayNamePermission
282340 ? ( [
283341 {
@@ -488,6 +546,7 @@ const DataProductsDetailsPage = ({
488546 fetchDataProductPermission ( ) ;
489547 fetchDataProductAssets ( ) ;
490548 getEntityFeedCount ( ) ;
549+ fetchActiveAnnouncement ( ) ;
491550 } , [ dataProductFqn ] ) ;
492551
493552 const toggleTabExpanded = ( ) => {
@@ -569,12 +628,13 @@ const DataProductsDetailsPage = ({
569628 titleColor = { dataProduct . style ?. color }
570629 />
571630 </ Box >
572- < Box sx = { { width : '320px' } } >
631+ < Box >
573632 < Box
574633 sx = { {
575634 display : 'flex' ,
576635 gap : 3 ,
577636 justifyContent : 'flex-end' ,
637+ alignItems : 'center' ,
578638 pb : '4px' ,
579639 } } >
580640 { ! isVersionsView && dataProductPermission . Create && (
@@ -646,6 +706,13 @@ const DataProductsDetailsPage = ({
646706 </ Dropdown >
647707 ) }
648708 </ ButtonGroup >
709+
710+ { activeAnnouncement && (
711+ < AnnouncementCard
712+ announcement = { activeAnnouncement }
713+ onClick = { handleOpenAnnouncementDrawer }
714+ />
715+ ) }
649716 </ Box >
650717 </ Box >
651718 </ Box >
@@ -737,6 +804,15 @@ const DataProductsDetailsPage = ({
737804 onCancel = { ( ) => setIsStyleEditing ( false ) }
738805 onSubmit = { onStyleSave }
739806 />
807+
808+ < AnnouncementDrawer
809+ showToastInSnackbar
810+ createPermission = { editAllPermission }
811+ entityFQN = { dataProduct . fullyQualifiedName ?? '' }
812+ entityType = { EntityType . DATA_PRODUCT }
813+ open = { isAnnouncementDrawerOpen }
814+ onClose = { handleCloseAnnouncementDrawer }
815+ />
740816 </ >
741817 ) ;
742818
0 commit comments