[MM-61539] Removed duplicate draft icons when no scheduled posts exist and updated draft icon (#29218)

* Removed duplicate draft icons

* Added tooltip

* Restored drafts count icon
Этот коммит содержится в:
Harshil Sharma
2024-11-15 19:20:00 +05:30
коммит произвёл GitHub
родитель 679e8c1025
Коммит 11ac1f4d19
2 изменённых файлов: 55 добавлений и 18 удалений

Просмотреть файл

@@ -2,7 +2,7 @@
// See LICENSE.txt for license information. // See LICENSE.txt for license information.
import classNames from 'classnames'; import classNames from 'classnames';
import React, {memo, useEffect, useRef} from 'react'; import React, {memo, useEffect, useMemo, useRef} from 'react';
import {FormattedMessage} from 'react-intl'; import {FormattedMessage} from 'react-intl';
import {useSelector, useDispatch} from 'react-redux'; import {useSelector, useDispatch} from 'react-redux';
import {NavLink, useRouteMatch} from 'react-router-dom'; import {NavLink, useRouteMatch} from 'react-router-dom';
@@ -19,6 +19,7 @@ import {makeGetDraftsCount} from 'selectors/drafts';
import DraftsTourTip from 'components/drafts/drafts_link/drafts_tour_tip/drafts_tour_tip'; import DraftsTourTip from 'components/drafts/drafts_link/drafts_tour_tip/drafts_tour_tip';
import ChannelMentionBadge from 'components/sidebar/sidebar_channel/channel_mention_badge'; import ChannelMentionBadge from 'components/sidebar/sidebar_channel/channel_mention_badge';
import WithTooltip from 'components/with_tooltip';
import {SCHEDULED_POST_URL_SUFFIX} from 'utils/constants'; import {SCHEDULED_POST_URL_SUFFIX} from 'utils/constants';
@@ -81,6 +82,30 @@ function DraftsLink() {
initialScheduledPostsLoaded.current = true; initialScheduledPostsLoaded.current = true;
}, [dispatch, isScheduledPostEnabled, teamId]); }, [dispatch, isScheduledPostEnabled, teamId]);
const showScheduledPostCount = isScheduledPostEnabled && teamScheduledPostCount > 0;
const tooltipText = useMemo(() => {
const lineBreaks = (x: React.ReactNode) => {
if (draftCount > 0 && teamScheduledPostCount > 0) {
return (<><br/>{x}</>);
}
return null;
};
return (
<FormattedMessage
id='drafts.tooltipText'
defaultMessage=''
values={{
draftCount,
scheduledPostCount: teamScheduledPostCount,
br: lineBreaks,
}}
/>
);
}, [draftCount, teamScheduledPostCount]);
if (!itemsExist && !urlMatches) { if (!itemsExist && !urlMatches) {
return null; return null;
} }
@@ -100,7 +125,10 @@ function DraftsLink() {
className='SidebarLink sidebar-item' className='SidebarLink sidebar-item'
tabIndex={0} tabIndex={0}
> >
{pencilIcon} <i
data-testid='sendPostIcon'
className='icon icon-send-post icon-send'
/>
<div className='SidebarChannelLinkLabel_wrapper'> <div className='SidebarChannelLinkLabel_wrapper'>
<span className='SidebarChannelLinkLabel sidebar-item__name'> <span className='SidebarChannelLinkLabel sidebar-item__name'>
<FormattedMessage <FormattedMessage
@@ -109,6 +137,12 @@ function DraftsLink() {
/> />
</span> </span>
</div> </div>
<WithTooltip
placement='right'
id='draft-scheduled-post-tooltip'
title={tooltipText}
>
<div>
{ {
draftCount > 0 && draftCount > 0 &&
<ChannelMentionBadge <ChannelMentionBadge
@@ -118,7 +152,7 @@ function DraftsLink() {
} }
{ {
isScheduledPostEnabled && teamScheduledPostCount > 0 && showScheduledPostCount &&
<ChannelMentionBadge <ChannelMentionBadge
unreadMentions={teamScheduledPostCount} unreadMentions={teamScheduledPostCount}
icon={scheduleIcon} icon={scheduleIcon}
@@ -126,6 +160,8 @@ function DraftsLink() {
hasUrgent={scheduledPostsHasError} hasUrgent={scheduledPostsHasError}
/> />
} }
</div>
</WithTooltip>
</NavLink> </NavLink>
<DraftsTourTip/> <DraftsTourTip/>
</li> </li>

Просмотреть файл

@@ -3612,6 +3612,7 @@
"drafts.sidebarLink": "Drafts", "drafts.sidebarLink": "Drafts",
"drafts.subtitle": "Any messages you've started will show here", "drafts.subtitle": "Any messages you've started will show here",
"drafts.title": "{prefix}Drafts - {displayName} {siteName}", "drafts.title": "{prefix}Drafts - {displayName} {siteName}",
"drafts.tooltipText": "{draftCount, plural, =0 {} =1 {1 Draft} other {{draftCount} Drafts}} <br></br> {scheduledPostCount, plural, =0 {} other {{scheduledPostCount} Scheduled}}",
"drafts.tutorial_tip.notNow": "Not now", "drafts.tutorial_tip.notNow": "Not now",
"drafts.tutorial_tip.viewDrafts": "View drafts", "drafts.tutorial_tip.viewDrafts": "View drafts",
"drafts.tutorialTip.description": "With the new Drafts view, all of your unfinished messages are collected in one place. Return here to read, edit, or send draft messages.", "drafts.tutorialTip.description": "With the new Drafts view, all of your unfinished messages are collected in one place. Return here to read, edit, or send draft messages.",