MM-60141 - Scheduled post copy text option (#29123)

* verified available actions on scheduled posts

* Review fixes

* Added copy text option for scheudled posts

* Added check for archived channel and deactivated DM

* Import optimisation
Этот коммит содержится в:
Harshil Sharma
2024-11-12 10:53:20 +05:30
коммит произвёл GitHub
родитель 847f42fd4c
Коммит 64bf13f250
3 изменённых файлов: 25 добавлений и 1 удалений

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

@@ -55,6 +55,13 @@ const sendNowTooltipText = (
/> />
); );
const copyTextTooltipText = (
<FormattedMessage
id='scheduled_post.action.copy_text'
defaultMessage='Copy text'
/>
);
type Props = { type Props = {
scheduledPost: ScheduledPost; scheduledPost: ScheduledPost;
channel?: Channel; channel?: Channel;
@@ -62,9 +69,10 @@ type Props = {
onDelete: (scheduledPostId: string) => Promise<{error?: string}>; onDelete: (scheduledPostId: string) => Promise<{error?: string}>;
onSend: (scheduledPostId: string) => void; onSend: (scheduledPostId: string) => void;
onEdit: () => void; onEdit: () => void;
onCopyText: () => void;
} }
function ScheduledPostActions({scheduledPost, channel, onReschedule, onDelete, onSend, onEdit}: Props) { function ScheduledPostActions({scheduledPost, channel, onReschedule, onDelete, onSend, onEdit, onCopyText}: Props) {
const dispatch = useDispatch(); const dispatch = useDispatch();
const userTimezone = useSelector(getCurrentTimezone); const userTimezone = useSelector(getCurrentTimezone);
@@ -149,6 +157,14 @@ function ScheduledPostActions({scheduledPost, channel, onReschedule, onDelete, o
/> />
} }
<Action
icon='icon-content-copy'
id='copy_text'
name='copy_text'
tooltipText={copyTextTooltipText}
onClick={onCopyText}
/>
{ {
showRescheduleOption && showRescheduleOption &&
<Action <Action

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

@@ -37,6 +37,7 @@ import PlaceholderScheduledPostsTitle
import EditPost from 'components/edit_post'; import EditPost from 'components/edit_post';
import Constants, {StoragePrefixes} from 'utils/constants'; import Constants, {StoragePrefixes} from 'utils/constants';
import {copyToClipboard} from 'utils/utils';
import type {GlobalState} from 'types/store'; import type {GlobalState} from 'types/store';
import type {PostDraft} from 'types/store/draft'; import type {PostDraft} from 'types/store/draft';
@@ -278,6 +279,10 @@ function DraftRow({
setIsEditing((isEditing) => !isEditing); setIsEditing((isEditing) => !isEditing);
}, []); }, []);
const handleCopyText = useCallback(() => {
copyToClipboard(item.message);
}, [item]);
const handleScheduledPostOnSend = useCallback(() => { const handleScheduledPostOnSend = useCallback(() => {
handleCancelEdit(); handleCancelEdit();
@@ -296,6 +301,7 @@ function DraftRow({
onDelete={handleSchedulePostOnDelete} onDelete={handleSchedulePostOnDelete}
onSend={handleScheduledPostOnSend} onSend={handleScheduledPostOnSend}
onEdit={handleSchedulePostEdit} onEdit={handleSchedulePostEdit}
onCopyText={handleCopyText}
/> />
); );
}, [ }, [
@@ -304,6 +310,7 @@ function DraftRow({
handleSchedulePostOnReschedule, handleSchedulePostOnReschedule,
handleScheduledPostOnSend, handleScheduledPostOnSend,
handleSchedulePostEdit, handleSchedulePostEdit,
handleCopyText,
item, item,
]); ]);

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

@@ -4859,6 +4859,7 @@
"Schedule_post.empty_state.subtitle": "Schedule drafts to send messages at a later time. Any scheduled drafts will show up here and can be modified after being scheduled.", "Schedule_post.empty_state.subtitle": "Schedule drafts to send messages at a later time. Any scheduled drafts will show up here and can be modified after being scheduled.",
"Schedule_post.empty_state.title": "No scheduled drafts at the moment", "Schedule_post.empty_state.title": "No scheduled drafts at the moment",
"schedule_post.tab.heading": "Scheduled", "schedule_post.tab.heading": "Scheduled",
"scheduled_post.action.copy_text": "Copy text",
"scheduled_post.action.delete": "Delete scheduled post", "scheduled_post.action.delete": "Delete scheduled post",
"scheduled_post.action.edit": "Edit scheduled post", "scheduled_post.action.edit": "Edit scheduled post",
"scheduled_post.action.reschedule": "Reschedule post", "scheduled_post.action.reschedule": "Reschedule post",