Skip to content

Commit 4a02120

Browse files
committed
fix: hide Open button if collection home is already open
1 parent 8c10dfe commit 4a02120

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/library-authoring/collections/CollectionInfo.tsx

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Tab,
66
Tabs,
77
} from '@openedx/paragon';
8-
import { Link } from 'react-router-dom';
8+
import { Link, useMatch } from 'react-router-dom';
99

1010
import type { CollectionHit } from '../../search-manager';
1111
import type { ContentLibrary } from '../data/api';
@@ -19,19 +19,24 @@ interface CollectionInfoProps {
1919

2020
const CollectionInfo = ({ library, collection }: CollectionInfoProps) => {
2121
const intl = useIntl();
22+
const url = `/library/${library.id}/collection/${collection.blockId}/`;
23+
const urlMatch = useMatch(url);
2224

2325
return (
2426
<Stack>
25-
<div className="d-flex flex-wrap">
26-
<Button
27-
as={Link}
28-
to={`/library/${library.id}/collection/${collection.blockId}/`}
29-
variant="outline-primary"
30-
className="m-1 text-nowrap flex-grow-1"
31-
>
32-
{intl.formatMessage(messages.openCollectionButton)}
33-
</Button>
34-
</div>
27+
{!urlMatch && (
28+
<div className="d-flex flex-wrap">
29+
<Button
30+
as={Link}
31+
to={`/library/${library.id}/collection/${collection.blockId}/`}
32+
variant="outline-primary"
33+
className="m-1 text-nowrap flex-grow-1"
34+
disabled={!!urlMatch}
35+
>
36+
{intl.formatMessage(messages.openCollectionButton)}
37+
</Button>
38+
</div>
39+
)}
3540
<Tabs
3641
variant="tabs"
3742
className="my-3 d-flex justify-content-around"

0 commit comments

Comments
 (0)