Commit 31ac3aa 1 parent ea702c8 commit 31ac3aa Copy full SHA for 31ac3aa
File tree 5 files changed +74
-17
lines changed
static/scripts/common/components
5 files changed +74
-17
lines changed Original file line number Diff line number Diff line change 10
10
import * as React from 'react' ;
11
11
12
12
import ENTITIES from '../../entities' ;
13
+ import ArtistCreditUsageLink
14
+ from '../static/scripts/common/components/ArtistCreditUsageLink' ;
13
15
import DescriptiveLink
14
16
from '../static/scripts/common/components/DescriptiveLink' ;
15
17
import EntityLink
@@ -43,8 +45,6 @@ function buildSection(
43
45
}
44
46
45
47
const entityUrlFragment = ENTITIES [ entityType ] . url ;
46
- const url = '/artist-credit/' + props . artistCredit . id +
47
- '/' + entityUrlFragment ;
48
48
49
49
return (
50
50
< React . Fragment key = { entityType } >
@@ -62,12 +62,14 @@ function buildSection(
62
62
{ entities . count > entities . entities . length ? (
63
63
< li key = "see-all" >
64
64
< em >
65
- < a href = { url } >
66
- { expand2text (
65
+ < ArtistCreditUsageLink
66
+ artistCredit = { props . artistCredit }
67
+ content = { expand2text (
67
68
seeAllMessage ( entities . count ) ,
68
69
{ num : formatCount ( props . $c , entities . count ) } ,
69
70
) }
70
- </ a >
71
+ subPath = { entityUrlFragment }
72
+ />
71
73
</ em >
72
74
</ li >
73
75
) : null }
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ import * as React from 'react';
11
11
12
12
import Tabs from '../components/Tabs' ;
13
13
import Layout from '../layout' ;
14
+ import ArtistCreditUsageLink
15
+ from '../static/scripts/common/components/ArtistCreditUsageLink' ;
14
16
import { reduceArtistCredit }
15
17
from '../static/scripts/common/immutable-entities' ;
16
18
@@ -54,19 +56,22 @@ const ArtistCreditLayout = ({
54
56
>
55
57
< div id = "content" >
56
58
< h1 >
57
- < a href = { '/artist-credit/' + artistCredit . id } >
58
- { texp . l (
59
+ < ArtistCreditUsageLink
60
+ artistCredit = { artistCredit }
61
+ content = { texp . l (
59
62
'Artist credit “{artist_credit}”' ,
60
63
{ artist_credit : reduceArtistCredit ( artistCredit ) } ,
61
64
) }
62
- </ a >
65
+ / >
63
66
</ h1 >
64
67
< Tabs >
65
68
{ tabLinks . map ( link => (
66
69
< li className = { page === link [ 0 ] ? 'sel' : '' } key = { link [ 0 ] } >
67
- < a href = { '/artist-credit/' + artistCredit . id + link [ 0 ] } >
68
- { link [ 1 ] ( ) }
69
- </ a >
70
+ < ArtistCreditUsageLink
71
+ artistCredit = { artistCredit }
72
+ content = { link [ 1 ] ( ) }
73
+ subPath = { link [ 0 ] . replace ( / ^ \/ / , '' ) }
74
+ />
70
75
</ li >
71
76
) ) }
72
77
</ Tabs >
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ import * as React from 'react';
11
11
12
12
import ArtistCreditLink
13
13
from '../../static/scripts/common/components/ArtistCreditLink' ;
14
+ import ArtistCreditUsageLink
15
+ from '../../static/scripts/common/components/ArtistCreditUsageLink' ;
14
16
import EntityLink from '../../static/scripts/common/components/EntityLink' ;
15
17
import bracketed from '../../static/scripts/common/utility/bracketed' ;
16
18
import loopParity from '../../utility/loopParity' ;
@@ -62,9 +64,10 @@ const ArtistCreditList = ({
62
64
{ ' ' }
63
65
< span className = "small" >
64
66
{ bracketed (
65
- < a href = { `/artist-credit/${ credit . id } ` } >
66
- { l ( 'see uses' ) }
67
- </ a > ,
67
+ < ArtistCreditUsageLink
68
+ artistCredit = { credit }
69
+ content = { l ( 'see uses' ) }
70
+ /> ,
68
71
) }
69
72
</ span >
70
73
</ td >
Original file line number Diff line number Diff line change 9
9
10
10
import * as React from 'react' ;
11
11
12
+ import ArtistCreditUsageLink
13
+ from '../../static/scripts/common/components/ArtistCreditUsageLink' ;
12
14
import ExpandedArtistCredit from
13
15
'../../static/scripts/common/components/ExpandedArtistCredit' ;
14
16
@@ -42,9 +44,12 @@ const EditArtistCredit = ({edit}: Props): React.Element<'table'> => {
42
44
< tr >
43
45
< th />
44
46
< td colSpan = "2" >
45
- < a href = { `/artist-credit/${ display . artist_credit . old . id } ` } >
46
- { l ( 'See all uses of the artist credit being changed.' ) }
47
- </ a >
47
+ < ArtistCreditUsageLink
48
+ artistCredit = { display . artist_credit . old }
49
+ content = { l (
50
+ 'See all uses of the artist credit being changed.' ,
51
+ ) }
52
+ />
48
53
</ td >
49
54
</ tr >
50
55
) : null }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * @flow strict-local
3
+ * Copyright (C) 2021 MetaBrainz Foundation
4
+ *
5
+ * This file is part of MusicBrainz, the open internet music database,
6
+ * and is licensed under the GPL version 2, or (at your option) any
7
+ * later version: http://www.gnu.org/licenses/gpl-2.0.txt
8
+ */
9
+
10
+ import * as React from 'react' ;
11
+
12
+ import { reduceArtistCredit } from '../immutable-entities' ;
13
+
14
+ type Props = {
15
+ + artistCredit : ArtistCreditT ,
16
+ + content ?: string ,
17
+ + subPath ?: string ,
18
+ + target ?: '_blank' ,
19
+ } ;
20
+
21
+ const ArtistCreditUsageLink = ( {
22
+ artistCredit,
23
+ content,
24
+ subPath,
25
+ ...props
26
+ } : Props ) : React . Element < 'a' > | null = > {
27
+ const id = artistCredit . id ;
28
+ if ( id == null ) {
29
+ return null ;
30
+ }
31
+ let href = `/artist-credit/${ id } ` ;
32
+ if ( nonEmpty ( subPath ) ) {
33
+ href += '/' + subPath ;
34
+ }
35
+ return (
36
+ < a href = { href } { ...props } >
37
+ { nonEmpty ( content ) ? content : reduceArtistCredit ( artistCredit ) }
38
+ </ a >
39
+ ) ;
40
+ } ;
41
+
42
+ export default ArtistCreditUsageLink ;
You can’t perform that action at this time.
0 commit comments