mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 22:53:25 +00:00
feat: stop force redirect to create collection form
This commit is contained in:
@@ -19,10 +19,6 @@ export default class ShowCollectionsController {
|
|||||||
this.linkService.getFavoriteLinksForAuthenticatedUser(),
|
this.linkService.getFavoriteLinksForAuthenticatedUser(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (collections.length === 0) {
|
|
||||||
return response.redirectToNamedRoute('collection.create-form');
|
|
||||||
}
|
|
||||||
|
|
||||||
const activeCollection = collections.find(
|
const activeCollection = collections.find(
|
||||||
(c) => c.id === activeCollectionId
|
(c) => c.id === activeCollectionId
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { DisplayPreferences } from '#shared/types/index';
|
import { DisplayPreferences } from '#shared/types/index';
|
||||||
import { SimpleGrid, Stack, StyleProp, useCombobox } from '@mantine/core';
|
import { SimpleGrid, Stack, StyleProp } from '@mantine/core';
|
||||||
import { LinkItem } from '~/components/dashboard/link/item/link_item';
|
import { LinkItem } from '~/components/dashboard/link/item/link_item';
|
||||||
import { NoLink } from '~/components/dashboard/link/no_link/no_link';
|
import { NoLink } from '~/components/dashboard/link/no_link/no_link';
|
||||||
import { useActiveCollection } from '~/hooks/collections/use_active_collection';
|
import { useActiveCollection } from '~/hooks/collections/use_active_collection';
|
||||||
@@ -15,13 +15,9 @@ export function LinkList({ hideMenu = false }: LinkListProps) {
|
|||||||
const favoriteLinks = useFavoriteLinks();
|
const favoriteLinks = useFavoriteLinks();
|
||||||
const { displayPreferences } = useDisplayPreferences();
|
const { displayPreferences } = useDisplayPreferences();
|
||||||
|
|
||||||
const combobox = useCombobox({
|
|
||||||
onDropdownClose: () => combobox.resetSelectedOption(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const links = activeCollection?.links || favoriteLinks;
|
const links = activeCollection?.links || favoriteLinks;
|
||||||
|
|
||||||
if (activeCollection?.links.length === 0) {
|
if (links.length === 0) {
|
||||||
return <NoLink hideMenu={hideMenu} />;
|
return <NoLink hideMenu={hideMenu} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,21 +12,27 @@ interface NoLinkProps extends LinkListProps {}
|
|||||||
export function NoLink({ hideMenu }: NoLinkProps) {
|
export function NoLink({ hideMenu }: NoLinkProps) {
|
||||||
const { t } = useTranslation('common');
|
const { t } = useTranslation('common');
|
||||||
const activeCollection = useActiveCollection();
|
const activeCollection = useActiveCollection();
|
||||||
return (
|
const isFavorite = !activeCollection?.id;
|
||||||
<Box className={styles.noCollection} p="xl">
|
|
||||||
<Text
|
const noLinkForCollection = t(
|
||||||
className={styles.text}
|
|
||||||
dangerouslySetInnerHTML={{
|
|
||||||
__html: t(
|
|
||||||
'home:no-link',
|
'home:no-link',
|
||||||
{ name: activeCollection?.name ?? '' } as any,
|
{ name: activeCollection?.name ?? '' } as any,
|
||||||
{
|
{
|
||||||
interpolation: { escapeValue: false },
|
interpolation: { escapeValue: false },
|
||||||
}
|
}
|
||||||
),
|
);
|
||||||
|
|
||||||
|
const noLinkForFavorite = t('home:no-link-favorite');
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box className={styles.noCollection} p="xl">
|
||||||
|
<Text
|
||||||
|
className={styles.text}
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: isFavorite ? noLinkForFavorite : noLinkForCollection,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{!hideMenu && (
|
{!hideMenu && !isFavorite && (
|
||||||
<Anchor
|
<Anchor
|
||||||
component={Link}
|
component={Link}
|
||||||
href={appendCollectionId(
|
href={appendCollectionId(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"select-collection": "Please select a collection",
|
"select-collection": "Please select a collection",
|
||||||
"or-create-one": "or create one",
|
"or-create-one": "or create one",
|
||||||
"no-link": "No link for <b>{{name}}</b>"
|
"no-link": "No link for <b>{{name}}</b>",
|
||||||
|
"no-link-favorite": "No favorite link"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"select-collection": "Veuillez sélectionner une collection",
|
"select-collection": "Veuillez sélectionner une collection",
|
||||||
"or-create-one": "ou en créer une",
|
"or-create-one": "ou en créer une",
|
||||||
"no-link": "Aucun lien pour <b>{{name}}</b>"
|
"no-link": "Aucun lien pour <b>{{name}}</b>",
|
||||||
|
"no-link-favorite": "Aucun lien dans les favoris"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,13 +39,15 @@ export default function Dashboard() {
|
|||||||
disabled
|
disabled
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
{!isFavorite && (
|
|
||||||
<Group>
|
<Group>
|
||||||
{activeCollection?.visibility === Visibility.PUBLIC && (
|
{!isFavorite &&
|
||||||
|
activeCollection?.visibility === Visibility.PUBLIC && (
|
||||||
|
<>
|
||||||
<SharedCollectionCopyLink />
|
<SharedCollectionCopyLink />
|
||||||
|
<Divider orientation="vertical" />
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Divider orientation="vertical" />
|
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
component={Link}
|
component={Link}
|
||||||
@@ -57,6 +59,7 @@ export default function Dashboard() {
|
|||||||
>
|
>
|
||||||
{t('collection.create')}
|
{t('collection.create')}
|
||||||
</Button>
|
</Button>
|
||||||
|
{!isFavorite && (
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
component={Link}
|
component={Link}
|
||||||
@@ -68,7 +71,10 @@ export default function Dashboard() {
|
|||||||
>
|
>
|
||||||
{t('collection.edit')}
|
{t('collection.edit')}
|
||||||
</Button>
|
</Button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!isFavorite && (
|
||||||
|
<>
|
||||||
<Divider orientation="vertical" />
|
<Divider orientation="vertical" />
|
||||||
<Button
|
<Button
|
||||||
variant="light"
|
variant="light"
|
||||||
@@ -81,9 +87,10 @@ export default function Dashboard() {
|
|||||||
>
|
>
|
||||||
{t('link.create')}
|
{t('link.create')}
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</>
|
||||||
)}
|
)}
|
||||||
</Group>
|
</Group>
|
||||||
|
</Group>
|
||||||
{displayPreferences.collectionListDisplay === 'inline' && !isMobile && (
|
{displayPreferences.collectionListDisplay === 'inline' && !isMobile && (
|
||||||
<InlineCollectionList />
|
<InlineCollectionList />
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user