Add empty state to CollectionAdder component (#39372)
This commit is contained in:
parent
96e23af892
commit
5098b8ccc9
@ -3,6 +3,7 @@ import { useCallback, useId, useState } from 'react';
|
|||||||
import { FormattedMessage, useIntl, defineMessages } from 'react-intl';
|
import { FormattedMessage, useIntl, defineMessages } from 'react-intl';
|
||||||
|
|
||||||
import type { ApiCollectionJSON } from '@/mastodon/api_types/collections';
|
import type { ApiCollectionJSON } from '@/mastodon/api_types/collections';
|
||||||
|
import { EmptyState } from '@/mastodon/components/empty_state';
|
||||||
import { LoadingIndicator } from '@/mastodon/components/loading_indicator';
|
import { LoadingIndicator } from '@/mastodon/components/loading_indicator';
|
||||||
import { NavigationFocusTarget } from '@/mastodon/components/navigation_focus_target';
|
import { NavigationFocusTarget } from '@/mastodon/components/navigation_focus_target';
|
||||||
import { useCurrentAccountId } from '@/mastodon/hooks/useAccountId';
|
import { useCurrentAccountId } from '@/mastodon/hooks/useAccountId';
|
||||||
@ -16,7 +17,10 @@ import { IconButton } from 'mastodon/components/icon_button';
|
|||||||
import { useAppDispatch, useAppSelector } from 'mastodon/store';
|
import { useAppDispatch, useAppSelector } from 'mastodon/store';
|
||||||
|
|
||||||
import { MAX_COLLECTION_ACCOUNT_COUNT } from '../collections/editor/accounts';
|
import { MAX_COLLECTION_ACCOUNT_COUNT } from '../collections/editor/accounts';
|
||||||
import { useCollectionsCreatedBy } from '../collections/overview/created_by_account';
|
import {
|
||||||
|
NewCollectionButton,
|
||||||
|
useCollectionsCreatedBy,
|
||||||
|
} from '../collections/overview/created_by_account';
|
||||||
|
|
||||||
import { CollectionToggle } from './collection_toggle';
|
import { CollectionToggle } from './collection_toggle';
|
||||||
|
|
||||||
@ -136,6 +140,23 @@ export const CollectionAdder: React.FC<{
|
|||||||
>
|
>
|
||||||
{status === 'loading' || !account ? (
|
{status === 'loading' || !account ? (
|
||||||
<LoadingIndicator />
|
<LoadingIndicator />
|
||||||
|
) : collections.length === 0 ? (
|
||||||
|
<EmptyState
|
||||||
|
title={
|
||||||
|
<FormattedMessage
|
||||||
|
id='empty_column.collections_self'
|
||||||
|
defaultMessage='You have not created any collections yet.'
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
message={
|
||||||
|
<FormattedMessage
|
||||||
|
id='empty_column.account_featured_self.showcase_accounts_desc'
|
||||||
|
defaultMessage='Collections are curated lists of accounts to help others discover more of the Fediverse.'
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<NewCollectionButton onClick={onClose} />
|
||||||
|
</EmptyState>
|
||||||
) : (
|
) : (
|
||||||
collections.map((item) => (
|
collections.map((item) => (
|
||||||
<ListItem key={item.id} collection={item} account={account} />
|
<ListItem key={item.id} collection={item} account={account} />
|
||||||
|
|||||||
@ -26,8 +26,14 @@ import {
|
|||||||
} from '../editor';
|
} from '../editor';
|
||||||
import classes from '../styles.module.scss';
|
import classes from '../styles.module.scss';
|
||||||
|
|
||||||
const CreateButton: React.FC = () => (
|
export const NewCollectionButton: React.FC<{ onClick?: () => void }> = ({
|
||||||
<Link to='/collections/new' className='button button--compact'>
|
onClick,
|
||||||
|
}) => (
|
||||||
|
<Link
|
||||||
|
to='/collections/new'
|
||||||
|
className='button button--compact'
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
<Icon id='plus' icon={AddIcon} />
|
<Icon id='plus' icon={AddIcon} />
|
||||||
<FormattedMessage {...editorMessages.newCollection} />
|
<FormattedMessage {...editorMessages.newCollection} />
|
||||||
</Link>
|
</Link>
|
||||||
@ -97,7 +103,7 @@ export const CollectionsCreatedByAccount: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<CreateButton />
|
<NewCollectionButton />
|
||||||
</EmptyState>
|
</EmptyState>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -129,7 +135,7 @@ export const CollectionsCreatedByAccount: React.FC = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</h2>
|
</h2>
|
||||||
{showCreateButton && <CreateButton />}
|
{showCreateButton && <NewCollectionButton />}
|
||||||
</div>
|
</div>
|
||||||
<ItemList>
|
<ItemList>
|
||||||
{isOwnCollectionPage && !canCreateMoreCollections && (
|
{isOwnCollectionPage && !canCreateMoreCollections && (
|
||||||
|
|||||||
@ -649,6 +649,7 @@
|
|||||||
"empty_column.collections": "{acct} has not created any collections yet.",
|
"empty_column.collections": "{acct} has not created any collections yet.",
|
||||||
"empty_column.collections.featured_in": "You have not been added to any collections yet.",
|
"empty_column.collections.featured_in": "You have not been added to any collections yet.",
|
||||||
"empty_column.collections.featured_in_undiscoverable": "In order for people to add you to collections, you need to allow featuring in discovery experiences from <link>Preferences > Privacy and reach</link>",
|
"empty_column.collections.featured_in_undiscoverable": "In order for people to add you to collections, you need to allow featuring in discovery experiences from <link>Preferences > Privacy and reach</link>",
|
||||||
|
"empty_column.collections_self": "You have not created any collections yet.",
|
||||||
"empty_column.community": "The local timeline is empty. Write something publicly to get the ball rolling!",
|
"empty_column.community": "The local timeline is empty. Write something publicly to get the ball rolling!",
|
||||||
"empty_column.direct": "You don't have any private mentions yet. When you send or receive one, it will show up here.",
|
"empty_column.direct": "You don't have any private mentions yet. When you send or receive one, it will show up here.",
|
||||||
"empty_column.disabled_feed": "This feed has been disabled by your server administrators.",
|
"empty_column.disabled_feed": "This feed has been disabled by your server administrators.",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user