Move scheduled statuses to menu

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak 2024-08-26 21:07:23 +02:00
parent 4040919776
commit a06ad248d6
3 changed files with 24 additions and 23 deletions

View file

@ -29,6 +29,7 @@ const messages = defineMessages({
events: { id: 'column.events', defaultMessage: 'Events' },
developers: { id: 'navigation.developers', defaultMessage: 'Developers' },
dashboard: { id: 'navigation.dashboard', defaultMessage: 'Dashboard' },
scheduledStatuses: { id: 'column.scheduled_statuses', defaultMessage: 'Scheduled posts' },
drafts: { id: 'navigation.drafts', defaultMessage: 'Drafts' },
addAccount: { id: 'profile_dropdown.add_account', defaultMessage: 'Add an existing account' },
followRequests: { id: 'navigation_bar.follow_requests', defaultMessage: 'Follow requests' },
@ -83,6 +84,7 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
const sidebarOpen = useAppSelector((state) => state.sidebar.sidebarOpen);
const settings = useAppSelector((state) => getSettings(state));
const followRequestsCount = useAppSelector((state) => state.user_lists.follow_requests.items.count());
const scheduledStatusCount = useAppSelector((state) => state.scheduled_statuses.size);
const draftCount = useAppSelector((state) => state.draft_statuses.size);
// const dashboardCount = useAppSelector((state) => state.admin.openReports.count() + state.admin.awaitingApproval.count());
const [sidebarVisible, setSidebarVisible] = useState(sidebarOpen);
@ -264,6 +266,15 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
/>
)}
{scheduledStatusCount > 0 && (
<SidebarLink
to='/scheduled_statuses'
icon={require('@tabler/icons/outline/calendar-stats.svg')}
text={intl.formatMessage(messages.scheduledStatuses)}
onClick={onClose}
/>
)}
{draftCount > 0 && (
<SidebarLink
to='/draft_statuses'

View file

@ -20,6 +20,7 @@ const messages = defineMessages({
profileDirectory: { id: 'navigation_bar.profile_directory', defaultMessage: 'Profile directory' },
followedTags: { id: 'navigation_bar.followed_tags', defaultMessage: 'Followed hashtags' },
developers: { id: 'navigation.developers', defaultMessage: 'Developers' },
scheduledStatuses: { id: 'column.scheduled_statuses', defaultMessage: 'Scheduled posts' },
drafts: { id: 'navigation.drafts', defaultMessage: 'Drafts' },
});
@ -36,6 +37,7 @@ const SidebarNavigation = () => {
const notificationCount = useAppSelector((state) => state.notifications.unread);
const followRequestsCount = useAppSelector((state) => state.user_lists.follow_requests.items.count());
const dashboardCount = useAppSelector((state) => state.admin.openReports.count() + state.admin.awaitingApproval.count());
const scheduledStatusCount = useAppSelector((state) => state.scheduled_statuses.size);
const draftCount = useAppSelector((state) => state.draft_statuses.size);
const restrictUnauth = instance.pleroma.metadata.restrict_unauthenticated;
@ -101,6 +103,15 @@ const SidebarNavigation = () => {
});
}
if (scheduledStatusCount > 0) {
menu.push({
to: '/scheduled_statuses',
icon: require('@tabler/icons/outline/calendar-stats.svg'),
text: intl.formatMessage(messages.scheduledStatuses),
count: scheduledStatusCount,
});
}
if (draftCount > 0) {
menu.push({
to: '/draft_statuses',

View file

@ -1,8 +1,8 @@
import clsx from 'clsx';
import { CLEAR_EDITOR_COMMAND, TextNode, type LexicalEditor } from 'lexical';
import React, { Suspense, useCallback, useEffect, useRef, useState } from 'react';
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
import { Link, useHistory } from 'react-router-dom';
import { defineMessages, useIntl } from 'react-intl';
import { useHistory } from 'react-router-dom';
import { length } from 'stringz';
import {
@ -38,7 +38,6 @@ import SpoilerInput from './spoiler-input';
import TextCharacterCounter from './text-character-counter';
import UploadForm from './upload-form';
import VisualCharacterCounter from './visual-character-counter';
import Warning from './warning';
import type { AutoSuggestion } from 'soapbox/components/autosuggest-input';
import type { Emoji } from 'soapbox/features/emoji';
@ -74,7 +73,6 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
const compose = useCompose(id);
const showSearch = useAppSelector((state) => state.search.submitted && !state.search.hidden);
const maxTootChars = configuration.statuses.max_characters;
const scheduledStatusCount = useAppSelector((state) => state.scheduled_statuses.size);
const features = useFeatures();
const {
@ -221,25 +219,6 @@ const ComposeForm = <ID extends string>({ id, shouldCondense, autoFocus, clickab
return (
<Stack className='w-full' space={4} ref={formRef} onClick={handleClick} element='form' onSubmit={handleSubmit}>
{scheduledStatusCount > 0 && !event && !group && (
<Warning
message={(
<FormattedMessage
id='compose_form.scheduled_statuses.message'
defaultMessage='You have scheduled posts. {click_here} to see them.'
values={{ click_here: (
<Link className='underline' to='/scheduled_statuses'>
<FormattedMessage
id='compose_form.scheduled_statuses.click_here'
defaultMessage='Click here'
/>
</Link>
) }}
/>)
}
/>
)}
<WarningContainer composeId={id} />
{!shouldCondense && !event && !group && groupId && <ReplyGroupIndicator composeId={id} />}